From patchwork Fri Dec 6 10:17:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 16618 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1C25744AAD6 for ; Fri, 6 Dec 2019 12:19:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 06F5968B654; Fri, 6 Dec 2019 12:19:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D81AD68B63D for ; Fri, 6 Dec 2019 12:18:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 5F5012945B7 for ; Fri, 6 Dec 2019 11:18:53 +0100 (CET) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id SIu3OM7ZloIR for ; Fri, 6 Dec 2019 11:18:52 +0100 (CET) Received: from quelana.khirnov.net (unknown [IPv6:2002:b061:f0a:201:5e:e696:5100:0]) (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 "quelana.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id 9CC292945B5 for ; Fri, 6 Dec 2019 11:18:52 +0100 (CET) Received: from localhost (quelana.khirnov.net [IPv6:::1]) by quelana.khirnov.net (Postfix) with ESMTP id 8F91A7F959 for ; Fri, 6 Dec 2019 11:18:46 +0100 (CET) Received: from quelana.khirnov.net ([IPv6:::1]) by localhost (quelana.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Kdw9WMziFuqP for ; Fri, 6 Dec 2019 11:18:45 +0100 (CET) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) by quelana.khirnov.net (Postfix) with ESMTP id 420A97F85D for ; Fri, 6 Dec 2019 11:18:45 +0100 (CET) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id C0D7B20E0152; Fri, 6 Dec 2019 11:17:48 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Dec 2019 11:17:01 +0100 Message-Id: <20191206101710.22028-7-anton@khirnov.net> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206101710.22028-1-anton@khirnov.net> References: <20191206101710.22028-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 007/244] lavf: convert the generic layer to the new channel layout X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/mux.c | 13 ++++++++++++- libavformat/utils.c | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index ae1f26c3da..dc4dc4518c 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -333,8 +333,19 @@ FF_ENABLE_DEPRECATION_WARNINGS par->ch_layout.u.mask : 0; } +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + /* if the caller is using the deprecated channel layout API, + * convert it to the new style */ + if (!par->ch_layout.nb_channels) { + par->ch_layout.order = par->channel_layout ? AV_CHANNEL_ORDER_NATIVE : AV_CHANNEL_ORDER_UNSPEC; + par->ch_layout.nb_channels = par->channels; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (!par->block_align) - par->block_align = par->channels * + par->block_align = par->ch_layout.nb_channels * av_get_bits_per_sample(par->codec_id) >> 3; break; case AVMEDIA_TYPE_VIDEO: diff --git a/libavformat/utils.c b/libavformat/utils.c index 13eadbbfd0..4eaeba2fb5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -528,6 +528,18 @@ static int update_stream_avctx(AVFormatContext *s) } } +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (st->codecpar->ch_layout.nb_channels && + !st->codecpar->channels) { + st->codecpar->channels = st->codecpar->ch_layout.nb_channels; + st->codecpar->channel_layout = st->codecpar->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + st->codecpar->ch_layout.u.mask : 0; + + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + /* update internal codec context, for the parser */ ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar); if (ret < 0) @@ -1695,8 +1707,12 @@ FF_ENABLE_DEPRECATION_WARNINGS return ret; st->codecpar->sample_rate = st->internal->avctx->sample_rate; st->codecpar->bit_rate = st->internal->avctx->bit_rate; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS st->codecpar->channels = st->internal->avctx->channels; st->codecpar->channel_layout = st->internal->avctx->channel_layout; +FF_ENABLE_DEPRECATION_WARNINGS +#endif st->codecpar->codec_id = st->internal->avctx->codec_id; } else { /* free packet */ @@ -4263,7 +4279,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, continue; if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb) continue; - if (type == AVMEDIA_TYPE_AUDIO && !(par->channels && par->sample_rate)) + if (type == AVMEDIA_TYPE_AUDIO && !(par->ch_layout.nb_channels && par->sample_rate)) continue; if (decoder_ret) { decoder = find_decoder(ic, st, par->codec_id);