Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <ffmpegagent-at-gmail.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 40/48] avcodec/h263dec: Use function ptr for decode_picture_header
Date: Mon, 23 Jun 2025 13:36:40 +0000
Message-ID: <b2b7cc1e25c5a5f417f81f0046b3447d562886aa.1750685809.git.ffmpegagent@gmail.com> (raw)
In-Reply-To: <pull.102.ffstaging.FFmpeg.1750685808.ffmpegagent@gmail.com>

From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h263dec.c       | 27 ++++++++++-----------------
 libavcodec/h263dec.h       |  8 +++-----
 libavcodec/mpeg4videodec.c |  3 ++-
 libavcodec/mpeg4videodec.h |  1 -
 libavcodec/msmpeg4dec.c    |  8 +++++---
 libavcodec/msmpeg4dec.h    |  1 -
 libavcodec/wmv2dec.c       |  3 ++-
 libavcodec/wmv2dec.h       |  1 -
 8 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 541eb34789..592a22df0d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -121,6 +121,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_H263:
     case AV_CODEC_ID_H263P:
         avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
+        h->decode_header = ff_h263_decode_picture_header;
         break;
     case AV_CODEC_ID_MPEG4:
         break;
@@ -144,13 +145,20 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
         s->h263_pred       = 1;
         s->msmpeg4_version = MSMP4_WMV2;
         break;
-    case AV_CODEC_ID_H263I:
     case AV_CODEC_ID_RV10:
     case AV_CODEC_ID_RV20:
         break;
+#if CONFIG_H263I_DECODER
+    case AV_CODEC_ID_H263I:
+        h->decode_header = ff_intel_h263_decode_picture_header;
+        break;
+#endif
+#if CONFIG_FLV_DECODER
     case AV_CODEC_ID_FLV1:
         s->h263_flv = 1;
+        h->decode_header = ff_flv_decode_picture_header;
         break;
+#endif
     default:
         av_unreachable("Switch contains a case for every codec using ff_h263_decode_init()");
     }
@@ -461,22 +469,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
     bak_height = h->c.height;
 
     /* let's go :-) */
