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 565FE40344 for ; Fri, 21 Jan 2022 20:20:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4EDD568B1B0; Fri, 21 Jan 2022 22:20:38 +0200 (EET) Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5BFA68B01C for ; Fri, 21 Jan 2022 22:20:31 +0200 (EET) Received: by mail-ua1-f45.google.com with SMTP id u6so19035214uaq.0 for ; Fri, 21 Jan 2022 12:20:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=ZRtlEVtvQAL3wfnW35tEgIeloru4DbvibXeHCnnUu1o=; b=Or3f6XqaSQHPNDAdXgHcKM29DXujKqvSKyp2VOR4X26UbvMru2wqNFtrdJuqcNbwAM WPzGjbuSCduKG3gmOXzDJcTOzOPqez2PRgUos9ZeYFpptq7wGGjuLwuHeg6AIvdBEOi7 qmObsStqBkyIPyifI8zcpS+HcH8ICLtUsDKj0H9E8Daw4n9Z7/DsOXIeCTCYLQVdygux 7+jE5QXgDsWyi/SAH1qKd84mIRhSnNwOYjvyQPajudV8FQ2JctDzxitah6dh61DwaWju LMfOJRmFutAVDS4caOeOMxj5CkD0gekCwyZiH0UU/FkLnbayIpN9Nu2lsbYrjWR1tczh XGwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=ZRtlEVtvQAL3wfnW35tEgIeloru4DbvibXeHCnnUu1o=; b=Z691pE427J3bnr6yy18sxfKhSnSAvNJJhEKqvelYfrf7d/buIcxupW1UQzAcXwoUAu iP/5N6uiZ3Bz6nVEw/mQvoU69/ukicp3bLZZ0cjwo7SjdFUIbu3wWZkVw/WVTmhpreBs tvdS3V/nx9Z/UecPbVedQeTtCxO8tkHtYrNWoY66Ma5mUGCcT5Sv2lXW7/ElYVUBX08x 7SZ+9v1uFzHWl9SYO7FBOahkjYeLI3vyp8tKDsqSpGYk3IX1OO/mhkvCQ8rXDpzQB4oA n1fORwEmTx/k/6Jjzsp/zu7Z1AT+Ms8mk5Rvt7OXZqQ019URj81wDDkoSkitKslyp6hu jVrg== X-Gm-Message-State: AOAM533IzbJYlxfmXEv14/1NBvmaz85viMUEW4J+o19HgG7DzUSWEVwk jVkv+p4unHyuEdBnrDOJd/YXBv/zTd8= X-Google-Smtp-Source: ABdhPJwtFJMLskVIT6SRQAnqd1IaqEdhjbdmPDwheE030o5xM3teedvDTPm8lG+DETfGL7OV2vtzOQ== X-Received: by 2002:a67:e0c1:: with SMTP id m1mr2588768vsl.47.1642796429865; Fri, 21 Jan 2022 12:20:29 -0800 (PST) Received: from [192.168.0.13] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id o1sm46164vsa.15.2022.01.21.12.20.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jan 2022 12:20:29 -0800 (PST) Message-ID: Date: Fri, 21 Jan 2022 17:20:26 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220113015101.4-1-jamrial@gmail.com> <20220113015612.448-3-jamrial@gmail.com> From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 091/281] matroska: convert to new channel layout API 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 1/21/2022 4:52 PM, Andreas Rheinhardt wrote: > James Almer: >> From: Vittorio Giovara >> >> Signed-off-by: Vittorio Giovara >> Signed-off-by: Anton Khirnov >> Signed-off-by: James Almer >> --- >> libavformat/matroskadec.c | 8 ++++++-- >> libavformat/matroskaenc.c | 10 +++++----- >> 2 files changed, 11 insertions(+), 7 deletions(-) >> >> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c >> index 78e5a4a203..62a36cbb8c 100644 >> --- a/libavformat/matroskadec.c >> +++ b/libavformat/matroskadec.c >> @@ -2083,7 +2083,7 @@ static int matroska_parse_flac(AVFormatContext *s, >> av_log(s, AV_LOG_WARNING, >> "Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n"); >> } else >> - st->codecpar->channel_layout = mask; >> + av_channel_layout_from_mask(&st->codecpar->ch_layout, mask); >> } >> av_dict_free(&dict); >> } >> @@ -2911,7 +2911,11 @@ static int matroska_parse_tracks(AVFormatContext *s) >> st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; >> st->codecpar->codec_tag = fourcc; >> st->codecpar->sample_rate = track->audio.out_samplerate; >> - st->codecpar->channels = track->audio.channels; >> + // channel layout may be already set by codec private checks above >> + if (st->codecpar->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && >> + !st->codecpar->ch_layout.u.mask) >> + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; >> + st->codecpar->ch_layout.nb_channels = track->audio.channels; >> if (!st->codecpar->bits_per_coded_sample) >> st->codecpar->bits_per_coded_sample = track->audio.bitdepth; >> if (st->codecpar->codec_id == AV_CODEC_ID_MP3 || >> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c >> index 152312102a..5278166e8c 100644 >> --- a/libavformat/matroskaenc.c >> +++ b/libavformat/matroskaenc.c >> @@ -657,9 +657,9 @@ static int put_wv_codecpriv(AVIOContext *pb, const AVCodecParameters *par) >> static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, >> const AVCodecParameters *par) >> { >> - int write_comment = (par->channel_layout && >> - !(par->channel_layout & ~0x3ffffULL) && >> - !ff_flac_is_native_layout(par->channel_layout)); >> + int write_comment = (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && par->ch_layout.u.mask && >> + !av_channel_layout_subset(&par->ch_layout, ~0x3ffffULL) && > > Why are you using this function although you already know that it is a > native layout, so that the typical & works fine? I think Vittorio originally wrote it as int write_comment = (!av_channel_layout_subset(&par->ch_layout, ~0x3ffffULL) && !ff_flac_is_native_layout(par->ch_layout.u.mask)); Which could potentially access the union's mask field on a layout other than native if av_channel_layout_subset() succeeded, so i added that check. But you're right it makes calling subset() superfluous, so will change it. > >> + !ff_flac_is_native_layout(par->ch_layout.u.mask)); >> int ret = ff_flac_write_header(pb, par->extradata, par->extradata_size, >> !write_comment); >> >> @@ -673,7 +673,7 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, >> uint8_t buf[32]; >> int64_t len; >> >> - snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout); >> + snprintf(buf, sizeof(buf), "0x%"PRIx64, par->ch_layout.u.mask); >> av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0); >> >> len = ff_vorbiscomment_length(dict, vendor, NULL, 0); >> @@ -1396,7 +1396,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, >> put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM"); >> >> subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 6 + 4 * 9); >> - put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , par->channels); >> + put_ebml_uint(pb, MATROSKA_ID_AUDIOCHANNELS, par->ch_layout.nb_channels); >> >> track->sample_rate_offset = avio_tell(pb); >> put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate); >> > > _______________________________________________ > 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".