FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
dnxhdenc.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/timer.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "fdctdsp.h"
#include "internal.h"
#include "mpegvideo.h"
#include "pixblockdsp.h"
#include "profiles.h"
#include "dnxhdenc.h"

Go to the source code of this file.

Macros

#define DNX10BIT_QMAT_SHIFT   18
 
#define RC_VARIANCE   1
 
#define LAMBDA_FRAC_BITS   10
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define BUCKET_BITS   8
 
#define RADIX_PASSES   4
 
#define NBUCKETS   (1 << BUCKET_BITS)
 

Functions

static void dnxhd_8bit_get_pixels_8x4_sym (int16_t *av_restrict block, const uint8_t *pixels, ptrdiff_t line_size)
 
static av_always_inline void dnxhd_10bit_get_pixels_8x4_sym (int16_t *av_restrict block, const uint8_t *pixels, ptrdiff_t line_size)
 
static int dnxhd_10bit_dct_quantize_444 (MpegEncContext *ctx, int16_t *block, int n, int qscale, int *overflow)
 
static int dnxhd_10bit_dct_quantize (MpegEncContext *ctx, int16_t *block, int n, int qscale, int *overflow)
 
static av_cold int dnxhd_init_vlc (DNXHDEncContext *ctx)
 
static av_cold int dnxhd_init_qmat (DNXHDEncContext *ctx, int lbias, int cbias)
 
static av_cold int dnxhd_init_rc (DNXHDEncContext *ctx)
 
static av_cold int dnxhd_encode_init (AVCodecContext *avctx)
 
static int dnxhd_write_header (AVCodecContext *avctx, uint8_t *buf)
 
static av_always_inline void dnxhd_encode_dc (DNXHDEncContext *ctx, int diff)
 
static av_always_inline void dnxhd_encode_block (DNXHDEncContext *ctx, int16_t *block, int last_index, int n)
 
static av_always_inline void dnxhd_unquantize_c (DNXHDEncContext *ctx, int16_t *block, int n, int qscale, int last_index)
 
static av_always_inline int dnxhd_ssd_block (int16_t *qblock, int16_t *block)
 
static av_always_inline int dnxhd_calc_ac_bits (DNXHDEncContext *ctx, int16_t *block, int last_index)
 
static av_always_inline void dnxhd_get_blocks (DNXHDEncContext *ctx, int mb_x, int mb_y)
 
static av_always_inline int dnxhd_switch_matrix (DNXHDEncContext *ctx, int i)
 
