[FFmpeg-devel] [PATCH] avcodec: add bink2 video decoder

James Almer jamrial at gmail.com
Sat Mar 21 06:11:23 EET 2020


On 3/20/2020 10:31 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  configure               |    1 +
>  libavcodec/Makefile     |    1 +
>  libavcodec/allcodecs.c  |    1 +
>  libavcodec/avcodec.h    |    1 +
>  libavcodec/bink2.c      |  869 ++++++++++++++++++++++++++++
>  libavcodec/bink2f.c     | 1125 ++++++++++++++++++++++++++++++++++++
>  libavcodec/bink2g.c     | 1197 +++++++++++++++++++++++++++++++++++++++
>  libavcodec/codec_desc.c |    7 +
>  libavformat/bink.c      |    3 +-
>  9 files changed, 3203 insertions(+), 2 deletions(-)
>  create mode 100644 libavcodec/bink2.c
>  create mode 100644 libavcodec/bink2f.c
>  create mode 100644 libavcodec/bink2g.c
> 
> diff --git a/configure b/configure
> index 18f2841765..1d89d49b41 100755
> --- a/configure
> +++ b/configure
> @@ -2678,6 +2678,7 @@ atrac3pal_decoder_select="mdct sinewin"
>  atrac9_decoder_select="mdct"
>  avrn_decoder_select="exif jpegtables"
>  bink_decoder_select="blockdsp hpeldsp"
> +bink2_decoder_select="blockdsp"
>  binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
>  binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
>  cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index c1c9a44f2b..a79b4c6524 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -230,6 +230,7 @@ OBJS-$(CONFIG_AYUV_ENCODER)            += v408enc.o
>  OBJS-$(CONFIG_BETHSOFTVID_DECODER)     += bethsoftvideo.o
>  OBJS-$(CONFIG_BFI_DECODER)             += bfi.o
>  OBJS-$(CONFIG_BINK_DECODER)            += bink.o binkdsp.o
> +OBJS-$(CONFIG_BINK2_DECODER)           += bink2.o
>  OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER)   += binkaudio.o
>  OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER)  += binkaudio.o
>  OBJS-$(CONFIG_BINTEXT_DECODER)         += bintext.o cga_data.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index b3184af954..d032547a9d 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -60,6 +60,7 @@ extern AVCodec ff_ayuv_decoder;
>  extern AVCodec ff_bethsoftvid_decoder;
>  extern AVCodec ff_bfi_decoder;
>  extern AVCodec ff_bink_decoder;
> +extern AVCodec ff_bink2_decoder;
>  extern AVCodec ff_bitpacked_decoder;
>  extern AVCodec ff_bmp_encoder;
>  extern AVCodec ff_bmp_decoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 78c483c25c..e8b20fa527 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -463,6 +463,7 @@ enum AVCodecID {
>      AV_CODEC_ID_MVDV,
>      AV_CODEC_ID_MVHA,
>      AV_CODEC_ID_CDTOONS,
> +    AV_CODEC_ID_BINKVIDEO2,
>  
>      /* various PCM "codecs" */
>      AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
> diff --git a/libavcodec/bink2.c b/libavcodec/bink2.c
> new file mode 100644
> index 0000000000..0ebce7feeb
> --- /dev/null
> +++ b/libavcodec/bink2.c
> @@ -0,0 +1,869 @@
> +/*
> + * Bink video 2 decoder
> + * Copyright (c) 2014 Konstantin Shishkov
> + * Copyright (c) 2019 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/avassert.h"
> +#include "libavutil/attributes.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/internal.h"
> +#include "avcodec.h"
> +#include "blockdsp.h"
> +#include "copy_block.h"
> +#include "idctdsp.h"

Seems unused.

> +#include "internal.h"
> +#include "mathops.h"
> +
> +#define BITSTREAM_READER_LE
> +#include "get_bits.h"
> +#include "unary.h"

[...]

> +#include "bink2f.c"
> +#include "bink2g.c"

You should compile these separately, and share the functions that are
directly called in bink2.c
Also, move the bink2f and bink2g tables to their corresponding files.


More information about the ffmpeg-devel mailing list