mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 18:40:03 +01:00
mpeg4videodec: move MpegEncContext.time_increment_bits to Mpeg4DecContext
The field remains in MpegEncContext for use in the encoder.
This commit is contained in:
@@ -62,6 +62,8 @@
|
|||||||
typedef struct Mpeg4DecContext {
|
typedef struct Mpeg4DecContext {
|
||||||
MpegEncContext m;
|
MpegEncContext m;
|
||||||
|
|
||||||
|
///< number of bits to represent the fractional part of time
|
||||||
|
int time_increment_bits;
|
||||||
int shape;
|
int shape;
|
||||||
} Mpeg4DecContext;
|
} Mpeg4DecContext;
|
||||||
|
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
|
|||||||
time_incr++;
|
time_incr++;
|
||||||
|
|
||||||
check_marker(&s->gb, "before time_increment in video packed header");
|
check_marker(&s->gb, "before time_increment in video packed header");
|
||||||
skip_bits(&s->gb, s->time_increment_bits); /* time_increment */
|
skip_bits(&s->gb, ctx->time_increment_bits); /* time_increment */
|
||||||
check_marker(&s->gb, "before vop_coding_type in video packed header");
|
check_marker(&s->gb, "before vop_coding_type in video packed header");
|
||||||
|
|
||||||
skip_bits(&s->gb, 2); /* vop coding type */
|
skip_bits(&s->gb, 2); /* vop coding type */
|
||||||
@@ -1719,14 +1719,14 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
|
ctx->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
|
||||||
if (s->time_increment_bits < 1)
|
if (ctx->time_increment_bits < 1)
|
||||||
s->time_increment_bits = 1;
|
ctx->time_increment_bits = 1;
|
||||||
|
|
||||||
check_marker(gb, "before fixed_vop_rate");
|
check_marker(gb, "before fixed_vop_rate");
|
||||||
|
|
||||||
if (get_bits1(gb) != 0) /* fixed_vop_rate */
|
if (get_bits1(gb) != 0) /* fixed_vop_rate */
|
||||||
s->avctx->time_base.num = get_bits(gb, s->time_increment_bits);
|
s->avctx->time_base.num = get_bits(gb, ctx->time_increment_bits);
|
||||||
else
|
else
|
||||||
s->avctx->time_base.num = 1;
|
s->avctx->time_base.num = 1;
|
||||||
|
|
||||||
@@ -2065,31 +2065,31 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
|
|||||||
|
|
||||||
check_marker(gb, "before time_increment");
|
check_marker(gb, "before time_increment");
|
||||||
|
|
||||||
if (s->time_increment_bits == 0 ||
|
if (ctx->time_increment_bits == 0 ||
|
||||||
!(show_bits(gb, s->time_increment_bits + 1) & 1)) {
|
!(show_bits(gb, ctx->time_increment_bits + 1) & 1)) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR,
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
"hmm, seems the headers are not complete, trying to guess time_increment_bits\n");
|
"hmm, seems the headers are not complete, trying to guess time_increment_bits\n");
|
||||||
|
|
||||||
for (s->time_increment_bits = 1;
|
for (ctx->time_increment_bits = 1;
|
||||||
s->time_increment_bits < 16;
|
ctx->time_increment_bits < 16;
|
||||||
s->time_increment_bits++) {
|
ctx->time_increment_bits++) {
|
||||||
if (s->pict_type == AV_PICTURE_TYPE_P ||
|
if (s->pict_type == AV_PICTURE_TYPE_P ||
|
||||||
(s->pict_type == AV_PICTURE_TYPE_S &&
|
(s->pict_type == AV_PICTURE_TYPE_S &&
|
||||||
s->vol_sprite_usage == GMC_SPRITE)) {
|
s->vol_sprite_usage == GMC_SPRITE)) {
|
||||||
if ((show_bits(gb, s->time_increment_bits + 6) & 0x37) == 0x30)
|
if ((show_bits(gb, ctx->time_increment_bits + 6) & 0x37) == 0x30)
|
||||||
break;
|
break;
|
||||||
} else if ((show_bits(gb, s->time_increment_bits + 5) & 0x1F) == 0x18)
|
} else if ((show_bits(gb, ctx->time_increment_bits + 5) & 0x1F) == 0x18)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR,
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
"my guess is %d bits ;)\n", s->time_increment_bits);
|
"my guess is %d bits ;)\n", ctx->time_increment_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_3IV1)
|
if (IS_3IV1)
|
||||||
time_increment = get_bits1(gb); // FIXME investigate further
|
time_increment = get_bits1(gb); // FIXME investigate further
|
||||||
else
|
else
|
||||||
time_increment = get_bits(gb, s->time_increment_bits);
|
time_increment = get_bits(gb, ctx->time_increment_bits);
|
||||||
|
|
||||||
if (s->pict_type != AV_PICTURE_TYPE_B) {
|
if (s->pict_type != AV_PICTURE_TYPE_B) {
|
||||||
s->last_time_base = s->time_base;
|
s->last_time_base = s->time_base;
|
||||||
@@ -2413,7 +2413,8 @@ static int mpeg4_update_thread_context(AVCodecContext *dst,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
s->shape = s1->shape;
|
s->shape = s1->shape;
|
||||||
|
s->time_increment_bits = s1->time_increment_bits;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2459,7 +2460,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
s->h263_pred = 1;
|
s->h263_pred = 1;
|
||||||
s->low_delay = 0; /* default, might be overriden in the vol header during header parsing */
|
s->low_delay = 0; /* default, might be overriden in the vol header during header parsing */
|
||||||
s->decode_mb = mpeg4_decode_mb;
|
s->decode_mb = mpeg4_decode_mb;
|
||||||
s->time_increment_bits = 4; /* default value for broken headers */
|
ctx->time_increment_bits = 4; /* default value for broken headers */
|
||||||
|
|
||||||
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
|
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
|
||||||
avctx->internal->allocate_progress = 1;
|
avctx->internal->allocate_progress = 1;
|
||||||
|
|||||||
@@ -716,9 +716,9 @@ do {\
|
|||||||
s->workaround_bugs = s1->workaround_bugs;
|
s->workaround_bugs = s1->workaround_bugs;
|
||||||
|
|
||||||
// MPEG4 timing info
|
// MPEG4 timing info
|
||||||
memcpy(&s->time_increment_bits, &s1->time_increment_bits,
|
memcpy(&s->last_time_base, &s1->last_time_base,
|
||||||
(char *) &s1->pb_field_time + sizeof(s1->pb_field_time) -
|
(char *) &s1->pb_field_time + sizeof(s1->pb_field_time) -
|
||||||
(char *) &s1->time_increment_bits);
|
(char *) &s1->last_time_base);
|
||||||
|
|
||||||
// B-frame info
|
// B-frame info
|
||||||
s->max_b_frames = s1->max_b_frames;
|
s->max_b_frames = s1->max_b_frames;
|
||||||
|
|||||||
@@ -569,7 +569,8 @@ typedef struct MpegEncContext {
|
|||||||
int custom_pcf;
|
int custom_pcf;
|
||||||
|
|
||||||
/* mpeg4 specific */
|
/* mpeg4 specific */
|
||||||
int time_increment_bits; ///< number of bits to represent the fractional part of time
|
///< number of bits to represent the fractional part of time (encoder only)
|
||||||
|
int time_increment_bits;
|
||||||
int last_time_base;
|
int last_time_base;
|
||||||
int time_base; ///< time in seconds of last I,P,S Frame
|
int time_base; ///< time in seconds of last I,P,S Frame
|
||||||
int64_t time; ///< time of current frame
|
int64_t time; ///< time of current frame
|
||||||
|
|||||||
Reference in New Issue
Block a user