[FFmpeg-devel] [PATCH 2/3] avcodec/av1_parser: export more timing information

James Almer jamrial at gmail.com
Mon Nov 18 16:48:09 EET 2019


Should help remuxing certain Annex B AV1 samples without a decoder.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/av1_parser.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
index 08721c356a..ff7fce4a07 100644
--- a/libavcodec/av1_parser.c
+++ b/libavcodec/av1_parser.c
@@ -53,6 +53,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
     AV1ParseContext *s = ctx->priv_data;
     CodedBitstreamFragment *td = &s->temporal_unit;
     CodedBitstreamAV1Context *av1 = s->cbc->priv_data;
+    AV1RawSequenceHeader *seq;
     int ret;
 
     *out_data = data;
@@ -86,10 +87,11 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
         goto end;
     }
 
+    seq = av1->sequence_header;
+
     for (int i = 0; i < td->nb_units; i++) {
         CodedBitstreamUnit *unit = &td->units[i];
         AV1RawOBU *obu = unit->content;
-        AV1RawSequenceHeader *seq = av1->sequence_header;
         AV1RawColorConfig *color = &seq->color_config;
         AV1RawFrameHeader *frame;
         int frame_type;
@@ -164,6 +166,12 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
         }
     }
 
+    if (seq->timing_info.num_units_in_display_tick && seq->timing_info.time_scale &&
+        seq->timing_info.equal_picture_interval) {
+        av_reduce(&avctx->framerate.den, &avctx->framerate.num,
+                  seq->timing_info.num_units_in_display_tick, seq->timing_info.time_scale, INT_MAX);
+        avctx->ticks_per_frame = seq->timing_info.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}));
 
-- 
2.24.0



More information about the ffmpeg-devel mailing list