FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
vc2enc.c File Reference
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "dirac.h"
#include "put_bits.h"
#include "internal.h"
#include "version.h"
#include "vc2enc_dwt.h"
#include "diractab.h"

Go to the source code of this file.

Data Structures

struct  VC2BaseVideoFormat
 
struct  SubBand
 
struct  Plane
 
struct  SliceArgs
 
struct  TransformArgs
 
struct  VC2EncContext
 

Macros

#define SSIZE_ROUND(b)   (FFALIGN((b), s->size_scaler) + 4 + s->prefix_bytes)
 
#define SLICE_REDIST_TOTAL   150
 
#define QUANT(c, mul, add, shift)   (((mul) * (c) + (add)) >> (shift))
 
#define VC2ENC_FLAGS   (AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Enumerations

enum  VC2_QM { VC2_QM_DEF = 0, VC2_QM_COL, VC2_QM_FLAT, VC2_QM_NB }
 

Functions

static av_always_inline void put_vc2_ue_uint (PutBitContext *pb, uint32_t val)
 
static av_always_inline int count_vc2_ue_uint (uint32_t val)
 
static void encode_parse_info (VC2EncContext *s, enum DiracParseCodes pcode)
 
static void encode_parse_params (VC2EncContext *s)
 
static void encode_frame_size (VC2EncContext *s)
 
static void encode_sample_fmt (VC2EncContext *s)
 
static void encode_scan_format (VC2EncContext *s)
 
static void encode_frame_rate (VC2EncContext *s)
 
static void encode_aspect_ratio (VC2EncContext *s)
 
static void encode_clean_area (VC2EncContext *s)
 
static void encode_signal_range (VC2EncContext *s)
 
static void encode_color_spec (VC2EncContext *s)
 
static void encode_source_params (VC2EncContext *s)
 
static void encode_seq_header (VC2EncContext *s)
 
static void encode_picture_header (VC2EncContext *s)
 
static void encode_slice_params (VC2EncContext *s)
 
static void init_quant_matrix (VC2EncContext *s)
 
static void encode_quant_matrix (VC2EncContext *s)
 
static void encode_transform_params (VC2EncContext *s)
 
static void encode_wavelet_transform (VC2EncContext *s)
 
static void encode_picture_start (VC2EncContext *s)
 
static void encode_subband (VC2EncContext *s, PutBitContext *pb, int sx, int sy, SubBand *b, int quant)
 
static int count_hq_slice (SliceArgs *slice, int quant_idx)
 
static int rate_control (AVCodecContext *avctx, void *arg)
 
static int calc_slice_sizes (VC2EncContext *s)
 
static int encode_hq_slice (AVCodecContext *avctx, void *arg)
 
static int encode_slices (VC2EncContext *s)
 
static int dwt_plane (AVCodecContext *avctx, void *arg)
 
static int encode_frame (VC2EncContext *s, AVPacket *avpkt, const AVFrame *frame, const char *aux_data, const int header_size, int field)
 
static av_cold int vc2_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet)
 
static av_cold int vc2_encode_end (AVCodecContext *avctx)
 
static av_cold int vc2_encode_init (AVCodecContext *avctx)
 

Variables

static const VC2BaseVideoFormat base_video_fmts []
 
static const int base_video_fmts_len = FF_ARRAY_ELEMS(base_video_fmts)
 
const uint8_t vc2_qm_col_tab [][4]
 
const uint8_t vc2_qm_flat_tab [][4]
 
static const AVOption vc2enc_options []
 
static const AVClass vc2enc_class
 
static const AVCodecDefault vc2enc_defaults []
 
static enum AVPixelFormat allowed_pix_fmts []
 
AVCodec ff_vc2_encoder
 

Macro Definition Documentation

#define SSIZE_ROUND (   b)    (FFALIGN((b), s->size_scaler) + 4 + s->prefix_bytes)

Definition at line 33 of file vc2enc.c.

Referenced by calc_slice_sizes(), rate_control(), and vc2_encode_frame().

#define SLICE_REDIST_TOTAL   150

Definition at line 36 of file vc2enc.c.

Referenced by calc_slice_sizes().

#define QUANT (   c,
  mul,
  add,
  shift 
)    (((mul) * (c) + (add)) >> (shift))

Definition at line 524 of file vc2enc.c.

Referenced by count_hq_slice(), and encode_subband().

#define VC2ENC_FLAGS   (AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)

Definition at line 1190 of file vc2enc.c.

Enumeration Type Documentation

enum VC2_QM
Enumerator
VC2_QM_DEF 
VC2_QM_COL 
VC2_QM_FLAT 
VC2_QM_NB 

Definition at line 78 of file vc2enc.c.

