From patchwork Tue Mar 16 06:22:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 26405 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5FB0644BC9E for ; Tue, 16 Mar 2021 08:23:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D5C568AE76; Tue, 16 Mar 2021 08:23:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDDE668AE6D for ; Tue, 16 Mar 2021 08:23:02 +0200 (EET) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=key1; t=1615875782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WFdaL+9Y+oh6QYrD+a7fXYxB8q26CRHrt2XM5J8OX88=; b=Ca5qE1P6M2fEPZRLLtljiFHum2HAQ91mWxwJOJ4gua6DMS3yvJByP/2inOJMJSlvx6P8d4 pY2sawJ0/Qvz/XdPFmRETmModOAoRrbADewsiYT1zMpkV//GKSslmJixKhRuPNX4ivUfjV rzyUsLqt/qId5XFhBzFmYNpH1bSGCY2r+DdfvO0sQwteQkltg10UM/G3LbjNXPAJZZM2AK 9ppQSdtZYiMyrvESHcz9lfNZ/PER8E3eQTlOBofnSuRcaDxFD7wpJhW1o+CKo76aCcezV0 qv4/K2vAho1XdQoKV7CTT8weXVfVBNr/rdGeHBmnTbFpTYrWavoM0VopSC3CDQ== From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Mar 2021 16:22:51 +1000 Message-Id: <20210316062254.22531-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: git-morningstar@zanevaniperen.com Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/adpcm_ima_cunning: support stereo X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Changes the sample format to S16P, but was only ever mono so it affects nothing. Signed-off-by: Zane van Iperen --- libavcodec/adpcm.c | 11 +++++++---- tests/fate/adpcm.mak | 18 +++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index eb228cc47a..44f14763fb 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -111,7 +111,6 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) switch(avctx->codec->id) { case AV_CODEC_ID_ADPCM_IMA_AMV: - case AV_CODEC_ID_ADPCM_IMA_CUNNING: max_channels = 1; break; case AV_CODEC_ID_ADPCM_DTK: @@ -197,6 +196,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) switch (avctx->codec->id) { case AV_CODEC_ID_ADPCM_AICA: + case AV_CODEC_ID_ADPCM_IMA_CUNNING: case AV_CODEC_ID_ADPCM_IMA_DAT4: case AV_CODEC_ID_ADPCM_IMA_QT: case AV_CODEC_ID_ADPCM_IMA_WAV: @@ -1377,10 +1377,13 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, } break; case AV_CODEC_ID_ADPCM_IMA_CUNNING: + for (channel = 0; channel < avctx->channels; channel++) { + int16_t *smp = samples_p[channel]; for (n = 0; n < nb_samples / 2; n++) { int v = bytestream2_get_byteu(&gb); - *samples++ = adpcm_ima_cunning_expand_nibble(&c->status[0], v & 0x0F); - *samples++ = adpcm_ima_cunning_expand_nibble(&c->status[0], v >> 4); + *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v & 0x0F); + *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v >> 4); + } } break; case AV_CODEC_ID_ADPCM_IMA_OKI: @@ -2162,7 +2165,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16p, adpcm_ea_xas, ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16, adpcm_ima_apc, "ADPCM IMA CRYO APC"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APM, sample_fmts_s16, adpcm_ima_apm, "ADPCM IMA Ubisoft APM"); -ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_CUNNING, sample_fmts_s16, adpcm_ima_cunning, "ADPCM IMA Cunning Developments"); +ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_CUNNING, sample_fmts_s16p, adpcm_ima_cunning, "ADPCM IMA Cunning Developments"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4, sample_fmts_s16, adpcm_ima_dat4, "ADPCM IMA Eurocom DAT4"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK3, sample_fmts_s16, adpcm_ima_dk3, "ADPCM IMA Duck DK3"); ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, "ADPCM IMA Duck DK4"); diff --git a/tests/fate/adpcm.mak b/tests/fate/adpcm.mak index c75a756bc3..84c6996bd4 100644 --- a/tests/fate/adpcm.mak +++ b/tests/fate/adpcm.mak @@ -113,31 +113,31 @@ FATE_ADPCM-$(call DEMDEC, ALP, ADPCM_IMA_ALP) += fate-adpcm-ima-alp-stereo fate-adpcm-ima-alp-stereo: CMD = md5 -i $(TARGET_SAMPLES)/alp/theme-cut.tun -f s16le FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-single -fate-adpcm-ima-cunning-single: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/GD-cut.5c -f s16le +fate-adpcm-ima-cunning-single: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/GD-cut.5c -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-track0 -fate-adpcm-ima-cunning-track0: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-cut.11c -map 0:a:0 -f s16le +fate-adpcm-ima-cunning-track0: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-cut.11c -map 0:a:0 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-track1 -fate-adpcm-ima-cunning-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-cut.11c -map 0:a:1 -f s16le +fate-adpcm-ima-cunning-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-cut.11c -map 0:a:1 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-t1 -fate-adpcm-ima-cunning-trunc-t1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t1.11c -map 0:a:0 -f s16le +fate-adpcm-ima-cunning-trunc-t1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t1.11c -map 0:a:0 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-t2-track0 -fate-adpcm-ima-cunning-trunc-t2-track0: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2.11c -map 0:a:0 -f s16le +fate-adpcm-ima-cunning-trunc-t2-track0: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2.11c -map 0:a:0 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-t2-track1 -fate-adpcm-ima-cunning-trunc-t2-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2.11c -map 0:a:1 -f s16le +fate-adpcm-ima-cunning-trunc-t2-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2.11c -map 0:a:1 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-t2a-track0 -fate-adpcm-ima-cunning-trunc-t2a-track0: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2a.11c -map 0:a:0 -f s16le +fate-adpcm-ima-cunning-trunc-t2a-track0: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2a.11c -map 0:a:0 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-t2a-track1 -fate-adpcm-ima-cunning-trunc-t2a-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2a.11c -map 0:a:1 -f s16le +fate-adpcm-ima-cunning-trunc-t2a-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-t2a.11c -map 0:a:1 -f s16le -af aresample FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-h2 -fate-adpcm-ima-cunning-trunc-h2: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-h2.11c -map 0:a:0 -f s16le +fate-adpcm-ima-cunning-trunc-h2: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-h2.11c -map 0:a:0 -f s16le -af aresample FATE_SAMPLES_AVCONV += $(FATE_ADPCM-yes) fate-adpcm: $(FATE_ADPCM-yes) From patchwork Tue Mar 16 06:22:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 26406 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id ABC5944BC9E for ; Tue, 16 Mar 2021 08:23:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 909AF68AEBF; Tue, 16 Mar 2021 08:23:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3539D68AE9D for ; Tue, 16 Mar 2021 08:23:04 +0200 (EET) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=key1; t=1615875783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g43x3D5dqIumvG0Pv94OYtzmYlcV4BICbrdnOTp/nvg=; b=CvhnvklcBBwnRz4eVNqIeL2lRN3xkO/Co2BS00B2t3+CSQIG/aGCCmQ0SapDqlcP011lST J9oihlx7ra4AU1PAizPceOm3gSx+Inm9TlZg/Va+7JTO7RO3wEVnmTuPWBh0R8SNf0Wcbl fw+jbG49OAAQuiXARkFLPsdsVyyrm1JAsUsSRFp0c/wNd/IIhymGZcz76ldR6J3Yvpva3g /dMOity/7PvUi3sCdNzjozB2E8t/5kLJVOpmGi+o7JWZdrWwXp8+oWWvSO1O/baTZLOPMD O/uMBo/Fi9tSaAjEGjKa1iKDiBiiDCnxvFRRNLZ5FbmpB/9qnTUuqyiTEXz4ng== From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Mar 2021 16:22:52 +1000 Message-Id: <20210316062254.22531-2-zane@zanevaniperen.com> In-Reply-To: <20210316062254.22531-1-zane@zanevaniperen.com> References: <20210316062254.22531-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: git-morningstar@zanevaniperen.com Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/adpcm_ima_cunning: reindent X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Zane van Iperen --- libavcodec/adpcm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 44f14763fb..5b6d1040af 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1379,11 +1379,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, case AV_CODEC_ID_ADPCM_IMA_CUNNING: for (channel = 0; channel < avctx->channels; channel++) { int16_t *smp = samples_p[channel]; - for (n = 0; n < nb_samples / 2; n++) { - int v = bytestream2_get_byteu(&gb); - *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v & 0x0F); - *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v >> 4); - } + for (n = 0; n < nb_samples / 2; n++) { + int v = bytestream2_get_byteu(&gb); + *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v & 0x0F); + *smp++ = adpcm_ima_cunning_expand_nibble(&c->status[channel], v >> 4); + } } break; case AV_CODEC_ID_ADPCM_IMA_OKI: From patchwork Tue Mar 16 06:22:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 26407 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D9AD644BC9E for ; Tue, 16 Mar 2021 08:23:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C2B0768AEDA; Tue, 16 Mar 2021 08:23:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0775168AE86 for ; Tue, 16 Mar 2021 08:23:06 +0200 (EET) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=key1; t=1615875785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aWQL4tdIqdl5oUhEfhI9sdGwZf8f/RuGKzGhorkA7vQ=; b=dvChtEKb5i1AKexWtL3uvYAmew2RC4MbskR2JElCU2HXgDcRTTLlODu6xJTNAJDuDAkbA9 ud/BCDMPsUplaHowpQbWH1m9R+ORgVbT1VdkviQFMvJTLyA+JW0oL2ddN4JWrC75VV8/5J FGjOm5HQLVUJp6b06vUkR8CJ94xhih9m+Ghv+5UvCz/crFitX3HSw9aOsnuMJ9Oak1GuXR 2Yo/74ak/7Qy3ORfyk8C5P+IaQCJO7AcFbh+PHdOlH1wFdkuXIJz3fsblsvt6+puC+B4Oy FnUtLNlmGdog64RLcTD7OuftKH/9gRnYGo15kcfwNGhFXIXnUTSS5+7ifO8pxw== From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Mar 2021 16:22:53 +1000 Message-Id: <20210316062254.22531-3-zane@zanevaniperen.com> In-Reply-To: <20210316062254.22531-1-zane@zanevaniperen.com> References: <20210316062254.22531-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: git-morningstar@zanevaniperen.com Subject: [FFmpeg-devel] [PATCH 3/4] avformat/pp_bnk: treat music files are stereo X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" These files are technically a series of planar mono tracks. If the "music" flag is set, merge the packets from the two mono tracks, essentially replicating: [0:a:0][0:a:1]join=inputs=2:channel_layout=stereo[a] Signed-off-by: Zane van Iperen --- libavformat/pp_bnk.c | 60 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c index 8364de1fd9..970ef09923 100644 --- a/libavformat/pp_bnk.c +++ b/libavformat/pp_bnk.c @@ -55,6 +55,8 @@ typedef struct PPBnkCtx { int track_count; PPBnkCtxTrack *tracks; uint32_t current_track; + int is_music; + AVPacket pkt; } PPBnkCtx; enum { @@ -194,8 +196,12 @@ static int pp_bnk_read_header(AVFormatContext *s) goto fail; } + ctx->is_music = (hdr.flags & PP_BNK_FLAG_MUSIC) && + (ctx->track_count == 2) && + (ctx->tracks[0].data_size == ctx->tracks[1].data_size); + /* Build the streams. */ - for (int i = 0; i < ctx->track_count; i++) { + for (int i = 0; i < (ctx->is_music ? 1 : ctx->track_count); i++) { if (!(st = avformat_new_stream(s, NULL))) { ret = AVERROR(ENOMEM); goto fail; @@ -204,14 +210,21 @@ static int pp_bnk_read_header(AVFormatContext *s) par = st->codecpar; par->codec_type = AVMEDIA_TYPE_AUDIO; par->codec_id = AV_CODEC_ID_ADPCM_IMA_CUNNING; - par->format = AV_SAMPLE_FMT_S16; - par->channel_layout = AV_CH_LAYOUT_MONO; - par->channels = 1; + par->format = AV_SAMPLE_FMT_S16P; + + if (ctx->is_music) { + par->channel_layout = AV_CH_LAYOUT_STEREO; + par->channels = 2; + } else { + par->channel_layout = AV_CH_LAYOUT_MONO; + par->channels = 1; + } + par->sample_rate = hdr.sample_rate; par->bits_per_coded_sample = 4; par->bits_per_raw_sample = 16; par->block_align = 1; - par->bit_rate = par->sample_rate * par->bits_per_coded_sample; + par->bit_rate = par->sample_rate * par->bits_per_coded_sample * par->channels; avpriv_set_pts_info(st, 64, 1, par->sample_rate); st->start_time = 0; @@ -253,7 +266,22 @@ static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt) size = FFMIN(trk->data_size - trk->bytes_read, PP_BNK_MAX_READ_SIZE); - if ((ret = av_get_packet(s->pb, pkt, size)) == AVERROR_EOF) { + if (!ctx->is_music) + ret = av_new_packet(&ctx->pkt, size); + else if (ctx->current_track == 0) + ret = av_new_packet(&ctx->pkt, size * 2); + else + ret = 0; + + if (ret < 0) + return ret; + + if (ctx->is_music) + ret = avio_read(s->pb, ctx->pkt.data + size * ctx->current_track, size); + else + ret = avio_read(s->pb, ctx->pkt.data, size); + + if (ret == AVERROR_EOF) { /* If we've hit EOF, don't attempt this track again. */ trk->data_size = trk->bytes_read; continue; @@ -261,10 +289,21 @@ static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt) return ret; } - trk->bytes_read += ret; - pkt->flags &= ~AV_PKT_FLAG_CORRUPT; - pkt->stream_index = ctx->current_track++; - pkt->duration = ret * 2; + trk->bytes_read += ret; + ctx->pkt.flags &= ~AV_PKT_FLAG_CORRUPT; + ctx->pkt.stream_index = ctx->current_track++; + ctx->pkt.duration = ret * 2; + + if (ctx->is_music) { + if (ctx->pkt.stream_index == 0) + return FFERROR_REDO; + + ctx->pkt.stream_index = 0; + } else { + ctx->pkt.size = ret; + } + + av_packet_move_ref(pkt, &ctx->pkt); return 0; } @@ -277,6 +316,7 @@ static int pp_bnk_read_close(AVFormatContext *s) PPBnkCtx *ctx = s->priv_data; av_freep(&ctx->tracks); + av_packet_unref(&ctx->pkt); return 0; } From patchwork Tue Mar 16 06:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 26408 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2CC3944BC9E for ; Tue, 16 Mar 2021 08:23:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D8FE68AF0A; Tue, 16 Mar 2021 08:23:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDB1368AE7A for ; Tue, 16 Mar 2021 08:23:07 +0200 (EET) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=key1; t=1615875787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YX5rcH0h7EFSNG+x/hoLDfkTTCsgtxFQwJdZraQgof0=; b=SglzC/sEaHpxyrgw3z8FWo+NIhQ/EOuyJQOljyRoo854ZHoxpoQcs9SwzVFoobvHX6H4ya ao/nv5hfdMpv+FpAyJc6yuSLofL591ffqRGlPu3v8BjpFRNGEdCygJBdmeveCL9kmKDzDv hK3A2MXmEa4zMaNJgVSJUI+FRbOdjdpQnistjUfULq2uQRh0Oj2xppSR4Fk0ltFnxqYGfC 73RKMW2zmp5s+iegnwhtU1G++sXtdXckcNjIeFjdRitNfKObHtCtzf4ut4Jb1OHQNWV80i zBot1z3NzpOftIOJdfb2GbgGjOJPVAepNxJynb6MpBE2NaL1fGs20Xy6GXStuw== From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Mar 2021 16:22:54 +1000 Message-Id: <20210316062254.22531-4-zane@zanevaniperen.com> In-Reply-To: <20210316062254.22531-1-zane@zanevaniperen.com> References: <20210316062254.22531-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: git-morningstar@zanevaniperen.com Subject: [FFmpeg-devel] [PATCH 4/4] fate: add adpcm_ima_cunning stereo test case X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Zane van Iperen --- tests/fate/adpcm.mak | 3 +++ tests/ref/fate/adpcm-ima-cunning-stereo | 1 + 2 files changed, 4 insertions(+) create mode 100644 tests/ref/fate/adpcm-ima-cunning-stereo diff --git a/tests/fate/adpcm.mak b/tests/fate/adpcm.mak index 84c6996bd4..f858a808c5 100644 --- a/tests/fate/adpcm.mak +++ b/tests/fate/adpcm.mak @@ -139,5 +139,8 @@ fate-adpcm-ima-cunning-trunc-t2a-track1: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bn FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-trunc-h2 fate-adpcm-ima-cunning-trunc-h2: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/VIDEOMOD-trunc-h2.11c -map 0:a:0 -f s16le -af aresample +FATE_ADPCM-$(call DEMDEC, PP_BNK, ADPCM_IMA_CUNNING) += fate-adpcm-ima-cunning-stereo +fate-adpcm-ima-cunning-stereo: CMD = md5 -y -i $(TARGET_SAMPLES)/pp_bnk/MOGODON2-cut.44c -f s16le -af aresample + FATE_SAMPLES_AVCONV += $(FATE_ADPCM-yes) fate-adpcm: $(FATE_ADPCM-yes) diff --git a/tests/ref/fate/adpcm-ima-cunning-stereo b/tests/ref/fate/adpcm-ima-cunning-stereo new file mode 100644 index 0000000000..7e11c8529d --- /dev/null +++ b/tests/ref/fate/adpcm-ima-cunning-stereo @@ -0,0 +1 @@ +c508235656525c97429153c639dbe8eb