[FFmpeg-devel] [PATCH 2/2] avformat: add vag demuxer

Michael Niedermayer michael at niedermayer.cc
Tue Oct 13 20:34:59 CEST 2015


On Tue, Oct 13, 2015 at 03:07:36PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libavformat/Makefile     |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/vag.c        | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 80 insertions(+)
>  create mode 100644 libavformat/vag.c
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 2971912..c2170c8 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -440,6 +440,7 @@ OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o apetag.o img2.o
>  OBJS-$(CONFIG_TTY_DEMUXER)               += tty.o sauce.o
>  OBJS-$(CONFIG_TXD_DEMUXER)               += txd.o
>  OBJS-$(CONFIG_UNCODEDFRAMECRC_MUXER)     += uncodedframecrcenc.o framehash.o
> +OBJS-$(CONFIG_VAG_DEMUXER)               += vag.o
>  OBJS-$(CONFIG_VC1_DEMUXER)               += rawdec.o
>  OBJS-$(CONFIG_VC1_MUXER)                 += rawenc.o
>  OBJS-$(CONFIG_VC1T_DEMUXER)              += vc1test.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 0ccde9d..f732611 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -307,6 +307,7 @@ void av_register_all(void)
>      REGISTER_DEMUXER (TXD,              txd);
>      REGISTER_DEMUXER (TTY,              tty);
>      REGISTER_MUXER   (UNCODEDFRAMECRC,  uncodedframecrc);
> +    REGISTER_DEMUXER (VAG,              vag);
>      REGISTER_MUXDEMUX(VC1,              vc1);
>      REGISTER_MUXDEMUX(VC1T,             vc1t);
>      REGISTER_DEMUXER (VIVO,             vivo);
> diff --git a/libavformat/vag.c b/libavformat/vag.c
> new file mode 100644
> index 0000000..e40159f
> --- /dev/null
> +++ b/libavformat/vag.c
> @@ -0,0 +1,78 @@
> +/*
> + * VAG demuxer
> + * Copyright (c) 2015 Paul B Mahol
> + *
> + * 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 "avformat.h"
> +#include "internal.h"
> +
> +static int vag_probe(AVProbeData *p)
> +{
> +    if (memcmp(p->buf, "VAGp", 4))
> +        return 0;
> +
> +    return AVPROBE_SCORE_MAX / 3 * 2;
> +}
> +
> +static int vag_read_header(AVFormatContext *s)
> +{
> +    AVStream *st;
> +
> +    st = avformat_new_stream(s, NULL);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +
> +    avio_skip(s->pb, 4);
> +    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
> +    st->codec->codec_id    = AV_CODEC_ID_ADPCM_PSX;
> +    st->codec->channels    = 1 + (avio_rb32(s->pb) == 0x00000004);
> +    avio_skip(s->pb, 4);
> +    st->duration           = avio_rb32(s->pb) / 16 * 28;
> +    st->codec->sample_rate = avio_rb32(s->pb);
> +    if (st->codec->sample_rate <= 0)
> +        return AVERROR_INVALIDDATA;
> +    avio_skip(s->pb, 28);
> +    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
> +
> +    return 0;
> +}
> +
> +static int vag_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    int ret;
> +
> +    if (avio_feof(s->pb))
> +        return AVERROR_EOF;
> +
> +    ret = av_get_packet(s->pb, pkt, 1024);

> +    if (ret > 0 && ret < 1024)
> +        av_shrink_packet(pkt, ret);

isnt that redundant ?
either way patch LGTM

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151013/51eaeef2/attachment.sig>


More information about the ffmpeg-devel mailing list