From patchwork Thu Jan 13 01:49:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 33308 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp14113iog; Wed, 12 Jan 2022 17:55:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT64ESH1+zvRizaneWS4JllgDeuxWpMkptwpAUQaOj/vTPWA2N+6WA7c+ayarxyLH83cqw X-Received: by 2002:a05:6402:51cd:: with SMTP id r13mr2208280edd.184.1642038933939; Wed, 12 Jan 2022 17:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642038933; cv=none; d=google.com; s=arc-20160816; b=Ksaxdjb+893WCbDUWcKERWNShGqpJCdqsLfxfVsEl3toJntzAphH9RriAa5Ph8Hzhy Xo3Tq4fnUgBihV5GrqEqTr1jNNjAR3yczyVl9PXvmJ2Kva5QV/xlKOw0/hqxUbQCvGX1 tLRVClGL0WrU1wHDFZu9/YoTFj5SGBZw5mPWYSJsl4lES3B6mYS8MfdUrahDShEIDEUX 5X48bSUtWlA122QcKw5h3fTR30NyVb7Dk3IPaSzmzSREyeMkPczGYgMPYJeHugMSeub6 +b2IvCLZa6KDWj3Lyw33yZHyUbm453ZdBVV9NID+jcDiOlHdbtlR0Ks6Fu3YHcL9AS69 +6aA== 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=k9uXem07yu4MRhoxbFzXsR9OKZdTfbstQW/0ET8ToB0=; b=Sgcwo1rzIMraS0gPuxeG/0tZa/x9CaBIhSa7y2XmA9lnS1crsp92bKnGlxtRi4luSb 5KnG8EyKngj7w9ktycwoD/35CqNeq4K0EGQl8G3n0Q/0BhRqzJ0llS8GaaNsge0nQxLO iZpRoxlHgRhHJOmQw8f3Je7dPn8L8rdoL+tBcj6/1FrbC5aBAuzXw8+W7++S5mcN4fnx 2OVcVDg53Un8aZALvjxU2eppP857jDZK9531kHiy6T+UoSuRPx8Bm7/DS3yJ2Xe4g9Ww Redsz2Md/xurZIHYn4mcxh33LcfGdalUp6pikw9Lq0PMfYa9GbWAZPMvN9XSden4BD+0 gkiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Ow4UdA9A; 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 qf24si836955ejc.107.2022.01.12.17.55.33; Wed, 12 Jan 2022 17:55:33 -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=Ow4UdA9A; 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 1BDB068AFD4; Thu, 13 Jan 2022 03:52:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6446B68AFA1 for ; Thu, 13 Jan 2022 03:52:23 +0200 (EET) Received: by mail-qk1-f182.google.com with SMTP id 193so4855203qkh.13 for ; Wed, 12 Jan 2022 17:52:23 -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=iVAezJUOtw7hicZc2BC6n0J1H4KFYdy7+AEzYJzxFMs=; b=Ow4UdA9Am6Q+d8A5oMl2zv3EXHSzaK0utIWR4AAoNJI0zMSGArVab4T7K/MlUzRMdt 65zPGTR1CkE4/YT39TFR20xLDZN98gzLDWADkUrJWGzstr88iotwLGSPr9UaYBPXGZfS GrSPiiNSthGd/mq1B6PXTVHxz3VK27XdjVGFoC8N0NA0awJN0kRMKC55c6oWcl0UZUSN vMgJ/y2z6gZP8pD2rNKZauBMu1561WC/7Zb0Tb6VUF+TZqfGfw6R86o+n6TuzS50aOL5 c4StMbt6+zd5ENxs2SvVRFKUxL2aexVhslNxwoUSLTiaROYaE2d8ovZDlFF0NZ9/MCVu RixQ== 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=iVAezJUOtw7hicZc2BC6n0J1H4KFYdy7+AEzYJzxFMs=; b=YGhQns1VSZc//yctoULOkIh5htc7YWIl0tz9mkqzinLu4UuIaWa/7fqUrEhVrwQL31 Taj4wlFRAeBLfCGPFEXczim9h5FIb23535WTIi2nBK41Gb1LyXOaKE5QzcJviOe9H9Gf qDljVMXxeWDwdF6UyhEz/CZ+Lod+JfTtcvESa5SYAK4eF3WviB/J47tCR+lN7UErdNOy ZwFwwtPY1brV7uIdndP27Czug1m26xNxVx6vDQ8KqZYbCxb7L4PjpFXoBpXOYVBlA5ry emJ0KWnZFsI9kcr2x6GOeX4aOd0jZX3mFTQ7vTj6PLk1ARQaMKcQSp4if9jG4kHN4ZeS WpCw== X-Gm-Message-State: AOAM533xV/dTrCWSaJckUk0Apr21nCVeGhrKMBSe4tyx5VjVz5e5lEhd Q3GDGdsqHL83mCyT5l12QsDe0sf/43M= X-Received: by 2002:a05:620a:1794:: with SMTP id ay20mr1777579qkb.485.1642038741544; Wed, 12 Jan 2022 17:52:21 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id i21sm1204710qti.31.2022.01.12.17.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 17:52:21 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 22:49:40 -0300 Message-Id: <20220113015101.4-19-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 018/281] adxdec: 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: Q+T6iRmkH60h From: Vittorio Giovara Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavformat/adxdec.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c index d91d43d114..fa91080f41 100644 --- a/libavformat/adxdec.c +++ b/libavformat/adxdec.c @@ -56,12 +56,12 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt) if (avio_feof(s->pb)) return AVERROR_EOF; - if (par->channels <= 0) { - av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels); + if (par->ch_layout.nb_channels <= 0) { + av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->ch_layout.nb_channels); return AVERROR_INVALIDDATA; } - size = BLOCK_SIZE * par->channels; + size = BLOCK_SIZE * par->ch_layout.nb_channels; pkt->pos = avio_tell(s->pb); pkt->stream_index = 0; @@ -79,8 +79,8 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt) size = ret; } - pkt->duration = size / (BLOCK_SIZE * par->channels); - pkt->pts = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->channels); + pkt->duration = size / (BLOCK_SIZE * par->ch_layout.nb_channels); + pkt->pts = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->ch_layout.nb_channels); return 0; } @@ -90,6 +90,8 @@ static int adx_read_header(AVFormatContext *s) ADXDemuxerContext *c = s->priv_data; AVCodecParameters *par; int ret; + int channels; + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -107,11 +109,11 @@ static int adx_read_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n"); return AVERROR_INVALIDDATA; } - par->channels = AV_RB8 (par->extradata + 7); + channels = AV_RB8 (par->extradata + 7); par->sample_rate = AV_RB32(par->extradata + 8); - if (par->channels <= 0) { - av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels); + if (channels <= 0) { + av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", channels); return AVERROR_INVALIDDATA; } @@ -120,9 +122,11 @@ static int adx_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } + par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + par->ch_layout.nb_channels = channels; par->codec_type = AVMEDIA_TYPE_AUDIO; par->codec_id = s->iformat->raw_codec_id; - par->bit_rate = (int64_t)par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES; + par->bit_rate = (int64_t)par->sample_rate * par->ch_layout.nb_channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES; avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);