diff mbox series

[FFmpeg-devel,v7,2/2] avformat/imfdec: preserve stream information

Message ID 20220806233520.1154-2-pal@sandflow.com
State New
Headers show
Series [FFmpeg-devel,v7,1/2] avformat: refactor ff_stream_encode_params_copy() to stream_params_copy() | 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

Pierre-Anthony Lemieux Aug. 6, 2022, 11:35 p.m. UTC
From: Pierre-Anthony Lemieux <pal@palemieux.com>

---
 libavformat/imfdec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 71dfb26958..5bbe7a53f8 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -573,18 +573,14 @@  static int set_context_streams_from_tracks(AVFormatContext *s)
         first_resource_stream = c->tracks[i]->resources[0].ctx->streams[0];
         av_log(s, AV_LOG_DEBUG, "Open the first resource of track %d\n", c->tracks[i]->index);
 
-        /* Copy stream information */
-        asset_stream = avformat_new_stream(s, NULL);
+        asset_stream = ff_stream_clone(s, first_resource_stream);
         if (!asset_stream) {
-            av_log(s, AV_LOG_ERROR, "Could not create stream\n");
+            av_log(s, AV_LOG_ERROR, "Could not clone stream\n");
             return AVERROR(ENOMEM);
         }
+
         asset_stream->id = i;
-        ret = avcodec_parameters_copy(asset_stream->codecpar, first_resource_stream->codecpar);
-        if (ret < 0) {
-            av_log(s, AV_LOG_ERROR, "Could not copy stream parameters\n");
-            return ret;
-        }
+        asset_stream->nb_frames = 0;
         avpriv_set_pts_info(asset_stream,
                             first_resource_stream->pts_wrap_bits,
                             first_resource_stream->time_base.num,