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 0F3A742B59 for ; Thu, 13 Jan 2022 01:53:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 19A2568AF04; Thu, 13 Jan 2022 03:52:11 +0200 (EET) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 717D568AEC5 for ; Thu, 13 Jan 2022 03:52:08 +0200 (EET) Received: by mail-qv1-f41.google.com with SMTP id iw1so5143557qvb.1 for ; Wed, 12 Jan 2022 17:52:08 -0800 (PST) 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=qDQGGh6rXAKlhttgE/bpMgCrH3+iOUDOS46BI9+kXTs=; b=SXBFFg2MQ6mLqR+w1xuSOYEbDDPrZ4SjcokMoc2/BHeiNTn7Uo0pV6mih9OxvGboNQ I6zX4Fr+xlH+xAroxlZV17uPuk5S6+s3jlUVA451D5BXkMK5feVPjscZK+vBwJWq3IKT /WrclYdZHca38urlQCmpNyfOwBpxCS9L60hfjHtGfHBZTH/cMVqNqJo5RRmsn6Z15+mv jRanlQaY8KF1MJ2dWot/lSNiJmjX9fXKQ54iUBA1rSpdkOqO3yfN2ZsjfDluxd+A/o/W orHirGb59cXKh5/3PmiSrRyqqon68SOk5b5RhUtTV53qw7tBms/5Q9s11uDD/Ky7oe8g Hd1Q== 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=qDQGGh6rXAKlhttgE/bpMgCrH3+iOUDOS46BI9+kXTs=; b=JSLfIMyCFL53n5dYQMdPg+LICY0QabtZSzAyehuLWQI8z34ON4fgfXxSmRg4qMy8N1 zO/xPkll5iB/paph2f2QYsRltjooRXLtmx0aDFa295D8uyGDpLlVBZtBvWi1I3fzqccX s4Evg8E1/YneUsh/iHSCdXe0D0/47tM5REc4pZfhs5pfPbYqWyNRYfW0tPBpbHQfntlk oEekAGNHLa1BoN7OYkaRSJMZCJnZEccOM2M4Xsxmr1f1vY6Gj7cwj3sL1E/p5v5uWE7+ K1+etRjH64Rc+yolKELpnLsS79s7igiJt3iuttt1wQB2TZwhgVlldnvYN9cH/LgYCum3 jIzg== X-Gm-Message-State: AOAM531pH7rKuuob2r6171YSycRqLlNbHvb0jcn0bi/659Y1X1+XWxZ1 F5RbK5mvPuo1EwfdlISGHZjBqcG5DaQ= X-Google-Smtp-Source: ABdhPJxCAWudSjgMwanfZpuVcGAmnhFAPyVrOoa4Bt7fNhawjmGTRua2ckIYsIyd6NarwaeGYDqZTQ== X-Received: by 2002:a05:6214:27c6:: with SMTP id ge6mr2095114qvb.47.1642038726464; Wed, 12 Jan 2022 17:52:06 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id i21sm1204710qti.31.2022.01.12.17.52.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 17:52:06 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 22:49:29 -0300 Message-Id: <20220113015101.4-8-jamrial@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220113015101.4-1-jamrial@gmail.com> References: <20220113015101.4-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 007/281] lavf: add a temporary compat layer for the channel layout API change 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: From: Anton Khirnov Mediates between old-style (de)muxers and new-style callers. Will be removed once all the (de)muxers are converted to the new API. Signed-off-by: James Almer --- libavformat/demux.c | 12 ++++++++++++ libavformat/mux.c | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/libavformat/demux.c b/libavformat/demux.c index f895f0ba85..c78c6c16a2 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -194,6 +194,18 @@ static int update_stream_avctx(AVFormatContext *s) sti->parser = NULL; } + /* if the demuxer exports old channel layouts, convert it to new */ + if (!st->codecpar->ch_layout.nb_channels && + st->codecpar->channels) { + if (st->codecpar->channel_layout) { + av_channel_layout_from_mask(&st->codecpar->ch_layout, + st->codecpar->channel_layout); + } else { + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + st->codecpar->ch_layout.nb_channels = st->codecpar->channels; + } + } + /* update internal codec context, for the parser */ ret = avcodec_parameters_to_context(sti->avctx, st->codecpar); if (ret < 0) diff --git a/libavformat/mux.c b/libavformat/mux.c index c387f8ec6e..775e3e0d76 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -272,6 +272,16 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) ret = AVERROR(EINVAL); goto fail; } + + /* if the new-style channel layout is set, convert it to old one + * for old-style muxers */ + if (par->ch_layout.nb_channels && + !par->channels) { + par->channels = par->ch_layout.nb_channels; + par->channel_layout = par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + par->ch_layout.u.mask : 0; + } + if (!par->block_align) par->block_align = par->channels * av_get_bits_per_sample(par->codec_id) >> 3; -- 2.34.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".