From patchwork Thu Aug 11 05:57:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 37233 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3d0d:b0:8d:a68e:8a0e with SMTP id y13csp163445pzi; Wed, 10 Aug 2022 22:57:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR65tuWw3eoR+uF7V3J1IbYe1i+KolB11XhhNIdwA5MRYF3t6dbQ3n58y2SRVSeZRHf6htjv X-Received: by 2002:a50:ec91:0:b0:440:9719:72ca with SMTP id e17-20020a50ec91000000b00440971972camr17355779edr.407.1660197473934; Wed, 10 Aug 2022 22:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660197473; cv=none; d=google.com; s=arc-20160816; b=wcfqoGrKdhe2BMijUqH1BzwuvsEubjIPrGfZP4eDwk6nz1dyJNURO8hvpZK2dZ8rTU 5lQvw5cfYkU3zfCO9Yyk2zIxGzwW1u0EuN3kmWsf7ULR0/GJDTbAl0r8Axtv3Xz9wF5s YS1T2vspNMBot4EerItU0OCaKNX0qyMciHmwDSKyqRs2NgrUE2nDDD3HQvAqurVRNBlU N12BOBrZfZfD60CdMZ09zBfYRxICkG7j3CRoctZMYOrCEQLfmtKKSjDI69OiVW2xMEfW kUQHGpQDvcFsZX3G/cIzgpxU1vbwaJcx6bDDbiKEGzDYERyikyQjg0pbArPt5fW5hSKo dMdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=Wf8qQlSRb8wvmj+nWh3r7aYn8Q/R/aq7Qpy8ORqa4io=; b=MHcZfxxq6gKHunrFXZ6cgezMU3Wn2YoJYUurTcZjIydG2jPQ5yFhtFvmDtcAp9Y+GY 6D2y4hO6MAmZtTErLQUft6y/2MGmBIXWXG0Kmc5/AD3tZYbr9konsUOIhMQuQPFLNBOa 5hzEARzcphm4EVgCdup5BW548BU4uyqgVD0N8n7JuE5d17fv89hp4vBm9F9/1AM2ruEo QKzfTSV5CFcx5WyBddWIWNpHUJtPo4fUD7Uez7qdVzpLFhLNcoensQcBHQvRbCi1BnN0 CzD2wm4CL8AkvzW/wyuSsb/j9iKy7IVl/KdDA5Ambzz/k5614pTEI4OPJh0IzQ1RpH8Y TxWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m14-20020a1709066d0e00b00730ac298aa9si5390872ejr.783.2022.08.10.22.57.52; Wed, 10 Aug 2022 22:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 198CE68B7D2; Thu, 11 Aug 2022 08:57:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5868F68B7A4 for ; Thu, 11 Aug 2022 08:57:42 +0300 (EEST) Received: by mail-pl1-f177.google.com with SMTP id g13so9197886plo.6 for ; Wed, 10 Aug 2022 22:57:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=TknRWNtwMCI24cdpvuAJcGs09Lq578bV83/kz8yTWX4=; b=ER1K6XCrDN/S4OIwGK9S76Ykl2rRq8v4nuCxKM4jwfHIKUlZlADQOrGEJ44io12KbK N9k9FT682cAhKhnrCaM+yoNNU43kuV5Jc7OKk0fuzFvhUzy7qgbZqCf7GiORNfVu2T4I YAJ9hUTh/kzx6/Z2rjWLIyztJFen/z45fuJRhmO/zCP80xvEBtXTyBW1eTlMEBwqWHTJ yejAb4e60rShJllEgtPr50gtkBAoZJmznHT4Pkd3jyYjbx0p0JIGRy2KC6nttyTViyvq 5Jg6xseglpQZ3DC0DuZMS4PW/GzTF4z4Fa+C+CEuM6Fot0QiB+Lpbm+LuxJDHjzJrV8b U+uA== X-Gm-Message-State: ACgBeo3GPnzU3KwUqJJ1NB+zCOWvj8OBux2S/9iFGEJfuhM3O0bpkxbD jJygPRAiG/t6DFMgvxvdj5bIvfDrOas= X-Received: by 2002:a17:902:dac7:b0:16e:fc21:4e17 with SMTP id q7-20020a170902dac700b0016efc214e17mr29740353plx.168.1660197459376; Wed, 10 Aug 2022 22:57:39 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id 2-20020a17090a0d4200b001f5834a86aesm2739808pju.20.2022.08.10.22.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 22:57:38 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Wed, 10 Aug 2022 22:57:35 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Aug 2022 22:57:32 -0700 Message-Id: <20220811055733.8127-1-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v8 1/2] avformat: refactor ff_stream_encode_params_copy() to stream_params_copy() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: x3cnLeER1KNU From: Pierre-Anthony Lemieux Further code style improvements. --- libavformat/avformat.c | 66 ++++++++++++++++++++++++++++++++++++++++ libavformat/fifo.c | 10 ++---- libavformat/internal.h | 11 +++++++ libavformat/mux.h | 9 ------ libavformat/mux_utils.c | 28 ----------------- libavformat/segment.c | 6 ++-- libavformat/tee.c | 8 ++--- libavformat/webm_chunk.c | 6 ++-- 8 files changed, 85 insertions(+), 59 deletions(-) diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 30d6ea6a49..19c7219471 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -235,6 +235,72 @@ int ff_stream_side_data_copy(AVStream *dst, const AVStream *src) return 0; } +/** + * Copy all stream parameters from source to destination stream, with the + * exception of the index field, which is usually set by avformat_new_stream(). + * + * @param dst pointer to destination AVStream + * @param src pointer to source AVStream + * @return >=0 on success, AVERROR code on error + */ +static int stream_params_copy(AVStream *dst, const AVStream *src) +{ + int ret; + + dst->id = src->id; + dst->time_base = src->time_base; + dst->start_time = src->start_time; + dst->duration = src->duration; + dst->nb_frames = src->nb_frames; + dst->disposition = src->disposition; + dst->discard = src->discard; + dst->sample_aspect_ratio = src->sample_aspect_ratio; + dst->avg_frame_rate = src->avg_frame_rate; + dst->event_flags = src->event_flags; + dst->r_frame_rate = src->r_frame_rate; + dst->pts_wrap_bits = src->pts_wrap_bits; + + av_dict_free(&dst->metadata); + ret = av_dict_copy(&dst->metadata, src->metadata, 0); + if (ret < 0) + return ret; + + ret = avcodec_parameters_copy(dst->codecpar, src->codecpar); + if (ret < 0) + return ret; + + ret = ff_stream_side_data_copy(dst, src); + if (ret < 0) + return ret; + + av_packet_unref(&dst->attached_pic); + if (src->attached_pic.data) { + ret = av_packet_ref(&dst->attached_pic, &src->attached_pic); + if (ret < 0) + return ret; + } + + return 0; +} + +AVStream *ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src) +{ + AVStream *st; + int ret; + + st = avformat_new_stream(dst_ctx, NULL); + if (!st) + return NULL; + + ret = stream_params_copy(st, src); + if (ret < 0) { + ff_remove_stream(dst_ctx, st); + return NULL; + } + + return st; +} + AVProgram *av_new_program(AVFormatContext *ac, int id) { AVProgram *program = NULL; diff --git a/libavformat/fifo.c b/libavformat/fifo.c index ead2bdc5cf..e28f6299d9 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -504,16 +504,10 @@ static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat, avf2->io_open = avf->io_open; avf2->flags = avf->flags; - for (i = 0; i < avf->nb_streams; ++i) { - AVStream *st = avformat_new_stream(avf2, NULL); - if (!st) + for (i = 0; i < avf->nb_streams; ++i) + if (!ff_stream_clone(avf2, avf->streams[i])) return AVERROR(ENOMEM); - ret = ff_stream_encode_params_copy(st, avf->streams[i]); - if (ret < 0) - return ret; - } - return 0; } diff --git a/libavformat/internal.h b/libavformat/internal.h index b6b8fbf56f..9b07cfb271 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -625,6 +625,17 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags); */ int ff_stream_side_data_copy(AVStream *dst, const AVStream *src); +/** + * Create a new stream and copy to it all parameters from a source stream, with + * the exception of the index field, which is set when the new stream is + * created. + * + * @param dst_ctx pointer to the context in which the new stream is created + * @param src pointer to source AVStream + * @return pointer to the new stream or NULL on error + */ +AVStream *ff_stream_clone(AVFormatContext *dst_ctx, const AVStream *src); + /** * Wrap ffurl_move() and log if error happens. * diff --git a/libavformat/mux.h b/libavformat/mux.h index c01da82194..1bfcaf795f 100644 --- a/libavformat/mux.h +++ b/libavformat/mux.h @@ -113,15 +113,6 @@ int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size) */ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options); -/** - * Copy encoding parameters from source to destination stream - * - * @param dst pointer to destination AVStream - * @param src pointer to source AVStream - * @return >=0 on success, AVERROR code on error - */ -int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src); - /** * Parse creation_time in AVFormatContext metadata if exists and warn if the * parsing fails. diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c index eb8ea3d560..2fa2ab5b0f 100644 --- a/libavformat/mux_utils.c +++ b/libavformat/mux_utils.c @@ -121,34 +121,6 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op return 0; } -int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src) -{ - int ret; - - dst->id = src->id; - dst->time_base = src->time_base; - dst->nb_frames = src->nb_frames; - dst->disposition = src->disposition; - dst->sample_aspect_ratio = src->sample_aspect_ratio; - dst->avg_frame_rate = src->avg_frame_rate; - dst->r_frame_rate = src->r_frame_rate; - - av_dict_free(&dst->metadata); - ret = av_dict_copy(&dst->metadata, src->metadata, 0); - if (ret < 0) - return ret; - - ret = avcodec_parameters_copy(dst->codecpar, src->codecpar); - if (ret < 0) - return ret; - - ret = ff_stream_side_data_copy(dst, src); - if (ret < 0) - return ret; - - return 0; -} - int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds) { AVDictionaryEntry *entry; diff --git a/libavformat/segment.c b/libavformat/segment.c index fa435d9f32..c904e20708 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -167,11 +167,9 @@ static int segment_mux_init(AVFormatContext *s) AVStream *st, *ist = s->streams[i]; AVCodecParameters *ipar = ist->codecpar, *opar; - if (!(st = avformat_new_stream(oc, NULL))) + st = ff_stream_clone(oc, ist); + if (!st) return AVERROR(ENOMEM); - ret = ff_stream_encode_params_copy(st, ist); - if (ret < 0) - return ret; opar = st->codecpar; if (!oc->oformat->codec_tag || av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == opar->codec_id || diff --git a/libavformat/tee.c b/libavformat/tee.c index f1f2a9d2a5..ffd28fd1f6 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -162,7 +162,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) char *format = NULL, *select = NULL, *on_fail = NULL; char *use_fifo = NULL, *fifo_options_str = NULL; AVFormatContext *avf2 = NULL; - AVStream *st, *st2; + AVStream *st; int stream_count; int fullret; char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, *tmp_select = NULL; @@ -284,14 +284,10 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) } tee_slave->stream_map[i] = stream_count++; - if (!(st2 = avformat_new_stream(avf2, NULL))) { + if (!ff_stream_clone(avf2, st)) { ret = AVERROR(ENOMEM); goto end; } - - ret = ff_stream_encode_params_copy(st2, st); - if (ret < 0) - goto end; } ret = ff_format_output_open(avf2, filename, &options); diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index d69db3a004..9e71a1209d 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -91,12 +91,10 @@ static int webm_chunk_init(AVFormatContext *s) if ((ret = av_dict_copy(&oc->metadata, s->metadata, 0)) < 0) return ret; - if (!(st = avformat_new_stream(oc, NULL))) + st = ff_stream_clone(oc, ost); + if (!st) return AVERROR(ENOMEM); - if ((ret = ff_stream_encode_params_copy(st, ost)) < 0) - return ret; - if (wc->http_method) if ((ret = av_dict_set(&dict, "method", wc->http_method, 0)) < 0) return ret; From patchwork Thu Aug 11 05:57:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 37234 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3d0d:b0:8d:a68e:8a0e with SMTP id y13csp163495pzi; Wed, 10 Aug 2022 22:58:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR757CMwvBe7p+OulUooioy2ZlLnEk4Z4UtXE86U86zNzdJEqPFsXNtjv8uxSH1Vz64N1Dlq X-Received: by 2002:a17:907:9710:b0:731:67b1:dc3b with SMTP id jg16-20020a170907971000b0073167b1dc3bmr11838121ejc.709.1660197483062; Wed, 10 Aug 2022 22:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660197483; cv=none; d=google.com; s=arc-20160816; b=NTz26R7TyjN73Q8MpyPt4GMDIBHtgjLH57ripOiyKwq4MmAMLIrjrXEbhP8EHv443a B1/35VeItnND0sYf7wWteCmkVVgczJI7No3OCW9INX7mDLnzG2X9Wa82bhaqCPBSI+DS qGWmEW3Cbg1QJvebJCvpzUdQ5Ym1/8d0KS4VoaV2rZaN3kvNuW19cGTzjiUXV2nJ5IpP kDZBZjykyZ4yetAc3JVdPLaqrFF10b9erWkrmQEJ0WroKsHlie6jBXp4KomAifVDuTzq cTUkqsrUQQnIR/gXxttpOxkfdv2GwhlF/l9JWZHNvT43WMnb39ULXPF7hKkdrjeCgU0q lBUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=EXoARz3OyMRxDqZzOa9UkS9XVD8W3/4w9lH4PYU7LK8=; b=CGB81t23qh2QBZd+FyCTowCV6iocNxIiG5jYyxzllnCk8Fxj+eabcz3DXO1d96MWwe 7Af2GC2u9E4Mw0GiiT1aPQB8VToIBtN0KIAFQKYVMGnVY7oRGCcNsod0if183ecHyhHO 3dJhCLZSb7usO5kb3T9mxpuIJL6QNOafF7qt4mXdWyTf4gZhyGp+jxipQtLD51GMmCb4 FQuXpL3l+ff3rs24ItqEfp/vfsGvDYTY3TkH3DwV0Y6ffrQS9Ed/VJ4LAMU1l4AhFkTI UChOyFS/SeVf9fZ2hmx2SH5ufwxa3P+E87HVDzjYQf1pHuHEJfM0ReSClZjkD7hMMQQ0 1GmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b7-20020a056402350700b0043de3215579si15318415edd.12.2022.08.10.22.58.02; Wed, 10 Aug 2022 22:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 329B468B8CC; Thu, 11 Aug 2022 08:57:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C47E68B7EB for ; Thu, 11 Aug 2022 08:57:44 +0300 (EEST) Received: by mail-pl1-f169.google.com with SMTP id z19so16144986plb.1 for ; Wed, 10 Aug 2022 22:57:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=gq6jei1+J599H3II8rkEZ0Id8tdW9lHrn5Hpa2S3bRI=; b=FVEOGFIVN2XW35JKmu5MhMquILrmz5B55iDKxYDQtZVwutFxuaz7dnbRXb6jJ8rvXk pxUPZ0EPiXqOoIfirnUrGqCw+IyYmPuhK5bhV8QuNg3RoBYPSDWSVKR8htROUp7zTKaB /3YPlln+/W5AfSCUJgJ0mB8aCFRghZl0/jxGy3Q9FEOAx6RzwMnMjFi01IJ7G7HwMf9z sDXkLTkvmNeIAWyBOdwQosnH2XJ7TeP2r89RXooZU/+omrfWnoDob0bt3ZOohE7OBYu3 rmUUhJ5/KzKhYtZxqGE9nZZeFmEQgpb2XZJOZMudHpRO1eLfb61eh5Wq2uaOZoS6kQw2 7rsQ== X-Gm-Message-State: ACgBeo1IHvP71beOjAL1RWLTdNDGrNZ5hlLyKFovuZIZYuojcGWLNg8F 40CavwgT+DyVxZKIVDP23RLOjlYUUcY= X-Received: by 2002:a17:903:192:b0:16f:8a63:18ef with SMTP id z18-20020a170903019200b0016f8a6318efmr29408089plg.95.1660197462459; Wed, 10 Aug 2022 22:57:42 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id m5-20020a170902768500b0016d4f05eb95sm13823386pll.272.2022.08.10.22.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 22:57:42 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Wed, 10 Aug 2022 22:57:39 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Aug 2022 22:57:33 -0700 Message-Id: <20220811055733.8127-2-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811055733.8127-1-pal@sandflow.com> References: <20220811055733.8127-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v8 2/2] avformat/imfdec: preserve stream information X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VF4y8yRzmZyo From: Pierre-Anthony Lemieux --- libavformat/imfdec.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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,