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 9422E42D6E for ; Thu, 13 Jan 2022 02:12:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9014068B248; Thu, 13 Jan 2022 03:56:37 +0200 (EET) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 42A7468B22B for ; Thu, 13 Jan 2022 03:56:30 +0200 (EET) Received: by mail-qt1-f179.google.com with SMTP id y17so5318411qtx.9 for ; Wed, 12 Jan 2022 17:56:30 -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=U5SSxlG8KW4xmY48w9xY6zQtgZJyTSJFpXWCjIStbJc=; b=kUGSggVQxFq8I29bngwM71PmeYhy1aaJEQUYmlFgGXONOU0vWDkzpYBrpawF2o3Qv6 04N3O+WsesLAQvf/tGZakwWQPUnIdeZ2sz8LdmM3YGhxyQbhImt7GUGyizKL3sUCyjHl TGRa/VHwiXKeIzp8/ddE5lI05q7o/Ev8fb2nLm4AomUe5rxBMAYYLl+I3+UlUQnLGn/F t+STr7lkXxK4/M+FOPDG8neewHGadLF4WY909Rwi9sqbDOo6HMeIw/wPwNEWla0E4Yvb QfGLDmmQCHaAN3mD5V170y9aQezQsSgvfctQnIZgiKdPKWpWff9rkck86IUEI5gYs2Y1 3j0A== 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=U5SSxlG8KW4xmY48w9xY6zQtgZJyTSJFpXWCjIStbJc=; b=tijEjW/YykI0RemBl1Hcs/16QK1gu8kLV9dSVUn57cTLKNIP8zMvr/ksF/gLY3Ht8U 2+3ghNO63RvLfeZ77EhgQPmcX1dpCE3vV7W81LU2rFw+pU3Lcu1Zb9GoaJFspHZXrWAJ Hj3k0nFOVCJOXGSdy6hChdf4kw9ENQSqKop2RgZl+ohJky5fKnTIC1ToDbw+3lesDtVY 8iyTHGJfZYLZznFMh90v+GxD3SdOMR7aL8WT1U/IkCwcL54w4Ws8lIEfC1wNOCrv7AOB fVrF9G+g+lsGQ2fTkHPeFHRtauycAOy5PXYgoau+XOT/RSVFE4x6EmB31L49jO+CdWHk F0Cw== X-Gm-Message-State: AOAM532ok4YfdBQyMUzHVrSvj8t103wLlil67kzOZpl9/jaJyrjq0tM3 /vLwFEV26x1Q6R4w58utcZdjh/qc/tY= X-Google-Smtp-Source: ABdhPJxDzwhVSL2+DVVEtjBpykxlxtVbBtwBRk6XpWI+VEIR/l5A4ai+xGpKe3Ua6K6VvS/u4fgz0g== X-Received: by 2002:ac8:6ec7:: with SMTP id f7mr2035670qtv.2.1642038988910; Wed, 12 Jan 2022 17:56:28 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id t11sm906506qkm.77.2022.01.12.17.56.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 17:56:28 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 22:55:45 -0300 Message-Id: <20220113015612.448-4-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 092/281] mca: 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: Signed-off-by: James Almer --- libavformat/mca.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libavformat/mca.c b/libavformat/mca.c index ca0f76d6bf..feda65dd85 100644 --- a/libavformat/mca.c +++ b/libavformat/mca.c @@ -62,7 +62,8 @@ static int read_header(AVFormatContext *s) avio_skip(s->pb, 0x4); // skip the file magic version = avio_rl16(s->pb); avio_skip(s->pb, 0x2); // padding - par->channels = avio_r8(s->pb); + par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + par->ch_layout.nb_channels = avio_r8(s->pb); avio_skip(s->pb, 0x1); // padding m->block_size = avio_rl16(s->pb); nb_samples = avio_rl32(s->pb); @@ -85,7 +86,7 @@ static int read_header(AVFormatContext *s) st->duration = nb_samples; // sanity checks - if (!par->channels || par->sample_rate <= 0 + if (!par->ch_layout.nb_channels || par->sample_rate <= 0 || loop_start > loop_end || m->block_count < 1) return AVERROR_INVALIDDATA; if ((ret = av_dict_set_int(&s->metadata, "loop_start", @@ -96,8 +97,8 @@ static int read_header(AVFormatContext *s) av_rescale(loop_end, AV_TIME_BASE, par->sample_rate), 0)) < 0) return ret; - if ((32 + 4 + m->block_size) > (INT_MAX / par->channels) || - (32 + 4 + m->block_size) * par->channels > INT_MAX - 8) + if ((32 + 4 + m->block_size) > (INT_MAX / par->ch_layout.nb_channels) || + (32 + 4 + m->block_size) * par->ch_layout.nb_channels > INT_MAX - 8) return AVERROR_INVALIDDATA; avpriv_set_pts_info(st, 64, 1, par->sample_rate); @@ -116,9 +117,9 @@ static int read_header(AVFormatContext *s) } } else if (version == 5) { // read data_start location from the header - if (0x30 * par->channels + 0x4 > header_size) + if (0x30 * par->ch_layout.nb_channels + 0x4 > header_size) return AVERROR_INVALIDDATA; - data_offset = header_size - 0x30 * par->channels - 0x4; + data_offset = header_size - 0x30 * par->ch_layout.nb_channels - 0x4; if ((ret_size = avio_seek(s->pb, data_offset, SEEK_SET)) < 0) return ret_size; m->data_start = avio_rl32(s->pb); @@ -144,21 +145,21 @@ static int read_header(AVFormatContext *s) } // coefficient alignment = 0x30; metadata size = 0x14 - if (0x30 * par->channels + nb_metadata * 0x14 > header_size) + if (0x30 * par->ch_layout.nb_channels + nb_metadata * 0x14 > header_size) return AVERROR_INVALIDDATA; coef_offset = - header_size - 0x30 * par->channels + nb_metadata * 0x14; + header_size - 0x30 * par->ch_layout.nb_channels + nb_metadata * 0x14; st->start_time = 0; par->codec_id = AV_CODEC_ID_ADPCM_THP_LE; - ret = ff_alloc_extradata(st->codecpar, 32 * par->channels); + ret = ff_alloc_extradata(st->codecpar, 32 * par->ch_layout.nb_channels); if (ret < 0) return ret; if ((ret_size = avio_seek(s->pb, coef_offset, SEEK_SET)) < 0) return ret_size; - for (ch = 0; ch < par->channels; ch++) { + for (ch = 0; ch < par->ch_layout.nb_channels; ch++) { if ((ret = ffio_read_size(s->pb, par->extradata + ch * 32, 32)) < 0) return ret; // 0x30 (alignment) - 0x20 (actual size, 32) = 0x10 (padding) @@ -187,7 +188,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) if (m->current_block > m->block_count) return AVERROR_EOF; - if ((ret = av_get_packet(s->pb, pkt, size * par->channels)) < 0) + if ((ret = av_get_packet(s->pb, pkt, size * par->ch_layout.nb_channels)) < 0) return ret; pkt->duration = samples; pkt->stream_index = 0; @@ -208,7 +209,7 @@ static int read_seek(AVFormatContext *s, int stream_index, if (timestamp >= m->block_count) timestamp = m->block_count - 1; ret = avio_seek(s->pb, m->data_start + timestamp * m->block_size * - st->codecpar->channels, SEEK_SET); + st->codecpar->ch_layout.nb_channels, SEEK_SET); if (ret < 0) return ret; -- 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".