[FFmpeg-devel] [PATCH 2/2] ADP demuxer

Michael Niedermayer michaelni at gmx.at
Sat Apr 20 22:01:23 CEST 2013


On Sat, Apr 20, 2013 at 12:03:21AM -0300, James Almer wrote:
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  Changelog                |  1 +
>  doc/general.texi         |  2 ++
>  libavformat/Makefile     |  1 +
>  libavformat/adp.c        | 86 ++++++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/allformats.c |  1 +
>  libavformat/version.h    |  2 +-
>  6 files changed, 92 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/adp.c
> 
> diff --git a/Changelog b/Changelog
> index 967792c..dfa1819 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -29,6 +29,7 @@ version <next>:
>    become the default at the next libavformat major bump.
>  - decent native animated GIF encoding
>  - ADPCM DTK decoder
> +- ADP demuxer
>  
>  
>  version 1.2:
> diff --git a/doc/general.texi b/doc/general.texi
> index 215abe6..6bb3603 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -147,6 +147,8 @@ library:
>      @tab Multimedia format used in game Heart Of Darkness.
>  @item Apple HTTP Live Streaming @tab   @tab X
>  @item Artworx Data Format       @tab   @tab X
> + at item ADP                       @tab   @tab X
> +    @tab Audio format used on the Nintendo Gamecube.
>  @item AFC                       @tab   @tab X
>      @tab Audio format used on the Nintendo Gamecube.
>  @item ASF                       @tab X @tab X
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 470e7f3..26c0944 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -55,6 +55,7 @@ OBJS-$(CONFIG_AC3_DEMUXER)               += ac3dec.o rawdec.o
>  OBJS-$(CONFIG_AC3_MUXER)                 += rawenc.o
>  OBJS-$(CONFIG_ACT_DEMUXER)               += act.o
>  OBJS-$(CONFIG_ADF_DEMUXER)               += bintext.o sauce.o
> +OBJS-$(CONFIG_ADP_DEMUXER)               += adp.o
>  OBJS-$(CONFIG_ADX_DEMUXER)               += adxdec.o
>  OBJS-$(CONFIG_ADX_MUXER)                 += rawenc.o
>  OBJS-$(CONFIG_ADTS_MUXER)                += adtsenc.o
> diff --git a/libavformat/adp.c b/libavformat/adp.c
> new file mode 100644
> index 0000000..398f2b6
> --- /dev/null
> +++ b/libavformat/adp.c
> @@ -0,0 +1,86 @@
> +/*
> + * ADP demuxer
> + * Copyright (c) 2013 James Almer
> + *
> + * 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 "libavutil/channel_layout.h"
> +#include "libavutil/intreadwrite.h"
> +#include "avformat.h"
> +#include "internal.h"
> +
> +typedef struct ADPDemuxContext {
> +    int64_t    filesize;
> +} ADPDemuxContext;
> +
> +static int adp_probe(AVProbeData *p)
> +{
> +    if (p->buf[0] == p->buf[2] && p->buf[1] == p->buf[3])
> +        return AVPROBE_SCORE_MAX / 3;
> +    return 0;
> +}

does this pass tools/probetest ?

also if there are multiple adpcm "packets" then more could maybe be
checked


> +
> +static int adp_read_header(AVFormatContext *s)
> +{
> +    ADPDemuxContext *adp = s->priv_data;
> +    AVStream *st;
> +
> +    st = avformat_new_stream(s, NULL);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +
> +    adp->filesize = avio_size(s->pb);
> +    st->codec->codec_type     = AVMEDIA_TYPE_AUDIO;
> +    st->codec->codec_id       = AV_CODEC_ID_ADPCM_DTK;
> +    st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
> +    st->codec->channels       = 2;
> +    st->codec->sample_rate    = 48000;
> +    st->start_time            = 0;
> +    st->duration              = adp->filesize / 32 * 28;
> +
> +    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
> +
> +    return 0;
> +}
> +
> +static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    ADPDemuxContext *adp = s->priv_data;
> +    int ret, size = FFMIN(adp->filesize, 32 * 1024);

this will fail with pipes and things where a filesize cannot be
determined

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130420/26703170/attachment.asc>


More information about the ffmpeg-devel mailing list