From patchwork Thu Jan 13 01:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 33329 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp17238iog; Wed, 12 Jan 2022 18:01:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGSrqUvD33+Llq556+ITm9ohRi6GkADNvSWvXeC/4faCAXUV2niPft9jZbUoqaAq+s56Xz X-Received: by 2002:a17:906:4983:: with SMTP id p3mr1870722eju.589.1642039267755; Wed, 12 Jan 2022 18:01:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642039267; cv=none; d=google.com; s=arc-20160816; b=eX5uTHKOSPPk9Ha2QScpSCNI8o3aFDhkTFus771uM4PmR+IBFAa5tJFhMxhz3LEtjV XANf1KwNH2gE2im6jGVMjfQNyuxhepfWSu/nwz6nHFaVBTGrvkfXRDVqu05Ygh6e67DC XCNrJLqdVQA0AeOtA25dwJsSuOX5i2Vb8nNHfXuSfi0U3m2LltiTjPE8yFpYrHZGmh1t kHKv1q8s3RTY2khHCG+y4m4glq2gJycZr6uj/9C0brzLFMDPKdSDDPYZNBDhqZ0fXSM4 VscngecnQQS+yTh9xWBJjGaUFQMAxYv4mET4EY1y6If+Omm01Q96t2kdMmT4vfm/yAMS h79g== 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=YcTDKmfBZ4vGjyAW+Pl3HEMFYjumade9CT3zMepzWSg=; b=wwNkcd6JdHc9vzlmiITcAJ32poQ+W+Y0OiScETK4Dvlwr5MOnqpWwFHZFW6BJLaLZl EAcFuqYRimI5BvGJXklu8y3Y1IdktteJXAX+FIO/ruSidwoAQWFy++Q9JEtEE/dBEVRg HNzXizMwsdt5aj6BuQizxkdelqaDoicPuj/bx1D2WwrsA/GrZRugerM8/kDfwj7kIozQ +VqEcDOefvjMgqfB0jz6fRC6iwbe/9iB1TQA6F57eGhIciuNpVcHZnONjMcKyQFpPF1s eA20iV9XjEiVd5FjBoearNF6b2yz7NDqYG3/k8Uoy1xOtAlcyaK1c5Ku7mbRoWlhUkSS yupQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=jUq74aNK; 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 dd13si815132ejc.841.2022.01.12.18.01.07; Wed, 12 Jan 2022 18:01:07 -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=jUq74aNK; 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 F08EC68B0B7; Thu, 13 Jan 2022 03:52:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F0FD68B094 for ; Thu, 13 Jan 2022 03:52:52 +0200 (EET) Received: by mail-qt1-f175.google.com with SMTP id f17so5323126qtf.8 for ; Wed, 12 Jan 2022 17:52:51 -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=V90TleMCo/OdvREtF6McaOJCvt/h/M8ck2S3Jg+P8Co=; b=jUq74aNK5F61TnYTFxswJ5JEpZ6r4SmiT/ZH+fRqAuqwxF5KMdz2HPdCnuwYFTJJxF tsVuZjiTduz2WEpgJ5OnLwNEKnL6CXagNjXOJiCZh527HG1uhNgK1VJccQSyt8qFsM2W qmtCEIafiwoXUd72vvPxu/x+oOBjLHwjVI5tSjgE3oLZ64QTvLlNBFs8gm7NpGeRRVhm fOh00pLDP9Tbx6klDXgzYTUwiLvJ/YYgIuG8OisaCXnyuoaQWHEFGV8u7eIWcV0bn4IC szPmAKbATQZ0aRGAUfArsgPB9v4gB1Le8UdDmFL9bXG0O+RIZE7ytsZEvB1devP3b7oK OZJg== 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=V90TleMCo/OdvREtF6McaOJCvt/h/M8ck2S3Jg+P8Co=; b=qF3ZFlo0KudJ0h+TFEe7wNkXzMDMhSAo+GW/oLEaAqp1TbQtaNy38scEgXpBzKlfPl pSl5+0Tpfrkp9dvMJNRXLLEmd+p67Dvp/TkgM9htwrZ42H9d/FXm1vRfWl/7RcLONX/n a6L7wTAK4VfmHFon8pVllqrNOoaz3/1Db8ZxZDb0SvJcFZsi4qp4j6L8VRCTSKKVs929 1oPmINKUoTq7hgp9S8h02vY8248Q9PMhC01xr5lc6ez+b9WmCeULeHnNpmpq4mRYKeIs SFuMPcQNLFxYCoJ521gHFnRCQZI7n1+728Dd37IuSwCJVG0PMXhvL2+nHIR4OGbA+ovl LehQ== X-Gm-Message-State: AOAM532SchOcB0xuEo1SC57TihH4StZfO6KITyNrUJI7Mj1jnaw13w7X YCNsQst4vfjf7tG51EANyHppPxBpSoQ= X-Received: by 2002:a05:622a:170a:: with SMTP id h10mr1970102qtk.497.1642038770692; Wed, 12 Jan 2022 17:52:50 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id i21sm1204710qti.31.2022.01.12.17.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 17:52:50 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 22:50:04 -0300 Message-Id: <20220113015101.4-43-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 042/281] caf: 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: x44OOblVbMpJ From: Vittorio Giovara Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavformat/cafdec.c | 7 ++++--- libavformat/cafenc.c | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 4b5b15b58d..6d57bc4058 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -76,10 +76,11 @@ static int read_desc_chunk(AVFormatContext *s) caf->bytes_per_packet = avio_rb32(pb); st->codecpar->block_align = caf->bytes_per_packet; caf->frames_per_packet = avio_rb32(pb); - st->codecpar->channels = avio_rb32(pb); + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + st->codecpar->ch_layout.nb_channels = avio_rb32(pb); st->codecpar->bits_per_coded_sample = avio_rb32(pb); - if (caf->bytes_per_packet < 0 || caf->frames_per_packet < 0 || st->codecpar->channels < 0) + if (caf->bytes_per_packet < 0 || caf->frames_per_packet < 0 || st->codecpar->ch_layout.nb_channels < 0) return AVERROR_INVALIDDATA; /* calculate bit rate for constant size packets */ @@ -172,7 +173,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size) } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) { // The data layout for Opus is currently unknown, so we do not export // extradata at all. Multichannel streams are not supported. - if (st->codecpar->channels > 2) { + if (st->codecpar->ch_layout.nb_channels > 2) { avpriv_request_sample(s, "multichannel Opus in CAF"); return AVERROR_PATCHWELCOME; } diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index 412b3230e3..396e946ceb 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -122,7 +122,7 @@ static int caf_write_header(AVFormatContext *s) return AVERROR_PATCHWELCOME; } - if (par->codec_id == AV_CODEC_ID_OPUS && par->channels > 2) { + if (par->codec_id == AV_CODEC_ID_OPUS && par->ch_layout.nb_channels > 2) { av_log(s, AV_LOG_ERROR, "Only mono and stereo are supported for Opus\n"); return AVERROR_INVALIDDATA; } @@ -138,7 +138,7 @@ static int caf_write_header(AVFormatContext *s) } if (par->codec_id != AV_CODEC_ID_MP3 || frame_size != 576) - frame_size = samples_per_packet(par->codec_id, par->channels, par->block_align); + frame_size = samples_per_packet(par->codec_id, par->ch_layout.nb_channels, par->block_align); ffio_wfourcc(pb, "caff"); //< mFileType avio_wb16(pb, 1); //< mFileVersion @@ -151,13 +151,13 @@ static int caf_write_header(AVFormatContext *s) avio_wb32(pb, codec_flags(par->codec_id)); //< mFormatFlags avio_wb32(pb, par->block_align); //< mBytesPerPacket avio_wb32(pb, frame_size); //< mFramesPerPacket - avio_wb32(pb, par->channels); //< mChannelsPerFrame + avio_wb32(pb, par->ch_layout.nb_channels); //< mChannelsPerFrame avio_wb32(pb, av_get_bits_per_sample(par->codec_id)); //< mBitsPerChannel - if (par->channel_layout) { + if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) { ffio_wfourcc(pb, "chan"); avio_wb64(pb, 12); - ff_mov_write_chan(pb, par->channel_layout); + ff_mov_write_chan(pb, par->ch_layout.u.mask); } if (par->codec_id == AV_CODEC_ID_ALAC) { @@ -247,7 +247,7 @@ static int caf_write_trailer(AVFormatContext *s) avio_seek(pb, caf->data, SEEK_SET); avio_wb64(pb, file_size - caf->data - 8); if (!par->block_align) { - int packet_size = samples_per_packet(par->codec_id, par->channels, par->block_align); + int packet_size = samples_per_packet(par->codec_id, par->ch_layout.nb_channels, par->block_align); if (!packet_size) { packet_size = st->duration / (caf->packets - 1); avio_seek(pb, FRAME_SIZE_OFFSET, SEEK_SET);