From patchwork Thu Jan 13 01:50:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 33361 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp22764iog; Wed, 12 Jan 2022 18:08:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx25VsobXx7wRfIwpfslN/BqWeYIHbWCc/IIGOI7TdYBQwthGBrXOH91zNVlFTGQ4BxBmuG X-Received: by 2002:a17:906:9743:: with SMTP id o3mr1904323ejy.162.1642039720053; Wed, 12 Jan 2022 18:08:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642039720; cv=none; d=google.com; s=arc-20160816; b=vugvUWrMECgE+lIU5CA6nyZ6SrqKrd4g+5AFfIgKI/YkbI9AXBH8coyQiPRX1TUVo/ kZCSLjZ8gnttranvfqUOgNHESMku2NItMPsKiUciUtK25GTtKaugBmUcQF3UU6OQA/uE s/Bv5kA6VJdvL0q8g8r8MGoycezFMIkVxM86usxbsZSIo6WAeh7MAhN+uwoYOsjjuJrc aN3o6eqVIa/mTeAYVb41YAjV2a815qT1+23qACHw0/cyajAg9gDoSzks43wD3ZOMUJJ7 NnaX/9CcN5954HJA/ajDYqAknYMxLsoVzk53MhMjMih1CvLlpVm3PoO79RlE0qbe2FPn 78uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=vHEdMBf2eOJ6q3+RK42jzAm5ZosaMX6fKJT/Dyxoku4=; b=W4/J6bX59ixGu00d0mJvKwjALxVVlu+Rt+11kVeQErON88cztLUL2ZfA6LCWJUtDcu w5t7qcYT3dfWZFVn77w3UpMTz03UX1JUAVJa2G3/HHQwEwZztkFw2nPLQQtUj94mA6rW 66bIPuLzt2H5H0FsWJSaF5po+PHpmo/zHLXzC7Spzj5cV714v0n6Fwo/BIoqyQpSR2iY Gg5WDe7BqE+78wsBnXGnu/yZKGiRXBwKltbgrjDvZLImJQijWuQHrsdIHZ0Qy/1IQ4u9 n53ExGAPU6IsTESdTqUTN1n3wF/UywuAlzOlJQ584VmeOH1QF7r+uiPW/HrnLyRmbv1h 8KfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=T7n8NXwH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c29si852361edn.585.2022.01.12.18.08.39; Wed, 12 Jan 2022 18:08:40 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=T7n8NXwH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E927068B1E3; Thu, 13 Jan 2022 03:53:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBB4D68B1C6 for ; Thu, 13 Jan 2022 03:53:34 +0200 (EET) Received: by mail-qk1-f174.google.com with SMTP id c190so3905145qkg.9 for ; Wed, 12 Jan 2022 17:53:34 -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=vVZ1pmap3q0Zbd49lCF2ayyQ8TI3pkbEDEo+NGbznrY=; b=T7n8NXwHJCO2wt00jH51ke/eki7jzUzPMMn03alY69jkdVmlRP8pPO5sh/VSM8S8Qy eVdnqliB3oZojCQnRqOFsbA6HX37b7/pngcUodrL6u+UL17HzFYMiph2+LRrTXfXEiSo QAuzgu1/Mpo4FCKEH9ewaMFuaA4TrZf163ZqiwzPhftQtQg0zltMAAwsj4DTRCquXJ1R SAOpRxsM8jSe4Zus5GeZ0LdUOAnvmYZMJXdJVuNGutNVGVPxJyKRJQXMcQ9YHv/CUg1U PyO3JlzLKE3t0mLMtqO+HvNxYkoxLpeK3NfUtFGfi856U0PRmAsFaNIwO6L0Prd8S187 xvDA== 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=vVZ1pmap3q0Zbd49lCF2ayyQ8TI3pkbEDEo+NGbznrY=; b=UAfcDUy4nx0F9TYPzGh3W6B9qoxqmYaIEjaHAwx31y/TjfTUEcjdCDDYsJitoSasMm hQmcpeV8T4e9J8Up+0DR9BB4sovfIE0nRylzEGmbFxCjCGW1nfKKTtudrLBff+rMfCFi 1gHub+KYxG/JRgdMyKKPHVH6fYm051NRotE7olIUCCq5nXOKAge85hpYLD9Mn8QDJEHc sJtn11NBGuLB4KDkYoMpNV2ick/eawAhxk4WrWVmNh8vlYibxE6nYpUAskn4kLBKxz6Y zAAvCkojU8hHDDapXC3sg/jBnNUP9Lcb9uTRjGEwIwR2bvjeLtDnjl5NUDTkD/gAMave WbKg== X-Gm-Message-State: AOAM533J/D93ZW2mkPc66Yt0G+Ch78EbwK65xvKS3B9L3zQ+s9Dqspa9 nUUp5TFzFz/iofgRffq6Xk1GawOkFSE= X-Received: by 2002:a05:620a:29d2:: with SMTP id s18mr1818479qkp.730.1642038813153; Wed, 12 Jan 2022 17:53:33 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id i21sm1204710qti.31.2022.01.12.17.53.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 17:53:32 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 22:50:39 -0300 Message-Id: <20220113015101.4-78-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 077/281] iff: 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: d8RcaIZu3eHs From: Vittorio Giovara Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavformat/iff.c | 63 ++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/libavformat/iff.c b/libavformat/iff.c index 078406b7e3..3c861ef34d 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -183,20 +183,20 @@ static const uint32_t dsd_5point0[] = { DSD_MLFT, DSD_MRGT, DSD_C, DSD_LS, DSD_R static const uint32_t dsd_5point1[] = { DSD_MLFT, DSD_MRGT, DSD_C, DSD_LFE, DSD_LS, DSD_RS }; typedef struct { - uint64_t layout; + AVChannelLayout layout; const uint32_t * dsd_layout; } DSDLayoutDesc; static const DSDLayoutDesc dsd_channel_layout[] = { - { AV_CH_LAYOUT_STEREO, dsd_stereo }, - { AV_CH_LAYOUT_5POINT0, dsd_5point0 }, - { AV_CH_LAYOUT_5POINT1, dsd_5point1 }, + { AV_CHANNEL_LAYOUT_STEREO, dsd_stereo }, + { AV_CHANNEL_LAYOUT_5POINT0, dsd_5point0 }, + { AV_CHANNEL_LAYOUT_5POINT1, dsd_5point1 }, }; -static const uint64_t dsd_loudspeaker_config[] = { - AV_CH_LAYOUT_STEREO, - 0, 0, - AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1, +static const AVChannelLayout dsd_loudspeaker_config[] = { + AV_CHANNEL_LAYOUT_STEREO, + { 0 }, { 0 }, + AV_CHANNEL_LAYOUT_5POINT0, AV_CHANNEL_LAYOUT_5POINT1, }; static const char * dsd_source_comment[] = { @@ -276,21 +276,21 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream *st, uint64_t eof) case MKTAG('C','H','N','L'): if (size < 2) return AVERROR_INVALIDDATA; - st->codecpar->channels = avio_rb16(pb); - if (size < 2 + st->codecpar->channels * 4) + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + st->codecpar->ch_layout.nb_channels = avio_rb16(pb); + if (size < 2 + st->codecpar->ch_layout.nb_channels * 4) return AVERROR_INVALIDDATA; - st->codecpar->channel_layout = 0; - if (st->codecpar->channels > FF_ARRAY_ELEMS(dsd_layout)) { + if (st->codecpar->ch_layout.nb_channels > FF_ARRAY_ELEMS(dsd_layout)) { avpriv_request_sample(s, "channel layout"); break; } - for (i = 0; i < st->codecpar->channels; i++) + for (i = 0; i < st->codecpar->ch_layout.nb_channels; i++) dsd_layout[i] = avio_rl32(pb); for (i = 0; i < FF_ARRAY_ELEMS(dsd_channel_layout); i++) { const DSDLayoutDesc * d = &dsd_channel_layout[i]; - if (av_get_channel_layout_nb_channels(d->layout) == st->codecpar->channels && - !memcmp(d->dsd_layout, dsd_layout, st->codecpar->channels * sizeof(uint32_t))) { - st->codecpar->channel_layout = d->layout; + if (d->layout.nb_channels == st->codecpar->ch_layout.nb_channels && + !memcmp(d->dsd_layout, dsd_layout, d->layout.nb_channels * sizeof(uint32_t))) { + st->codecpar->ch_layout = d->layout; break; } } @@ -337,8 +337,8 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream *st, uint64_t eof) config = avio_rb16(pb); if (config != 0xFFFF) { if (config < FF_ARRAY_ELEMS(dsd_loudspeaker_config)) - st->codecpar->channel_layout = dsd_loudspeaker_config[config]; - if (!st->codecpar->channel_layout) + st->codecpar->ch_layout = dsd_loudspeaker_config[config]; + if (!st->codecpar->ch_layout.nb_channels) avpriv_request_sample(s, "loudspeaker configuration %d", config); } break; @@ -431,8 +431,7 @@ static int iff_read_header(AVFormatContext *s) if (!st) return AVERROR(ENOMEM); - st->codecpar->channels = 1; - st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; + st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; iff->is_64bit = avio_rl32(pb) == ID_FRM8; avio_skip(pb, iff->is_64bit ? 8 : 4); // codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content @@ -485,12 +484,13 @@ static int iff_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; avio_skip(pb, 2); st->codecpar->sample_rate = num / den; - st->codecpar->channels = avio_rb16(pb); + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + st->codecpar->ch_layout.nb_channels = avio_rb16(pb); iff->maud_compression = avio_rb16(pb); - if (st->codecpar->channels == 1) - st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; - else if (st->codecpar->channels == 2) - st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; + if (st->codecpar->ch_layout.nb_channels == 1) + st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; + else if (st->codecpar->ch_layout.nb_channels == 2) + st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; break; case ID_ABIT: @@ -513,11 +513,9 @@ static int iff_read_header(AVFormatContext *s) if (data_size < 4) return AVERROR_INVALIDDATA; if (avio_rb32(pb) < 6) { - st->codecpar->channels = 1; - st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; + st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } else { - st->codecpar->channels = 2; - st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; + st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; } break; @@ -760,8 +758,11 @@ static int iff_read_header(AVFormatContext *s) } st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id); - st->codecpar->bit_rate = (int64_t)st->codecpar->channels * st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample; - st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample; + st->codecpar->bit_rate = (int64_t)st->codecpar->ch_layout.nb_channels * + st->codecpar->sample_rate * + st->codecpar->bits_per_coded_sample; + st->codecpar->block_align = st->codecpar->ch_layout.nb_channels * + st->codecpar->bits_per_coded_sample; if ((st->codecpar->codec_tag == ID_DSD || st->codecpar->codec_tag == ID_MAUD) && st->codecpar->block_align <= 0) return AVERROR_INVALIDDATA; break;