-    if (CONFIG_WMV2_DECODER && h->c.msmpeg4_version == MSMP4_WMV2) {
-        ret = ff_wmv2_decode_picture_header(h);
-#if CONFIG_MSMPEG4DEC
-    } else if (h->c.msmpeg4_version != MSMP4_UNUSED) {
-        ret = ff_msmpeg4_decode_picture_header(h);
-#endif
-    } else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
-        ret = ff_mpeg4_decode_picture_header(h);
-    } else if (CONFIG_H263I_DECODER && h->c.codec_id == AV_CODEC_ID_H263I) {
-        ret = ff_intel_h263_decode_picture_header(h);
-    } else if (CONFIG_FLV_DECODER && h->c.h263_flv) {
-        ret = ff_flv_decode_picture_header(h);
-    } else {
-        ret = ff_h263_decode_picture_header(h);
-    }
-
+    ret = h->decode_header(h);
     if (ret < 0 || ret == FRAME_SKIPPED) {
         if (   h->c.width  != bak_width
             || h->c.height != bak_height) {
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index 0c6228f9d9..2b43dda568 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -25,11 +25,6 @@
 #include "vlc.h"
 #include "libavutil/mem_internal.h"
 
-/**
- * Return value for header parsers if frame is not coded.
- * */
-#define FRAME_SKIPPED 100
-
 // The defines below define the number of bits that are read at once for
 // reading vlc values. Changing these may improve speed and data cache needs
 // be aware though that decreasing them may need the number of stages that is
@@ -72,6 +67,9 @@ typedef struct H263DecContext {
     int rv10_version; ///< RV10 version: 0 or 3
     int rv10_first_dc_coded[3];
 
+    int (*decode_header)(struct H263DecContext *const h);
+#define FRAME_SKIPPED 100 ///< Frame is not coded
+
     int (*decode_mb)(struct H263DecContext *h);
 #define SLICE_OK         0
 #define SLICE_ERROR     -1
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c53f5c103a..bc17b0ed09 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3736,7 +3736,7 @@ end:
         return decode_vop_header(ctx, gb, parse_only);
 }
 
-int ff_mpeg4_decode_picture_header(H263DecContext *const h)
+static int mpeg4_decode_picture_header(H263DecContext *const h)
 {
     Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
 
@@ -4017,6 +4017,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     h->c.h263_pred = 1;
     h->c.low_delay = 0; /* default, might be overridden in the vol header during header parsing */
+    h->decode_header = mpeg4_decode_picture_header;
     h->decode_mb   = mpeg4_decode_mb;
     ctx->time_increment_bits = 4; /* default value for broken headers */
     ctx->quant_precision     = 5;
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index 337125d4e3..aafde454ea 100644
--- a/libavcodec/mpeg4videodec.h
+++ b/libavcodec/mpeg4videodec.h
@@ -109,7 +109,6 @@ typedef struct Mpeg4DecContext {
     int dct_precision;
 } Mpeg4DecContext;
 
-int ff_mpeg4_decode_picture_header(H263DecContext *const h);
 int ff_mpeg4_parse_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb,
                                   int header, int parse_only);
 void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb,
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 59ceb7dac6..a96a0335f7 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -360,7 +360,7 @@ static av_cold void msmpeg4_decode_init_static(void)
     ff_msmp4_vc1_vlcs_init_once();
 }
 
-int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
+static int msmpeg4_decode_picture_header(H263DecContext *const h)
 {
     MSMP4DecContext *const ms = mpv_to_msmpeg4(h);
     int code;
@@ -445,7 +445,7 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
             h->c.inter_intra_pred= 0;
             break;
         default:
-            av_unreachable("ff_msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
+            av_unreachable("msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
         }
         h->c.no_rounding = 1;
         if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
@@ -498,7 +498,7 @@ int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
                                   ms->bit_rate <= II_BITRATE;
             break;
         default:
-            av_unreachable("ff_msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
+            av_unreachable("msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
         }
 
         if (h->c.avctx->debug&FF_DEBUG_PICT_INFO)
@@ -847,6 +847,8 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
     // We unquantize inter blocks as we parse them.
     h->c.dct_unquantize_inter = NULL;
 
+    h->decode_header = msmpeg4_decode_picture_header;
+
     ff_msmpeg4_common_init(&h->c);
 
     switch (h->c.msmpeg4_version) {
diff --git a/libavcodec/msmpeg4dec.h b/libavcodec/msmpeg4dec.h
index 11a36f2136..e0fb3cf483 100644
--- a/libavcodec/msmpeg4dec.h
+++ b/libavcodec/msmpeg4dec.h
@@ -53,7 +53,6 @@ extern const VLCElem *ff_mb_non_intra_vlc[4];
 extern VLCElem ff_inter_intra_vlc[8];
 
 int ff_msmpeg4_decode_init(AVCodecContext *avctx);
-int ff_msmpeg4_decode_picture_header(H263DecContext *const h);
 int ff_msmpeg4_decode_ext_header(H263DecContext *const h, int buf_size);
 void ff_msmpeg4_decode_motion(MSMP4DecContext *ms, int *mx_ptr, int *my_ptr);
 int ff_msmpeg4_decode_block(MSMP4DecContext *ms, int16_t * block,
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 4ceae05bdf..53d127d37f 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -201,7 +201,7 @@ static int decode_ext_header(WMV2DecContext *w)
     return 0;
 }
 
-int ff_wmv2_decode_picture_header(H263DecContext *const h)
+static int wmv2_decode_picture_header(H263DecContext *const h)
 {
     int code;
 
@@ -574,6 +574,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
     if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
         return ret;
 
+    h->decode_header = wmv2_decode_picture_header;
     h->decode_mb = wmv2_decode_mb;
 
     ff_wmv2_common_init(s);
diff --git a/libavcodec/wmv2dec.h b/libavcodec/wmv2dec.h
index 4dd9359dc9..1bd0d13725 100644
--- a/libavcodec/wmv2dec.h
+++ b/libavcodec/wmv2dec.h
@@ -24,7 +24,6 @@
 #include "mpegvideo.h"
 struct H263DecContext;
 
-int ff_wmv2_decode_picture_header(struct H263DecContext *const h);
 int ff_wmv2_decode_secondary_picture_header(struct H263DecContext *const h);
 void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64],
                     uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
-- 
ffmpeg-codebot

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2025-06-23 13:45 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 13:36 [FFmpeg-devel] [PATCH 00/48] H263DecContext ffmpegagent
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 01/48] avcodec/ituh263dec: Use correct logcontext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 02/48] avcodec/rl: Avoid branch in index lookup Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 03/48] avcodec/ituh263enc: Simplify creating LUT Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 04/48] avcodec/ituh263dec: Only initialize ff_h263_rl_inter when needed Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 05/48] avcodec/mpegvideoenc: Allocate blocks as part of MPVEncContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 06/48] avcodec/mpegvideo: Add MPVContext typedef Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 07/48] avcodec/mpegvideo_dec: Factor debugging dct coefficients out Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 08/48] avcodec/mpegvideo_dec: Reindent after the previous commit Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 09/48] avcodec/mpeg_er: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 10/48] avcodec/mpegvideodec: Remove size expectation from ff_mpv_reconstruct_mb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 11/48] avcodec/h261dec: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 12/48] avcodec/h261dec: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 13/48] avcodec/mpeg12dec: Put GetBitContext on the stack where advantageous Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 14/48] avcodec/mpeg12dec: Remove unused function parameter Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 15/48] avcodec/rv34: Don't use MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 16/48] avcodec/rv34: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 17/48] avcodec/intrax8: Don't pretend to need more than one int16_t[64] Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 18/48] avcodec/vc1: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 19/48] avcodec/vc1: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 20/48] avcodec/mpeg12dec: Deduplicate variables Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 21/48] avcodec/mpegvideo: Move flipflop_rounding to {MSMPEG4Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 22/48] avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 23/48] avcodec/mpeg4videodec: Avoid unnecessary indirections Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 24/48] avcodec/{h263, mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext* Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 25/48] avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 26/48] avcodec/h263dec: Add H263DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 27/48] avcodec/h263dec: Remove redundant block parameter from decode_mb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 28/48] avcodec/h263dec: Don't use MpegEncContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 29/48] avcodec/h263dec: Stop using MpegEncContext.gb Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 30/48] avcodec/mpeg12dec: Add Mpeg12SliceContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 31/48] avcodec/mpegvideo: Add missing headers Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 32/48] avcodec/mpeg12dec: Move MpegEncContext.gb to Mpeg12SliceContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 33/48] avcodec/mpeg12dec: Don't use MPVContext.block Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 34/48] avcodec/mpegvideo: Move fields only used by H.263 decoders to H263DecCtx Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 35/48] avcodec/mpegvideo: Move mb_num_left to {H263, RV34}DecContext Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 36/48] avcodec/mpeg12dec: Put mb_skip_run on the stack Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 37/48] avcodec/mpegvideo: Move mb_skip_run to {RV34Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 38/48] avcodec/mpegvideo: Move SLICE_* defs to h263dec.h, h261dec.c Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 39/48] avcodec/msmpeg4dec: Move ff_msmpeg4_decode_init() down Andreas Rheinhardt
2025-06-23 13:36 ` Andreas Rheinhardt [this message]
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 41/48] avcodec/ituh263enc: Inline value of h263_flv Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 42/48] avcodec/flvdec: Binarize h263_flv Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 43/48] avcodec/mpegvideo: Move fields to {H263Dec, MPVEnc}Context when possible Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 44/48] avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 45/48] avcodec/mpegvideo: Move partitioned_frame to {H263Dec, MPVEnc}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 46/48] avcodec/mpegvideo: Move loop_filter to {H263Dec, MPVEnc, VC1}Context Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 47/48] avcodec/rv34: Don't report progress unnecessarily Andreas Rheinhardt
2025-06-23 13:36 ` [FFmpeg-devel] [PATCH 48/48] avcodec/rv34: Fix spelling mistake Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2b7cc1e25c5a5f417f81f0046b3447d562886aa.1750685809.git.ffmpegagent@gmail.com \
    --to=ffmpegagent-at-gmail.com@ffmpeg.org \
    --cc=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git