diff mbox series

[FFmpeg-devel,20/31] fftools/ffmpeg_dec: pass input timebase through DecoderOpts

Message ID 20240124081702.4759-20-anton@khirnov.net
State Accepted
Commit 970281766200491c4e5bb2ea1480d8afc1548a3d
Headers show
Series [FFmpeg-devel,01/31] fftools/ffmpeg_dec: split Decoder into a private and public part | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Jan. 24, 2024, 8:16 a.m. UTC
Do not read it from AVStream directly.

This is a step towards decoupling Decoder and InputStream.
---
 fftools/ffmpeg.h       | 2 ++
 fftools/ffmpeg_dec.c   | 5 +----
 fftools/ffmpeg_demux.c | 2 ++
 3 files changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 106f943a2b..5d6a538aa0 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -298,6 +298,8 @@  typedef struct DecoderOpts {
     char                       *hwaccel_device;
     enum AVPixelFormat          hwaccel_output_format;
 
+    AVRational                  time_base;
+
     // Either forced (when DECODER_FLAG_FRAMERATE_FORCED is set) or
     // estimated (otherwise) video framerate.
     AVRational                  framerate;
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 46eac025a3..4a2ea83f97 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -998,10 +998,7 @@  int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
 
     dp->dec_ctx->opaque                = dp;
     dp->dec_ctx->get_format            = get_format;
-
-    /* Useful for subtitles retiming by lavf (FIXME), skipping samples in
-     * audio, and video decoders such as cuvid or mediacodec */
-    dp->dec_ctx->pkt_timebase = ist->st->time_base;
+    dp->dec_ctx->pkt_timebase          = o->time_base;
 
     if (!av_dict_get(*dec_opts, "threads", NULL, 0))
         av_dict_set(dec_opts, "threads", "auto", 0);
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 7cb85c127a..4cced4a7f8 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1152,6 +1152,8 @@  static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
     ds->first_dts   = AV_NOPTS_VALUE;
     ds->next_dts    = AV_NOPTS_VALUE;
 
+    ds->dec_opts.time_base = st->time_base;
+
     ds->ts_scale = 1.0;
     MATCH_PER_STREAM_OPT(ts_scale, dbl, ds->ts_scale, ic, st);