From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 67ED94372C for ; Wed, 27 Jul 2022 09:44:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B8AAE68B9A3; Wed, 27 Jul 2022 12:44:19 +0300 (EEST) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1ECE968B2C8 for ; Wed, 27 Jul 2022 12:44:12 +0300 (EEST) Received: by mail-pg1-f180.google.com with SMTP id bf13so15449020pgb.11 for ; Wed, 27 Jul 2022 02:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandflow-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=LG55uXDb/Jb2/UdY0yDXf1RMpf7TtCdEgbXnL4/dit0=; b=ATpB/yeMQ4n1dpng/RV/ynRpXNyZJc0+GXaVkSRvgYOjrk/ClHEJfZJPM4uiAimboy 6SzaNfUYsqcd+u+8JYKS4NHY8Q6S66dH2QUrMfuaRkCkjxAkD+rvJ6qT+fwGpNvQ6oFs l/V8t8453f5v9wP+czNF2cu5LP9zuOPjTuhH9aTMQZG5/29bmDm2sldBWqHIQ9auOFWq 62iVvjiN7opdQg9+MGEkTaLCz522TLVqw8S+xJ9K7Jbvzy/N/y3oS84Z7cJezneJ15F8 A3eMDkpznbtC3zI7E8Ppdic3SEh4pvjwJ+wgCXYzzHvJqGzPq8segbiGkeNrcB6bKA/l OtaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=LG55uXDb/Jb2/UdY0yDXf1RMpf7TtCdEgbXnL4/dit0=; b=PnSLYzpPPwzQ1TlnALurjSUzmjenVBKMuxX8SbdBppFii1oy+gJYpUyDezJCWlqqEC t852LEo+rttKhTjpH5SbDD+FOLkz4tW1gkwcFEyekIBXuw0BmFRxvcM1ub/4YxOcLRj+ uzLa045epvBhFrDwbyPZjaMtRhRs7FlbNevzqoHPdXkRrzS8LEp6c2Y37LbaWbgz/XkA dzM/IOGnrDQTGmqWCjRC8lwMt9f9o6/JZjiFKbvQB6pkkhSKCfrbEEDKu/7Q3isuVNzK uiLlcsPzMUu3G66rAr6Pcte3ghAClHhhDydcJpNAhEDCSBBaTKLe/9yhBQ+jC08i/f9G kSJw== X-Gm-Message-State: AJIora+s61/w3Ea/UNfejTllA0oWZaaEQStGpuTPGow1Ugs5DsEiKW7L ItgfxtcUDcdETlg48HBT4WLBmz7azm1DKPib X-Google-Smtp-Source: AGRyM1tPMfEMAYk1qHByt3wjWPfTsL/RErTsfOFk0+MudoCqxBmwEUjK3k8qVTRUxW6/EbSNVjPLXw== X-Received: by 2002:a63:904c:0:b0:41a:4974:4778 with SMTP id a73-20020a63904c000000b0041a49744778mr16858240pge.489.1658899969751; Tue, 26 Jul 2022 22:32:49 -0700 (PDT) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com. [209.85.214.175]) by smtp.gmail.com with ESMTPSA id r18-20020a170902be1200b0016784c93f23sm12454405pls.197.2022.07.26.22.32.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Jul 2022 22:32:48 -0700 (PDT) Received: by mail-pl1-f175.google.com with SMTP id x7so1326216pll.7 for ; Tue, 26 Jul 2022 22:32:47 -0700 (PDT) X-Received: by 2002:a17:90b:4a42:b0:1f2:b638:bc2e with SMTP id lb2-20020a17090b4a4200b001f2b638bc2emr2615460pjb.185.1658899966338; Tue, 26 Jul 2022 22:32:46 -0700 (PDT) MIME-Version: 1.0 References: <20220725081645.12834-1-pal@sandflow.com> In-Reply-To: From: Pierre-Anthony Lemieux Date: Wed, 27 Jul 2022 07:32:35 +0200 X-Gmail-Original-Message-ID: Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] avformat: refactor ff_stream_encode_params_copy() to ff_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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, Jul 26, 2022 at 8:17 AM Andreas Rheinhardt wrote: > > pal@sandflow.com: > > From: Pierre-Anthony Lemieux > > > > As discussed at https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298491.html. > > Note that ff_stream_params_copy() does not copy the index field, which is > > usually set by avformat_new_stream(). > > > > --- > > libavformat/avformat.c | 37 +++++++++++++++++++++++++++++++++++++ > > libavformat/fifo.c | 2 +- > > libavformat/internal.h | 10 ++++++++++ > > libavformat/mux.h | 9 --------- > > libavformat/mux_utils.c | 28 ---------------------------- > > libavformat/segment.c | 2 +- > > libavformat/tee.c | 2 +- > > libavformat/webm_chunk.c | 2 +- > > 8 files changed, 51 insertions(+), 41 deletions(-) > > > > diff --git a/libavformat/avformat.c b/libavformat/avformat.c > > index 30d6ea6a49..c426dbfa45 100644 > > --- a/libavformat/avformat.c > > +++ b/libavformat/avformat.c > > @@ -235,6 +235,43 @@ int ff_stream_side_data_copy(AVStream *dst, const AVStream *src) > > return 0; > > } > > > > +int ff_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; > > + > > + ret = av_packet_ref(&dst->attached_pic, &src->attached_pic); > > This will allocate a buffer of size AV_INPUT_BUFFER_PADDING_SIZE in > dst->attached_pic (and set the size of the data of said packet to 0) if > the size of the data of src->attached_pic is zero (in particular, if it > is truely blank). This is not desired. As I understand it, this behavior is triggered if src->attached_pic is not null and not ref-counted. Is that right? If so, are there circumstances where src->attached_pic is not ref-counted? ff_add_attached_pic() seems to add ref-counted data. av_packet_ref() creates a ref-counted buffer if the src packet does not contain one. Changing that behavior would require duplicating the mechanics of av_packet_ref(). ... or maybe there is a much simpler approach? > > > + if (ret < 0) > > + return ret; > > + > > + return 0; > > +} > > + > > AVProgram *av_new_program(AVFormatContext *ac, int id) > > { > > AVProgram *program = NULL; > > diff --git a/libavformat/fifo.c b/libavformat/fifo.c > > index ead2bdc5cf..fef116d040 100644 > > --- a/libavformat/fifo.c > > +++ b/libavformat/fifo.c > > @@ -509,7 +509,7 @@ static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat, > > if (!st) > > return AVERROR(ENOMEM); > > > > - ret = ff_stream_encode_params_copy(st, avf->streams[i]); > > + ret = ff_stream_params_copy(st, avf->streams[i]); > > if (ret < 0) > > return ret; > > } > > diff --git a/libavformat/internal.h b/libavformat/internal.h > > index b6b8fbf56f..774ff57698 100644 > > --- a/libavformat/internal.h > > +++ b/libavformat/internal.h > > @@ -625,6 +625,16 @@ 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); > > > > +/** > > + * 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 > > + */ > > +int ff_stream_params_copy(AVStream *dst, 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..a8f3e94714 100644 > > --- a/libavformat/segment.c > > +++ b/libavformat/segment.c > > @@ -169,7 +169,7 @@ static int segment_mux_init(AVFormatContext *s) > > > > if (!(st = avformat_new_stream(oc, NULL))) > > return AVERROR(ENOMEM); > > - ret = ff_stream_encode_params_copy(st, ist); > > + ret = ff_stream_params_copy(st, ist); > > if (ret < 0) > > return ret; > > opar = st->codecpar; > > diff --git a/libavformat/tee.c b/libavformat/tee.c > > index f1f2a9d2a5..dbfad604d0 100644 > > --- a/libavformat/tee.c > > +++ b/libavformat/tee.c > > @@ -289,7 +289,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) > > goto end; > > } > > > > - ret = ff_stream_encode_params_copy(st2, st); > > + ret = ff_stream_params_copy(st2, st); > > if (ret < 0) > > goto end; > > } > > diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c > > index d69db3a004..39f21fce7a 100644 > > --- a/libavformat/webm_chunk.c > > +++ b/libavformat/webm_chunk.c > > @@ -94,7 +94,7 @@ static int webm_chunk_init(AVFormatContext *s) > > if (!(st = avformat_new_stream(oc, NULL))) > > return AVERROR(ENOMEM); > > > > - if ((ret = ff_stream_encode_params_copy(st, ost)) < 0) > > + if ((ret = ff_stream_params_copy(st, ost)) < 0) > > return ret; > > > > if (wc->http_method) > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".