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 MAX_QUANT_INDEX   FF_ARRAY_ELEMS(ff_dirac_qscale_tab)
 
#define COEF_LUT_TAB   2048
 
#define SSIZE_ROUND(b)   (FFALIGN((b), s->size_scaler) + 4 + s->prefix_bytes)
 
#define SLICE_REDIST_TOTAL   150
 
#define QUANT(c, qf)   (((c) << 2)/(qf))
 
#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 av_always_inline void get_vc2_ue_uint (int val, uint8_t *nbits, uint32_t *eval)
 
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 MAX_QUANT_INDEX   FF_ARRAY_ELEMS(ff_dirac_qscale_tab)

Definition at line 33 of file vc2enc.c.

Referenced by vc2_encode_init().

#define COEF_LUT_TAB   2048

Definition at line 37 of file vc2enc.c.

Referenced by count_hq_slice(), encode_subband(), and vc2_encode_init().

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

Definition at line 40 of file vc2enc.c.

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

#define SLICE_REDIST_TOTAL   150

Definition at line 43 of file vc2enc.c.

Referenced by calc_slice_sizes().

#define QUANT (   c,
  qf 
)    (((c) << 2)/(qf))

Definition at line 562 of file vc2enc.c.

Referenced by count_hq_slice(), encode_subband(), and vc2_encode_init().

#define VC2ENC_FLAGS   (AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)

Definition at line 1240 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 85 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 218 of file vc2enc.c.

Referenced by count_hq_slice().

static av_always_inline void get_vc2_ue_uint ( int  val,
uint8_t nbits,
uint32_t *  eval 
)
static

Definition at line 234 of file vc2enc.c.

Referenced by vc2_encode_init().

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

Definition at line 266 of file vc2enc.c.

Referenced by encode_frame().

static void encode_parse_params ( VC2EncContext s)
static

Definition at line 298 of file vc2enc.c.

Referenced by encode_seq_header().

static void encode_frame_size ( VC2EncContext s)
static

Definition at line 307 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_sample_fmt ( VC2EncContext s)
static

Definition at line 318 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_scan_format ( VC2EncContext s)
static

Definition at line 334 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_frame_rate ( VC2EncContext s)
static

Definition at line 342 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_aspect_ratio ( VC2EncContext s)
static

Definition at line 354 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_clean_area ( VC2EncContext s)
static

Definition at line 366 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_signal_range ( VC2EncContext s)
static

Definition at line 372 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_color_spec ( VC2EncContext s)
static

Definition at line 380 of file vc2enc.c.

Referenced by encode_source_params().

static void encode_source_params ( VC2EncContext s)
static

Definition at line 425 of file vc2enc.c.

Referenced by encode_seq_header().

static void encode_seq_header ( VC2EncContext s)
static

Definition at line 438 of file vc2enc.c.

Referenced by encode_frame().

static void encode_picture_header ( VC2EncContext s)
static

Definition at line 448 of file vc2enc.c.

Referenced by encode_picture_start().

static void encode_slice_params ( VC2EncContext s)
static

Definition at line 455 of file vc2enc.c.

Referenced by encode_transform_params().

static void init_quant_matrix ( VC2EncContext s)
static

Definition at line 480 of file vc2enc.c.

Referenced by calc_slice_sizes().

static void encode_quant_matrix ( VC2EncContext s)
static

Definition at line 522 of file vc2enc.c.

Referenced by encode_transform_params().

static void encode_transform_params ( VC2EncContext s)
static

Definition at line 537 of file vc2enc.c.

Referenced by encode_wavelet_transform().

static void encode_wavelet_transform ( VC2EncContext s)
static

Definition at line 547 of file vc2enc.c.

Referenced by encode_picture_start().

static void encode_picture_start ( VC2EncContext s)
static

Definition at line 554 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 565 of file vc2enc.c.

Referenced by encode_hq_slice().

static int count_hq_slice ( SliceArgs slice,
int  quant_idx 
)
static

Definition at line 598 of file vc2enc.c.

Referenced by calc_slice_sizes(), and rate_control().

static int rate_control ( AVCodecContext avctx,
void arg 
)
static

Definition at line 664 of file vc2enc.c.

Referenced by calc_slice_sizes().

static int calc_slice_sizes ( VC2EncContext s)
static

Definition at line 692 of file vc2enc.c.

Referenced by encode_frame().

static int encode_hq_slice ( AVCodecContext avctx,
void arg 
)
static

Definition at line 768 of file vc2enc.c.

Referenced by encode_slices().

static int encode_slices ( VC2EncContext s)
static

Definition at line 824 of file vc2enc.c.

Referenced by encode_frame().

static int dwt_plane ( AVCodecContext avctx,
void arg 
)
static

Definition at line 885 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 942 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 996 of file vc2enc.c.

static av_cold int vc2_encode_end ( AVCodecContext avctx)
static

Definition at line 1046 of file vc2enc.c.

Referenced by vc2_encode_init().

static av_cold int vc2_encode_init ( AVCodecContext avctx)
static

Definition at line 1065 of file vc2enc.c.

Variable Documentation

const VC2BaseVideoFormat base_video_fmts[]
static

Definition at line 52 of file vc2enc.c.

const int base_video_fmts_len = FF_ARRAY_ELEMS(base_video_fmts)
static

Definition at line 83 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 464 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 472 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:1240

Definition at line 1241 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:70
av_default_item_name
static const AVOption vc2enc_options[]
Definition: vc2enc.c:1241

Definition at line 1258 of file vc2enc.c.

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

Definition at line 1266 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:345
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:346
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:344
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:341
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:342
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:348
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62

Definition at line 1271 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:1065
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int vc2_encode_end(AVCodecContext *avctx)
Definition: vc2enc.c:1046
#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:996
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static const AVCodecDefault vc2enc_defaults[]
Definition: vc2enc.c:1266
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:1023
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
static enum AVPixelFormat allowed_pix_fmts[]
Definition: vc2enc.c:1271
static const AVCodecDefault defaults[]
Definition: dcaenc.c:975
static const AVClass vc2enc_class
Definition: vc2enc.c:1258

Definition at line 1278 of file vc2enc.c.