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 33E2842117 for ; Mon, 28 Mar 2022 23:26:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D91FA68B2F8; Tue, 29 Mar 2022 02:25:59 +0300 (EEST) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5121068B2BB for ; Tue, 29 Mar 2022 02:25:52 +0300 (EEST) Received: by mail-oi1-f178.google.com with SMTP id i7so3240183oie.7 for ; Mon, 28 Mar 2022 16:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wVAE86e9eyyIHV1gqH1ubCEcoxas9uY4gziz5wsWq2Y=; b=ZmsbmfZmMnBxTbaKT+KnoSfc3n1e8/mmaMH98/GdRFBT4dd4fZ850k750Bz5FGTGiT 84KGklkfu207isK4HOa83aGvfmXj7JRgEvM31A1S3WJNKIhOClzFON38H77opcrRasyx wR78fbgTQcn6Q/FB5nTs925BFYEFJy6kEMZ4s8oXNnfVlr9zQI4g0fd4lK2KjWUTI4D0 Z3oP3NDvY5Woc+Mqtj40fX+ITRAET/CLolCYslJSp9lXJ7KZmaf9oeeR3j63CsvYsAWm YHeA651+f7n9Xxa7qfCoO2/iWHaHSOeMjRJTfCGCB783/eP9Ojp/waQUjrmuS9nblDeh yF9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wVAE86e9eyyIHV1gqH1ubCEcoxas9uY4gziz5wsWq2Y=; b=J0dhANWLv7I8D5wyg8iD8j7JqE9f0N53ULaatiRVW/+QNehqz1oDcxMs5aiuVZhyef eXqcsHZNe1jBbMRvWb9ClhHg/rSKKU4QmlBAlZuUdrEB0YnVq6F+wqpMTmw0NrJtrnxB SINQCEcXo3c35n65dYx+XlZE6HtQVy50IORCv7Q7+eeNZ31RpsAYE3fqbZW0vTa8HYUN Xuvy6dOFilox9Fpz29f/1YW+ivROqUJdVwKBJMMd4nSxbS4S4pn76bY0oentTnE1OSRp /EF/QvH9R5gXg7fvmiKtStDTfomil3EOKZbqgbNSZeUCqp9Hoq7Zd6Mc/VgohCPvzEsy HDag== X-Gm-Message-State: AOAM532BQeirNRKcVngzZV/LqBuEMw1bLDsBUTRomXu0/YaC2iwTdvkq NOT/t4L3tUmTbTo+6WPKcIO0RpWOgrvNcg== X-Google-Smtp-Source: ABdhPJzhZ4AxqzYX154IXTjp81vQR+x2K8e3iAkL5amojcUH3LvYIid9y5ZFvHqN+czmU5fFvoj4Jw== X-Received: by 2002:a05:6808:1201:b0:2d9:a01a:48b8 with SMTP id a1-20020a056808120100b002d9a01a48b8mr758191oil.259.1648509950716; Mon, 28 Mar 2022 16:25:50 -0700 (PDT) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id gk6-20020a0568703c0600b000de4880b357sm7198456oab.50.2022.03.28.16.25.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 16:25:50 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 28 Mar 2022 20:24:52 -0300 Message-Id: <20220328232453.54773-6-jamrial@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220328232453.54773-1-jamrial@gmail.com> References: <20220328232453.54773-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] avformat/movenc: don't use mono layout when a front center label is expected 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 output streams where a multichannel stream needs to be stored as one track per channel, each track will have a channel layout describing the position of the channel they contain. For the track with front center, the mov muxer was using the mov layout "mono" instead of the label for the front center position. Since our channel layout API considers front center == mono, we need to do some heuristics. To achieve this, we make sure all audio tracks contain streams with a single channel, and only one of them is front center. In that case, we write the front center label instead of signaling mono layout. Fixes the last part of ticket #2865 Signed-off-by: James Almer --- libavformat/movenc.c | 25 +++++++++++++++++++++++++ libavformat/movenc.h | 1 + 2 files changed, 26 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 263649f1da..b9956e699c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -887,6 +887,17 @@ static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra return ret; } + if (layout_tag == MOV_CH_LAYOUT_MONO && track->mono_as_fc > 0) { + av_assert0(!channel_desc); + channel_desc = av_malloc(sizeof(*channel_desc)); + if (!channel_desc) + return AVERROR(ENOMEM); + + layout_tag = 0; + bitmap = 0; + *channel_desc = 3; // channel label "Center" + } + num_desc = layout_tag ? 0 : track->par->ch_layout.nb_channels; avio_wb32(pb, 0); // Size @@ -6970,6 +6981,20 @@ static int mov_write_header(AVFormatContext *s) if (j == i) continue; + if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + (trackj->par->ch_layout.nb_channels != 1 || + !av_channel_layout_compare(&trackj->par->ch_layout, + &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) + ) + track->mono_as_fc = -1; + + if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + av_channel_layout_compare(&trackj->par->ch_layout, + &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO) && + trackj->par->ch_layout.nb_channels == 1 && track->mono_as_fc >= 0 + ) + track->mono_as_fc++; + if (stj->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || av_channel_layout_compare(&trackj->par->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO) || diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 2ac84ed070..67d6d4fb66 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -107,6 +107,7 @@ typedef struct MOVTrack { int tag; ///< stsd fourcc AVStream *st; AVCodecParameters *par; + int mono_as_fc; int multichannel_as_mono; int vos_len; -- 2.35.1 _______________________________________________ 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".