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 E96F3485DF for ; Mon, 11 Dec 2023 11:48:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22A5D68D031; Mon, 11 Dec 2023 13:48:11 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 71FC968D167 for ; Mon, 11 Dec 2023 13:48:04 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 206DD2405ED for ; Mon, 11 Dec 2023 12:48:04 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Fxw5GJOBDGkL for ; Mon, 11 Dec 2023 12:48:03 +0100 (CET) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6702E2400AC for ; Mon, 11 Dec 2023 12:48:03 +0100 (CET) Received: by lain.khirnov.net (Postfix, from userid 1000) id 537871601B9; Mon, 11 Dec 2023 12:48:03 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20231205224402.14540-4-jamrial@gmail.com> References: <20231205224402.14540-1-jamrial@gmail.com> <20231205224402.14540-4-jamrial@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches Date: Mon, 11 Dec 2023 12:48:03 +0100 Message-ID: <170229528332.8914.3392013065667453741@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 3/8] ffmpeg: add support for muxing AVStreamGroups 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: Quoting James Almer (2023-12-05 23:43:57) > Starting with IAMF support. > > Signed-off-by: James Almer > --- > fftools/ffmpeg.h | 2 + > fftools/ffmpeg_mux_init.c | 335 ++++++++++++++++++++++++++++++++++++++ > fftools/ffmpeg_opt.c | 2 + > 3 files changed, 339 insertions(+) Missing documentation. > +static int of_add_groups(Muxer *mux, const OptionsContext *o) > +{ > + AVFormatContext *oc = mux->fc; > + int ret; > + > + /* process manually set groups */ > + for (int i = 0; i < o->nb_stream_groups; i++) { > + AVDictionary *dict = NULL, *tmp = NULL; > + const AVDictionaryEntry *e; > + AVStreamGroup *stg = NULL; > + int type; > + const char *token; > + char *str, *ptr = NULL; > + const AVOption opts[] = { > + { "type", "Set group type", offsetof(AVStreamGroup, type), AV_OPT_TYPE_INT, > + { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "type" }, > + { "iamf_audio_element", NULL, 0, AV_OPT_TYPE_CONST, > + { .i64 = AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT }, .unit = "type" }, > + { "iamf_mix_presentation", NULL, 0, AV_OPT_TYPE_CONST, > + { .i64 = AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION }, .unit = "type" }, > + { NULL }, > + }; > + const AVClass class = { > + .class_name = "StreamGroupType", > + .item_name = av_default_item_name, > + .option = opts, > + .version = LIBAVUTIL_VERSION_INT, > + }; > + const AVClass *pclass = &class; > + > + str = av_strdup(o->stream_groups[i].u.str); > + if (!str) > + goto end; > + > + token = av_strtok(str, ",", &ptr); > + if (token) { Too many indentation levels, move this whole block into a separate function. > + ret = av_dict_parse_string(&dict, token, "=", ":", AV_DICT_MULTIKEY); > + if (ret < 0) { > + av_log(mux, AV_LOG_ERROR, "Error parsing group specification %s\n", token); > + goto end; > + } > + > + // "type" is not a user settable option in AVStreamGroup This comment confuses me. > + e = av_dict_get(dict, "type", NULL, 0); > + if (!e) { > + av_log(mux, AV_LOG_ERROR, "No type define for Steam Group %d\n", i); 1) Steam 2) defined? Or maybe specified. 3) Print the string, not the index. > + ret = AVERROR(EINVAL); > + goto end; > + } > + > + ret = av_opt_eval_int(&pclass, opts, e->value, &type); > + if (ret < 0 || type == AV_STREAM_GROUP_PARAMS_NONE) { > + av_log(mux, AV_LOG_ERROR, "Invalid group type \"%s\"\n", e->value); > + goto end; > + } > + > + av_dict_copy(&tmp, dict, 0); > + stg = avformat_stream_group_create(oc, type, &tmp); > + if (!stg) { > + ret = AVERROR(ENOMEM); > + goto end; > + } > + av_dict_set(&tmp, "type", NULL, 0); > + > + e = NULL; > + while (e = av_dict_get(dict, "st", e, 0)) { > + unsigned int idx = strtol(e->value, NULL, 0); > + if (idx >= oc->nb_streams) { > + av_log(mux, AV_LOG_ERROR, "Invalid stream index %d\n", idx); > + ret = AVERROR(EINVAL); > + goto end; > + } This block seems confused about signedness of e->value. > + avformat_stream_group_add_stream(stg, oc->streams[idx]); Unchecked return value. -- Anton Khirnov _______________________________________________ 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".