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 6E44444D79 for ; Tue, 21 Nov 2023 21:57:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCA3B68CC89; Tue, 21 Nov 2023 23:57:56 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A9F468BDD0 for ; Tue, 21 Nov 2023 23:57:50 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A6763E91BA for ; Tue, 21 Nov 2023 22:57:49 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7TY4RV0SpXSJ for ; Tue, 21 Nov 2023 22:57:46 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 983E6E9196 for ; Tue, 21 Nov 2023 22:57:46 +0100 (CET) Date: Tue, 21 Nov 2023 22:57:46 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20231121211442.8723-2-jamrial@gmail.com> Message-ID: References: <20231121211442.8723-1-jamrial@gmail.com> <20231121211442.8723-2-jamrial@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/5] avformat: introduce AVStreamGroup 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, 21 Nov 2023, James Almer wrote: > Signed-off-by: James Almer > --- > libavformat/avformat.c | 178 +++++++++++++++++++++++++++++++++++++++-- > libavformat/avformat.h | 163 +++++++++++++++++++++++++++++++++++++ > libavformat/dump.c | 33 ++++++-- > libavformat/internal.h | 33 ++++++++ > libavformat/options.c | 90 +++++++++++++++++++++ > 5 files changed, 486 insertions(+), 11 deletions(-) > > diff --git a/libavformat/avformat.c b/libavformat/avformat.c > index 5b8bb7879e..4e31924c71 100644 > --- a/libavformat/avformat.c > +++ b/libavformat/avformat.c [...] > @@ -493,6 +524,46 @@ static int match_stream_specifier(const AVFormatContext *s, const AVStream *st, > match = 0; > if (nopic && (st->disposition & AV_DISPOSITION_ATTACHED_PIC)) > match = 0; > + } else if (*spec == 'g' && *(spec + 1) == ':') { > + int64_t group_idx = -1, group_id = -1; > + int found = 0; > + char *endptr; > + spec += 2; > + if (*spec == '#' || (*spec == 'i' && *(spec + 1) == ':')) { > + spec += 1 + (*spec == 'i'); > + group_id = strtol(spec, &endptr, 0); > + if (spec == endptr || (*endptr && *endptr++ != ':')) > + return AVERROR(EINVAL); > + spec = endptr; > + } else { > + group_idx = strtol(spec, &endptr, 0); > + /* Disallow empty id and make sure that if we are not at the end, then another specifier must follow. */ > + if (spec == endptr || (*endptr && *endptr++ != ':')) > + return AVERROR(EINVAL); > + spec = endptr; > + } > + if (match) { > + if (group_id > 0) { > + for (unsigned i = 0; i < s->nb_stream_groups; i++) { > + if (group_id == s->stream_groups[i]->id) { > + group_idx = i; > + break; > + } > + } > + } > + if (group_idx < 0 || group_idx > s->nb_stream_groups) > + return AVERROR(EINVAL); > + for (unsigned j = 0; j < s->stream_groups[group_idx]->nb_streams; j++) { > + if (st->index == s->stream_groups[group_idx]->streams[j]->index) { > + found = 1; > + if (g) > + *g = s->stream_groups[group_idx]; > + break; > + } > + } > + } > + if (!found) > + match = 0; The documentation for the stream specifier changes are missing from doc/fftools-common-opts.texi. You should update relevant docs preferably in this patch... [...] > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1018,6 +1018,77 @@ typedef struct AVStream { > int pts_wrap_bits; > } AVStream; > > +enum AVStreamGroupParamsType { > + AV_STREAM_GROUP_PARAMS_NONE, > +}; > + > +typedef struct AVStreamGroup { > + /** > + * A class for @ref avoptions. Set by avformat_stream_group_create(). > + */ > + const AVClass *av_class; > + > + void *priv_data; > + > + /** > + * Group index in AVFormatContext. > + */ > + unsigned int index; > + > + /** > + * Group type-specific group ID. > + * > + * decoding: set by libavformat > + * encoding: may set by the user, replaced by libavformat if left unset > + */ > + int64_t id; I don't quite get the encoding case where libavformat replaces the unset ID... Also, what is unset? 0 or -1? Because as far as I see 0 is the default, maybe -1 is better if unset has some special meaning? [...] > diff --git a/libavformat/internal.h b/libavformat/internal.h > index 7702986c9c..c6181683ef 100644 > --- a/libavformat/internal.h > +++ b/libavformat/internal.h > @@ -202,6 +202,7 @@ typedef struct FFStream { > */ > AVStream pub; > > + AVFormatContext *fmtctx; > /** > * Set to 1 if the codec allows reordering, so pts can be different > * from dts. > @@ -427,6 +428,26 @@ static av_always_inline const FFStream *cffstream(const AVStream *st) > return (const FFStream*)st; > } > > +typedef struct FFStreamGroup { > + /** > + * The public context. > + */ > + AVStreamGroup pub; > + > + AVFormatContext *fmtctx; If the only purpose of storing this is sanity checking if the user calls API with matching stream and stream group, then maybe better to make it ptrdiff_t, so nobody will try to misuse this to access the format context or do logging, etc... Regards, Marton _______________________________________________ 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".