[FFmpeg-devel] [PATCH] avcodec/av1_parser: export timing information when present

James Almer jamrial at gmail.com
Sat Jan 7 17:22:36 EET 2023


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/av1_parser.c                  |  8 ++++
 tests/ref/fate/webm-av1-extradata-update | 48 ++++++++++++------------
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
index 4cbd7408a0..afa006ed08 100644
--- a/libavcodec/av1_parser.c
+++ b/libavcodec/av1_parser.c
@@ -162,6 +162,14 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
     avctx->color_trc = (enum AVColorTransferCharacteristic) color->transfer_characteristics;
     avctx->color_range = color->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
 
+    if (seq->timing_info_present_flag) {
+        const AV1RawTimingInfo *timing = &seq->timing_info;
+        av_reduce(&avctx->framerate.den, &avctx->framerate.num,
+                  timing->num_units_in_display_tick, timing->time_scale, INT_MAX);
+        if (timing->equal_picture_interval)
+            avctx->ticks_per_frame = timing->num_ticks_per_picture_minus_1 + 1;
+    }
+
     if (avctx->framerate.num)
         avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
 
diff --git a/tests/ref/fate/webm-av1-extradata-update b/tests/ref/fate/webm-av1-extradata-update
index 9dd2056e0e..68bbb9ad89 100644
--- a/tests/ref/fate/webm-av1-extradata-update
+++ b/tests/ref/fate/webm-av1-extradata-update
@@ -6,27 +6,27 @@ fbf3091fdf05b2856c578e7c948d68c3 *tests/data/fate/webm-av1-extradata-update.webm
 #codec_id 0: av1
 #dimensions 0: 240x100
 #sar 0: 3/1
-0,          0,          0,        0,     8168, 0x1851ab62
-0,         42,         42,        0,     7040, 0x967788f9, F=0x0
-0,         83,         83,        0,        4, 0x01f400e2, F=0x0
-0,        125,        125,        0,       48, 0x49ad107e, F=0x0
-0,        167,        167,        0,        4, 0x021c00fa, F=0x0
-0,        208,        208,        0,      279, 0x69728439, F=0x0
-0,        250,        250,        0,        4, 0x01c400d2, F=0x0
-0,        292,        292,        0,       63, 0x9bbf1836, F=0x0
-0,        333,        333,        0,        4, 0x026c012a, F=0x0
-0,        375,        375,        0,     1065, 0xce2003ac, F=0x0
-0,        417,        417,        0,        4, 0x019400c2, F=0x0
-0,        458,        458,        0,       52, 0x7a0112f1, F=0x0
-0,        500,        500,        0,        4, 0x021c010a, F=0x0
-0,        542,        542,        0,      689, 0x1e8b49e7, F=0x0
-0,        583,        583,        0,        4, 0x01e400f2, F=0x0
-0,        625,        625,        0,      209, 0x124c6790, F=0x0
-0,        667,        667,        0,       42, 0xea690e31, F=0x0
-0,        708,        708,        0,     3521, 0xd76ee284, F=0x0
-0,        750,        750,        0,       63, 0x4572188f, F=0x0
-0,        792,        792,        0,      386, 0xb078c259, F=0x0
-0,        833,        833,        0,      178, 0x1ebb5121, F=0x0
-0,        875,        875,        0,       60, 0x729317f7, F=0x0
-0,        917,        917,        0,       40, 0xad970a66, F=0x0
-0,        958,        958,        0,       61, 0xcc0d1a20, F=0x0
+0,          0,          0,       41,     8168, 0x1851ab62
+0,         42,         42,       41,     7040, 0x967788f9, F=0x0
+0,         83,         83,       41,        4, 0x01f400e2, F=0x0
+0,        125,        125,       41,       48, 0x49ad107e, F=0x0
+0,        167,        167,       41,        4, 0x021c00fa, F=0x0
+0,        208,        208,       41,      279, 0x69728439, F=0x0
+0,        250,        250,       41,        4, 0x01c400d2, F=0x0
+0,        292,        292,       41,       63, 0x9bbf1836, F=0x0
+0,        333,        333,       41,        4, 0x026c012a, F=0x0
+0,        375,        375,       41,     1065, 0xce2003ac, F=0x0
+0,        417,        417,       41,        4, 0x019400c2, F=0x0
+0,        458,        458,       41,       52, 0x7a0112f1, F=0x0
+0,        500,        500,       41,        4, 0x021c010a, F=0x0
+0,        542,        542,       41,      689, 0x1e8b49e7, F=0x0
+0,        583,        583,       41,        4, 0x01e400f2, F=0x0
+0,        625,        625,       41,      209, 0x124c6790, F=0x0
+0,        667,        667,       41,       42, 0xea690e31, F=0x0
+0,        708,        708,       41,     3521, 0xd76ee284, F=0x0
+0,        750,        750,       41,       63, 0x4572188f, F=0x0
+0,        792,        792,       41,      386, 0xb078c259, F=0x0
+0,        833,        833,       41,      178, 0x1ebb5121, F=0x0
+0,        875,        875,       41,       60, 0x729317f7, F=0x0
+0,        917,        917,       41,       40, 0xad970a66, F=0x0
+0,        958,        958,       41,       61, 0xcc0d1a20, F=0x0
-- 
2.39.0



More information about the ffmpeg-devel mailing list