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 7EF1342F5D for ; Thu, 13 Jan 2022 02:49:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82DEE68BA25; Thu, 13 Jan 2022 04:08:00 +0200 (EET) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB20F68BA0C for ; Thu, 13 Jan 2022 04:07:57 +0200 (EET) Received: by mail-qt1-f177.google.com with SMTP id l17so5358850qtk.7 for ; Wed, 12 Jan 2022 18:07:57 -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=YlC9WgujL0CkDpusKgWxVEJ0iqLIH6LZg0a7vVwDuww=; b=kjUiu1UrwZdqa2QO5WSdEu4XGdjT3MshT8ERfWDllTqbbA38WopB507RbEWnoRcwyN 1oqnw1UL4hWaCh6TIm25459e7vcEpMQtwReXl2MEug9nhMb0kMjv8s9bM8A4kPbAc+dM 2WWbLT5H82vUQc2F5fV6cvC/IjfXUkSf8uKyW7fmF8K+RCE8IkpN+/aFx/w++g3GTUQo JLUGQTIp+Xxe8EmFYPFYcPLAGow/s/Oe+5vlRcn5e05L+SNWLlYZOrBL91XL/zR5IPNL 1yrZgiKTD3UdH77al/psG6oNBYSzAU/dGNDKhcyRjxRzMKNjwT7DMnR74HhDgRq9zfKB OrDg== 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=YlC9WgujL0CkDpusKgWxVEJ0iqLIH6LZg0a7vVwDuww=; b=To9ylsfWr3p7kA/dLot1B63HLX0QIvs5B3cJXB87Rj/Hz2Uc+uf9oOm1aGK/6l2/IS WcYZWiZVMI1dH2C4bcu5pSn0cP5xrtUHSN046nCmXTPxbSVz7DKTFWGEsOP+o4HHi0xv P2Tv9AasG/QyT8STp53O9Tg4YoEH+/+5AzsInYp+Fnf8rbqVXk3jP1kLwPf3qJAMZyeE FFP42fty61yaUC/jqrYOlsVp4Rr1fFCFUQbeSut9zg8Q83VkRJAmz7XQFtpkBCzoh0UQ E3qZSWesgBWKlBba79QGFQfIZKeikuA+ppx7KCDgobyUIzxGDozYWf5EhO1vuGUH3upM T10w== X-Gm-Message-State: AOAM530xrX3r9NEb/9NaJqzeIet079Osqiwd7W1mh3A2teOTmpDCUKuA w3D6L89LMsv7lNmYfmr9EZqiShhUi8A= X-Google-Smtp-Source: ABdhPJzhOeiL5aMDRA9rG8oWQ41Cw/YzLFb5gWsmXJAgd1eFN4kgiIruC2l2syGGDwYH0BQrJAN5Uw== X-Received: by 2002:ac8:5bd3:: with SMTP id b19mr1632733qtb.92.1642039676018; Wed, 12 Jan 2022 18:07:56 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id a16sm1085946qta.13.2022.01.12.18.07.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:07:55 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:07:06 -0300 Message-Id: <20220113020713.801-23-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 262/281] tak: 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-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 Signed-off-by: James Almer --- libavcodec/takdec.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 926dbf611e..15543098b5 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -734,9 +734,14 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, avctx->sample_rate = s->ti.sample_rate; set_sample_rate_params(avctx); } - if (s->ti.ch_layout) - avctx->channel_layout = s->ti.ch_layout; - avctx->channels = s->ti.channels; + + av_channel_layout_uninit(&avctx->ch_layout); + if (s->ti.ch_layout) { + av_channel_layout_from_mask(&avctx->ch_layout, s->ti.ch_layout); + } else { + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avctx->ch_layout.nb_channels = s->ti.channels; + } s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples : s->ti.frame_samples; @@ -747,7 +752,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, ff_thread_finish_setup(avctx); if (avctx->bits_per_raw_sample <= 16) { - int buf_size = av_samples_get_buffer_size(NULL, avctx->channels, + int buf_size = av_samples_get_buffer_size(NULL, avctx->ch_layout.nb_channels, s->nb_samples, AV_SAMPLE_FMT_S32P, 0); if (buf_size < 0) @@ -756,28 +761,28 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, if (!s->decode_buffer) return AVERROR(ENOMEM); ret = av_samples_fill_arrays((uint8_t **)s->decoded, NULL, - s->decode_buffer, avctx->channels, + s->decode_buffer, avctx->ch_layout.nb_channels, s->nb_samples, AV_SAMPLE_FMT_S32P, 0); if (ret < 0) return ret; } else { - for (chan = 0; chan < avctx->channels; chan++) + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) s->decoded[chan] = (int32_t *)frame->extended_data[chan]; } if (s->nb_samples < 16) { - for (chan = 0; chan < avctx->channels; chan++) { + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) { int32_t *decoded = s->decoded[chan]; for (i = 0; i < s->nb_samples; i++) decoded[i] = get_sbits(gb, avctx->bits_per_raw_sample); } } else { if (s->ti.codec == TAK_CODEC_MONO_STEREO) { - for (chan = 0; chan < avctx->channels; chan++) + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) if (ret = decode_channel(s, chan)) return ret; - if (avctx->channels == 2) { + if (avctx->ch_layout.nb_channels == 2) { s->nb_subframes = get_bits(gb, 1) + 1; if (s->nb_subframes > 1) { s->subframe_len[1] = get_bits(gb, 6); @@ -792,13 +797,13 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, int ch_mask = 0; chan = get_bits(gb, 4) + 1; - if (chan > avctx->channels) + if (chan > avctx->ch_layout.nb_channels) return AVERROR_INVALIDDATA; for (i = 0; i < chan; i++) { int nbit = get_bits(gb, 4); - if (nbit >= avctx->channels) + if (nbit >= avctx->ch_layout.nb_channels) return AVERROR_INVALIDDATA; if (ch_mask & 1 << nbit) @@ -808,10 +813,10 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, if (s->mcdparams[i].present) { s->mcdparams[i].index = get_bits(gb, 2); s->mcdparams[i].chan2 = get_bits(gb, 4); - if (s->mcdparams[i].chan2 >= avctx->channels) { + if (s->mcdparams[i].chan2 >= avctx->ch_layout.nb_channels) { av_log(avctx, AV_LOG_ERROR, "invalid channel 2 (%d) for %d channel(s)\n", - s->mcdparams[i].chan2, avctx->channels); + s->mcdparams[i].chan2, avctx->ch_layout.nb_channels); return AVERROR_INVALIDDATA; } if (s->mcdparams[i].index == 1) { @@ -829,7 +834,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, ch_mask |= 1 << nbit; } } else { - chan = avctx->channels; + chan = avctx->ch_layout.nb_channels; for (i = 0; i < chan; i++) { s->mcdparams[i].present = 0; s->mcdparams[i].chan1 = i; @@ -855,7 +860,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, } } - for (chan = 0; chan < avctx->channels; chan++) { + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) { int32_t *decoded = s->decoded[chan]; if (s->lpc_mode[chan]) @@ -886,7 +891,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, /* convert to output buffer */ switch (avctx->sample_fmt) { case AV_SAMPLE_FMT_U8P: - for (chan = 0; chan < avctx->channels; chan++) { + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) { uint8_t *samples = (uint8_t *)frame->extended_data[chan]; int32_t *decoded = s->decoded[chan]; for (i = 0; i < s->nb_samples; i++) @@ -894,7 +899,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_SAMPLE_FMT_S16P: - for (chan = 0; chan < avctx->channels; chan++) { + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) { int16_t *samples = (int16_t *)frame->extended_data[chan]; int32_t *decoded = s->decoded[chan]; for (i = 0; i < s->nb_samples; i++) @@ -902,7 +907,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_SAMPLE_FMT_S32P: - for (chan = 0; chan < avctx->channels; chan++) { + for (chan = 0; chan < avctx->ch_layout.nb_channels; chan++) { int32_t *samples = (int32_t *)frame->extended_data[chan]; for (i = 0; i < s->nb_samples; i++) samples[i] *= 1U << 8; -- 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".