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 89B7C42D17 for ; Thu, 13 Jan 2022 02:06:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 37AD868B1AF; Thu, 13 Jan 2022 03:53:27 +0200 (EET) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 04AAA68B195 for ; Thu, 13 Jan 2022 03:53:24 +0200 (EET) Received: by mail-qv1-f41.google.com with SMTP id hu2so5077913qvb.8 for ; Wed, 12 Jan 2022 17:53:24 -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=tEWniB7hh2+vRu/NWJAV4Zqj98eQOGlBbWzRkiKB5/M=; b=lY3WCcTprFkj2rtZKVdnoklGq69mHAfDagvSZ/uEgH8LOn2VS8xxJt1Gj8j7gNPO7k gzKE127I6k2W2yup0ZD31M8Ut8CvX7q1LeJ0BpvcbA3KZ4ujoVNigHKiLjWJZ6+rBTel IMo2grt5FWE4EVbLav3i6Fy6Yf+iawEpcRlqMiLMGZGi6lugjfUZtNkRxHTHy9FWXwrI hRWhJL2+Lo6ZCzBpv7uP5so+Czd6FrZh+cN4CYSUmtDaLi6bzK11Ks7whV1l0ELqmywW pjDXRrv4Y03eebKcGOFk9i63Iv4dVRuQy3RHwYqZOoDiwyOfp3rSu6Rhj2T4gN12WPtS 1J9g== 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=tEWniB7hh2+vRu/NWJAV4Zqj98eQOGlBbWzRkiKB5/M=; b=oOgdESKinfUfqTdtW5lUSL01TTuC7MWGXMXnEmB4QKZcrKoGRPUP20GEx6qp7OnfFt akfbCjpQDeQDuhKwyzsmnlsc5kopAcOjT5WdcgaaI5CS2MBPai/IaubEcPXkeuTFl/kg 2svNjgO/O27ZjCy1MR5ivf9ZfY68pb5kV6dJQG0SFtY3euK3rbEW3L0pSdY1YuQ3z3hR Pi0EPWGuCMIKAYxgoZe/qPedRlh0pqA9brCPsfLC31OjhoGDAD1O4/4skwlkGTpy1Gvu g9rMhO3Ss7/9RGh0sjaKFKGFIEZPrm6+S72Xrs5kDFOfmefdE2tAw1yQzNFQnZyvczoY K10g== X-Gm-Message-State: AOAM532PU4H/fA1dBD39YsHl1g8sZytbca7x8CbPe9gDDtE2PiTodiO7 ECFQeAnmCYYBZkz0xWjwpwnEo+/WKns= X-Google-Smtp-Source: ABdhPJxvZaLAe6eh1mSfzcDyep59K03MWE+FJ+GxetvNY/I30CGkrEPq+qL3VHm6cbKLevL50FXfww== X-Received: by 2002:a05:6214:caf:: with SMTP id s15mr281719qvs.115.1642038803488; Wed, 12 Jan 2022 17:53:23 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id i21sm1204710qti.31.2022.01.12.17.53.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 17:53:23 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 22:50:31 -0300 Message-Id: <20220113015101.4-70-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 069/281] genh: 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 --- libavformat/genh.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libavformat/genh.c b/libavformat/genh.c index f9b222d8cd..139205ecc5 100644 --- a/libavformat/genh.c +++ b/libavformat/genh.c @@ -55,18 +55,19 @@ static int genh_read_header(AVFormatContext *s) return AVERROR(ENOMEM); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; - st->codecpar->channels = avio_rl32(s->pb); - if (st->codecpar->channels <= 0 || st->codecpar->channels > FF_SANE_NB_CHANNELS) + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + st->codecpar->ch_layout.nb_channels = avio_rl32(s->pb); + if (st->codecpar->ch_layout.nb_channels <= 0) return AVERROR_INVALIDDATA; - 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; align = c->interleave_size = avio_rl32(s->pb); - if (align < 0 || align > INT_MAX / st->codecpar->channels) + if (align < 0 || align > INT_MAX / st->codecpar->ch_layout.nb_channels) return AVERROR_INVALIDDATA; - st->codecpar->block_align = align * st->codecpar->channels; + st->codecpar->block_align = align * st->codecpar->ch_layout.nb_channels; st->codecpar->sample_rate = avio_rl32(s->pb); avio_skip(s->pb, 4); st->duration = avio_rl32(s->pb); @@ -76,7 +77,7 @@ static int genh_read_header(AVFormatContext *s) case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break; case 1: case 11: st->codecpar->bits_per_coded_sample = 4; - st->codecpar->block_align = 36 * st->codecpar->channels; + st->codecpar->block_align = 36 * st->codecpar->ch_layout.nb_channels; st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break; case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break; case 3: st->codecpar->codec_id = st->codecpar->block_align > 0 ? @@ -122,13 +123,13 @@ static int genh_read_header(AVFormatContext *s) coef_splitted[1] = avio_rl32(s->pb); if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_THP) { - if (st->codecpar->channels > 2) { - avpriv_request_sample(s, "channels %d>2", st->codecpar->channels); + if (st->codecpar->ch_layout.nb_channels > 2) { + avpriv_request_sample(s, "channels %d>2", st->codecpar->ch_layout.nb_channels); return AVERROR_PATCHWELCOME; } - ff_alloc_extradata(st->codecpar, 32 * st->codecpar->channels); - for (ch = 0; ch < st->codecpar->channels; ch++) { + ff_alloc_extradata(st->codecpar, 32 * st->codecpar->ch_layout.nb_channels); + for (ch = 0; ch < st->codecpar->ch_layout.nb_channels; ch++) { if (coef_type & 1) { avpriv_request_sample(s, "coef_type & 1"); return AVERROR_PATCHWELCOME; @@ -139,7 +140,7 @@ static int genh_read_header(AVFormatContext *s) } if (c->dsp_int_type == 1) { - st->codecpar->block_align = 8 * st->codecpar->channels; + st->codecpar->block_align = 8 * st->codecpar->ch_layout.nb_channels; if (c->interleave_size != 1 && c->interleave_size != 2 && c->interleave_size != 4) @@ -164,16 +165,16 @@ static int genh_read_packet(AVFormatContext *s, AVPacket *pkt) int ret; if (c->dsp_int_type == 1 && par->codec_id == AV_CODEC_ID_ADPCM_THP && - par->channels > 1) { + par->ch_layout.nb_channels > 1) { int i, ch; if (avio_feof(s->pb)) return AVERROR_EOF; - ret = av_new_packet(pkt, 8 * par->channels); + ret = av_new_packet(pkt, 8 * par->ch_layout.nb_channels); if (ret < 0) return ret; for (i = 0; i < 8 / c->interleave_size; i++) { - for (ch = 0; ch < par->channels; ch++) { + for (ch = 0; ch < par->ch_layout.nb_channels; ch++) { pkt->data[ch * 8 + i*c->interleave_size+0] = avio_r8(s->pb); pkt->data[ch * 8 + i*c->interleave_size+1] = avio_r8(s->pb); } @@ -183,7 +184,8 @@ static int genh_read_packet(AVFormatContext *s, AVPacket *pkt) ret = av_get_packet(s->pb, pkt, par->block_align * 1024); } else { - ret = av_get_packet(s->pb, pkt, par->block_align ? par->block_align : 1024 * par->channels); + ret = av_get_packet(s->pb, pkt, par->block_align ? par->block_align : + 1024 * par->ch_layout.nb_channels); } pkt->stream_index = 0; -- 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".