diff mbox series

[FFmpeg-devel,25/31] fftools/ffmpeg_dec: pass AVCodecParameters through DecoderOpts

Message ID 20240124081702.4759-25-anton@khirnov.net
State Accepted
Commit 1b2c539a0f4b48ed124ff6dc375bd67111efdddc
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 retrieve it from InputStream directly.

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

Patch

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index b169b1a323..02c614d0ff 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -298,6 +298,7 @@  typedef struct DecoderOpts {
     char                       *name;
 
     const AVCodec              *codec;
+    const AVCodecParameters    *par;
 
     /* hwaccel options */
     enum HWAccelID              hwaccel_id;
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index c64b9f5b70..fd1c9ca609 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -990,13 +990,13 @@  int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
             return AVERROR(ENOMEM);
     }
 
-    dp->sar_override = ist->par->sample_aspect_ratio;
+    dp->sar_override = o->par->sample_aspect_ratio;
 
     dp->dec_ctx = avcodec_alloc_context3(codec);
     if (!dp->dec_ctx)
         return AVERROR(ENOMEM);
 
-    ret = avcodec_parameters_to_context(dp->dec_ctx, ist->par);
+    ret = avcodec_parameters_to_context(dp->dec_ctx, o->par);
     if (ret < 0) {
         av_log(dp, AV_LOG_ERROR, "Error initializing the decoder context.\n");
         return ret;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index f66319aafe..6216b7c684 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -931,6 +931,7 @@  static int ist_use(InputStream *ist, int decoding_needed)
         ds->dec_opts.name = ds->dec_name;
 
         ds->dec_opts.codec = ist->dec;
+        ds->dec_opts.par   = ist->par;
 
         ret = dec_open(ist, d->sch, ds->sch_idx_dec,
                        &ist->decoder_opts, &ds->dec_opts);