From patchwork Sun Jan 19 08:33:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 17418 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 4B96444A76F for ; Sun, 19 Jan 2020 10:33:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3475F68B0BF; Sun, 19 Jan 2020 10:33:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 195A468B0BD for ; Sun, 19 Jan 2020 10:33:46 +0200 (EET) Date: Sun, 19 Jan 2020 08:33:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1579422824; bh=NRNbN1xUDSApkdBic7MtdFSm7fe7QRidtYheogOcMa8=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=ZOnR1jjylvclvbwgJWQs3wBPdLxe/vdJZftTgyJNhz8jV6e9lvd1HgPzx8y/y0rVX lmHBayw5dBvq6HSXf4Bu3VgP8WfDSQQZSVp/h5jwrGOFvzunphJcWOKYnOv0IEbMiA 9bc9qnciJ28+3aO2sNCoYHgR152N3qa5aCAHqLjw= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200119083325.3377-2-zane@zanevaniperen.com> In-Reply-To: <20200119083325.3377-1-zane@zanevaniperen.com> References: <20200119083325.3377-1-zane@zanevaniperen.com> Feedback-ID: xylLYHwBzJW7F28tHN-oL9EBm6h5yqtCqG6YwPpJ2oMwBYJT6-HxTnFTF6p18axLiSywX61iUfj4CElBGg8-GA==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=0.3 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_RHS_DOB shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 1/2] avcodec: add decoder for argonaut games' adpcm codec 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" Adds support for the ADPCM variant used by some Argonaut Games' games, such as 'Croc! Legend of the Gobbos', and 'Croc 2'. Signed-off-by: Zane van Iperen --- Changelog | 2 +- doc/general.texi | 1 + libavcodec/Makefile | 1 + libavcodec/adpcm_argo.c | 264 ++++++++++++++++++++++++++++++++++++++++ libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/version.h | 2 +- 8 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 libavcodec/adpcm_argo.c diff --git a/Changelog b/Changelog index 2ccd2645fc..e26320c0ce 100644 --- a/Changelog +++ b/Changelog @@ -30,7 +30,7 @@ version : - MPEG-H 3D Audio support in mp4 - thistogram filter - freezeframes filter - +- Argonaut Games ADPCM decoder version 4.2: - tpad filter diff --git a/doc/general.texi b/doc/general.texi index 4bd4b4f6b9..85db50462c 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1079,6 +1079,7 @@ following image formats are supported: @item ACELP.KELVIN @tab @tab X @item ADPCM 4X Movie @tab @tab X @item APDCM Yamaha AICA @tab @tab X +@item ADPCM Argonaut Games @tab @tab X @item ADPCM CDROM XA @tab @tab X @item ADPCM Creative Technology @tab @tab X @tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2 diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c1f35b40d8..526b3ce96b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -817,6 +817,7 @@ OBJS-$(CONFIG_ADPCM_ADX_ENCODER) += adxenc.o adx.o OBJS-$(CONFIG_ADPCM_AFC_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_AGM_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_AICA_DECODER) += adpcm.o adpcm_data.o +OBJS-$(CONFIG_ADPCM_ARGO_DECODER) += adpcm_argo.o OBJS-$(CONFIG_ADPCM_CT_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_DTK_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_EA_DECODER) += adpcm.o adpcm_data.o diff --git a/libavcodec/adpcm_argo.c b/libavcodec/adpcm_argo.c new file mode 100644 index 0000000000..d5b32e62ba --- /dev/null +++ b/libavcodec/adpcm_argo.c @@ -0,0 +1,264 @@ +/* + * Argonaut Games ADPCM decoder + * + * Copyright (C) 2020 Zane van Iperen (zane@zanevaniperen.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avcodec.h" +#include "internal.h" +#include "libavutil/avassert.h" + +/* + * Sanity Checks: + * + * ./ffmpeg -loglevel error -i OUTRO.ASF -map 0:a -f md5 - + * MD5=e0428a6c55382f48502f04b3a7f7b94b + * + * ./ffmpeg -loglevel error -i CBK2.asf -map 0:a -f md5 - + * MD5=589f3f3c518e5d58aa404b7576db5b70 +*/ + +/** + * Decode a block of 4-bit ADPCM samples for a channel. + * + * @param c The shift amount - 2. + * @param dst A pointer to the buffer to write the decoded samples, + * @p stride elements apart. + * @param src A pointer to the first encoded sample. + * This should be `nsamples / 2` bytes. + * @param prev The two previous samples, with @p stride elements + * between each channel. + * @param nsamples The number of samples in the channel. + * @param stride The difference in int16_t's between output samples. + * This is 0 for mono, 1 for stereo. + * + * @remark Each iteration does 2 samples at a time to avoid nasty bit-twiddling. + */ +typedef int16_t *(*ADPCMDecoder) ( + uint8_t c, + int16_t *dst, + const uint8_t *src, + const int16_t *prev, + int nsamples, + int stride +); + +/* + * Decoder 1: (prev0 + (s << (c + 2))) + */ +static int16_t *adpcm_decoder_1(uint8_t c, int16_t *dst, const uint8_t *src, + const int16_t *prev_, + int nsamples, int stride) +{ + int16_t prev; + int8_t s; + + av_assert0(stride == 0 || stride == 1); + ++stride; + + prev = prev_[stride]; + + c += 2; + for (int i = 0; i < nsamples / 2; ++i, ++src) { + s = (int8_t) ((*src & 0xF0u) << 0u); + *dst = prev = ((prev << 6) + (s << c)) >> 6; + dst += stride; + + s = (int8_t) ((*src & 0x0Fu) << 4u); + *dst = prev = ((prev << 6) + (s << c)) >> 6; + dst += stride; + } + + return dst; +} + +/* + * Decoder 2: (2 * prev0) - (1 * prev1) + (s << (c + 2)) + */ +static int16_t *adpcm_decoder_2(uint8_t c, int16_t * dst, const uint8_t * src, + const int16_t * prev_, + int nsamples, int stride) +{ + int16_t cprev[2]; + int8_t s; + + av_assert0(stride == 0 || stride == 1); + ++stride; + + /* [t-1, t-2] */ + cprev[0] = prev_[stride]; + cprev[1] = prev_[0]; + + c += 2; + for (int i = 0; i < nsamples / 2; ++i, ++src) { + + /* NB: (x << 7) == 2*(x << 6) */ + + s = (int8_t) ((*src & 0xF0u) << 0u); + *dst = ((cprev[0] << 7) - (cprev[1] << 6) + (s << c)) >> 6; + cprev[1] = cprev[0]; + cprev[0] = *dst; + dst += stride; + + s = (int8_t) ((*src & 0x0Fu) << 4u); + *dst = ((cprev[0] << 7) - (cprev[1] << 6) + (s << c)) >> 6; + cprev[1] = cprev[0]; + cprev[0] = *dst; + dst += stride; + } + + return dst; +} + +static ADPCMDecoder adpcm_decoders[2] = { adpcm_decoder_1, adpcm_decoder_2 }; + +/** + * Decode a block of ADPCM samples. + * + * The format of each block: + * uint8_t left_control; + * uint4_t left_samples[]; + * ---- and if stereo ---- + * uint8_t right_control; + * uint4_t right_samples[]; + * + * Format of the control byte: + * MSB [SSSSDRRR] LSB + * S = (Shift Amount - 2) + * D = Decoder flag. If set, use decoder 2, otherwise use decoder 1 + * R = Reserved + * + * @param dst A pointer to the buffer to write the samples. + * This must be at least `nsamples * nchannels` + * @param src A pointer to the current block. + * @param prev A pointer to the previous two decoded samples, one per channel. + * For mono this is: [Lt-2, Lt-1] + * For stereo this is: [Lt-2, Rt-2, Lt-1, Rt-1] + * @param nsamples The number of samples per channel in the block. + * Must be divisible by and greater than 2. + * @param nchannels The number of channels. Must be 1 or 2. + */ +static int16_t *adpcm_decode_block(int16_t *dst, const uint8_t *src, + const int16_t *prev, + int nsamples, int nchannels) +{ + unsigned char c; + + av_assert0(nsamples > 2 && (nsamples & 0x1) == 0); + av_assert0(nchannels == 1 || nchannels == 2); + + /* NB: nsamples/2 because samples are 4 bits, not 8. */ + for (int i = 0; i < nchannels; ++i, src += nsamples / 2) { + /* Get the control byte and run the samples through the decoder. */ + c = *src++; + adpcm_decoders[!!(c & 0x04)] (c >> 4, dst + i, src, prev + i, nsamples, nchannels - 1); + } + + return dst + (nsamples * nchannels); +} + + +#define MAX_CHANNELS (2) +#define PREVIOUS_SAMPLE_COUNT (2) + +typedef struct ADPCMArgoDecoderContext { + int16_t prev[MAX_CHANNELS * PREVIOUS_SAMPLE_COUNT]; +} ADPCMArgoDecoderContext; + +static av_cold int adpcm_decode_init(AVCodecContext *avctx) +{ + ADPCMArgoDecoderContext *ctx = avctx->priv_data; + + if (avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Invalid channel count %d\n", avctx->channels); + return AVERROR(EINVAL); + } + + if (avctx->bits_per_coded_sample != 4) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", avctx->bits_per_coded_sample); + return AVERROR(EINVAL); + } + + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + for (int i = 0; i < MAX_CHANNELS * PREVIOUS_SAMPLE_COUNT; ++i) + ctx->prev[i] = 0; + + return 0; +} + +static int adpcm_decode_frame(AVCodecContext * avctx, void *data, + int *got_frame_ptr, AVPacket * avpkt) +{ + int r; + AVFrame *frame = data; + ADPCMArgoDecoderContext *argo = avctx->priv_data; + int16_t *dst; + + if (avctx->channels == 1 && avpkt->size != 17) { + av_log(avctx, AV_LOG_WARNING, + "unexpected mono packet size, expected 17, got %d\n", + avpkt->size); + } else if(avctx->channels == 2 && avpkt->size != 34) { + av_log(avctx, AV_LOG_WARNING, + "unexpected stereo packet size, expected 34, got %d\n", + avpkt->size); + } + + frame->nb_samples = ((avpkt->size - avctx->channels) / avctx->channels) * + (8 / avctx->bits_per_coded_sample); + + /* get output buffer */ + if ((r = ff_get_buffer(avctx, frame, 0)) < 0) + return r; + + dst = adpcm_decode_block((int16_t *) frame->data[0], avpkt->data, argo->prev, frame->nb_samples, avctx->channels); + + /* Save the previous samples for the next frame. */ + r = avctx->channels * PREVIOUS_SAMPLE_COUNT; + for (int i = 0; i < r; ++i) + argo->prev[i] = *(dst - (r - i)); + + *got_frame_ptr = 1; + return avpkt->size; +} + +const int64_t channel_layouts[] = { + AV_CH_LAYOUT_MONO, + AV_CH_LAYOUT_STEREO, + 0 +}; + +const enum AVSampleFormat sample_formats[] = { + AV_SAMPLE_FMT_S16, + AV_SAMPLE_FMT_NONE +}; + + +AVCodec ff_adpcm_argo_decoder = { + .name = "adpcm_argo", + .long_name = NULL_IF_CONFIG_SMALL("ADPCM Argonaut Games"), + .type = AVMEDIA_TYPE_AUDIO, + .id = AV_CODEC_ID_ADPCM_ARGO, + .priv_data_size = sizeof(ADPCMArgoDecoderContext), + .init = adpcm_decode_init, + .decode = adpcm_decode_frame, + .capabilities = AV_CODEC_CAP_DR1, + .sample_fmts = sample_formats, + .channel_layouts = channel_layouts +}; diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ec7366144f..01a083d06b 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -582,6 +582,7 @@ extern AVCodec ff_adpcm_adx_decoder; extern AVCodec ff_adpcm_afc_decoder; extern AVCodec ff_adpcm_agm_decoder; extern AVCodec ff_adpcm_aica_decoder; +extern AVCodec ff_adpcm_argo_decoder; extern AVCodec ff_adpcm_ct_decoder; extern AVCodec ff_adpcm_dtk_decoder; extern AVCodec ff_adpcm_ea_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 4b0e7c0853..ce126353b3 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -545,6 +545,7 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_IMA_DAT4, AV_CODEC_ID_ADPCM_MTAF, AV_CODEC_ID_ADPCM_AGM, + AV_CODEC_ID_ADPCM_ARGO, /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 529b838e5b..32f573d58c 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2297,6 +2297,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("ADPCM AmuseGraphics Movie AGM"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_ADPCM_ARGO, + .type = AVMEDIA_TYPE_AUDIO, + .name = "adpcm_argo", + .long_name = NULL_IF_CONFIG_SMALL("ADPCM Argonaut Games"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, /* AMR */ { diff --git a/libavcodec/version.h b/libavcodec/version.h index 6cf333eeb6..2fba26e8d0 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 66 +#define LIBAVCODEC_VERSION_MINOR 67 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Sun Jan 19 08:33:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 17419 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 7D0CC44A76F for ; Sun, 19 Jan 2020 10:34:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 650E168B0AE; Sun, 19 Jan 2020 10:34:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.protonmail.ch (mail1.protonmail.ch [185.70.40.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 68DE468B04D for ; Sun, 19 Jan 2020 10:33:53 +0200 (EET) Date: Sun, 19 Jan 2020 08:33:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1579422832; bh=dlwHd1nxe9NQatkb1TSGeMTbh+tAOIALgkWwf+imDWM=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=Oo5uu3BmzntSfWMwyPpW/kVgIKz7lx92C+JEmu8q/MdOxIiFEGNa5g89YwNlK8UeR BY0j2Y4sTkirHbZ1pBxhI6dXQuOtEcmNkkrzJtfpybrYP58SjFEFQPtgFlRfBla0sv ZAtF7kVVLrgh4UP2JbeMna+MEPbWpaGGv2Zyb0Y0= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200119083325.3377-3-zane@zanevaniperen.com> In-Reply-To: <20200119083325.3377-1-zane@zanevaniperen.com> References: <20200119083325.3377-1-zane@zanevaniperen.com> Feedback-ID: xylLYHwBzJW7F28tHN-oL9EBm6h5yqtCqG6YwPpJ2oMwBYJT6-HxTnFTF6p18axLiSywX61iUfj4CElBGg8-GA==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=0.3 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_RHS_DOB shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat: add demuxer for argonaut games' ASF format 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" Adds support for the custom ASF container used by some Argonaut Games' games, such as 'Croc! Legend of the Gobbos', and 'Croc 2'. Can also handle the sample files in: https://samples.ffmpeg.org/game-formats/brender/part2.zip Signed-off-by: Zane van Iperen Reviewed-by: Andreas Rheinhardt --- Changelog | 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/argo_asf.c | 260 +++++++++++++++++++++++++++++++++++++++ libavformat/version.h | 4 +- 5 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 libavformat/argo_asf.c diff --git a/Changelog b/Changelog index e26320c0ce..bc1593bfd1 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ version : - thistogram filter - freezeframes filter - Argonaut Games ADPCM decoder +- Argonaut Games ASF demuxer version 4.2: - tpad filter diff --git a/libavformat/Makefile b/libavformat/Makefile index 52f29b1a6d..ba6ea8c4a6 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -99,6 +99,7 @@ OBJS-$(CONFIG_APTX_MUXER) += rawenc.o OBJS-$(CONFIG_APTX_HD_DEMUXER) += aptxdec.o rawdec.o OBJS-$(CONFIG_APTX_HD_MUXER) += rawenc.o OBJS-$(CONFIG_AQTITLE_DEMUXER) += aqtitledec.o subtitles.o +OBJS-$(CONFIG_ARGO_ASF_DEMUXER) += argo_asf.o OBJS-$(CONFIG_ASF_DEMUXER) += asfdec_f.o asf.o asfcrypt.o \ avlanguage.o OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \ diff --git a/libavformat/allformats.c b/libavformat/allformats.c index ff9bdb906f..fe74a32e47 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -60,6 +60,7 @@ extern AVOutputFormat ff_aptx_muxer; extern AVInputFormat ff_aptx_hd_demuxer; extern AVOutputFormat ff_aptx_hd_muxer; extern AVInputFormat ff_aqtitle_demuxer; +extern AVInputFormat ff_argo_asf_demuxer; extern AVInputFormat ff_asf_demuxer; extern AVOutputFormat ff_asf_muxer; extern AVInputFormat ff_asf_o_demuxer; diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c new file mode 100644 index 0000000000..d8f2d71009 --- /dev/null +++ b/libavformat/argo_asf.c @@ -0,0 +1,260 @@ +/* + * Argonaut Games ASF demuxer + * + * Copyright (C) 2020 Zane van Iperen (zane@zanevaniperen.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" + +#define ASF_TAG MKTAG('A', 'S', 'F', '\0') +#define ASF_FILE_HEADER_SIZE (24) +#define ASF_CHUNK_HEADER_SIZE (20) + +typedef struct ArgoASFFileHeader { + uint32_t magic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ + uint16_t version_major; /*< File Major Version. */ + uint16_t version_minor; /*< File Minor Version. */ + uint32_t num_chunks; /*< No. chunks in the file. */ + uint32_t chunk_offset; /*< Offset to the first chunk from the start of the file. */ + int8_t name[8]; /*< Name. */ +} ArgoASFFileHeader; + +typedef struct ArgoASFChunkHeader { + uint32_t num_blocks; /*< No. blocks in the chunk. */ + uint32_t num_samples; /*< No. samples per channel in a block. */ + uint32_t unk1; /*< Unknown */ + uint16_t sample_rate; /*< Sample rate. */ + uint16_t unk2; /*< Unknown. */ + uint32_t flags; /*< Stream flags. */ +} ArgoASFChunkHeader; + +enum { + ASF_CF_BITS_PER_SAMPLE = (1 << 0), /*< 16-bit if set, 8 otherwise. */ + ASF_CF_STEREO = (1 << 1), /*< Stereo if set, mono otherwise. */ + ASF_CF_ALWAYS1_1 = (1 << 2), /*< Unknown, always seems to be set. */ + ASF_CF_ALWAYS1_2 = (1 << 3), /*< Unknown, always seems to be set. */ + + ASF_CF_ALWAYS1 = ASF_CF_ALWAYS1_1 | ASF_CF_ALWAYS1_2, + ASF_CF_ALWAYS0 = ~(ASF_CF_BITS_PER_SAMPLE | ASF_CF_STEREO | ASF_CF_ALWAYS1) +}; + +typedef struct ArgoASFDemuxContext +{ + ArgoASFFileHeader fhdr; + ArgoASFChunkHeader ckhdr; + uint32_t blocks_read; +} ArgoASFDemuxContext; + +static void argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf) +{ + hdr->magic = AV_RL32(buf + 0); + hdr->version_major = AV_RL16(buf + 4); + hdr->version_minor = AV_RL16(buf + 6); + hdr->num_chunks = AV_RL32(buf + 8); + hdr->chunk_offset = AV_RL32(buf + 12); + for(int i = 0; i < 8; ++i) + hdr->name[i] = AV_RL8(buf + 16 + i); +} + +static void argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf) +{ + hdr->num_blocks = AV_RL32(buf + 0); + hdr->num_samples = AV_RL32(buf + 4); + hdr->unk1 = AV_RL32(buf + 8); + hdr->sample_rate = AV_RL16(buf + 12); + hdr->unk2 = AV_RL16(buf + 14); + hdr->flags = AV_RL32(buf + 16); +} + +/* + * Known versions: + * 1.1: The sample files in /game-formats/brender/part2.zip + * 1.2: Croc! Legend of the Gobbos + * 2.1: Croc 2 + */ +static int argo_asf_is_known_version(const ArgoASFFileHeader *hdr) +{ + return (hdr->version_major == 1 && hdr->version_minor == 1) || + (hdr->version_major == 1 && hdr->version_minor == 2) || + (hdr->version_major == 2 && hdr->version_minor == 1); +} + +static int argo_asf_probe(const AVProbeData *p) +{ + int score; + ArgoASFFileHeader hdr; + + if (p->buf_size < ASF_FILE_HEADER_SIZE) + return AVPROBE_SCORE_RETRY; + + score = 0; + if (av_match_ext(p->filename, "asf")) + score += AVPROBE_SCORE_EXTENSION; + + argo_asf_parse_file_header(&hdr, p->buf); + + if(hdr.magic != ASF_TAG) + return 0; + + if (argo_asf_is_known_version(&hdr)) + score += 25; + + /* Have only ever seen these with 1 chunk. */ + if (hdr.num_chunks == 1) + score += 25; + + if (hdr.chunk_offset > INT_MAX) + score -= 50; + + if (score > AVPROBE_SCORE_MAX) + score = AVPROBE_SCORE_MAX; + + return score; +} + + + +static int argo_asf_read_header(AVFormatContext *s) +{ + int64_t ret; + AVIOContext *pb = s->pb; + AVStream *st; + ArgoASFDemuxContext *asf = s->priv_data; + uint8_t buf[FFMAX(ASF_FILE_HEADER_SIZE, ASF_CHUNK_HEADER_SIZE)]; + + if (!(st = avformat_new_stream(s, NULL))) + return AVERROR(ENOMEM); + + if ((ret = avio_read(pb, buf, ASF_FILE_HEADER_SIZE)) < 0) + return ret; + else if (ret != ASF_FILE_HEADER_SIZE) + return AVERROR(EIO); + + argo_asf_parse_file_header(&asf->fhdr, buf); + + if (!argo_asf_is_known_version(&asf->fhdr)) { + avpriv_request_sample(s, "Version %hu.%hu", + asf->fhdr.version_major, asf->fhdr.version_minor + ); + return AVERROR_PATCHWELCOME; + } + + if (asf->fhdr.chunk_offset < ASF_FILE_HEADER_SIZE) + return AVERROR_INVALIDDATA; + + if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 0) + return ret; + + if ((ret = avio_read(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0) + return ret; + else if (ret != ASF_CHUNK_HEADER_SIZE) + return AVERROR(EIO); + + argo_asf_parse_chunk_header(&asf->ckhdr, buf); + + if ((asf->ckhdr.flags & ASF_CF_ALWAYS1) != ASF_CF_ALWAYS1 || (asf->ckhdr.flags & ASF_CF_ALWAYS0) != 0) { + avpriv_request_sample(s, "Nonstandard flags (0x%08X)", asf->ckhdr.flags); + return AVERROR_PATCHWELCOME; + } + + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_ADPCM_ARGO; + st->codecpar->format = AV_SAMPLE_FMT_S16; + + if (asf->ckhdr.flags & ASF_CF_STEREO) { + st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; + st->codecpar->channels = 2; + } else { + st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; + st->codecpar->channels = 1; + } + + st->codecpar->sample_rate = asf->ckhdr.sample_rate; + + st->codecpar->bits_per_coded_sample = 4; + + if (asf->ckhdr.flags & ASF_CF_BITS_PER_SAMPLE) + st->codecpar->bits_per_raw_sample = 16; + else + st->codecpar->bits_per_raw_sample = 8; + + if (st->codecpar->bits_per_raw_sample != 16) { + /* The header allows for these, but I've never seen any files with them. */ + avpriv_request_sample(s, "Non 16-bit samples"); + return AVERROR_PATCHWELCOME; + } + + /* + * (nchannel control bytes) + ((bytes_per_channel) * nchannel) + * For mono, this is 17. For stereo, this is 34. + */ + st->codecpar->frame_size = st->codecpar->channels + + (asf->ckhdr.num_samples / 2) * + st->codecpar->channels; + + st->codecpar->block_align = st->codecpar->frame_size; + + st->codecpar->bit_rate = st->codecpar->channels * + st->codecpar->sample_rate * + st->codecpar->bits_per_coded_sample; + + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + st->start_time = 0; + st->duration = asf->ckhdr.num_blocks * asf->ckhdr.num_samples; + st->nb_frames = asf->ckhdr.num_blocks; + return 0; +} + +static int argo_asf_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + ArgoASFDemuxContext *asf = s->priv_data; + + AVStream *st = s->streams[0]; + AVIOContext *pb = s->pb; + int ret; + + if (asf->blocks_read >= asf->ckhdr.num_blocks) + return AVERROR_EOF; + + if ((ret = av_get_packet(pb, pkt, st->codecpar->frame_size)) < 0) + return ret; + else if (ret != st->codecpar->frame_size) + return AVERROR_INVALIDDATA; + + pkt->stream_index = st->index; + pkt->duration = asf->ckhdr.num_samples; + + ++asf->blocks_read; + return 0; +} + +/* + * Not actually sure what ASF stands for. + * - Argonaut Sound File? + * - Audio Stream File? + */ +AVInputFormat ff_argo_asf_demuxer = { + .name = "argo_asf", + .long_name = NULL_IF_CONFIG_SMALL("Argonaut Games ASF"), + .priv_data_size = sizeof(ArgoASFDemuxContext), + .read_probe = argo_asf_probe, + .read_header = argo_asf_read_header, + .read_packet = argo_asf_read_packet +}; diff --git a/libavformat/version.h b/libavformat/version.h index 0a79868663..f72fb9478a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 35 -#define LIBAVFORMAT_VERSION_MICRO 103 +#define LIBAVFORMAT_VERSION_MINOR 36 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From patchwork Sun Jan 19 14:20:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 17421 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 5268144AF9C for ; Sun, 19 Jan 2020 16:20:17 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F1E268AE68; Sun, 19 Jan 2020 16:20:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CD0268AE56 for ; Sun, 19 Jan 2020 16:20:10 +0200 (EET) Date: Sun, 19 Jan 2020 14:20:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1579443609; bh=GoUVwqDPBOYHBiUOq2+tA7huDsijwD8o4QR8hs7RYK4=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=uN3svE+iB61szGz2/M7HmirFAjSoDh0bJ0JWVZCm34Vf0GtbZlI0o7hU6yJIhLcQN eMxyx6iUqHCkes2n03doPZ5ZRTB+Oo4rZVOF0weBsUhdBBJnypJCvwPloBjf1KOwNw L7wvai2b51gnLg9hHIuCQoBW7zu3z5+DfYb6hXlQ= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200119141945.16889-1-zane@zanevaniperen.com> Feedback-ID: xylLYHwBzJW7F28tHN-oL9EBm6h5yqtCqG6YwPpJ2oMwBYJT6-HxTnFTF6p18axLiSywX61iUfj4CElBGg8-GA==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=0.3 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_RHS_DOB shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 3/4] avcodec/adpcm_argo: formatting fixes 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 --- Changelog | 1 + libavcodec/adpcm_argo.c | 53 +++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Changelog b/Changelog index bc1593bfd1..65ef01c77d 100644 --- a/Changelog +++ b/Changelog @@ -33,6 +33,7 @@ version : - Argonaut Games ADPCM decoder - Argonaut Games ASF demuxer + version 4.2: - tpad filter - AV1 decoding support through libdav1d diff --git a/libavcodec/adpcm_argo.c b/libavcodec/adpcm_argo.c index d5b32e62ba..e6ebaac911 100644 --- a/libavcodec/adpcm_argo.c +++ b/libavcodec/adpcm_argo.c @@ -62,8 +62,7 @@ typedef int16_t *(*ADPCMDecoder) ( * Decoder 1: (prev0 + (s << (c + 2))) */ static int16_t *adpcm_decoder_1(uint8_t c, int16_t *dst, const uint8_t *src, - const int16_t *prev_, - int nsamples, int stride) + const int16_t *prev_, int nsamples, int stride) { int16_t prev; int8_t s; @@ -74,12 +73,12 @@ static int16_t *adpcm_decoder_1(uint8_t c, int16_t *dst, const uint8_t *src, prev = prev_[stride]; c += 2; - for (int i = 0; i < nsamples / 2; ++i, ++src) { - s = (int8_t) ((*src & 0xF0u) << 0u); + for (int i = 0; i < nsamples / 2; i++, src++) { + s = (int8_t)((*src & 0xF0u) << 0u); *dst = prev = ((prev << 6) + (s << c)) >> 6; dst += stride; - s = (int8_t) ((*src & 0x0Fu) << 4u); + s = (int8_t)((*src & 0x0Fu) << 4u); *dst = prev = ((prev << 6) + (s << c)) >> 6; dst += stride; } @@ -90,9 +89,8 @@ static int16_t *adpcm_decoder_1(uint8_t c, int16_t *dst, const uint8_t *src, /* * Decoder 2: (2 * prev0) - (1 * prev1) + (s << (c + 2)) */ -static int16_t *adpcm_decoder_2(uint8_t c, int16_t * dst, const uint8_t * src, - const int16_t * prev_, - int nsamples, int stride) +static int16_t *adpcm_decoder_2(uint8_t c, int16_t *dst, const uint8_t *src, + const int16_t *prev_, int nsamples, int stride) { int16_t cprev[2]; int8_t s; @@ -105,17 +103,17 @@ static int16_t *adpcm_decoder_2(uint8_t c, int16_t * dst, const uint8_t * src, cprev[1] = prev_[0]; c += 2; - for (int i = 0; i < nsamples / 2; ++i, ++src) { + for (int i = 0; i < nsamples / 2; i++, src++) { /* NB: (x << 7) == 2*(x << 6) */ - s = (int8_t) ((*src & 0xF0u) << 0u); + s = (int8_t)((*src & 0xF0u) << 0u); *dst = ((cprev[0] << 7) - (cprev[1] << 6) + (s << c)) >> 6; cprev[1] = cprev[0]; cprev[0] = *dst; dst += stride; - s = (int8_t) ((*src & 0x0Fu) << 4u); + s = (int8_t)((*src & 0x0Fu) << 4u); *dst = ((cprev[0] << 7) - (cprev[1] << 6) + (s << c)) >> 6; cprev[1] = cprev[0]; cprev[0] = *dst; @@ -154,16 +152,15 @@ static ADPCMDecoder adpcm_decoders[2] = { adpcm_decoder_1, adpcm_decoder_2 }; * @param nchannels The number of channels. Must be 1 or 2. */ static int16_t *adpcm_decode_block(int16_t *dst, const uint8_t *src, - const int16_t *prev, - int nsamples, int nchannels) + const int16_t *prev, int nsamples, int nchannels) { - unsigned char c; + uint8_t c; av_assert0(nsamples > 2 && (nsamples & 0x1) == 0); av_assert0(nchannels == 1 || nchannels == 2); /* NB: nsamples/2 because samples are 4 bits, not 8. */ - for (int i = 0; i < nchannels; ++i, src += nsamples / 2) { + for (int i = 0; i < nchannels; i++, src += nsamples / 2) { /* Get the control byte and run the samples through the decoder. */ c = *src++; adpcm_decoders[!!(c & 0x04)] (c >> 4, dst + i, src, prev + i, nsamples, nchannels - 1); @@ -173,8 +170,8 @@ static int16_t *adpcm_decode_block(int16_t *dst, const uint8_t *src, } -#define MAX_CHANNELS (2) -#define PREVIOUS_SAMPLE_COUNT (2) +#define MAX_CHANNELS 2 +#define PREVIOUS_SAMPLE_COUNT 2 typedef struct ADPCMArgoDecoderContext { int16_t prev[MAX_CHANNELS * PREVIOUS_SAMPLE_COUNT]; @@ -186,26 +183,26 @@ static av_cold int adpcm_decode_init(AVCodecContext *avctx) if (avctx->channels > MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Invalid channel count %d\n", avctx->channels); - return AVERROR(EINVAL); + return AVERROR_INVALIDDATA; } if (avctx->bits_per_coded_sample != 4) { av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", avctx->bits_per_coded_sample); - return AVERROR(EINVAL); + return AVERROR_INVALIDDATA; } avctx->sample_fmt = AV_SAMPLE_FMT_S16; - for (int i = 0; i < MAX_CHANNELS * PREVIOUS_SAMPLE_COUNT; ++i) + for (int i = 0; i < MAX_CHANNELS * PREVIOUS_SAMPLE_COUNT; i++) ctx->prev[i] = 0; return 0; } -static int adpcm_decode_frame(AVCodecContext * avctx, void *data, - int *got_frame_ptr, AVPacket * avpkt) +static int adpcm_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) { - int r; + int ret; AVFrame *frame = data; ADPCMArgoDecoderContext *argo = avctx->priv_data; int16_t *dst; @@ -214,7 +211,7 @@ static int adpcm_decode_frame(AVCodecContext * avctx, void *data, av_log(avctx, AV_LOG_WARNING, "unexpected mono packet size, expected 17, got %d\n", avpkt->size); - } else if(avctx->channels == 2 && avpkt->size != 34) { + } else if (avctx->channels == 2 && avpkt->size != 34) { av_log(avctx, AV_LOG_WARNING, "unexpected stereo packet size, expected 34, got %d\n", avpkt->size); @@ -224,14 +221,14 @@ static int adpcm_decode_frame(AVCodecContext * avctx, void *data, (8 / avctx->bits_per_coded_sample); /* get output buffer */ - if ((r = ff_get_buffer(avctx, frame, 0)) < 0) - return r; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; - dst = adpcm_decode_block((int16_t *) frame->data[0], avpkt->data, argo->prev, frame->nb_samples, avctx->channels); + dst = adpcm_decode_block((int16_t*)frame->data[0], avpkt->data, argo->prev, frame->nb_samples, avctx->channels); /* Save the previous samples for the next frame. */ r = avctx->channels * PREVIOUS_SAMPLE_COUNT; - for (int i = 0; i < r; ++i) + for (int i = 0; i < r; i++) argo->prev[i] = *(dst - (r - i)); *got_frame_ptr = 1; From patchwork Sun Jan 19 14:20:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 17422 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 4CDDA44AF9C for ; Sun, 19 Jan 2020 16:20:18 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 328E268B0ED; Sun, 19 Jan 2020 16:20:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 31B3D68B042 for ; Sun, 19 Jan 2020 16:20:11 +0200 (EET) Date: Sun, 19 Jan 2020 14:20:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1579443610; bh=+eiRT1nkH+nVFQh3ZRsDutMEm31blG4Y6ffVZUPnQ0o=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=k0XrNC3CCVyDvtF5tejqxhyF90qksDmpUVjtZNfVLRqjzRKrhpiuBnA5nc1+rbCRh IwakX4biGletjKcfoSN4IJDb23zeLrQoSiSbq5xwfBrpg6/f2cJB07ebM9M2pdHbkp fQlxWoac2SMp/0k/hit3VvdCGN1xaVupyzCDMfo0= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200119141945.16889-2-zane@zanevaniperen.com> Feedback-ID: xylLYHwBzJW7F28tHN-oL9EBm6h5yqtCqG6YwPpJ2oMwBYJT6-HxTnFTF6p18axLiSywX61iUfj4CElBGg8-GA==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=0.3 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_RHS_DOB shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 4/4] avformat/argo_asf: formatting fixes 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 --- libavformat/argo_asf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index d8f2d71009..d51d16f6b7 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -24,8 +24,8 @@ #include "libavutil/intreadwrite.h" #define ASF_TAG MKTAG('A', 'S', 'F', '\0') -#define ASF_FILE_HEADER_SIZE (24) -#define ASF_CHUNK_HEADER_SIZE (20) +#define ASF_FILE_HEADER_SIZE 24 +#define ASF_CHUNK_HEADER_SIZE 20 typedef struct ArgoASFFileHeader { uint32_t magic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ @@ -69,7 +69,7 @@ static void argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *bu hdr->version_minor = AV_RL16(buf + 6); hdr->num_chunks = AV_RL32(buf + 8); hdr->chunk_offset = AV_RL32(buf + 12); - for(int i = 0; i < 8; ++i) + for (int i = 0; i < 8; i++) hdr->name[i] = AV_RL8(buf + 16 + i); } @@ -110,7 +110,7 @@ static int argo_asf_probe(const AVProbeData *p) argo_asf_parse_file_header(&hdr, p->buf); - if(hdr.magic != ASF_TAG) + if (hdr.magic != ASF_TAG) return 0; if (argo_asf_is_known_version(&hdr))