Function Documentation

static av_always_inline void put_vc2_ue_uint ( PutBitContext pb,
uint32_t  val 
)
static
static av_always_inline int count_vc2_ue_uint ( uint32_t  val)
static

Definition at line 211 of file vc2enc.c.

Referenced by count_hq_slice().

static void encode_parse_info ( VC2EncContext s,
enum DiracParseCodes  pcode 
)
static

Definition at line 228 of file vc2enc.c.

Referenced by encode_frame().

static void encode_parse_params ( VC2EncContext s)
static

Definition at line 260 of file vc2enc.c.

Referenced by encode_seq_header().

static void encode_frame_size ( VC2EncContext s)
static

Definition at line 269 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_sample_fmt ( VC2EncContext s)
static

Definition at line 280 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_scan_format ( VC2EncContext s)
static

Definition at line 296 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_frame_rate ( VC2EncContext s)
static

Definition at line 304 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_aspect_ratio ( VC2EncContext s)
static

Definition at line 316 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_clean_area ( VC2EncContext s)
static

Definition at line 328 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_signal_range ( VC2EncContext s)
static

Definition at line 334 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_color_spec ( VC2EncContext s)
static

Definition at line 342 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_source_params ( VC2EncContext s)
static

Definition at line 387 of file vc2enc.c.

Referenced by encode_seq_header().

static void encode_seq_header ( VC2EncContext s)
static

Definition at line 400 of file vc2enc.c.

Referenced by encode_frame().

static void encode_picture_header ( VC2EncContext s)
static

Definition at line 410 of file vc2enc.c.

Referenced by encode_picture_start().

static void encode_slice_params ( VC2EncContext s)
static

Definition at line 417 of file vc2enc.c.

Referenced by encode_transform_params().

static void init_quant_matrix ( VC2EncContext s)
static

Definition at line 442 of file vc2enc.c.

Referenced by calc_slice_sizes().

static void encode_quant_matrix ( VC2EncContext s)
static

Definition at line 484 of file vc2enc.c.

Referenced by encode_transform_params().

static void encode_transform_params ( VC2EncContext s)
static

Definition at line 499 of file vc2enc.c.

Referenced by encode_wavelet_transform().

static void encode_wavelet_transform ( VC2EncContext s)
static

Definition at line 509 of file vc2enc.c.

Referenced by encode_picture_start().

static void encode_picture_start ( VC2EncContext s)
static

Definition at line 516 of file vc2enc.c.

Referenced by encode_frame().

static void encode_subband ( VC2EncContext s,
PutBitContext pb,
int  sx,
int  sy,
SubBand b,
int  quant 
)
static

Definition at line 527 of file vc2enc.c.

Referenced by encode_hq_slice().

static int count_hq_slice ( SliceArgs slice,
int  quant_idx 
)
static

Definition at line 553 of file vc2enc.c.

Referenced by calc_slice_sizes(), and rate_control().

static int rate_control ( AVCodecContext avctx,
void arg 
)
static

Definition at line 615 of file vc2enc.c.

Referenced by calc_slice_sizes().

static int calc_slice_sizes ( VC2EncContext s)
static

Definition at line 643 of file vc2enc.c.

Referenced by encode_frame().

static int encode_hq_slice ( AVCodecContext avctx,
void arg 
)
static

Definition at line 721 of file vc2enc.c.

Referenced by encode_slices().

static int encode_slices ( VC2EncContext s)
static

Definition at line 777 of file vc2enc.c.

Referenced by encode_frame().

static int dwt_plane ( AVCodecContext avctx,
void arg 
)
static

Definition at line 838 of file vc2enc.c.

Referenced by encode_frame().

static int encode_frame ( VC2EncContext s,
AVPacket avpkt,
const AVFrame frame,
const char *  aux_data,
const int  header_size,
int  field 
)
static

Definition at line 895 of file vc2enc.c.

Referenced by vc2_encode_frame().

static av_cold int vc2_encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int got_packet 
)
static

Definition at line 949 of file vc2enc.c.

static av_cold int vc2_encode_end ( AVCodecContext avctx)
static

Definition at line 1002 of file vc2enc.c.

Referenced by vc2_encode_init().

static av_cold int vc2_encode_init ( AVCodecContext avctx)
static

Definition at line 1019 of file vc2enc.c.

Variable Documentation

const VC2BaseVideoFormat base_video_fmts[]
static

Definition at line 45 of file vc2enc.c.

const int base_video_fmts_len = FF_ARRAY_ELEMS(base_video_fmts)
static

Definition at line 76 of file vc2enc.c.

Referenced by vc2_encode_init().

