summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-05 15:45:42 +0200
committerAnton Khirnov <anton@khirnov.net>2023-05-15 10:31:55 +0200
commite930b834a928546f9cbc937f6633709053448232 (patch)
treeb6490fcbb8d5dbc7e8d2f1142754e4268071e8ae /libavcodec
parent70433abf7fbc978b5fa0d06951d61ac18ac335f8 (diff)
downloadffmpeg-e930b834a928546f9cbc937f6633709053448232.tar.gz
lavf: use AV_CODEC_PROP_FIELDS where appropriate
H.264 and mpeg12 parsers need to be adjusted at the same time to stop using the value of AVCodecContext.ticks_per_frame, because it is not set correctly unless the codec has been opened. Previously this would result in both the parser and lavf seeing the same incorrect value, which would cancel out. Updating lavf and not the parsers would result in correct value in lavf, but the wrong one in parsers, which would break some tests.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264_parser.c4
-rw-r--r--libavcodec/mpegvideo_parser.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 46134a1c48..43abc45f9c 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -568,7 +568,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
if (p->sei.common.unregistered.x264_build < 44U)
den *= 2;
av_reduce(&avctx->framerate.den, &avctx->framerate.num,
- sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);
+ sps->num_units_in_tick * 2, den, 1 << 30);
}
av_freep(&rbsp.rbsp_buffer);
@@ -625,7 +625,7 @@ static int h264_parse(AVCodecParserContext *s,
parse_nal_units(s, avctx, buf, buf_size);
if (avctx->framerate.num)
- time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
+ time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){2, 1}));
if (p->sei.picture_timing.cpb_removal_delay >= 0) {
s->dts_sync_point = p->sei.buffering_period.present;
s->dts_ref_dts_delta = p->sei.picture_timing.cpb_removal_delay;
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index 8e7e88ff25..08e5316960 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -129,6 +129,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
s->pict_type = (buf[1] >> 3) & 7;
if (bytes_left >= 4)
vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3);
+ s->repeat_pict = 1;
}
break;
case SEQ_START_CODE:
@@ -186,7 +187,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
progressive_frame = buf[4] & (1 << 7);
/* check if we must repeat the frame */
- s->repeat_pict = 1;
if (repeat_first_field) {
if (pc->progressive_sequence) {
if (top_field_first)