This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 0d2ab41ec82e01e9f47deef20ecba8902f6a24d9 Author: Andreas Rheinhardt <[email protected]> AuthorDate: Tue Dec 30 13:26:33 2025 +0100 Commit: Andreas Rheinhardt <[email protected]> CommitDate: Fri Jan 2 18:39:48 2026 +0100 avcodec/h261: Remove H261Context It only contains a single field, so add this directly to MPVContext and remove private_ctx. This avoids an indirection in ff_h261_loop_filter(). Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/h261.c | 3 +-- libavcodec/h261.h | 7 ------- libavcodec/h261dec.c | 20 ++++++++------------ libavcodec/h261enc.c | 32 ++++++++++++++------------------ libavcodec/mpegvideo.h | 6 +++--- 5 files changed, 26 insertions(+), 42 deletions(-) diff --git a/libavcodec/h261.c b/libavcodec/h261.c index 8e0e13459a..babbd48dcb 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -60,14 +60,13 @@ static void h261_loop_filter(uint8_t *src, ptrdiff_t stride) void ff_h261_loop_filter(MpegEncContext *s) { - H261Context *const h = s->private_ctx; const ptrdiff_t linesize = s->linesize; const ptrdiff_t uvlinesize = s->uvlinesize; uint8_t *dest_y = s->dest[0]; uint8_t *dest_cb = s->dest[1]; uint8_t *dest_cr = s->dest[2]; - if (!(IS_FIL(h->mtype))) + if (!(IS_FIL(s->mtype))) return; h261_loop_filter(dest_y, linesize); diff --git a/libavcodec/h261.h b/libavcodec/h261.h index fb5fc6f940..14d5b4a2fd 100644 --- a/libavcodec/h261.h +++ b/libavcodec/h261.h @@ -31,13 +31,6 @@ #include "mpegutils.h" #include "rl.h" -/** - * H261Context - */ -typedef struct H261Context { - int mtype; -} H261Context; - #define MB_TYPE_H261_FIL MB_TYPE_CODEC_SPECIFIC extern const uint8_t ff_h261_mba_code[35]; diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 32d41903e7..a25595faf6 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -59,8 +59,6 @@ typedef struct H261DecContext { GetBitContext gb; - H261Context common; - int current_mba; int mba_diff; int current_mv_x; @@ -104,7 +102,6 @@ static av_cold int h261_decode_init(AVCodecContext *avctx) * for all frames and override it after having decoded the frame. */ s->pict_type = AV_PICTURE_TYPE_P; - s->private_ctx = &h->common; // set defaults ret = ff_mpv_decode_init(s, avctx); if (ret < 0) @@ -211,7 +208,7 @@ static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2) s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skipped = 1; - h->common.mtype &= ~MB_TYPE_H261_FIL; + s->mtype &= ~MB_TYPE_H261_FIL; if (s->cur_pic.motion_val[0]) { int b_stride = 2*s->mb_width + 1; @@ -352,7 +349,6 @@ static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded static int h261_decode_mb(H261DecContext *h) { MpegEncContext *const s = &h->s; - H261Context *const com = &h->common; int i, cbp, xy; cbp = 63; @@ -389,23 +385,23 @@ static int h261_decode_mb(H261DecContext *h) h261_init_dest(s); // Read mtype - com->mtype = get_vlc2(&h->gb, h261_mtype_vlc, H261_MTYPE_VLC_BITS, 2); - if (com->mtype < 0) { + s->mtype = get_vlc2(&h->gb, h261_mtype_vlc, H261_MTYPE_VLC_BITS, 2); + if (s->mtype < 0) { av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index\n"); return SLICE_ERROR; } // Read mquant - if (IS_QUANT(com->mtype)) { + if (IS_QUANT(s->mtype)) { s->qscale = get_bits(&h->gb, 5); if (!s->qscale) s->qscale = 1; } - s->mb_intra = IS_INTRA4x4(com->mtype); + s->mb_intra = IS_INTRA4x4(s->mtype); // Read mv - if (IS_16X16(com->mtype)) { + if (IS_16X16(s->mtype)) { /* Motion vector data is included for all MC macroblocks. MVD is * obtained from the macroblock vector by subtracting the vector * of the preceding macroblock. For this calculation the vector @@ -428,7 +424,7 @@ static int h261_decode_mb(H261DecContext *h) } // Read cbp - if (HAS_CBP(com->mtype)) + if (HAS_CBP(s->mtype)) cbp = get_vlc2(&h->gb, h261_cbp_vlc, H261_CBP_VLC_BITS, 1) + 1; if (s->mb_intra) { @@ -452,7 +448,7 @@ static int h261_decode_mb(H261DecContext *h) intra: /* decode each block */ - if (s->mb_intra || HAS_CBP(com->mtype)) { + if (s->mb_intra || HAS_CBP(s->mtype)) { s->bdsp.clear_blocks(h->block[0]); for (i = 0; i < 6; i++) { if (h261_decode_block(h, h->block[i], i, cbp & 32) < 0) diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index c75e029d68..d13511a6f4 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -58,8 +58,6 @@ static uint8_t h261_mv_codes[64][2]; typedef struct H261EncContext { MPVMainEncContext s; - H261Context common; - int gob_number; enum { H261_QCIF = 0, @@ -232,12 +230,11 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64], /* The following is only allowed because this encoder * does not use slice threading. */ H261EncContext *const h = (H261EncContext *)s; - H261Context *const com = &h->common; int mvd, mv_diff_x, mv_diff_y, i, cbp; cbp = 63; // avoid warning mvd = 0; - com->mtype = 0; + s->c.mtype = 0; if (!s->c.mb_intra) { /* compute cbp */ @@ -264,34 +261,34 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64], /* calculate MTYPE */ if (!s->c.mb_intra) { - com->mtype++; + s->c.mtype++; if (mvd || s->loop_filter) - com->mtype += 3; + s->c.mtype += 3; if (s->loop_filter) - com->mtype += 3; + s->c.mtype += 3; if (cbp) - com->mtype++; - av_assert1(com->mtype > 1); + s->c.mtype++; + av_assert1(s->c.mtype > 1); } if (s->dquant && cbp) { - com->mtype++; + s->c.mtype++; } else s->c.qscale -= s->dquant; put_bits(&s->pb, - ff_h261_mtype_bits[com->mtype], - ff_h261_mtype_code[com->mtype]); + ff_h261_mtype_bits[s->c.mtype], + ff_h261_mtype_code[s->c.mtype]); - com->mtype = ff_h261_mtype_map[com->mtype]; + s->c.mtype = ff_h261_mtype_map[s->c.mtype]; - if (IS_QUANT(com->mtype)) { + if (IS_QUANT(s->c.mtype)) { ff_set_qscale(&s->c, s->c.qscale + s->dquant); put_bits(&s->pb, 5, s->c.qscale); } - if (IS_16X16(com->mtype)) { + if (IS_16X16(s->c.mtype)) { mv_diff_x = (motion_x >> 1) - s->c.last_mv[0][0][0]; mv_diff_y = (motion_y >> 1) - s->c.last_mv[0][0][1]; s->c.last_mv[0][0][0] = (motion_x >> 1); @@ -300,7 +297,7 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64], h261_encode_motion(&s->pb, mv_diff_y); } - if (HAS_CBP(com->mtype)) { + if (HAS_CBP(s->c.mtype)) { av_assert1(cbp > 0); put_bits(&s->pb, ff_h261_cbp_tab[cbp - 1][1], @@ -310,7 +307,7 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64], /* encode each block */ h261_encode_block(h, block[i], i); - if (!IS_16X16(com->mtype)) { + if (!IS_16X16(s->c.mtype)) { s->c.last_mv[0][0][0] = 0; s->c.last_mv[0][0][1] = 0; } @@ -370,7 +367,6 @@ static av_cold int h261_encode_init(AVCodecContext *avctx) avctx->width, avctx->height); return AVERROR(EINVAL); } - s->c.private_ctx = &h->common; h->s.encode_picture_header = h261_encode_picture_header; s->encode_mb = h261_encode_mb; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index c9ec79cfad..d448ac6b5a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -80,9 +80,6 @@ typedef struct MpegEncContext { * offsets used in ASM. */ struct AVCodecContext *avctx; - /* The following pointer is intended for codecs sharing code - * between decoder and encoder and in need of a common context to do so. */ - void *private_ctx; /* the following parameters must be initialized before encoding */ int width, height;///< picture size. must be a multiple of 16 enum OutputFormat out_format; ///< output format @@ -210,6 +207,9 @@ typedef struct MpegEncContext { int resync_mb_x; ///< x position of last resync marker int resync_mb_y; ///< y position of last resync marker + /* H.261 specific */ + int mtype; + /* H.263 specific */ int obmc; ///< overlapped block motion compensation _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
