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 DD84342EDD for ; Thu, 13 Jan 2022 02:36:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 605A668B754; Thu, 13 Jan 2022 04:03:25 +0200 (EET) Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C986D68B65D for ; Thu, 13 Jan 2022 04:03:21 +0200 (EET) Received: by mail-qv1-f50.google.com with SMTP id kc16so5153098qvb.3 for ; Wed, 12 Jan 2022 18:03:21 -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=ttlJXthsb4ELOyWO4AVgM7mpydFRIvGM45LmHQxocMg=; b=qujmILH78XtCtGKR2LgFyd2ttBcg1oNjo4EtblFboXS9GfZ6e+ISR4qiyaAUgRdAUQ 7qauaKDP5dQNJs6xfQUtgFkqIP8C0sZo4yzf4BDcNpSDuXc/LOumEkedJyF+dEWzIyGs o/bMCG56Nxn0o/80ye4w3oaXBxwXIDaLysnaBVn/YjPZLD54jCbxbPzFVN+qlrZgdwhS Tjy7nxWBAPgZX2LcGnjkyzrPSQgN0Wayg1oqYp66E+Jy1Eh87P8jBcxsLHp+StladEno 1Q7dzRcLsgvvQ7J5KoWkFkUzsadnRuFvTOPHMhqNABIswu2VQC2ExxRY631Ra5dry2UX wZzQ== 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=ttlJXthsb4ELOyWO4AVgM7mpydFRIvGM45LmHQxocMg=; b=JoYesaDSxWUbiIWFzVOZg46ibQnxUdQWhheoD+8enYpG5wZ0l2PBwh/J0reNmS4urs 3bHTXmjvd1V6rShqPZibpKPMThgn+QMtf6wfbOg5FlOrdhGVUwYBfHafX3R06I5cH45l lm4XAaPc85C/pRuLto8akidnOqCtGfu+6lRnqe8apjxljWLaue+yydLnGgNnqctnvAvZ /ACOYARI7dwE73PjEyInSI/ePaKYq/2vUm9fxGbS62jeQxKYnPQRZ1khblHBmRN9Ff1s Y5edyTH05F7p2siBXZxx4cOXVy3qhCe4MOusymhzPxfodjiql5kmY49OSmnSW002EwLn c4wA== X-Gm-Message-State: AOAM532S4ZSQSh7qpU7q5jgXYM1B7gQOKOeFGn925HoktNS04LW8uX+A Dzkld/7uO2YYNEP3mRhX4eMZ7fvthpU= X-Google-Smtp-Source: ABdhPJwFXOJvtXPHg0re0FmIIoWRd301FbWEZ80OKCqwWovaNlmLEtF60CsyIy1uF9iy+Q4CG6nbQw== X-Received: by 2002:a05:6214:23c6:: with SMTP id hr6mr2146178qvb.126.1642039400356; Wed, 12 Jan 2022 18:03:20 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id v1sm1045961qtc.95.2022.01.12.18.03.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:03:20 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:02:32 -0300 Message-Id: <20220113020242.661-20-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 199/281] cook: 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: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavcodec/cook.c | 25 ++++++++++++++----------- libavcodec/cook_parser.c | 4 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 3720772102..6f9bdb55e0 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1054,7 +1054,7 @@ static void dump_cook_context(COOKContext *q) PRINT("js_vlc_bits", q->subpacket[0].js_vlc_bits); } ff_dlog(q->avctx, "COOKContext\n"); - PRINT("nb_channels", q->avctx->channels); + PRINT("nb_channels", q->avctx->ch_layout.nb_channels); PRINT("bit_rate", (int)q->avctx->bit_rate); PRINT("sample_rate", q->avctx->sample_rate); PRINT("samples_per_channel", q->subpacket[0].samples_per_channel); @@ -1079,6 +1079,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) unsigned int channel_mask = 0; int samples_per_frame = 0; int ret; + int channels = avctx->ch_layout.nb_channels; + q->avctx = avctx; /* Take care of the codec specific extradata. */ @@ -1091,7 +1093,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) bytestream2_init(&gb, avctx->extradata, avctx->extradata_size); /* Take data from the AVCodecContext (RM container). */ - if (!avctx->channels) { + if (!channels) { av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n"); return AVERROR_INVALIDDATA; } @@ -1123,7 +1125,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->subpacket[s].js_vlc_bits = bytestream2_get_be16(&gb); /* Initialize extradata related variables. */ - q->subpacket[s].samples_per_channel = samples_per_frame / avctx->channels; + q->subpacket[s].samples_per_channel = samples_per_frame / channels; q->subpacket[s].bits_per_subpacket = avctx->block_align * 8; /* Initialize default data states. */ @@ -1138,21 +1140,21 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->subpacket[s].joint_stereo = 0; switch (q->subpacket[s].cookversion) { case MONO: - if (avctx->channels != 1) { + if (channels != 1) { avpriv_request_sample(avctx, "Container channels != 1"); return AVERROR_PATCHWELCOME; } av_log(avctx, AV_LOG_DEBUG, "MONO\n"); break; case STEREO: - if (avctx->channels != 1) { + if (channels != 1) { q->subpacket[s].bits_per_subpdiv = 1; q->subpacket[s].num_channels = 2; } av_log(avctx, AV_LOG_DEBUG, "STEREO\n"); break; case JOINT_STEREO: - if (avctx->channels != 2) { + if (channels != 2) { avpriv_request_sample(avctx, "Container channels != 2"); return AVERROR_PATCHWELCOME; } @@ -1174,7 +1176,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "MULTI_CHANNEL\n"); channel_mask |= q->subpacket[s].channel_mask = bytestream2_get_be32(&gb); - if (av_get_channel_layout_nb_channels(q->subpacket[s].channel_mask) > 1) { + if (channels > 1) { q->subpacket[s].total_subbands = q->subpacket[s].subbands + q->subpacket[s].js_subband_start; q->subpacket[s].joint_stereo = 1; @@ -1233,8 +1235,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->subpacket[s].gains2.now = q->subpacket[s].gain_3; q->subpacket[s].gains2.previous = q->subpacket[s].gain_4; - if (q->num_subpackets + q->subpacket[s].num_channels > q->avctx->channels) { - av_log(avctx, AV_LOG_ERROR, "Too many subpackets %d for channels %d\n", q->num_subpackets, q->avctx->channels); + if (q->num_subpackets + q->subpacket[s].num_channels > channels) { + av_log(avctx, AV_LOG_ERROR, "Too many subpackets %d for channels %d\n", q->num_subpackets, channels); return AVERROR_INVALIDDATA; } @@ -1282,10 +1284,11 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) } avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; + av_channel_layout_uninit(&avctx->ch_layout); if (channel_mask) - avctx->channel_layout = channel_mask; + av_channel_layout_from_mask(&avctx->ch_layout, channel_mask); else - avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; + av_channel_layout_default(&avctx->ch_layout, channels); dump_cook_context(q); diff --git a/libavcodec/cook_parser.c b/libavcodec/cook_parser.c index a05ebf94b8..0d9473845e 100644 --- a/libavcodec/cook_parser.c +++ b/libavcodec/cook_parser.c @@ -41,8 +41,8 @@ static int cook_parse(AVCodecParserContext *s1, AVCodecContext *avctx, CookParseContext *s = s1->priv_data; if (!s->duration && - avctx->extradata && avctx->extradata_size >= 8 && avctx->channels) - s->duration = AV_RB16(avctx->extradata + 4) / avctx->channels; + avctx->extradata && avctx->extradata_size >= 8 && avctx->ch_layout.nb_channels) + s->duration = AV_RB16(avctx->extradata + 4) / avctx->ch_layout.nb_channels; s1->duration = s->duration; -- 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".