[FFmpeg-cvslog] avcodec/mpegvideo: Move fields to {H263Dec,MPVEnc}Context when possible
Andreas Rheinhardt
git at videolan.org
Thu Jul 3 21:56:33 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Jun 22 13:36:36 2025 +0200| [3c06d87c93e0b2c0845e5400eaf2a2cfc1a4bcb1] | committer: Andreas Rheinhardt
avcodec/mpegvideo: Move fields to {H263Dec,MPVEnc}Context when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c06d87c93e0b2c0845e5400eaf2a2cfc1a4bcb1
---
libavcodec/flvdec.c | 6 ++--
libavcodec/flvenc.c | 2 +-
libavcodec/h261enc.c | 2 +-
libavcodec/h263dec.c | 14 ++++----
libavcodec/h263dec.h | 14 ++++++++
libavcodec/intelh263dec.c | 4 +--
libavcodec/ituh263dec.c | 84 +++++++++++++++++++++++-----------------------
libavcodec/ituh263enc.c | 44 ++++++++++++------------
libavcodec/mpeg12enc.c | 3 +-
libavcodec/mpeg4videodec.c | 20 ++++++-----
libavcodec/mpeg4videoenc.c | 18 +++++-----
libavcodec/mpegvideo.c | 2 --
libavcodec/mpegvideo.h | 11 ------
libavcodec/mpegvideo_dec.c | 2 --
libavcodec/mpegvideo_enc.c | 40 +++++++++++-----------
libavcodec/mpegvideoenc.h | 11 ++++++
libavcodec/msmpeg4dec.c | 8 ++---
libavcodec/msmpeg4enc.c | 6 ++--
libavcodec/ratecontrol.c | 4 +--
libavcodec/rv10.c | 2 +-
libavcodec/rv20enc.c | 8 ++---
libavcodec/snowenc.c | 2 +-
libavcodec/vaapi_mpeg4.c | 2 +-
libavcodec/wmv2dec.c | 2 +-
libavcodec/wmv2enc.c | 2 +-
25 files changed, 162 insertions(+), 151 deletions(-)
diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 881f63ed1a..0f6eaad5c6 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -40,8 +40,8 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
return AVERROR_INVALIDDATA;
}
- h->c.h263_flv = format;
- h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
+ h->flv = format;
+ h->picture_number = get_bits(&h->gb, 8); /* picture timestamp */
format = get_bits(&h->gb, 3);
switch (format) {
case 0:
@@ -101,7 +101,7 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->c.avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
h->c.droppable ? 'D' : av_get_picture_type_char(h->c.pict_type),
- h->c.h263_flv, h->c.qscale, h->c.picture_number);
+ h->flv, h->c.qscale, h->picture_number);
}
return 0;
diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c
index 91e1f07365..0b6e73b11e 100644
--- a/libavcodec/flvenc.c
+++ b/libavcodec/flvenc.c
@@ -35,7 +35,7 @@ int ff_flv_encode_picture_header(MPVMainEncContext *const m)
/* 0: H.263 escape codes 1: 11-bit escape codes */
put_bits(&s->pb, 5, 1);
put_bits(&s->pb, 8,
- (((int64_t) s->c.picture_number * 30 * s->c.avctx->time_base.num) / // FIXME use timestamp
+ (((int64_t) s->picture_number * 30 * s->c.avctx->time_base.num) / // FIXME use timestamp
s->c.avctx->time_base.den) & 0xff); /* TemporalReference */
if (s->c.width == 352 && s->c.height == 288)
format = 2;
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 466a0387c5..89a6a69755 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -77,7 +77,7 @@ static int h261_encode_picture_header(MPVMainEncContext *const m)
put_bits(&s->pb, 20, 0x10); /* PSC */
- temp_ref = s->c.picture_number * 30000LL * s->c.avctx->time_base.num /
+ temp_ref = s->picture_number * 30000LL * s->c.avctx->time_base.num /
(1001LL * s->c.avctx->time_base.den); // FIXME maybe this should use a timestamp
put_sbits(&s->pb, 5, temp_ref); /* TemporalReference */
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 670d250304..ef78e87901 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -231,7 +231,7 @@ static int decode_slice(H263DecContext *const h)
for (; h->c.mb_y < h->c.mb_height; h->c.mb_y++) {
/* per-row end of slice checks */
if (h->c.msmpeg4_version != MSMP4_UNUSED) {
- if (h->c.resync_mb_y + h->c.slice_height == h->c.mb_y) {
+ if (h->c.resync_mb_y + h->slice_height == h->c.mb_y) {
ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,
h->c.mb_x - 1, h->c.mb_y, ER_MB_END);
@@ -330,7 +330,7 @@ static int decode_slice(H263DecContext *const h)
(h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&h->gb) >= 48 &&
show_bits(&h->gb, 24) == 0x4010 &&
- !h->c.data_partitioning)
+ !h->data_partitioning)
h->padding_bug_score += 32;
/* try to detect the padding bug */
@@ -338,7 +338,7 @@ static int decode_slice(H263DecContext *const h)
(h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&h->gb) >= 0 &&
get_bits_left(&h->gb) < 137 &&
- !h->c.data_partitioning) {
+ !h->data_partitioning) {
const int bits_count = get_bits_count(&h->gb);
const int bits_left = h->gb.size_in_bits - bits_count;
@@ -364,7 +364,7 @@ static int decode_slice(H263DecContext *const h)
get_bits_left(&h->gb) < 300 &&
h->c.pict_type == AV_PICTURE_TYPE_I &&
show_bits(&h->gb, 8) == 0 &&
- !h->c.data_partitioning) {
+ !h->data_partitioning) {
h->padding_bug_score += 32;
}
@@ -379,7 +379,7 @@ static int decode_slice(H263DecContext *const h)
if (h->c.workaround_bugs & FF_BUG_AUTODETECT) {
if (
- (h->padding_bug_score > -2 && !h->c.data_partitioning))
+ (h->padding_bug_score > -2 && !h->data_partitioning))
h->c.workaround_bugs |= FF_BUG_NO_PADDING;
else
h->c.workaround_bugs &= ~FF_BUG_NO_PADDING;
@@ -573,8 +573,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
slice_ret = decode_slice(h);
while (h->c.mb_y < h->c.mb_height) {
if (h->c.msmpeg4_version != MSMP4_UNUSED) {
- if (h->c.slice_height == 0 || h->c.mb_x != 0 || slice_ret < 0 ||
- (h->c.mb_y % h->c.slice_height) != 0 || get_bits_left(&h->gb) < 0)
+ if (h->slice_height == 0 || h->c.mb_x != 0 || slice_ret < 0 ||
+ (h->c.mb_y % h->slice_height) != 0 || get_bits_left(&h->gb) < 0)
break;
} else {
int prev_x = h->c.mb_x, prev_y = h->c.mb_y;
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index 2b43dda568..a7b5e54ae7 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -47,21 +47,35 @@ typedef struct H263DecContext {
int mb_num_left; ///< number of MBs left in this video packet (for partitioned slices only)
+ int picture_number;
+
int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
/* motion compensation */
int h263_long_vectors; ///< use horrible H.263v1 long vector mode
+ /* FLV specific */
+ int flv; ///< use flv H.263 header
+
/* H.263 specific */
int ehc_mode;
+ int gob_index;
/* H.263+ specific */
int custom_pcf;
+ int umvplus; ///< == H.263+ && unrestricted_mv
+ int h263_slice_structured;
+ int alt_inter_vlc; ///< alternative inter vlc
+ int modified_quant;
/* MPEG-4 specific */
int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4
int skipped_last_frame;
int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5
+ int data_partitioning; ///< data partitioning flag from header
+
+ /* MSMPEG4 specific */
+ int slice_height; ///< in macroblocks
/* RV10 specific */
int rv10_version; ///< RV10 version: 0 or 3
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index 1640defaab..73d56f4195 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -39,7 +39,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h)
av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1;
}
- h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
+ h->picture_number = get_bits(&h->gb, 8); /* picture timestamp */
if (check_marker(h->c.avctx, &h->gb, "after picture_number") != 1) {
return -1; /* marker */
@@ -119,7 +119,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h)
if (skip_1stop_8data_bits(&h->gb) < 0)
return AVERROR_INVALIDDATA;
- h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
+ h->gob_index = H263_GOB_HEIGHT(h->c.height);
ff_h263_show_pict_info(h, 0);
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 0cd5d073ed..b99100590c 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -84,14 +84,14 @@ void ff_h263_show_pict_info(H263DecContext *const h, int h263_plus)
h->c.qscale, av_get_picture_type_char(h->c.pict_type),
h->gb.size_in_bits, 1-h->c.no_rounding,
h->c.obmc ? " AP" : "",
- h->c.umvplus ? " UMV" : "",
+ h->umvplus ? " UMV" : "",
h->h263_long_vectors ? " LONG" : "",
h263_plus ? " +" : "",
h->c.h263_aic ? " AIC" : "",
- h->c.alt_inter_vlc ? " AIV" : "",
- h->c.modified_quant ? " MQ" : "",
+ h->alt_inter_vlc ? " AIV" : "",
+ h->modified_quant ? " MQ" : "",
h->c.loop_filter ? " LOOP" : "",
- h->c.h263_slice_structured ? " SS" : "",
+ h->h263_slice_structured ? " SS" : "",
h->c.avctx->framerate.num, h->c.avctx->framerate.den);
}
}
@@ -179,7 +179,7 @@ static int h263_decode_gob_header(H263DecContext *const h)
if(left<=13)
return -1;
- if (h->c.h263_slice_structured) {
+ if (h->h263_slice_structured) {
if (check_marker(h->c.avctx, &h->gb, "before MBA")==0)
return -1;
@@ -196,7 +196,7 @@ static int h263_decode_gob_header(H263DecContext *const h)
}else{
gob_number = get_bits(&h->gb, 5); /* GN */
h->c.mb_x = 0;
- h->c.mb_y = h->c.gob_index* gob_number;
+ h->c.mb_y = h->gob_index* gob_number;
skip_bits(&h->gb, 2); /* GFID */
h->c.qscale = get_bits(&h->gb, 5); /* GQUANT */
}
@@ -377,19 +377,19 @@ static void preview_obmc(H263DecContext *const h)
}else{
get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
if (cbpc & 8) {
- skip_bits(&h->gb, h->c.modified_quant ? (get_bits1(&h->gb) ? 1 : 5) : 2);
+ skip_bits(&h->gb, h->modified_quant ? (get_bits1(&h->gb) ? 1 : 5) : 2);
}
if ((cbpc & 16) == 0) {
h->c.cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
/* 16x16 motion prediction */
mot_val= ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y);
- if (h->c.umvplus)
+ if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x);
else
mx = ff_h263_decode_motion(h, pred_x, 1);
- if (h->c.umvplus)
+ if (h->umvplus)
my = h263p_decode_umotion(h, pred_y);
else
my = ff_h263_decode_motion(h, pred_y, 1);
@@ -402,16 +402,16 @@ static void preview_obmc(H263DecContext *const h)
h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
for(i=0;i<4;i++) {
mot_val = ff_h263_pred_motion(&h->c, i, 0, &pred_x, &pred_y);
- if (h->c.umvplus)
+ if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x);
else
mx = ff_h263_decode_motion(h, pred_x, 1);
- if (h->c.umvplus)
+ if (h->umvplus)
my = h263p_decode_umotion(h, pred_y);
else
my = ff_h263_decode_motion(h, pred_y, 1);
- if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (h->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
mot_val[0] = mx;
mot_val[1] = my;
@@ -434,7 +434,7 @@ static void h263_decode_dquant(H263DecContext *const h)
static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
int qscale;
- if (h->c.modified_quant) {
+ if (h->modified_quant) {
if (get_bits1(&h->gb))
qscale = ff_modified_quant_tab[get_bits1(&h->gb)][h->c.qscale];
else
@@ -598,7 +598,7 @@ retry:
return -1;
}
/* escape */
- if (CONFIG_FLV_DECODER && h->c.h263_flv) {
+ if (CONFIG_FLV_DECODER && h->flv) {
int is11 = SHOW_UBITS(re, &h->gb, 1);
SKIP_CACHE(re, &h->gb, 1);
run = SHOW_UBITS(re, &h->gb, 7) + 1;
@@ -646,7 +646,7 @@ retry:
block[scan_table[i]] = level;
break;
}
- if(h->c.alt_inter_vlc && rl == &ff_h263_rl_inter && !h->c.mb_intra){
+ if(h->alt_inter_vlc && rl == &ff_h263_rl_inter && !h->c.mb_intra){
//Looks like a hack but no, it's the way it is supposed to work ...
rl = &ff_rl_intra_aic;
i = 0;
@@ -826,7 +826,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
return SLICE_ERROR;
}
- if (!h->c.alt_inter_vlc|| (cbpc & 3)!=3)
+ if (!h->alt_inter_vlc|| (cbpc & 3)!=3)
cbpy ^= 0xF;
cbp = (cbpc & 3) | (cbpy << 2);
@@ -840,7 +840,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
/* 16x16 motion prediction */
h->c.mv_type = MV_TYPE_16X16;
ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y);
- if (h->c.umvplus)
+ if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x);
else
mx = ff_h263_decode_motion(h, pred_x, 1);
@@ -848,7 +848,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
if (mx >= 0xffff)
return SLICE_ERROR;
- if (h->c.umvplus)
+ if (h->umvplus)
my = h263p_decode_umotion(h, pred_y);
else
my = ff_h263_decode_motion(h, pred_y, 1);
@@ -858,21 +858,21 @@ int ff_h263_decode_mb(H263DecContext *const h)
h->c.mv[0][0][0] = mx;
h->c.mv[0][0][1] = my;
- if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (h->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
} else {
h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
h->c.mv_type = MV_TYPE_8X8;
for(i=0;i<4;i++) {
mot_val = ff_h263_pred_motion(&h->c, i, 0, &pred_x, &pred_y);
- if (h->c.umvplus)
+ if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x);
else
mx = ff_h263_decode_motion(h, pred_x, 1);
if (mx >= 0xffff)
return SLICE_ERROR;
- if (h->c.umvplus)
+ if (h->umvplus)
my = h263p_decode_umotion(h, pred_y);
else
my = ff_h263_decode_motion(h, pred_y, 1);
@@ -880,7 +880,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
return SLICE_ERROR;
h->c.mv[0][i][0] = mx;
h->c.mv[0][i][1] = my;
- if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (h->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
mot_val[0] = mx;
mot_val[1] = my;
@@ -926,7 +926,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
return SLICE_ERROR;
}
- if (!h->c.alt_inter_vlc || (cbpc & 3)!=3)
+ if (!h->alt_inter_vlc || (cbpc & 3)!=3)
cbpy ^= 0xF;
cbp = (cbpc & 3) | (cbpy << 2);
@@ -951,21 +951,21 @@ int ff_h263_decode_mb(H263DecContext *const h)
int16_t *mot_val = ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y);
h->c.mv_dir = MV_DIR_FORWARD;
- if (h->c.umvplus)
+ if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x);
else
mx = ff_h263_decode_motion(h, pred_x, 1);
if (mx >= 0xffff)
return SLICE_ERROR;
- if (h->c.umvplus)
+ if (h->umvplus)
my = h263p_decode_umotion(h, pred_y);
else
my = ff_h263_decode_motion(h, pred_y, 1);
if (my >= 0xffff)
return SLICE_ERROR;
- if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (h->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
h->c.mv[0][0][0] = mx;
@@ -978,21 +978,21 @@ int ff_h263_decode_mb(H263DecContext *const h)
int16_t *mot_val = ff_h263_pred_motion(&h->c, 0, 1, &pred_x, &pred_y);
h->c.mv_dir |= MV_DIR_BACKWARD;
- if (h->c.umvplus)
+ if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x);
else
mx = ff_h263_decode_motion(h, pred_x, 1);
if (mx >= 0xffff)
return SLICE_ERROR;
- if (h->c.umvplus)
+ if (h->umvplus)
my = h263p_decode_umotion(h, pred_y);
else
my = ff_h263_decode_motion(h, pred_y, 1);
if (my >= 0xffff)
return SLICE_ERROR;
- if (h->c.umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
+ if (h->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
h->c.mv[1][0][0] = mx;
@@ -1112,9 +1112,9 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
/* temporal reference */
i = get_bits(&h->gb, 8); /* picture timestamp */
- i -= (i - (h->c.picture_number & 0xFF) + 128) & ~0xFF;
+ i -= (i - (h->picture_number & 0xFF) + 128) & ~0xFF;
- h->c.picture_number = (h->c.picture_number&~0xFF) + i;
+ h->picture_number = (h->picture_number&~0xFF) + i;
/* PTYPE starts here */
if (check_marker(h->c.avctx, &h->gb, "in PTYPE") != 1) {
@@ -1175,7 +1175,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
format = get_bits(&h->gb, 3);
ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format);
h->custom_pcf = get_bits1(&h->gb);
- h->c.umvplus = get_bits1(&h->gb); /* Unrestricted Motion Vector */
+ h->umvplus = get_bits1(&h->gb); /* Unrestricted Motion Vector */
if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
}
@@ -1185,16 +1185,16 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
if (h->c.avctx->lowres)
h->c.loop_filter = 0;
- h->c.h263_slice_structured = get_bits1(&h->gb);
+ h->h263_slice_structured = get_bits1(&h->gb);
if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
}
if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
}
- h->c.alt_inter_vlc = get_bits1(&h->gb);
- h->c.modified_quant = get_bits1(&h->gb);
- if (h->c.modified_quant)
+ h->alt_inter_vlc = get_bits1(&h->gb);
+ h->modified_quant = get_bits1(&h->gb);
+ if (h->modified_quant)
h->c.chroma_qscale_table= ff_h263_chroma_qscale_table;
skip_bits(&h->gb, 1); /* Prevent start code emulation */
@@ -1277,11 +1277,11 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
skip_bits(&h->gb, 2); //extended Temporal reference
if (ufep) {
- if (h->c.umvplus) {
+ if (h->umvplus) {
if (get_bits1(&h->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
skip_bits1(&h->gb);
}
- if (h->c.h263_slice_structured) {
+ if (h->h263_slice_structured) {
if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
}
@@ -1313,7 +1313,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
h->c.mb_height = (h->c.height + 15U) / 16;
h->c.mb_num = h->c.mb_width * h->c.mb_height;
- h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
+ h->gob_index = H263_GOB_HEIGHT(h->c.height);
if (h->pb_frame) {
skip_bits(&h->gb, 3); /* Temporal reference for B-pictures */
@@ -1323,11 +1323,11 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
}
if (h->c.pict_type!=AV_PICTURE_TYPE_B) {
- h->c.time = h->c.picture_number;
+ h->c.time = h->picture_number;
h->c.pp_time = h->c.time - h->c.last_non_b_time;
h->c.last_non_b_time = h->c.time;
}else{
- h->c.time = h->c.picture_number;
+ h->c.time = h->picture_number;
h->c.pb_time = h->c.pp_time - (h->c.last_non_b_time - h->c.time);
if (h->c.pp_time <= h->c.pb_time ||
h->c.pp_time <= h->c.pp_time - h->c.pb_time ||
@@ -1342,7 +1342,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
if (skip_1stop_8data_bits(&h->gb) < 0)
return AVERROR_INVALIDDATA;
- if (h->c.h263_slice_structured) {
+ if (h->h263_slice_structured) {
if (check_marker(h->c.avctx, &h->gb, "SEPB1") != 1) {
return -1;
}
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 682d4bd24e..250ce0b043 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -244,7 +244,7 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
put_bits(&s->pb, 22, 0x20); /* PSC */
- temp_ref= s->c.picture_number * (int64_t)coded_frame_rate * s->c.avctx->time_base.num / //FIXME use timestamp
+ temp_ref = s->picture_number * (int64_t)coded_frame_rate * s->c.avctx->time_base.num / //FIXME use timestamp
(coded_frame_rate_base * (int64_t)s->c.avctx->time_base.den);
put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */
@@ -281,16 +281,16 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
put_bits(&s->pb, 3, format);
put_bits(&s->pb,1, custom_pcf);
- put_bits(&s->pb,1, s->c.umvplus); /* Unrestricted Motion Vector */
+ put_bits(&s->pb,1, s->umvplus); /* Unrestricted Motion Vector */
put_bits(&s->pb,1,0); /* SAC: off */
put_bits(&s->pb,1,s->c.obmc); /* Advanced Prediction Mode */
put_bits(&s->pb,1,s->c.h263_aic); /* Advanced Intra Coding */
put_bits(&s->pb,1,s->c.loop_filter); /* Deblocking Filter */
- put_bits(&s->pb,1,s->c.h263_slice_structured); /* Slice Structured */
+ put_bits(&s->pb,1,s->h263_slice_structured); /* Slice Structured */
put_bits(&s->pb,1,0); /* Reference Picture Selection: off */
put_bits(&s->pb,1,0); /* Independent Segment Decoding: off */
- put_bits(&s->pb,1,s->c.alt_inter_vlc); /* Alternative Inter VLC */
- put_bits(&s->pb,1,s->c.modified_quant); /* Modified Quantization: */
+ put_bits(&s->pb,1,s->alt_inter_vlc); /* Alternative Inter VLC */
+ put_bits(&s->pb,1,s->modified_quant); /* Modified Quantization: */
put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
put_bits(&s->pb,3,0); /* Reserved */
@@ -327,11 +327,11 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
}
/* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
- if (s->c.umvplus)
+ if (s->umvplus)
// put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
//FIXME check actual requested range
put_bits(&s->pb,2,1); /* unlimited */
- if(s->c.h263_slice_structured)
+ if (s->h263_slice_structured)
put_bits(&s->pb,2,0); /* no weird submodes */
put_bits(&s->pb, 5, s->c.qscale);
@@ -339,7 +339,7 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
put_bits(&s->pb, 1, 0); /* no PEI */
- if(s->c.h263_slice_structured){
+ if (s->h263_slice_structured) {
put_bits(&s->pb, 1, 1);
av_assert1(s->c.mb_x == 0 && s->c.mb_y == 0);
@@ -374,7 +374,7 @@ void ff_h263_encode_gob_header(MPVEncContext *const s, int mb_line)
{
put_bits(&s->pb, 17, 1); /* GBSC */
- if(s->c.h263_slice_structured){
+ if (s->h263_slice_structured) {
put_bits(&s->pb, 1, 1);
ff_h263_encode_mba(s);
@@ -385,7 +385,7 @@ void ff_h263_encode_gob_header(MPVEncContext *const s, int mb_line)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 2, s->c.pict_type == AV_PICTURE_TYPE_I); /* GFID */
}else{
- int gob_number= mb_line / s->c.gob_index;
+ int gob_number = mb_line / s->gob_index;
put_bits(&s->pb, 5, gob_number); /* GN */
put_bits(&s->pb, 2, s->c.pict_type == AV_PICTURE_TYPE_I); /* GFID */
@@ -479,7 +479,7 @@ static void h263_encode_block(MPVEncContext *const s, int16_t block[], int n)
if (s->c.h263_aic && s->c.mb_intra)
rl = &ff_rl_intra_aic;
- if(s->c.alt_inter_vlc && !s->c.mb_intra){
+ if (s->alt_inter_vlc && !s->c.mb_intra) {
int aic_vlc_bits=0;
int inter_vlc_bits=0;
int wrong_pos=-1;
@@ -634,7 +634,7 @@ static void h263_encode_mb(MPVEncContext *const s,
cbpc = cbp & 3;
cbpy = cbp >> 2;
- if(s->c.alt_inter_vlc==0 || cbpc!=3)
+ if (!s->alt_inter_vlc || cbpc!=3)
cbpy ^= 0xF;
if(s->dquant) cbpc+= 8;
if(s->c.mv_type==MV_TYPE_16X16){
@@ -653,7 +653,7 @@ static void h263_encode_mb(MPVEncContext *const s,
/* motion vectors: 16x16 mode */
ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y);
- if (!s->c.umvplus) {
+ if (!s->umvplus) {
ff_h263_encode_motion_vector(s, motion_x - pred_x,
motion_y - pred_y, 1);
}
@@ -682,7 +682,7 @@ static void h263_encode_mb(MPVEncContext *const s,
motion_x = s->c.cur_pic.motion_val[0][s->c.block_index[i]][0];
motion_y = s->c.cur_pic.motion_val[0][s->c.block_index[i]][1];
- if (!s->c.umvplus) {
+ if (!s->umvplus) {
ff_h263_encode_motion_vector(s, motion_x - pred_x,
motion_y - pred_y, 1);
}
@@ -718,7 +718,7 @@ static void h263_encode_mb(MPVEncContext *const s,
else
level = (level - (scale>>1))/scale;
- if (!s->c.modified_quant) {
+ if (!s->modified_quant) {
if (level < -127)
level = -127;
else if (level > 127)
@@ -838,18 +838,18 @@ av_cold void ff_h263_encode_init(MPVMainEncContext *const m)
}
s->ac_esc_length= 7+1+6+8;
- if (s->c.modified_quant)
+ if (s->modified_quant)
s->c.chroma_qscale_table = ff_h263_chroma_qscale_table;
// Only used for H.263 and H.263+
- s->c.gob_index = H263_GOB_HEIGHT(s->c.height);
+ s->gob_index = H263_GOB_HEIGHT(s->c.height);
// use fcodes >1 only for MPEG-4 & H.263 & H.263+ FIXME
switch(s->c.codec_id){
case AV_CODEC_ID_H263P:
- if (s->c.umvplus)
+ if (s->umvplus)
m->fcode_tab = umv_fcode_tab + MAX_MV;
- if (s->c.modified_quant) {
+ if (s->modified_quant) {
s->min_qcoeff= -2047;
s->max_qcoeff= 2047;
}else{
@@ -922,10 +922,10 @@ const FFCodec ff_h263_encoder = {
};
static const AVOption h263p_options[] = {
- { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "umv", "Use unlimited motion vectors.", FF_MPV_OFFSET(umvplus), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "aiv", "Use alternative inter VLC.", FF_MPV_OFFSET(alt_inter_vlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
+ { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", FF_MPV_OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE},
FF_MPV_COMMON_OPTS
FF_MPV_COMMON_MOTION_EST_OPTS
{ NULL },
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 521a915aa0..fb480d0eec 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -350,9 +350,8 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
put_header(s, PICTURE_START_CODE);
/* temporal reference */
- // RAL: s->c.picture_number instead of s->fake_picture_number
put_bits(&s->pb, 10,
- (s->c.picture_number - mpeg12->gop_picture_number) & 0x3ff);
+ (s->picture_number - mpeg12->gop_picture_number) & 0x3ff);
put_bits(&s->pb, 3, s->c.pict_type);
m->vbv_delay_pos = put_bytes_count(&s->pb, 0);
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index bc17b0ed09..aaf2ecf7c4 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2699,7 +2699,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
} else {
/* is setting low delay flag only once the smartest thing to do?
* low delay detection will not be overridden. */
- if (h->c.picture_number == 0) {
+ if (h->picture_number == 0) {
switch (ctx->vo_type) {
case SIMPLE_VO_TYPE:
case ADV_SIMPLE_VO_TYPE:
@@ -2938,8 +2938,8 @@ no_cplx_est:
ctx->resync_marker = !get_bits1(gb); /* resync_marker_disabled */
- h->c.data_partitioning = get_bits1(gb);
- if (h->c.data_partitioning)
+ h->data_partitioning = get_bits1(gb);
+ if (h->data_partitioning)
ctx->rvlc = get_bits1(gb);
if (vo_ver_id != 1) {
@@ -2996,7 +2996,7 @@ no_cplx_est:
h->c.low_delay,
ctx->scalability ? "scalability " :"" ,
h->c.quarter_sample ? "qpel " : "",
- h->c.data_partitioning ? "partition " : "",
+ h->data_partitioning ? "partition " : "",
ctx->rvlc ? "rvlc " : ""
);
}
@@ -3222,7 +3222,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
h->c.low_delay = 0;
}
- h->c.partitioned_frame = h->c.data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
+ h->c.partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
if (h->c.partitioned_frame)
h->decode_mb = mpeg4_decode_partitioned_mb;
else
@@ -3437,7 +3437,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
h->c.pict_type == AV_PICTURE_TYPE_I ? 'I' : (h->c.pict_type == AV_PICTURE_TYPE_P ? 'P' : (h->c.pict_type == AV_PICTURE_TYPE_B ? 'B' : 'S')),
gb->size_in_bits,h->c.progressive_sequence, h->c.alternate_scan,
h->c.top_field_first, h->c.quarter_sample ? 'q' : 'h',
- h->c.data_partitioning, ctx->resync_marker,
+ h->data_partitioning, ctx->resync_marker,
ctx->num_sprite_warping_points, ctx->sprite_warping_accuracy,
1 - h->c.no_rounding, ctx->vo_type,
ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold,
@@ -3472,13 +3472,13 @@ end:
* (divx4/xvid/opendivx). Note we cannot detect divx5 without B-frames
* easily (although it's buggy too) */
if (ctx->vo_type == 0 && ctx->vol_control_parameters == 0 &&
- ctx->divx_version == -1 && h->c.picture_number == 0) {
+ ctx->divx_version == -1 && h->picture_number == 0) {
av_log(h->c.avctx, AV_LOG_WARNING,
"looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
h->c.low_delay = 1;
}
- h->c.picture_number++; // better than pic number==0 always ;)
+ h->picture_number++; // better than pic number==0 always ;)
if (h->c.workaround_bugs & FF_BUG_EDGE) {
h->c.h_edge_pos = h->c.width;
@@ -3898,7 +3898,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
s->sprite_brightness_change = s1->sprite_brightness_change;
s->sprite_warping_accuracy = s1->sprite_warping_accuracy;
s->num_sprite_warping_points = s1->num_sprite_warping_points;
- s->h.c.data_partitioning = s1->h.c.data_partitioning;
+ s->h.data_partitioning = s1->h.data_partitioning;
s->mpeg_quant = s1->mpeg_quant;
s->rvlc = s1->rvlc;
s->resync_marker = s1->resync_marker;
@@ -3923,6 +3923,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
s->h.skipped_last_frame = s1->h.skipped_last_frame;
s->h.padding_bug_score = s1->h.padding_bug_score; // FIXME: racy
+ s->h.picture_number = s1->h.picture_number;
+
memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_shift));
memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj));
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 540ab8e4c3..7432c1f9bd 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -453,10 +453,10 @@ static void mpeg4_encode_mb(MPVEncContext *const s, int16_t block[][64],
int motion_x, int motion_y)
{
int cbpc, cbpy, pred_x, pred_y;
- PutBitContext *const pb2 = s->c.data_partitioning ? &s->pb2 : &s->pb;
- PutBitContext *const tex_pb = s->c.data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B ? &s->tex_pb : &s->pb;
- PutBitContext *const dc_pb = s->c.data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_I ? &s->pb2 : &s->pb;
- const int interleaved_stats = (s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->c.data_partitioning ? 1 : 0;
+ PutBitContext *const pb2 = s->data_partitioning ? &s->pb2 : &s->pb;
+ PutBitContext *const tex_pb = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B ? &s->tex_pb : &s->pb;
+ PutBitContext *const dc_pb = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_I ? &s->pb2 : &s->pb;
+ const int interleaved_stats = (s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->data_partitioning;
if (!s->c.mb_intra) {
int i, cbp;
@@ -994,8 +994,8 @@ static void mpeg4_encode_vol_header(Mpeg4EncContext *const m4,
put_bits(&s->pb, 1, s->c.quarter_sample);
put_bits(&s->pb, 1, 1); /* complexity estimation disable */
put_bits(&s->pb, 1, s->rtp_mode ? 0 : 1); /* resync marker disable */
- put_bits(&s->pb, 1, s->c.data_partitioning ? 1 : 0);
- if (s->c.data_partitioning)
+ put_bits(&s->pb, 1, s->data_partitioning);
+ if (s->data_partitioning)
put_bits(&s->pb, 1, 0); /* no rvlc */
if (vo_ver_id != 1) {
@@ -1027,13 +1027,13 @@ static int mpeg4_encode_picture_header(MPVMainEncContext *const m)
if (!(s->c.avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy
mpeg4_encode_visual_object_header(m);
- if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || s->c.picture_number == 0) // HACK, the reference sw is buggy
+ if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || s->picture_number == 0) // HACK, the reference sw is buggy
mpeg4_encode_vol_header(m4, 0, 0);
}
mpeg4_encode_gop_header(m);
}
- s->c.partitioned_frame = s->c.data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B;
+ s->c.partitioned_frame = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B;
put_bits32(&s->pb, VOP_STARTCODE); /* vop header */
put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */
@@ -1338,7 +1338,7 @@ void ff_mpeg4_encode_video_packet_header(MPVEncContext *const s)
#define OFFSET(x) offsetof(MPVEncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "data_partitioning", "Use data partitioning.", OFFSET(c.data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+ { "data_partitioning", "Use data partitioning.", FF_MPV_OFFSET(data_partitioning), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "alternate_scan", "Enable alternate scantable.", OFFSET(c.alternate_scan), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "mpeg_quant", "Use MPEG quantizers instead of H.263",
OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE },
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 9c3589752c..a137fe31db 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -194,8 +194,6 @@ av_cold void ff_mpv_common_defaults(MpegEncContext *s)
s->progressive_sequence = 1;
s->picture_structure = PICT_FRAME;
- s->picture_number = 0;
-
s->slice_context_count = 1;
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 9318801019..3b47a02ae1 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -87,9 +87,6 @@ typedef struct MpegEncContext {
enum OutputFormat out_format; ///< output format
int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions
-/* the following codec id fields are deprecated in favor of codec_id */
- int h263_flv; ///< use flv H.263 header
-
enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
int encoding; ///< true if we are encoding (vs decoding)
int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically
@@ -98,7 +95,6 @@ typedef struct MpegEncContext {
/* sequence parameters */
int context_initialized;
- int picture_number; //FIXME remove, unclear definition
int mb_width, mb_height; ///< number of MBs horizontally & vertically
int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
@@ -215,15 +211,10 @@ typedef struct MpegEncContext {
int resync_mb_y; ///< y position of last resync marker
/* H.263 specific */
- int gob_index;
int obmc; ///< overlapped block motion compensation
/* H.263+ specific */
- int umvplus; ///< == H.263+ && unrestricted_mv
int h263_aic_dir; ///< AIC direction: 0 = left, 1 = top
- int h263_slice_structured;
- int alt_inter_vlc; ///< alternative inter vlc
- int modified_quant;
int loop_filter;
/* MPEG-4 specific */
@@ -238,12 +229,10 @@ typedef struct MpegEncContext {
uint16_t pb_field_time; ///< like above, just for interlaced
int mcsel;
int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
- int data_partitioning; ///< data partitioning flag from header
int partitioned_frame; ///< is current frame partitioned
int low_delay; ///< no reordering needed / has no B-frames
/* MSMPEG4 specific */
- int slice_height; ///< in macroblocks
int first_slice_line; ///< used in MPEG-4 too to handle resync markers
enum {
MSMP4_UNUSED,
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 1ae36dc751..e9d0009f3c 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -97,8 +97,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
s->quarter_sample = s1->quarter_sample;
- s->picture_number = s1->picture_number;
-
ff_mpv_replace_picture(&s->cur_pic, &s1->cur_pic);
ff_mpv_replace_picture(&s->last_pic, &s1->last_pic);
ff_mpv_replace_picture(&s->next_pic, &s1->next_pic);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f54f458ab8..ff6d6a8cd7 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -924,9 +924,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->c.out_format = FMT_H263;
/* Fx */
s->c.h263_aic = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0;
- s->c.modified_quant = s->c.h263_aic;
+ s->modified_quant = s->c.h263_aic;
s->c.loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
- s->me.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->c.umvplus;
+ s->me.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->umvplus;
s->flipflop_rounding = 1;
/* /Fx */
@@ -955,7 +955,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->c.out_format = FMT_H263;
avctx->delay = 0;
s->c.low_delay = 1;
- s->c.modified_quant = 1;
+ s->modified_quant = 1;
// Set here to force allocation of dc_val;
// will be set later on a per-frame basis.
s->c.h263_aic = 1;
@@ -1078,7 +1078,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
if (s->c.slice_context_count > 1) {
s->rtp_mode = 1;
if (avctx->codec_id == AV_CODEC_ID_H263P)
- s->c.h263_slice_structured = 1;
+ s->h263_slice_structured = 1;
}
ret = ff_mpv_init_duplicate_contexts(&s->c);
if (ret < 0)
@@ -1853,7 +1853,7 @@ static int select_input_picture(MPVMainEncContext *const m)
ff_mpv_unref_picture(&s->c.cur_pic);
return ret;
}
- s->c.picture_number = s->c.cur_pic.ptr->display_picture_number;
+ s->picture_number = s->c.cur_pic.ptr->display_picture_number;
}
return 0;
@@ -1963,7 +1963,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
/* output? */
if (s->new_pic->data[0]) {
- int growing_buffer = context_count == 1 && !s->c.data_partitioning;
+ int growing_buffer = context_count == 1 && !s->data_partitioning;
size_t pkt_size = 10000 + s->c.mb_width * s->c.mb_height *
(growing_buffer ? 64 : (MAX_MB_BYTES + 100));
if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) {
@@ -2738,7 +2738,7 @@ static void encode_mb_hq(MPVEncContext *const s, MBBackup *const backup, MBBacku
s->block = s->blocks[*next_block];
s->pb = pb[*next_block];
- if (s->c.data_partitioning) {
+ if (s->data_partitioning) {
s->pb2 = pb2 [*next_block];
s->tex_pb= tex_pb[*next_block];
}
@@ -2754,7 +2754,7 @@ static void encode_mb_hq(MPVEncContext *const s, MBBackup *const backup, MBBacku
encode_mb(s, motion_x, motion_y);
score= put_bits_count(&s->pb);
- if (s->c.data_partitioning) {
+ if (s->data_partitioning) {
score+= put_bits_count(&s->pb2);
score+= put_bits_count(&s->tex_pb);
}
@@ -2774,7 +2774,7 @@ static void encode_mb_hq(MPVEncContext *const s, MBBackup *const backup, MBBacku
*dmin= score;
*next_block^=1;
- save_context_after_encode(best, s, s->c.data_partitioning);
+ save_context_after_encode(best, s, s->data_partitioning);
}
}
@@ -2915,8 +2915,8 @@ static void write_mb_info(MPVEncContext *const s)
{
uint8_t *ptr = s->mb_info_ptr + s->mb_info_size - 12;
int offset = put_bits_count(&s->pb);
- int mba = s->c.mb_x + s->c.mb_width * (s->c.mb_y % s->c.gob_index);
- int gobn = s->c.mb_y / s->c.gob_index;
+ int mba = s->c.mb_x + s->c.mb_width * (s->c.mb_y % s->gob_index);
+ int gobn = s->c.mb_y / s->gob_index;
int pred_x, pred_y;
if (CONFIG_H263_ENCODER)
ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y);
@@ -3068,7 +3068,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
av_log(s->c.avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1;
}
- if (s->c.data_partitioning) {
+ if (s->data_partitioning) {
if (put_bytes_left(&s->pb2, 0) < MAX_MB_BYTES ||
put_bytes_left(&s->tex_pb, 0) < MAX_MB_BYTES) {
av_log(s->c.avctx, AV_LOG_ERROR, "encoded partitioned frame too large\n");
@@ -3101,8 +3101,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
switch (s->c.codec_id) {
case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P:
- if (!s->c.h263_slice_structured)
- if (s->c.mb_x || s->c.mb_y % s->c.gob_index) is_gob_start = 0;
+ if (!s->h263_slice_structured)
+ if (s->c.mb_x || s->c.mb_y % s->gob_index) is_gob_start = 0;
break;
case AV_CODEC_ID_MPEG2VIDEO:
if (s->c.mb_x == 0 && s->c.mb_y != 0) is_gob_start = 1;
@@ -3128,7 +3128,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
current_packet_size= put_bits_ptr(&s->pb) - s->ptr_lastgob;
if (s->error_rate && s->c.resync_mb_x + s->c.resync_mb_y > 0) {
- int r = put_bytes_count(&s->pb, 0) + s->c.picture_number + 16 + s->c.mb_x + s->c.mb_y;
+ int r = put_bytes_count(&s->pb, 0) + s->picture_number + 16 + s->c.mb_x + s->c.mb_y;
int d = 100 / s->error_rate;
if(r % d == 0){
current_packet_size=0;
@@ -3194,7 +3194,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
backup_context_before_encode(&backup_s, s);
backup_s.pb= s->pb;
- if (s->c.data_partitioning) {
+ if (s->data_partitioning) {
backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb;
}
@@ -3417,14 +3417,14 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
}
- store_context_after_encode(s, &best_s, s->c.data_partitioning);
+ store_context_after_encode(s, &best_s, s->data_partitioning);
pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb);
ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb;
- if (s->c.data_partitioning) {
+ if (s->data_partitioning) {
pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2);
ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
@@ -3711,7 +3711,7 @@ static void set_frame_distances(MPVEncContext *const s)
}else{
s->c.pp_time = s->c.time - s->c.last_non_b_time;
s->c.last_non_b_time = s->c.time;
- av_assert1(s->c.picture_number == 0 || s->c.pp_time > 0);
+ av_assert1(s->picture_number == 0 || s->c.pp_time > 0);
}
}
@@ -3814,7 +3814,7 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt)
m->mb_var_sum, m->mc_mb_var_sum);
}
- if (!s->c.umvplus) {
+ if (!s->umvplus) {
if (s->c.pict_type == AV_PICTURE_TYPE_P || s->c.pict_type == AV_PICTURE_TYPE_S) {
s->f_code = ff_get_best_fcode(m, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 7aa8af5412..ad48ce6df3 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -128,6 +128,8 @@ typedef struct MPVEncContext {
int dct_count[2];
uint16_t (*dct_offset)[64];
+ int picture_number;
+
/* statistics, used for 2-pass encoding */
int mv_bits;
int i_tex_bits;
@@ -139,11 +141,18 @@ typedef struct MPVEncContext {
int mb_skip_run;
/* H.263 specific */
+ int gob_index;
int mb_info; ///< interval for outputting info about mb offsets as side data
int prev_mb_info, last_mb_info;
int mb_info_size;
uint8_t *mb_info_ptr;
+ /* H.263+ specific */
+ int umvplus; ///< == H.263+ && unrestricted_mv
+ int h263_slice_structured;
+ int alt_inter_vlc; ///< alternative inter vlc
+ int modified_quant;
+
/* MJPEG specific */
struct MJpegContext *mjpeg_ctx;
int esc_pos;
@@ -152,11 +161,13 @@ typedef struct MPVEncContext {
int last_mv_dir; ///< last mv_dir, used for B-frame encoding
/* MPEG-4 specific */
+ int data_partitioning; ///< data partitioning flag, set via option
int mpeg_quant;
PutBitContext tex_pb; ///< used for data partitioned VOPs
PutBitContext pb2; ///< used for data partitioned VOPs
/* MSMPEG4 specific */
+ int slice_height; ///< in macroblocks
int flipflop_rounding; ///< also used for MPEG-4, H.263+
int esc3_level_length;
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index a96a0335f7..d2249559c9 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -403,7 +403,7 @@ static int msmpeg4_decode_picture_header(H263DecContext *const h)
return -1;
}
- h->c.slice_height = code;
+ h->slice_height = code;
}else{
/* 0x17: one slice, 0x18: two slices, ... */
if (code < 0x17){
@@ -411,7 +411,7 @@ static int msmpeg4_decode_picture_header(H263DecContext *const h)
return -1;
}
- h->c.slice_height = h->c.mb_height / (code - 0x16);
+ h->slice_height = h->c.mb_height / (code - 0x16);
}
switch (h->c.msmpeg4_version) {
@@ -455,7 +455,7 @@ static int msmpeg4_decode_picture_header(H263DecContext *const h)
ms->rl_table_index,
ms->dc_table_index,
ms->per_mb_rl_table,
- h->c.slice_height);
+ h->slice_height);
} else {
switch (h->c.msmpeg4_version) {
case MSMP4_V1:
@@ -866,7 +866,7 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
av_unreachable("List contains all cases using ff_msmpeg4_decode_init()");
}
- h->c.slice_height = h->c.mb_height; //to avoid 1/0 if the first frame is not a keyframe
+ h->slice_height = h->c.mb_height; //to avoid 1/0 if the first frame is not a keyframe
ff_thread_once(&init_static_once, msmpeg4_decode_init_static);
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index bcb4af23e9..874e0c1f2b 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -243,8 +243,8 @@ static int msmpeg4_encode_picture_header(MPVMainEncContext *const m)
s->c.inter_intra_pred, s->c.width, s->c.height);
if (s->c.pict_type == AV_PICTURE_TYPE_I) {
- s->c.slice_height = s->c.mb_height/1;
- put_bits(&s->pb, 5, 0x16 + s->c.mb_height/s->c.slice_height);
+ s->slice_height = s->c.mb_height/1;
+ put_bits(&s->pb, 5, 0x16 + s->c.mb_height / s->slice_height);
if (s->c.msmpeg4_version == MSMP4_WMV1) {
ff_msmpeg4_encode_ext_header(s);
@@ -332,7 +332,7 @@ void ff_msmpeg4_encode_motion(MSMPEG4EncContext *const ms,
void ff_msmpeg4_handle_slices(MPVEncContext *const s)
{
if (s->c.mb_x == 0) {
- if (s->c.slice_height && (s->c.mb_y % s->c.slice_height) == 0) {
+ if (s->slice_height && (s->c.mb_y % s->slice_height) == 0) {
if (s->c.msmpeg4_version < MSMP4_WMV1)
ff_mpeg4_clean_buffers(&s->c);
s->c.first_slice_line = 1;
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 3dc44683d0..7f89b5b218 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -901,7 +901,7 @@ void ff_get_2pass_fcode(MPVMainEncContext *const m)
{
MPVEncContext *const s = &m->s;
const RateControlContext *rcc = &m->rc_context;
- const RateControlEntry *rce = &rcc->entry[s->c.picture_number];
+ const RateControlEntry *rce = &rcc->entry[s->picture_number];
s->f_code = rce->f_code;
s->b_code = rce->b_code;
@@ -920,7 +920,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *const m, int dry_run)
double diff;
double short_term_q;
double fps;
- int picture_number = s->c.picture_number;
+ int picture_number = s->picture_number;
int64_t wanted_bits;
RateControlEntry local_rce, *rce;
double bits;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index c104efc212..ed702dfb66 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -372,7 +372,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
h->h263_long_vectors = avctx->extradata[3] & 1;
rv->sub_id = AV_RB32A(avctx->extradata + 4);
if (avctx->codec_id == AV_CODEC_ID_RV20) {
- h->c.modified_quant = 1;
+ h->modified_quant = 1;
h->c.chroma_qscale_table = ff_h263_chroma_qscale_table;
}
diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c
index ef2228bb26..31fc33ddc7 100644
--- a/libavcodec/rv20enc.c
+++ b/libavcodec/rv20enc.c
@@ -44,7 +44,7 @@ int ff_rv20_encode_picture_header(MPVMainEncContext *const m)
put_bits(&s->pb, 1, 0); /* unknown bit */
put_bits(&s->pb, 5, s->c.qscale);
- put_sbits(&s->pb, 8, s->c.picture_number); //FIXME wrong, but correct is not known
+ put_sbits(&s->pb, 8, s->picture_number); //FIXME wrong, but correct is not known
s->c.mb_x = s->c.mb_y = 0;
ff_h263_encode_mba(s);
@@ -52,9 +52,9 @@ int ff_rv20_encode_picture_header(MPVMainEncContext *const m)
av_assert1(s->f_code == 1);
av_assert1(!s->me.unrestricted_mv);
- av_assert1(!s->c.alt_inter_vlc);
- av_assert1(!s->c.umvplus);
- av_assert1(s->c.modified_quant == 1);
+ av_assert1(!s->alt_inter_vlc);
+ av_assert1(!s->umvplus);
+ av_assert1(s->modified_quant == 1);
av_assert1(s->c.loop_filter == 1);
s->c.h263_aic = s->c.pict_type == AV_PICTURE_TYPE_I;
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 68da7f55e7..1db2429a3f 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1792,7 +1792,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
pic->pict_type = pict->pict_type;
pic->quality = pict->quality;
- mpv->c.picture_number = avctx->frame_num;
+ mpv->picture_number = avctx->frame_num;
if(avctx->flags&AV_CODEC_FLAG_PASS2){
mpv->c.pict_type = pic->pict_type = enc->m.rc_context.entry[avctx->frame_num].new_pict_type;
s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I;
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index 20f96f791b..d936a290cd 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -72,7 +72,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx,
.sprite_warping_accuracy = ctx->sprite_warping_accuracy,
.quant_type = ctx->mpeg_quant,
.quarter_sample = s->quarter_sample,
- .data_partitioned = s->data_partitioning,
+ .data_partitioned = ctx->h.data_partitioning,
.reversible_vlc = ctx->rvlc,
.resync_marker_disable = !ctx->resync_marker,
},
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 53d127d37f..a5c47b722e 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -188,7 +188,7 @@ static int decode_ext_header(WMV2DecContext *w)
if (code == 0)
return AVERROR_INVALIDDATA;
- h->c.slice_height = h->c.mb_height / code;
+ h->slice_height = h->c.mb_height / code;
if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
av_log(h->c.avctx, AV_LOG_DEBUG,
diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c
index 9e1d62b90e..5c78712e4e 100644
--- a/libavcodec/wmv2enc.c
+++ b/libavcodec/wmv2enc.c
@@ -68,7 +68,7 @@ static int encode_ext_header(WMV2EncContext *w)
flush_put_bits(&pb);
- s->c.slice_height = s->c.mb_height / code;
+ s->slice_height = s->c.mb_height / code;
return 0;
}
More information about the ffmpeg-cvslog
mailing list