[FFmpeg-devel] [PATCH] lavf: add avs2 demuxer
Michael Niedermayer
michael at niedermayer.cc
Wed Aug 1 03:43:33 EEST 2018
On Tue, Jul 31, 2018 at 11:02:20PM +0800, hwren wrote:
> Signed-off-by: hwren <hwrenx at 126.com>
> ---
> libavformat/Makefile | 1 +
> libavformat/allformats.c | 1 +
> libavformat/davs2.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 66 insertions(+)
> create mode 100644 libavformat/davs2.c
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index f2f3aab..c4534b8 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -110,6 +110,7 @@ OBJS-$(CONFIG_AST_DEMUXER) += ast.o astdec.o
> OBJS-$(CONFIG_AST_MUXER) += ast.o astenc.o
> OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o
> OBJS-$(CONFIG_AU_MUXER) += au.o rawenc.o
> +OBJS-$(CONFIG_AVS2_DEMUXER) += davs2.o rawdec.o
> OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o
> OBJS-$(CONFIG_AVI_MUXER) += avienc.o mpegtsenc.o avlanguage.o rawutils.o
> OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o swf.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index adcc8d9..38eaeea 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -76,6 +76,7 @@ extern AVInputFormat ff_avisynth_demuxer;
> extern AVOutputFormat ff_avm2_muxer;
> extern AVInputFormat ff_avr_demuxer;
> extern AVInputFormat ff_avs_demuxer;
> +extern AVInputFormat ff_avs2_demuxer;
> extern AVInputFormat ff_bethsoftvid_demuxer;
> extern AVInputFormat ff_bfi_demuxer;
> extern AVInputFormat ff_bintext_demuxer;
> diff --git a/libavformat/davs2.c b/libavformat/davs2.c
> new file mode 100644
> index 0000000..8c90fd8
> --- /dev/null
> +++ b/libavformat/davs2.c
> @@ -0,0 +1,64 @@
> +/*
> + * AVS2 video stream probe.
> + *
> + * Copyright (C) 2018 Huiwen Ren, <hwrenx at 126.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 "rawdec.h"
> +#include "libavcodec/internal.h"
> +#include "libavutil/intreadwrite.h"
> +
> +#define ISSQH(x) ((x) == 0xB0 )
> +#define ISEND(x) ((x) == 0xB1 )
> +#define ISPIC(x) ((x) == 0xB3 || (x) == 0xB6)
> +#define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 0xB5 || (x) == 0xB7 )
> +#define ISAVS2(x) ((x) == 0x12 || (x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 )
> +
> +static int avs2_probe(AVProbeData *p)
> +{
> + uint32_t code= -1;
> + uint8_t state=0;
> + const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0;
> +
> + while (ptr < end) {
> + ptr = avpriv_find_start_code(ptr, end, &code);
> + state = code & 0xFF;
> + if ((code & 0xffffff00) == 0x100) {
> + if (ISUNIT(state)) {
> + if (sqb) {
> + break;
> + }
> + if (ISSQH(state)) {
> + if (!ISAVS2(*ptr))
> + return 0;
> + sqb = ptr;
> + } else if (ISEND(state)) {
> + return 0;
> + }
> + }
> + }
> + }
> + if (sqb && ptr-sqb >= 21){
> + return AVPROBE_SCORE_EXTENSION+2;
> + }
> + return 0;
> +}
this fails
tools/probetest 256 4096
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180801/4f1617fe/attachment.sig>
More information about the ffmpeg-devel
mailing list