static int dnxhd_calc_bits_thread (AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 
static int dnxhd_encode_thread (AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 
static void dnxhd_setup_threads_slices (DNXHDEncContext *ctx)
 
static int dnxhd_mb_var_thread (AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 
static int dnxhd_encode_rdo (AVCodecContext *avctx, DNXHDEncContext *ctx)
 
static int dnxhd_find_qscale (DNXHDEncContext *ctx)
 
static int get_bucket (int value, int shift)
 
static void radix_count (const RCCMPEntry *data, int size, int buckets[RADIX_PASSES][NBUCKETS])
 
static void radix_sort_pass (RCCMPEntry *dst, const RCCMPEntry *data, int size, int buckets[NBUCKETS], int pass)
 
static void radix_sort (RCCMPEntry *data, RCCMPEntry *tmp, int size)
 
static int dnxhd_encode_fast (AVCodecContext *avctx, DNXHDEncContext *ctx)
 
static void dnxhd_load_picture (DNXHDEncContext *ctx, const AVFrame *frame)
 
static int dnxhd_encode_picture (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int dnxhd_encode_end (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass dnxhd_class
 
static const AVCodecDefault dnxhd_defaults []
 
AVCodec ff_dnxhd_encoder
 

Macro Definition Documentation

#define DNX10BIT_QMAT_SHIFT   18

Definition at line 41 of file dnxhdenc.c.

Referenced by dnxhd_10bit_dct_quantize(), and dnxhd_init_qmat().

#define RC_VARIANCE   1

Definition at line 42 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread(), and dnxhd_encode_fast().

#define LAMBDA_FRAC_BITS   10

Definition at line 43 of file dnxhdenc.c.

Referenced by dnxhd_encode_rdo(), and dnxhd_init_rc().

Definition at line 45 of file dnxhdenc.c.

#define BUCKET_BITS   8

Definition at line 1159 of file dnxhdenc.c.

Referenced by radix_count(), and radix_sort_pass().

#define RADIX_PASSES   4

Definition at line 1160 of file dnxhdenc.c.

Referenced by radix_count(), and radix_sort().

#define NBUCKETS   (1 << BUCKET_BITS)

Definition at line 1161 of file dnxhdenc.c.

Referenced by get_bucket(), and radix_sort().

Function Documentation

static void dnxhd_8bit_get_pixels_8x4_sym ( int16_t *av_restrict  block,
const uint8_t pixels,
ptrdiff_t  line_size 
)
static

Definition at line 77 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static av_always_inline void dnxhd_10bit_get_pixels_8x4_sym ( int16_t *av_restrict  block,
const uint8_t pixels,
ptrdiff_t  line_size 
)
static

Definition at line 101 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static int dnxhd_10bit_dct_quantize_444 ( MpegEncContext ctx,
int16_t *  block,
int  n,
int  qscale,
int overflow 
)
static

Definition at line 115 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static int dnxhd_10bit_dct_quantize ( MpegEncContext ctx,
int16_t *  block,
int  n,
int  qscale,
int overflow 
)
static

Definition at line 174 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static av_cold int dnxhd_init_vlc ( DNXHDEncContext ctx)
static

Definition at line 205 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static av_cold int dnxhd_init_qmat ( DNXHDEncContext ctx,
int  lbias,
int  cbias 
)
static

Definition at line 266 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static av_cold int dnxhd_init_rc ( DNXHDEncContext ctx)
static

Definition at line 346 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

static av_cold int dnxhd_encode_init ( AVCodecContext avctx)
static

Definition at line 365 of file dnxhdenc.c.

static int dnxhd_write_header ( AVCodecContext avctx,
uint8_t buf 
)
static

Definition at line 548 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

static av_always_inline void dnxhd_encode_dc ( DNXHDEncContext ctx,
int  diff 
)
static

Definition at line 584 of file dnxhdenc.c.

Referenced by dnxhd_encode_block().

static av_always_inline void dnxhd_encode_block ( DNXHDEncContext ctx,
int16_t *  block,
int  last_index,
int  n 
)
static

Definition at line 599 of file dnxhdenc.c.

Referenced by dnxhd_encode_thread().

static av_always_inline void dnxhd_unquantize_c ( DNXHDEncContext ctx,
int16_t *  block,
int  n,
int  qscale,
int  last_index 
)
static

Definition at line 625 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread().

static av_always_inline int dnxhd_ssd_block ( int16_t *  qblock,
int16_t *  block 
)
static

Definition at line 673 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread().

static av_always_inline int dnxhd_calc_ac_bits ( DNXHDEncContext ctx,
int16_t *  block,
int  last_index 
)
static

Definition at line 683 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread().

static av_always_inline void dnxhd_get_blocks ( DNXHDEncContext ctx,
int  mb_x,
int  mb_y 
)
static

Definition at line 702 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread(), and dnxhd_encode_thread().

static av_always_inline int dnxhd_switch_matrix ( DNXHDEncContext ctx,
int  i 
)
static

Definition at line 830 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread(), and dnxhd_encode_thread().

static int dnxhd_calc_bits_thread ( AVCodecContext avctx,
void arg,
int  jobnr,
int  threadnr 
)
static

Definition at line 843 of file dnxhdenc.c.

Referenced by dnxhd_encode_rdo(), and dnxhd_find_qscale().

static int dnxhd_encode_thread ( AVCodecContext avctx,
void arg,
int  jobnr,
int  threadnr 
)
static

Definition at line 900 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

static void dnxhd_setup_threads_slices ( DNXHDEncContext ctx)
static

Definition at line 939 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

static int dnxhd_mb_var_thread ( AVCodecContext avctx,
void arg,
int  jobnr,
int  threadnr 
)
static

Definition at line 958 of file dnxhdenc.c.

Referenced by dnxhd_encode_fast().

static int dnxhd_encode_rdo ( AVCodecContext avctx,
DNXHDEncContext ctx 
)
static

Definition at line 1026 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

static int dnxhd_find_qscale ( DNXHDEncContext ctx)
static

Definition at line 1103 of file dnxhdenc.c.

Referenced by dnxhd_encode_fast().

static int get_bucket ( int  value,
int  shift 
)
inlinestatic

Definition at line 1163 of file dnxhdenc.c.

Referenced by radix_count(), and radix_sort_pass().

static void radix_count ( const RCCMPEntry data,
int  size,
int  buckets[RADIX_PASSES][NBUCKETS] 
)
static

Definition at line 1170 of file dnxhdenc.c.

Referenced by radix_sort().

static void radix_sort_pass ( RCCMPEntry dst,
const RCCMPEntry data,
int  size,
int  buckets[NBUCKETS],
int  pass 
)
static

Definition at line 1191 of file dnxhdenc.c.

Referenced by radix_sort().

static void radix_sort ( RCCMPEntry data,
RCCMPEntry tmp,
int  size 
)
static

Definition at line 1203 of file dnxhdenc.c.

Referenced by dnxhd_encode_fast().

static int dnxhd_encode_fast ( AVCodecContext avctx,
DNXHDEncContext ctx 
)
static

Definition at line 1215 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

static void dnxhd_load_picture ( DNXHDEncContext ctx,
const AVFrame frame 
)
static

Definition at line 1259 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

static int dnxhd_encode_picture ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame frame,
int got_packet 
)
static

Definition at line 1278 of file dnxhdenc.c.

static av_cold int dnxhd_encode_end ( AVCodecContext avctx)
static

Definition at line 1348 of file dnxhdenc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "nitris_compat", "encode with Avid Nitris compatibility",
0x42, AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "ibias", "intra quant bias",
{ .i64 = 0 }, INT_MIN, INT_MAX, VE },
{ "profile", NULL, 0x42, AV_OPT_TYPE_INT,
{ .i64 = FF_PROFILE_DNXHD },
{ "dnxhd", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHD },
0, 0, VE, "profile" },
{ "dnxhr_444", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_444 },
0, 0, VE, "profile" },
{ "dnxhr_hqx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_HQX },
0, 0, VE, "profile" },
{ "dnxhr_hq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_HQ },
0, 0, VE, "profile" },
{ "dnxhr_sq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_SQ },
0, 0, VE, "profile" },
{ "dnxhr_lb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_DNXHR_LB },
0, 0, VE, "profile" },
{ NULL }
}
#define FF_PROFILE_DNXHD
Definition: avcodec.h:2858
#define NULL
Definition: coverity.c:32
#define FF_PROFILE_DNXHR_LB
Definition: avcodec.h:2859
#define FF_PROFILE_DNXHR_HQ
Definition: avcodec.h:2861
#define FF_PROFILE_DNXHR_SQ
Definition: avcodec.h:2860
#define FF_PROFILE_DNXHR_HQX
Definition: avcodec.h:2862
#define VE
Definition: dnxhdenc.c:45
#define FF_PROFILE_DNXHR_444
Definition: avcodec.h:2863

Definition at line 46 of file dnxhdenc.c.

const AVClass dnxhd_class
static
Initial value:
= {
.class_name = "dnxhd",
.item_name = av_default_item_name,
.option = options,
}
#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 options[]
Definition: dnxhdenc.c:46

Definition at line 70 of file dnxhdenc.c.

const AVCodecDefault dnxhd_defaults[]
static
Initial value:
= {
{ "qmax", "1024" },
{ NULL },
}
#define NULL
Definition: coverity.c:32

Definition at line 1378 of file dnxhdenc.c.

AVCodec ff_dnxhd_encoder
Initial value:
= {
.name = "dnxhd",
.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
.priv_data_size = sizeof(DNXHDEncContext),
.close = dnxhd_encode_end,
.pix_fmts = (const enum AVPixelFormat[]) {
},
.priv_class = &dnxhd_class,
.defaults = dnxhd_defaults,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:384
static const AVClass dnxhd_class
Definition: dnxhdenc.c:70
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:1045
const AVProfile ff_dnxhd_profiles[]
Definition: profiles.c:49
static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
Definition: dnxhdenc.c:1348
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1015
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
static const AVCodecDefault dnxhd_defaults[]
Definition: dnxhdenc.c:1378
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:1019
static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: dnxhdenc.c:1278
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
Definition: dnxhdenc.c:365
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60

Definition at line 1383 of file dnxhdenc.c.