1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/mpegvideo: Move fields to {H263Dec,MPVEnc}Context when possible

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-06-22 13:36:36 +02:00
parent 00ea78f426
commit 3c06d87c93
25 changed files with 162 additions and 151 deletions

View File

@ -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"); av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
h->c.h263_flv = format; h->flv = format;
h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */ h->picture_number = get_bits(&h->gb, 8); /* picture timestamp */
format = get_bits(&h->gb, 3); format = get_bits(&h->gb, 3);
switch (format) { switch (format) {
case 0: case 0:
@ -101,7 +101,7 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) { 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", 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.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; return 0;

View File

@ -35,7 +35,7 @@ int ff_flv_encode_picture_header(MPVMainEncContext *const m)
/* 0: H.263 escape codes 1: 11-bit escape codes */ /* 0: H.263 escape codes 1: 11-bit escape codes */
put_bits(&s->pb, 5, 1); put_bits(&s->pb, 5, 1);
put_bits(&s->pb, 8, 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 */ s->c.avctx->time_base.den) & 0xff); /* TemporalReference */
if (s->c.width == 352 && s->c.height == 288) if (s->c.width == 352 && s->c.height == 288)
format = 2; format = 2;

View File

@ -77,7 +77,7 @@ static int h261_encode_picture_header(MPVMainEncContext *const m)
put_bits(&s->pb, 20, 0x10); /* PSC */ 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 (1001LL * s->c.avctx->time_base.den); // FIXME maybe this should use a timestamp
put_sbits(&s->pb, 5, temp_ref); /* TemporalReference */ put_sbits(&s->pb, 5, temp_ref); /* TemporalReference */

View File

@ -231,7 +231,7 @@ static int decode_slice(H263DecContext *const h)
for (; h->c.mb_y < h->c.mb_height; h->c.mb_y++) { for (; h->c.mb_y < h->c.mb_height; h->c.mb_y++) {
/* per-row end of slice checks */ /* per-row end of slice checks */
if (h->c.msmpeg4_version != MSMP4_UNUSED) { 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, 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); 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) && (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&h->gb) >= 48 && get_bits_left(&h->gb) >= 48 &&
show_bits(&h->gb, 24) == 0x4010 && show_bits(&h->gb, 24) == 0x4010 &&
!h->c.data_partitioning) !h->data_partitioning)
h->padding_bug_score += 32; h->padding_bug_score += 32;
/* try to detect the padding bug */ /* try to detect the padding bug */
@ -338,7 +338,7 @@ static int decode_slice(H263DecContext *const h)
(h->c.workaround_bugs & FF_BUG_AUTODETECT) && (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
get_bits_left(&h->gb) >= 0 && get_bits_left(&h->gb) >= 0 &&
get_bits_left(&h->gb) < 137 && 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_count = get_bits_count(&h->gb);
const int bits_left = h->gb.size_in_bits - bits_count; 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 && get_bits_left(&h->gb) < 300 &&
h->c.pict_type == AV_PICTURE_TYPE_I && h->c.pict_type == AV_PICTURE_TYPE_I &&
show_bits(&h->gb, 8) == 0 && show_bits(&h->gb, 8) == 0 &&
!h->c.data_partitioning) { !h->data_partitioning) {
h->padding_bug_score += 32; 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->c.workaround_bugs & FF_BUG_AUTODETECT) {
if ( 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; h->c.workaround_bugs |= FF_BUG_NO_PADDING;
else else
h->c.workaround_bugs &= ~FF_BUG_NO_PADDING; 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); slice_ret = decode_slice(h);
while (h->c.mb_y < h->c.mb_height) { while (h->c.mb_y < h->c.mb_height) {
if (h->c.msmpeg4_version != MSMP4_UNUSED) { if (h->c.msmpeg4_version != MSMP4_UNUSED) {
if (h->c.slice_height == 0 || h->c.mb_x != 0 || slice_ret < 0 || if (h->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) (h->c.mb_y % h->slice_height) != 0 || get_bits_left(&h->gb) < 0)
break; break;
} else { } else {
int prev_x = h->c.mb_x, prev_y = h->c.mb_y; int prev_x = h->c.mb_x, prev_y = h->c.mb_y;

View File

@ -47,21 +47,35 @@ typedef struct H263DecContext {
int mb_num_left; ///< number of MBs left in this video packet (for partitioned slices only) 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) int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
/* motion compensation */ /* motion compensation */
int h263_long_vectors; ///< use horrible H.263v1 long vector mode int h263_long_vectors; ///< use horrible H.263v1 long vector mode
/* FLV specific */
int flv; ///< use flv H.263 header
/* H.263 specific */ /* H.263 specific */
int ehc_mode; int ehc_mode;
int gob_index;
/* H.263+ specific */ /* H.263+ specific */
int custom_pcf; 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 */ /* MPEG-4 specific */
int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4 int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4
int skipped_last_frame; int skipped_last_frame;
int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5 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 */ /* RV10 specific */
int rv10_version; ///< RV10 version: 0 or 3 int rv10_version; ///< RV10 version: 0 or 3

View File

@ -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"); av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
return -1; 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) { if (check_marker(h->c.avctx, &h->gb, "after picture_number") != 1) {
return -1; /* marker */ 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) if (skip_1stop_8data_bits(&h->gb) < 0)
return AVERROR_INVALIDDATA; 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); ff_h263_show_pict_info(h, 0);

View File

@ -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->c.qscale, av_get_picture_type_char(h->c.pict_type),
h->gb.size_in_bits, 1-h->c.no_rounding, h->gb.size_in_bits, 1-h->c.no_rounding,
h->c.obmc ? " AP" : "", h->c.obmc ? " AP" : "",
h->c.umvplus ? " UMV" : "", h->umvplus ? " UMV" : "",
h->h263_long_vectors ? " LONG" : "", h->h263_long_vectors ? " LONG" : "",
h263_plus ? " +" : "", h263_plus ? " +" : "",
h->c.h263_aic ? " AIC" : "", h->c.h263_aic ? " AIC" : "",
h->c.alt_inter_vlc ? " AIV" : "", h->alt_inter_vlc ? " AIV" : "",
h->c.modified_quant ? " MQ" : "", h->modified_quant ? " MQ" : "",
h->c.loop_filter ? " LOOP" : "", 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); 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) if(left<=13)
return -1; return -1;
if (h->c.h263_slice_structured) { if (h->h263_slice_structured) {
if (check_marker(h->c.avctx, &h->gb, "before MBA")==0) if (check_marker(h->c.avctx, &h->gb, "before MBA")==0)
return -1; return -1;
@ -196,7 +196,7 @@ static int h263_decode_gob_header(H263DecContext *const h)
}else{ }else{
gob_number = get_bits(&h->gb, 5); /* GN */ gob_number = get_bits(&h->gb, 5); /* GN */
h->c.mb_x = 0; 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 */ skip_bits(&h->gb, 2); /* GFID */
h->c.qscale = get_bits(&h->gb, 5); /* GQUANT */ h->c.qscale = get_bits(&h->gb, 5); /* GQUANT */
} }
@ -377,19 +377,19 @@ static void preview_obmc(H263DecContext *const h)
}else{ }else{
get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1); get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
if (cbpc & 8) { 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) { if ((cbpc & 16) == 0) {
h->c.cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV; h->c.cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
/* 16x16 motion prediction */ /* 16x16 motion prediction */
mot_val= ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y); 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); mx = h263p_decode_umotion(h, pred_x);
else else
mx = ff_h263_decode_motion(h, pred_x, 1); mx = ff_h263_decode_motion(h, pred_x, 1);
if (h->c.umvplus) if (h->umvplus)
my = h263p_decode_umotion(h, pred_y); my = h263p_decode_umotion(h, pred_y);
else else
my = ff_h263_decode_motion(h, pred_y, 1); 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; h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
for(i=0;i<4;i++) { for(i=0;i<4;i++) {
mot_val = ff_h263_pred_motion(&h->c, i, 0, &pred_x, &pred_y); 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); mx = h263p_decode_umotion(h, pred_x);
else else
mx = ff_h263_decode_motion(h, pred_x, 1); mx = ff_h263_decode_motion(h, pred_x, 1);
if (h->c.umvplus) if (h->umvplus)
my = h263p_decode_umotion(h, pred_y); my = h263p_decode_umotion(h, pred_y);
else else
my = ff_h263_decode_motion(h, pred_y, 1); 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 */ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
mot_val[0] = mx; mot_val[0] = mx;
mot_val[1] = my; 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 }; static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
int qscale; int qscale;
if (h->c.modified_quant) { if (h->modified_quant) {
if (get_bits1(&h->gb)) if (get_bits1(&h->gb))
qscale = ff_modified_quant_tab[get_bits1(&h->gb)][h->c.qscale]; qscale = ff_modified_quant_tab[get_bits1(&h->gb)][h->c.qscale];
else else
@ -598,7 +598,7 @@ retry:
return -1; return -1;
} }
/* escape */ /* escape */
if (CONFIG_FLV_DECODER && h->c.h263_flv) { if (CONFIG_FLV_DECODER && h->flv) {
int is11 = SHOW_UBITS(re, &h->gb, 1); int is11 = SHOW_UBITS(re, &h->gb, 1);
SKIP_CACHE(re, &h->gb, 1); SKIP_CACHE(re, &h->gb, 1);
run = SHOW_UBITS(re, &h->gb, 7) + 1; run = SHOW_UBITS(re, &h->gb, 7) + 1;
@ -646,7 +646,7 @@ retry:
block[scan_table[i]] = level; block[scan_table[i]] = level;
break; 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 ... //Looks like a hack but no, it's the way it is supposed to work ...
rl = &ff_rl_intra_aic; rl = &ff_rl_intra_aic;
i = 0; i = 0;
@ -826,7 +826,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
return SLICE_ERROR; return SLICE_ERROR;
} }
if (!h->c.alt_inter_vlc|| (cbpc & 3)!=3) if (!h->alt_inter_vlc|| (cbpc & 3)!=3)
cbpy ^= 0xF; cbpy ^= 0xF;
cbp = (cbpc & 3) | (cbpy << 2); cbp = (cbpc & 3) | (cbpy << 2);
@ -840,7 +840,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
/* 16x16 motion prediction */ /* 16x16 motion prediction */
h->c.mv_type = MV_TYPE_16X16; h->c.mv_type = MV_TYPE_16X16;
ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y); 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); mx = h263p_decode_umotion(h, pred_x);
else else
mx = ff_h263_decode_motion(h, pred_x, 1); mx = ff_h263_decode_motion(h, pred_x, 1);
@ -848,7 +848,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
if (mx >= 0xffff) if (mx >= 0xffff)
return SLICE_ERROR; return SLICE_ERROR;
if (h->c.umvplus) if (h->umvplus)
my = h263p_decode_umotion(h, pred_y); my = h263p_decode_umotion(h, pred_y);
else else
my = ff_h263_decode_motion(h, pred_y, 1); 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][0] = mx;
h->c.mv[0][0][1] = my; 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 */ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
} else { } else {
h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV; h->c.cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
h->c.mv_type = MV_TYPE_8X8; h->c.mv_type = MV_TYPE_8X8;
for(i=0;i<4;i++) { for(i=0;i<4;i++) {
mot_val = ff_h263_pred_motion(&h->c, i, 0, &pred_x, &pred_y); 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); mx = h263p_decode_umotion(h, pred_x);
else else
mx = ff_h263_decode_motion(h, pred_x, 1); mx = ff_h263_decode_motion(h, pred_x, 1);
if (mx >= 0xffff) if (mx >= 0xffff)
return SLICE_ERROR; return SLICE_ERROR;
if (h->c.umvplus) if (h->umvplus)
my = h263p_decode_umotion(h, pred_y); my = h263p_decode_umotion(h, pred_y);
else else
my = ff_h263_decode_motion(h, pred_y, 1); my = ff_h263_decode_motion(h, pred_y, 1);
@ -880,7 +880,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
return SLICE_ERROR; return SLICE_ERROR;
h->c.mv[0][i][0] = mx; h->c.mv[0][i][0] = mx;
h->c.mv[0][i][1] = my; 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 */ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
mot_val[0] = mx; mot_val[0] = mx;
mot_val[1] = my; mot_val[1] = my;
@ -926,7 +926,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
return SLICE_ERROR; return SLICE_ERROR;
} }
if (!h->c.alt_inter_vlc || (cbpc & 3)!=3) if (!h->alt_inter_vlc || (cbpc & 3)!=3)
cbpy ^= 0xF; cbpy ^= 0xF;
cbp = (cbpc & 3) | (cbpy << 2); 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); int16_t *mot_val = ff_h263_pred_motion(&h->c, 0, 0, &pred_x, &pred_y);
h->c.mv_dir = MV_DIR_FORWARD; h->c.mv_dir = MV_DIR_FORWARD;
if (h->c.umvplus) if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x); mx = h263p_decode_umotion(h, pred_x);
else else
mx = ff_h263_decode_motion(h, pred_x, 1); mx = ff_h263_decode_motion(h, pred_x, 1);
if (mx >= 0xffff) if (mx >= 0xffff)
return SLICE_ERROR; return SLICE_ERROR;
if (h->c.umvplus) if (h->umvplus)
my = h263p_decode_umotion(h, pred_y); my = h263p_decode_umotion(h, pred_y);
else else
my = ff_h263_decode_motion(h, pred_y, 1); my = ff_h263_decode_motion(h, pred_y, 1);
if (my >= 0xffff) if (my >= 0xffff)
return SLICE_ERROR; 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 */ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
h->c.mv[0][0][0] = mx; 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); int16_t *mot_val = ff_h263_pred_motion(&h->c, 0, 1, &pred_x, &pred_y);
h->c.mv_dir |= MV_DIR_BACKWARD; h->c.mv_dir |= MV_DIR_BACKWARD;
if (h->c.umvplus) if (h->umvplus)
mx = h263p_decode_umotion(h, pred_x); mx = h263p_decode_umotion(h, pred_x);
else else
mx = ff_h263_decode_motion(h, pred_x, 1); mx = ff_h263_decode_motion(h, pred_x, 1);
if (mx >= 0xffff) if (mx >= 0xffff)
return SLICE_ERROR; return SLICE_ERROR;
if (h->c.umvplus) if (h->umvplus)
my = h263p_decode_umotion(h, pred_y); my = h263p_decode_umotion(h, pred_y);
else else
my = ff_h263_decode_motion(h, pred_y, 1); my = ff_h263_decode_motion(h, pred_y, 1);
if (my >= 0xffff) if (my >= 0xffff)
return SLICE_ERROR; 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 */ skip_bits1(&h->gb); /* Bit stuffing to prevent PSC */
h->c.mv[1][0][0] = mx; h->c.mv[1][0][0] = mx;
@ -1112,9 +1112,9 @@ int ff_h263_decode_picture_header(H263DecContext *const h)
/* temporal reference */ /* temporal reference */
i = get_bits(&h->gb, 8); /* picture timestamp */ 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 */ /* PTYPE starts here */
if (check_marker(h->c.avctx, &h->gb, "in PTYPE") != 1) { 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); format = get_bits(&h->gb, 3);
ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format); ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format);
h->custom_pcf = get_bits1(&h->gb); 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) { if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); 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) if (h->c.avctx->lowres)
h->c.loop_filter = 0; 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) { if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n"); av_log(h->c.avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
} }
if (get_bits1(&h->gb) != 0) { if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); av_log(h->c.avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
} }
h->c.alt_inter_vlc = get_bits1(&h->gb); h->alt_inter_vlc = get_bits1(&h->gb);
h->c.modified_quant = get_bits1(&h->gb); h->modified_quant = get_bits1(&h->gb);
if (h->c.modified_quant) if (h->modified_quant)
h->c.chroma_qscale_table= ff_h263_chroma_qscale_table; h->c.chroma_qscale_table= ff_h263_chroma_qscale_table;
skip_bits(&h->gb, 1); /* Prevent start code emulation */ 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 skip_bits(&h->gb, 2); //extended Temporal reference
if (ufep) { if (ufep) {
if (h->c.umvplus) { if (h->umvplus) {
if (get_bits1(&h->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ if (get_bits1(&h->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
skip_bits1(&h->gb); skip_bits1(&h->gb);
} }
if (h->c.h263_slice_structured) { if (h->h263_slice_structured) {
if (get_bits1(&h->gb) != 0) { if (get_bits1(&h->gb) != 0) {
av_log(h->c.avctx, AV_LOG_ERROR, "rectangular slices not supported\n"); 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_height = (h->c.height + 15U) / 16;
h->c.mb_num = h->c.mb_width * h->c.mb_height; 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) { if (h->pb_frame) {
skip_bits(&h->gb, 3); /* Temporal reference for B-pictures */ 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) { 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.pp_time = h->c.time - h->c.last_non_b_time;
h->c.last_non_b_time = h->c.time; h->c.last_non_b_time = h->c.time;
}else{ }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); 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 || if (h->c.pp_time <= h->c.pb_time ||
h->c.pp_time <= 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) if (skip_1stop_8data_bits(&h->gb) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (h->c.h263_slice_structured) { if (h->h263_slice_structured) {
if (check_marker(h->c.avctx, &h->gb, "SEPB1") != 1) { if (check_marker(h->c.avctx, &h->gb, "SEPB1") != 1) {
return -1; return -1;
} }

View File

@ -244,7 +244,7 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
coded_frame_rate_base= (1000+best_clock_code)*best_divisor; coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
put_bits(&s->pb, 22, 0x20); /* PSC */ 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); (coded_frame_rate_base * (int64_t)s->c.avctx->time_base.den);
put_sbits(&s->pb, 8, temp_ref); /* TemporalReference */ 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, 3, format);
put_bits(&s->pb,1, custom_pcf); 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,0); /* SAC: off */
put_bits(&s->pb,1,s->c.obmc); /* Advanced Prediction Mode */ 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.h263_aic); /* Advanced Intra Coding */
put_bits(&s->pb,1,s->c.loop_filter); /* Deblocking Filter */ 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); /* Reference Picture Selection: off */
put_bits(&s->pb,1,0); /* Independent Segment Decoding: 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->alt_inter_vlc); /* Alternative Inter VLC */
put_bits(&s->pb,1,s->c.modified_quant); /* Modified Quantization: */ 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,1,1); /* "1" to prevent start code emulation */
put_bits(&s->pb,3,0); /* Reserved */ 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) */ /* 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 */ // put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
//FIXME check actual requested range //FIXME check actual requested range
put_bits(&s->pb,2,1); /* unlimited */ 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,2,0); /* no weird submodes */
put_bits(&s->pb, 5, s->c.qscale); 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 */ 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); put_bits(&s->pb, 1, 1);
av_assert1(s->c.mb_x == 0 && s->c.mb_y == 0); 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 */ put_bits(&s->pb, 17, 1); /* GBSC */
if(s->c.h263_slice_structured){ if (s->h263_slice_structured) {
put_bits(&s->pb, 1, 1); put_bits(&s->pb, 1, 1);
ff_h263_encode_mba(s); 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, 1, 1);
put_bits(&s->pb, 2, s->c.pict_type == AV_PICTURE_TYPE_I); /* GFID */ put_bits(&s->pb, 2, s->c.pict_type == AV_PICTURE_TYPE_I); /* GFID */
}else{ }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, 5, gob_number); /* GN */
put_bits(&s->pb, 2, s->c.pict_type == AV_PICTURE_TYPE_I); /* GFID */ 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) if (s->c.h263_aic && s->c.mb_intra)
rl = &ff_rl_intra_aic; 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 aic_vlc_bits=0;
int inter_vlc_bits=0; int inter_vlc_bits=0;
int wrong_pos=-1; int wrong_pos=-1;
@ -634,7 +634,7 @@ static void h263_encode_mb(MPVEncContext *const s,
cbpc = cbp & 3; cbpc = cbp & 3;
cbpy = cbp >> 2; cbpy = cbp >> 2;
if(s->c.alt_inter_vlc==0 || cbpc!=3) if (!s->alt_inter_vlc || cbpc!=3)
cbpy ^= 0xF; cbpy ^= 0xF;
if(s->dquant) cbpc+= 8; if(s->dquant) cbpc+= 8;
if(s->c.mv_type==MV_TYPE_16X16){ if(s->c.mv_type==MV_TYPE_16X16){
@ -653,7 +653,7 @@ static void h263_encode_mb(MPVEncContext *const s,
/* motion vectors: 16x16 mode */ /* motion vectors: 16x16 mode */
ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y); 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, ff_h263_encode_motion_vector(s, motion_x - pred_x,
motion_y - pred_y, 1); 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_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]; 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, ff_h263_encode_motion_vector(s, motion_x - pred_x,
motion_y - pred_y, 1); motion_y - pred_y, 1);
} }
@ -718,7 +718,7 @@ static void h263_encode_mb(MPVEncContext *const s,
else else
level = (level - (scale>>1))/scale; level = (level - (scale>>1))/scale;
if (!s->c.modified_quant) { if (!s->modified_quant) {
if (level < -127) if (level < -127)
level = -127; level = -127;
else if (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; 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; s->c.chroma_qscale_table = ff_h263_chroma_qscale_table;
// Only used for H.263 and H.263+ // 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 // use fcodes >1 only for MPEG-4 & H.263 & H.263+ FIXME
switch(s->c.codec_id){ switch(s->c.codec_id){
case AV_CODEC_ID_H263P: case AV_CODEC_ID_H263P:
if (s->c.umvplus) if (s->umvplus)
m->fcode_tab = umv_fcode_tab + MAX_MV; m->fcode_tab = umv_fcode_tab + MAX_MV;
if (s->c.modified_quant) { if (s->modified_quant) {
s->min_qcoeff= -2047; s->min_qcoeff= -2047;
s->max_qcoeff= 2047; s->max_qcoeff= 2047;
}else{ }else{
@ -922,10 +922,10 @@ const FFCodec ff_h263_encoder = {
}; };
static const AVOption h263p_options[] = { static const AVOption h263p_options[] = {
{ "umv", "Use unlimited motion vectors.", OFFSET(umvplus), 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.", OFFSET(alt_inter_vlc), 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 }, { "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_OPTS
FF_MPV_COMMON_MOTION_EST_OPTS FF_MPV_COMMON_MOTION_EST_OPTS
{ NULL }, { NULL },

View File

@ -350,9 +350,8 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
put_header(s, PICTURE_START_CODE); put_header(s, PICTURE_START_CODE);
/* temporal reference */ /* temporal reference */
// RAL: s->c.picture_number instead of s->fake_picture_number
put_bits(&s->pb, 10, 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); put_bits(&s->pb, 3, s->c.pict_type);
m->vbv_delay_pos = put_bytes_count(&s->pb, 0); m->vbv_delay_pos = put_bytes_count(&s->pb, 0);

View File

@ -2699,7 +2699,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
} else { } else {
/* is setting low delay flag only once the smartest thing to do? /* is setting low delay flag only once the smartest thing to do?
* low delay detection will not be overridden. */ * low delay detection will not be overridden. */
if (h->c.picture_number == 0) { if (h->picture_number == 0) {
switch (ctx->vo_type) { switch (ctx->vo_type) {
case SIMPLE_VO_TYPE: case SIMPLE_VO_TYPE:
case ADV_SIMPLE_VO_TYPE: case ADV_SIMPLE_VO_TYPE:
@ -2938,8 +2938,8 @@ no_cplx_est:
ctx->resync_marker = !get_bits1(gb); /* resync_marker_disabled */ ctx->resync_marker = !get_bits1(gb); /* resync_marker_disabled */
h->c.data_partitioning = get_bits1(gb); h->data_partitioning = get_bits1(gb);
if (h->c.data_partitioning) if (h->data_partitioning)
ctx->rvlc = get_bits1(gb); ctx->rvlc = get_bits1(gb);
if (vo_ver_id != 1) { if (vo_ver_id != 1) {
@ -2996,7 +2996,7 @@ no_cplx_est:
h->c.low_delay, h->c.low_delay,
ctx->scalability ? "scalability " :"" , ctx->scalability ? "scalability " :"" ,
h->c.quarter_sample ? "qpel " : "", h->c.quarter_sample ? "qpel " : "",
h->c.data_partitioning ? "partition " : "", h->data_partitioning ? "partition " : "",
ctx->rvlc ? "rvlc " : "" ctx->rvlc ? "rvlc " : ""
); );
} }
@ -3222,7 +3222,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb,
h->c.low_delay = 0; 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) if (h->c.partitioned_frame)
h->decode_mb = mpeg4_decode_partitioned_mb; h->decode_mb = mpeg4_decode_partitioned_mb;
else 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')), 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, 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.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, ctx->num_sprite_warping_points, ctx->sprite_warping_accuracy,
1 - h->c.no_rounding, ctx->vo_type, 1 - h->c.no_rounding, ctx->vo_type,
ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold, 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 * (divx4/xvid/opendivx). Note we cannot detect divx5 without B-frames
* easily (although it's buggy too) */ * easily (although it's buggy too) */
if (ctx->vo_type == 0 && ctx->vol_control_parameters == 0 && 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, av_log(h->c.avctx, AV_LOG_WARNING,
"looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
h->c.low_delay = 1; 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) { if (h->c.workaround_bugs & FF_BUG_EDGE) {
h->c.h_edge_pos = h->c.width; 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_brightness_change = s1->sprite_brightness_change;
s->sprite_warping_accuracy = s1->sprite_warping_accuracy; s->sprite_warping_accuracy = s1->sprite_warping_accuracy;
s->num_sprite_warping_points = s1->num_sprite_warping_points; 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->mpeg_quant = s1->mpeg_quant;
s->rvlc = s1->rvlc; s->rvlc = s1->rvlc;
s->resync_marker = s1->resync_marker; 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.skipped_last_frame = s1->h.skipped_last_frame;
s->h.padding_bug_score = s1->h.padding_bug_score; // FIXME: racy 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_shift, s1->sprite_shift, sizeof(s1->sprite_shift));
memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj)); memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj));

View File

@ -453,10 +453,10 @@ static void mpeg4_encode_mb(MPVEncContext *const s, int16_t block[][64],
int motion_x, int motion_y) int motion_x, int motion_y)
{ {
int cbpc, cbpy, pred_x, pred_y; int cbpc, cbpy, pred_x, pred_y;
PutBitContext *const pb2 = s->c.data_partitioning ? &s->pb2 : &s->pb; PutBitContext *const pb2 = s->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 tex_pb = s->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; 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->c.data_partitioning ? 1 : 0; const int interleaved_stats = (s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->data_partitioning;
if (!s->c.mb_intra) { if (!s->c.mb_intra) {
int i, cbp; 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, s->c.quarter_sample);
put_bits(&s->pb, 1, 1); /* complexity estimation disable */ 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->rtp_mode ? 0 : 1); /* resync marker disable */
put_bits(&s->pb, 1, s->c.data_partitioning ? 1 : 0); put_bits(&s->pb, 1, s->data_partitioning);
if (s->c.data_partitioning) if (s->data_partitioning)
put_bits(&s->pb, 1, 0); /* no rvlc */ put_bits(&s->pb, 1, 0); /* no rvlc */
if (vo_ver_id != 1) { 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->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy
mpeg4_encode_visual_object_header(m); 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_vol_header(m4, 0, 0);
} }
mpeg4_encode_gop_header(m); 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_bits32(&s->pb, VOP_STARTCODE); /* vop header */
put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */ 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 OFFSET(x) offsetof(MPVEncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = { 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 }, { "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", { "mpeg_quant", "Use MPEG quantizers instead of H.263",
OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE }, OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE },

View File

@ -194,8 +194,6 @@ av_cold void ff_mpv_common_defaults(MpegEncContext *s)
s->progressive_sequence = 1; s->progressive_sequence = 1;
s->picture_structure = PICT_FRAME; s->picture_structure = PICT_FRAME;
s->picture_number = 0;
s->slice_context_count = 1; s->slice_context_count = 1;
} }

View File

@ -87,9 +87,6 @@ typedef struct MpegEncContext {
enum OutputFormat out_format; ///< output format enum OutputFormat out_format; ///< output format
int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions 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 */ enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
int encoding; ///< true if we are encoding (vs decoding) int encoding; ///< true if we are encoding (vs decoding)
int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically
@ -98,7 +95,6 @@ typedef struct MpegEncContext {
/* sequence parameters */ /* sequence parameters */
int context_initialized; int context_initialized;
int picture_number; //FIXME remove, unclear definition
int mb_width, mb_height; ///< number of MBs horizontally & vertically 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 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 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 int resync_mb_y; ///< y position of last resync marker
/* H.263 specific */ /* H.263 specific */
int gob_index;
int obmc; ///< overlapped block motion compensation int obmc; ///< overlapped block motion compensation
/* H.263+ specific */ /* H.263+ specific */
int umvplus; ///< == H.263+ && unrestricted_mv
int h263_aic_dir; ///< AIC direction: 0 = left, 1 = top 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; int loop_filter;
/* MPEG-4 specific */ /* MPEG-4 specific */
@ -238,12 +229,10 @@ typedef struct MpegEncContext {
uint16_t pb_field_time; ///< like above, just for interlaced uint16_t pb_field_time; ///< like above, just for interlaced
int mcsel; int mcsel;
int quarter_sample; ///< 1->qpel, 0->half pel ME/MC 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 partitioned_frame; ///< is current frame partitioned
int low_delay; ///< no reordering needed / has no B-frames int low_delay; ///< no reordering needed / has no B-frames
/* MSMPEG4 specific */ /* MSMPEG4 specific */
int slice_height; ///< in macroblocks
int first_slice_line; ///< used in MPEG-4 too to handle resync markers int first_slice_line; ///< used in MPEG-4 too to handle resync markers
enum { enum {
MSMP4_UNUSED, MSMP4_UNUSED,

View File

@ -97,8 +97,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst,
s->quarter_sample = s1->quarter_sample; 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->cur_pic, &s1->cur_pic);
ff_mpv_replace_picture(&s->last_pic, &s1->last_pic); ff_mpv_replace_picture(&s->last_pic, &s1->last_pic);
ff_mpv_replace_picture(&s->next_pic, &s1->next_pic); ff_mpv_replace_picture(&s->next_pic, &s1->next_pic);

View File

@ -924,9 +924,9 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->c.out_format = FMT_H263; s->c.out_format = FMT_H263;
/* Fx */ /* Fx */
s->c.h263_aic = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0; 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->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; s->flipflop_rounding = 1;
/* /Fx */ /* /Fx */
@ -955,7 +955,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->c.out_format = FMT_H263; s->c.out_format = FMT_H263;
avctx->delay = 0; avctx->delay = 0;
s->c.low_delay = 1; s->c.low_delay = 1;
s->c.modified_quant = 1; s->modified_quant = 1;
// Set here to force allocation of dc_val; // Set here to force allocation of dc_val;
// will be set later on a per-frame basis. // will be set later on a per-frame basis.
s->c.h263_aic = 1; 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) { if (s->c.slice_context_count > 1) {
s->rtp_mode = 1; s->rtp_mode = 1;
if (avctx->codec_id == AV_CODEC_ID_H263P) 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); ret = ff_mpv_init_duplicate_contexts(&s->c);
if (ret < 0) if (ret < 0)
@ -1853,7 +1853,7 @@ static int select_input_picture(MPVMainEncContext *const m)
ff_mpv_unref_picture(&s->c.cur_pic); ff_mpv_unref_picture(&s->c.cur_pic);
return ret; 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; return 0;
@ -1963,7 +1963,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
/* output? */ /* output? */
if (s->new_pic->data[0]) { 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 * size_t pkt_size = 10000 + s->c.mb_width * s->c.mb_height *
(growing_buffer ? 64 : (MAX_MB_BYTES + 100)); (growing_buffer ? 64 : (MAX_MB_BYTES + 100));
if (CONFIG_MJPEG_ENCODER && avctx->codec_id == AV_CODEC_ID_MJPEG) { 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->block = s->blocks[*next_block];
s->pb = pb[*next_block]; s->pb = pb[*next_block];
if (s->c.data_partitioning) { if (s->data_partitioning) {
s->pb2 = pb2 [*next_block]; s->pb2 = pb2 [*next_block];
s->tex_pb= tex_pb[*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); encode_mb(s, motion_x, motion_y);
score= put_bits_count(&s->pb); 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->pb2);
score+= put_bits_count(&s->tex_pb); 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; *dmin= score;
*next_block^=1; *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; uint8_t *ptr = s->mb_info_ptr + s->mb_info_size - 12;
int offset = put_bits_count(&s->pb); 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 mba = s->c.mb_x + s->c.mb_width * (s->c.mb_y % s->gob_index);
int gobn = s->c.mb_y / s->c.gob_index; int gobn = s->c.mb_y / s->gob_index;
int pred_x, pred_y; int pred_x, pred_y;
if (CONFIG_H263_ENCODER) if (CONFIG_H263_ENCODER)
ff_h263_pred_motion(&s->c, 0, 0, &pred_x, &pred_y); 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"); av_log(s->c.avctx, AV_LOG_ERROR, "encoded frame too large\n");
return -1; return -1;
} }
if (s->c.data_partitioning) { if (s->data_partitioning) {
if (put_bytes_left(&s->pb2, 0) < MAX_MB_BYTES || if (put_bytes_left(&s->pb2, 0) < MAX_MB_BYTES ||
put_bytes_left(&s->tex_pb, 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"); 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) { switch (s->c.codec_id) {
case AV_CODEC_ID_H263: case AV_CODEC_ID_H263:
case AV_CODEC_ID_H263P: case AV_CODEC_ID_H263P:
if (!s->c.h263_slice_structured) if (!s->h263_slice_structured)
if (s->c.mb_x || s->c.mb_y % s->c.gob_index) is_gob_start = 0; if (s->c.mb_x || s->c.mb_y % s->gob_index) is_gob_start = 0;
break; break;
case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
if (s->c.mb_x == 0 && s->c.mb_y != 0) is_gob_start = 1; 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; 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) { 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; int d = 100 / s->error_rate;
if(r % d == 0){ if(r % d == 0){
current_packet_size=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_context_before_encode(&backup_s, s);
backup_s.pb= s->pb; backup_s.pb= s->pb;
if (s->c.data_partitioning) { if (s->data_partitioning) {
backup_s.pb2= s->pb2; backup_s.pb2= s->pb2;
backup_s.tex_pb= s->tex_pb; 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); pb_bits_count= put_bits_count(&s->pb);
flush_put_bits(&s->pb); flush_put_bits(&s->pb);
ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
s->pb= backup_s.pb; s->pb= backup_s.pb;
if (s->c.data_partitioning) { if (s->data_partitioning) {
pb2_bits_count= put_bits_count(&s->pb2); pb2_bits_count= put_bits_count(&s->pb2);
flush_put_bits(&s->pb2); flush_put_bits(&s->pb2);
ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); 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{ }else{
s->c.pp_time = s->c.time - s->c.last_non_b_time; s->c.pp_time = s->c.time - s->c.last_non_b_time;
s->c.last_non_b_time = s->c.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); 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) { 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); s->f_code = ff_get_best_fcode(m, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);

View File

@ -128,6 +128,8 @@ typedef struct MPVEncContext {
int dct_count[2]; int dct_count[2];
uint16_t (*dct_offset)[64]; uint16_t (*dct_offset)[64];
int picture_number;
/* statistics, used for 2-pass encoding */ /* statistics, used for 2-pass encoding */
int mv_bits; int mv_bits;
int i_tex_bits; int i_tex_bits;
@ -139,11 +141,18 @@ typedef struct MPVEncContext {
int mb_skip_run; int mb_skip_run;
/* H.263 specific */ /* H.263 specific */
int gob_index;
int mb_info; ///< interval for outputting info about mb offsets as side data int mb_info; ///< interval for outputting info about mb offsets as side data
int prev_mb_info, last_mb_info; int prev_mb_info, last_mb_info;
int mb_info_size; int mb_info_size;
uint8_t *mb_info_ptr; 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 */ /* MJPEG specific */
struct MJpegContext *mjpeg_ctx; struct MJpegContext *mjpeg_ctx;
int esc_pos; int esc_pos;
@ -152,11 +161,13 @@ typedef struct MPVEncContext {
int last_mv_dir; ///< last mv_dir, used for B-frame encoding int last_mv_dir; ///< last mv_dir, used for B-frame encoding
/* MPEG-4 specific */ /* MPEG-4 specific */
int data_partitioning; ///< data partitioning flag, set via option
int mpeg_quant; int mpeg_quant;
PutBitContext tex_pb; ///< used for data partitioned VOPs PutBitContext tex_pb; ///< used for data partitioned VOPs
PutBitContext pb2; ///< used for data partitioned VOPs PutBitContext pb2; ///< used for data partitioned VOPs
/* MSMPEG4 specific */ /* MSMPEG4 specific */
int slice_height; ///< in macroblocks
int flipflop_rounding; ///< also used for MPEG-4, H.263+ int flipflop_rounding; ///< also used for MPEG-4, H.263+
int esc3_level_length; int esc3_level_length;

View File

@ -403,7 +403,7 @@ static int msmpeg4_decode_picture_header(H263DecContext *const h)
return -1; return -1;
} }
h->c.slice_height = code; h->slice_height = code;
}else{ }else{
/* 0x17: one slice, 0x18: two slices, ... */ /* 0x17: one slice, 0x18: two slices, ... */
if (code < 0x17){ if (code < 0x17){
@ -411,7 +411,7 @@ static int msmpeg4_decode_picture_header(H263DecContext *const h)
return -1; 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) { switch (h->c.msmpeg4_version) {
@ -455,7 +455,7 @@ static int msmpeg4_decode_picture_header(H263DecContext *const h)
ms->rl_table_index, ms->rl_table_index,
ms->dc_table_index, ms->dc_table_index,
ms->per_mb_rl_table, ms->per_mb_rl_table,
h->c.slice_height); h->slice_height);
} else { } else {
switch (h->c.msmpeg4_version) { switch (h->c.msmpeg4_version) {
case MSMP4_V1: 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()"); 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); ff_thread_once(&init_static_once, msmpeg4_decode_init_static);

View File

@ -243,8 +243,8 @@ static int msmpeg4_encode_picture_header(MPVMainEncContext *const m)
s->c.inter_intra_pred, s->c.width, s->c.height); s->c.inter_intra_pred, s->c.width, s->c.height);
if (s->c.pict_type == AV_PICTURE_TYPE_I) { if (s->c.pict_type == AV_PICTURE_TYPE_I) {
s->c.slice_height = s->c.mb_height/1; s->slice_height = s->c.mb_height/1;
put_bits(&s->pb, 5, 0x16 + s->c.mb_height/s->c.slice_height); put_bits(&s->pb, 5, 0x16 + s->c.mb_height / s->slice_height);
if (s->c.msmpeg4_version == MSMP4_WMV1) { if (s->c.msmpeg4_version == MSMP4_WMV1) {
ff_msmpeg4_encode_ext_header(s); 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) void ff_msmpeg4_handle_slices(MPVEncContext *const s)
{ {
if (s->c.mb_x == 0) { 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) if (s->c.msmpeg4_version < MSMP4_WMV1)
ff_mpeg4_clean_buffers(&s->c); ff_mpeg4_clean_buffers(&s->c);
s->c.first_slice_line = 1; s->c.first_slice_line = 1;

View File

@ -901,7 +901,7 @@ void ff_get_2pass_fcode(MPVMainEncContext *const m)
{ {
MPVEncContext *const s = &m->s; MPVEncContext *const s = &m->s;
const RateControlContext *rcc = &m->rc_context; 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->f_code = rce->f_code;
s->b_code = rce->b_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 diff;
double short_term_q; double short_term_q;
double fps; double fps;
int picture_number = s->c.picture_number; int picture_number = s->picture_number;
int64_t wanted_bits; int64_t wanted_bits;
RateControlEntry local_rce, *rce; RateControlEntry local_rce, *rce;
double bits; double bits;

View File

@ -372,7 +372,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
h->h263_long_vectors = avctx->extradata[3] & 1; h->h263_long_vectors = avctx->extradata[3] & 1;
rv->sub_id = AV_RB32A(avctx->extradata + 4); rv->sub_id = AV_RB32A(avctx->extradata + 4);
if (avctx->codec_id == AV_CODEC_ID_RV20) { 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; h->c.chroma_qscale_table = ff_h263_chroma_qscale_table;
} }

View File

@ -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, 1, 0); /* unknown bit */
put_bits(&s->pb, 5, s->c.qscale); 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; s->c.mb_x = s->c.mb_y = 0;
ff_h263_encode_mba(s); 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->f_code == 1);
av_assert1(!s->me.unrestricted_mv); av_assert1(!s->me.unrestricted_mv);
av_assert1(!s->c.alt_inter_vlc); av_assert1(!s->alt_inter_vlc);
av_assert1(!s->c.umvplus); av_assert1(!s->umvplus);
av_assert1(s->c.modified_quant == 1); av_assert1(s->modified_quant == 1);
av_assert1(s->c.loop_filter == 1); av_assert1(s->c.loop_filter == 1);
s->c.h263_aic = s->c.pict_type == AV_PICTURE_TYPE_I; s->c.h263_aic = s->c.pict_type == AV_PICTURE_TYPE_I;

View File

@ -1792,7 +1792,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
pic->pict_type = pict->pict_type; pic->pict_type = pict->pict_type;
pic->quality = pict->quality; pic->quality = pict->quality;
mpv->c.picture_number = avctx->frame_num; mpv->picture_number = avctx->frame_num;
if(avctx->flags&AV_CODEC_FLAG_PASS2){ 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; 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; s->keyframe = pic->pict_type == AV_PICTURE_TYPE_I;

View File

@ -72,7 +72,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx,
.sprite_warping_accuracy = ctx->sprite_warping_accuracy, .sprite_warping_accuracy = ctx->sprite_warping_accuracy,
.quant_type = ctx->mpeg_quant, .quant_type = ctx->mpeg_quant,
.quarter_sample = s->quarter_sample, .quarter_sample = s->quarter_sample,
.data_partitioned = s->data_partitioning, .data_partitioned = ctx->h.data_partitioning,
.reversible_vlc = ctx->rvlc, .reversible_vlc = ctx->rvlc,
.resync_marker_disable = !ctx->resync_marker, .resync_marker_disable = !ctx->resync_marker,
}, },

View File

@ -188,7 +188,7 @@ static int decode_ext_header(WMV2DecContext *w)
if (code == 0) if (code == 0)
return AVERROR_INVALIDDATA; 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) if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
av_log(h->c.avctx, AV_LOG_DEBUG, av_log(h->c.avctx, AV_LOG_DEBUG,

View File

@ -68,7 +68,7 @@ static int encode_ext_header(WMV2EncContext *w)
flush_put_bits(&pb); flush_put_bits(&pb);
s->c.slice_height = s->c.mb_height / code; s->slice_height = s->c.mb_height / code;
return 0; return 0;
} }