[FFmpeg-devel] [PATCH 3/4] avcodec: add a native SMPTE VC-2 encoder

Michael Niedermayer michael at niedermayer.cc
Tue Feb 2 14:58:10 CET 2016


On Tue, Feb 02, 2016 at 12:35:29PM +0000, Rostislav Pehlivanov wrote:
> A new revision of the 'Dirac' encoder previously submitted.
> 
> Changes from previous version:
>     - Rename to vc2
>     - Fix an out of array bound read on setting quantization matrices
> 
> Original commit message:
> 
> This commit adds a new encoder capable of creating SMPTE Dirac/VC-2 HQ
> profile files.
> 
> Dirac is a wavelet based codec created by the BBC a little more than 10
> years ago. Since then, wavelets have mostly gone out of style as they
> did not provide adequate encoding gains at lower bitrates. Dirac was a
> fully featured video codec equipped with perceptual masking, support for
> most popular pixel formats, interlacing, overlapped-block motion
> compensation, and other features. It found new life after being stripped
> of various features and standardized as the VC-2 codec by the SMPTE with
> an extra profile, the HQ profile that this encoder supports, added.
> 
> The HQ profile was based off of the Low-Delay profile previously
> existing in Dirac. The profile forbids DC prediction and arithmetic
> coding to focus on high performance and low delay at higher bitrates.
> The standard bitrates for this profile vary but generally 1:4
> compression is expected (~525 Mbps vs the 2200 Mbps for uncompressed
> 1080p50). The codec only supports I-frames, hence the high bitrates.
> 
> The structure of this encoder is simple: do a DWT transform on the
> entire image, split it into multiple slices (specified by the user) and
> encode them in parallel. All of the slices are of the same size, making
> rate control and threading very trivial. Although only in C, this
> encoder
> is capable of 30 frames per second on an 4 core 8 threads Ivy Bridge.
> A lookup table is used to encode most of the coefficients.
> 
> No code was used from the GSoC encoder from 2007 except for the 2
> transform functions in diracenc_transforms.c. All other code was written
> from scratch.
> 
> This encoder outperforms any other encoders in quality, usability and in
> features. Other existing implementations do not support 4 level
> transforms or 64x64 blocks (slices), which greatly increase compression.
> 
> As previously said, the codec is meant for broadcasting, hence support
> for non-broadcasting image widths, heights, bit depths, aspect ratios,
> etc. are limited by the "level". Although this codec supports a few
> chroma subsamplings (420, 422, 444), signalling those is generally
> outside the specifications of the level used (3) and the reference
> decoder will outright refuse to read any image with such a flag
> signalled (it only supports 1920x1080 yuv422p10). However, most
> implementations will happily read files with alternate dimensions,
> framerates and formats signalled.
> 
> Therefore, in order to encode files other than 1080p50 yuv422p10le, you
> need to provide an "-strict -2" argument to the command line. The FFmpeg
> decoder will happily read any files made with non-standard parameters,
> dimensions and subsamplings, and so will other implementations. IMO this
> should be "-strict -1", but I'll leave that up for discussion.
> 
> There are still plenty of stuff to implement, for instance 5 more
> wavelet transforms are still in the specs and supported by the decoder.
> 
> Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
> ---
>  libavcodec/Makefile     |    1 +
>  libavcodec/allcodecs.c  |    1 +
>  libavcodec/vc2enc.c     | 1154 +++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/vc2enc_dwt.c |  234 ++++++++++
>  libavcodec/vc2enc_dwt.h |   54 +++
>  5 files changed, 1444 insertions(+)
>  create mode 100644 libavcodec/vc2enc.c
>  create mode 100644 libavcodec/vc2enc_dwt.c
>  create mode 100644 libavcodec/vc2enc_dwt.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 941057b..f6a4fbb 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -543,6 +543,7 @@ OBJS-$(CONFIG_VC1_DECODER)             += vc1dec.o vc1_block.o vc1_loopfilter.o
>                                            wmv2dsp.o
>  OBJS-$(CONFIG_VC1_MMAL_DECODER)        += mmaldec.o
>  OBJS-$(CONFIG_VC1_QSV_DECODER)         += qsvdec_vc1.o
> +OBJS-$(CONFIG_VC2_ENCODER)             += vc2enc.o vc2enc_dwt.o diractab.o
>  OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
>  OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdaudio.o
>  OBJS-$(CONFIG_VMDVIDEO_DECODER)        += vmdvideo.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index c7c1af5..2097db0 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -336,6 +336,7 @@ void avcodec_register_all(void)
>      REGISTER_DECODER(VC1IMAGE,          vc1image);
>      REGISTER_DECODER(VC1_MMAL,          vc1_mmal);
>      REGISTER_DECODER(VC1_QSV,           vc1_qsv);
> +    REGISTER_ENCODER(VC2,               vc2);
>      REGISTER_DECODER(VCR1,              vcr1);
>      REGISTER_DECODER(VMDVIDEO,          vmdvideo);
>      REGISTER_DECODER(VMNC,              vmnc);
> diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
> new file mode 100644
> index 0000000..afafe42
> --- /dev/null
> +++ b/libavcodec/vc2enc.c
> @@ -0,0 +1,1154 @@
> +/*
> + * Copyright (C) 2016 Open Broadcast Systems Ltd.
> + * Author    (C) 2016 Rostislav Pehlivanov <atomnuker at gmail.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 "libavutil/ffversion.h"
> +#include "libavutil/pixdesc.h"
> +#include "libavutil/opt.h"
> +#include "dirac.h"
> +#include "put_bits.h"
> +#include "internal.h"
> +
> +#include "vc2enc_dwt.h"

> +#include "diractab.h"

src/libavcodec/diracdec.c:40:22: fatal error: diractab.h: No such file or directory

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- 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/20160202/eefad8b5/attachment.sig>


More information about the ffmpeg-devel mailing list