const uint8_t vc2_qm_col_tab[][4]
Initial value:
= {
{20, 9, 15, 4},
{ 0, 6, 6, 4},
{ 0, 3, 3, 5},
{ 0, 3, 5, 1},
{ 0, 11, 10, 11}
}

Definition at line 426 of file vc2enc.c.

Referenced by init_quant_matrix().

const uint8_t vc2_qm_flat_tab[][4]
Initial value:
= {
{ 0, 0, 0, 0},
{ 0, 0, 0, 0},
{ 0, 0, 0, 0},
{ 0, 0, 0, 0},
{ 0, 0, 0, 0}
}

Definition at line 434 of file vc2enc.c.

Referenced by init_quant_matrix().

const AVOption vc2enc_options[]
static
Initial value:
= {
{"tolerance", "Max undershoot in percent", 0x42, AV_OPT_TYPE_DOUBLE, {.dbl = 5.0f}, 0.0f, 45.0f, VC2ENC_FLAGS, "tolerance"},
{"slice_width", "Slice width", 0x42, AV_OPT_TYPE_INT, {.i64 = 32}, 32, 1024, VC2ENC_FLAGS, "slice_width"},
{"slice_height", "Slice height", 0x42, AV_OPT_TYPE_INT, {.i64 = 16}, 8, 1024, VC2ENC_FLAGS, "slice_height"},
{"wavelet_depth", "Transform depth", 0x42, AV_OPT_TYPE_INT, {.i64 = 4}, 1, 5, VC2ENC_FLAGS, "wavelet_depth"},
{"wavelet_type", "Transform type", 0x42, AV_OPT_TYPE_INT, {.i64 = VC2_TRANSFORM_9_7}, 0, VC2_TRANSFORMS_NB, VC2ENC_FLAGS, "wavelet_idx"},
{"9_7", "Deslauriers-Dubuc (9,7)", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_TRANSFORM_9_7}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "wavelet_idx"},
{"5_3", "LeGall (5,3)", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_TRANSFORM_5_3}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "wavelet_idx"},
{"haar", "Haar (with shift)", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_TRANSFORM_HAAR_S}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "wavelet_idx"},
{"haar_noshift", "Haar (without shift)", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_TRANSFORM_HAAR}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "wavelet_idx"},
{"qm", "Custom quantization matrix", 0x42, AV_OPT_TYPE_INT, {.i64 = VC2_QM_DEF}, 0, VC2_QM_NB, VC2ENC_FLAGS, "quant_matrix"},
{"default", "Default from the specifications", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_QM_DEF}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "quant_matrix"},
{"color", "Prevents low bitrate discoloration", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_QM_COL}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "quant_matrix"},
{"flat", "Optimize for PSNR", 0, AV_OPT_TYPE_CONST, {.i64 = VC2_QM_FLAT}, INT_MIN, INT_MAX, VC2ENC_FLAGS, "quant_matrix"},
{NULL}
}
#define NULL
Definition: coverity.c:32
#define VC2ENC_FLAGS
Definition: vc2enc.c:1190

Definition at line 1191 of file vc2enc.c.

const AVClass vc2enc_class
static
Initial value:
= {
.class_name = "SMPTE VC-2 encoder",
.option = vc2enc_options,
.item_name = av_default_item_name,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption vc2enc_options[]
Definition: vc2enc.c:1191

Definition at line 1208 of file vc2enc.c.

const AVCodecDefault vc2enc_defaults[]
static
Initial value:
= {
{ "b", "600000000" },
{ NULL },
}
#define NULL
Definition: coverity.c:32

Definition at line 1216 of file vc2enc.c.

enum AVPixelFormat allowed_pix_fmts[]
static
Initial value:
= {
}
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:373
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:368
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62

Definition at line 1221 of file vc2enc.c.

AVCodec ff_vc2_encoder
Initial value:
= {
.name = "vc2",
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-2"),
.priv_data_size = sizeof(VC2EncContext),
.close = vc2_encode_end,
.capabilities = AV_CODEC_CAP_SLICE_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
.encode2 = vc2_encode_frame,
.priv_class = &vc2enc_class,
}
static av_cold int vc2_encode_init(AVCodecContext *avctx)
Definition: vc2enc.c:1019
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int vc2_encode_end(AVCodecContext *avctx)
Definition: vc2enc.c:1002
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet)
Definition: vc2enc.c:949
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVCodecDefault vc2enc_defaults[]
Definition: vc2enc.c:1216
static const AVCodecDefault defaults[]
Definition: amfenc_h264.c:361
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:1019
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
static enum AVPixelFormat allowed_pix_fmts[]
Definition: vc2enc.c:1221
static const AVClass vc2enc_class
Definition: vc2enc.c:1208

Definition at line 1228 of file vc2enc.c.