FFmpeg
Macros | Functions | Variables
dnxhdenc.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "codec_internal.h"
#include "encode.h"
#include "fdctdsp.h"
#include "mathops.h"
#include "mpegvideo.h"
#include "mpegvideoenc.h"
#include "pixblockdsp.h"
#include "packet_internal.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 *restrict block, const uint8_t *pixels, ptrdiff_t line_size)
 
static av_always_inline void dnxhd_10bit_get_pixels_8x4_sym (int16_t *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 (PutBitContext *pb, DNXHDEncContext *ctx, int diff)
 
static av_always_inline void dnxhd_encode_block (PutBitContext *pb, 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)
 
void ff_dnxhdenc_init (DNXHDEncContext *ctx)
 

Variables

static const AVOption options []
 
static const AVClass dnxhd_class
 
static const FFCodecDefault dnxhd_defaults []
 
const FFCodec ff_dnxhd_encoder
 

Macro Definition Documentation

◆ DNX10BIT_QMAT_SHIFT

#define DNX10BIT_QMAT_SHIFT   18

Definition at line 46 of file dnxhdenc.c.

◆ RC_VARIANCE

#define RC_VARIANCE   1

Definition at line 47 of file dnxhdenc.c.

◆ LAMBDA_FRAC_BITS

#define LAMBDA_FRAC_BITS   10

Definition at line 48 of file dnxhdenc.c.

◆ VE

Definition at line 50 of file dnxhdenc.c.

◆ BUCKET_BITS

#define BUCKET_BITS   8

Definition at line 1133 of file dnxhdenc.c.

◆ RADIX_PASSES

#define RADIX_PASSES   4

Definition at line 1134 of file dnxhdenc.c.

◆ NBUCKETS

#define NBUCKETS   (1 << BUCKET_BITS)

Definition at line 1135 of file dnxhdenc.c.

Function Documentation

◆ dnxhd_8bit_get_pixels_8x4_sym()

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

Definition at line 82 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_10bit_get_pixels_8x4_sym()

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

Definition at line 106 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_10bit_dct_quantize_444()

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

Definition at line 120 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_10bit_dct_quantize()

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

Definition at line 179 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_init_vlc()

static av_cold int dnxhd_init_vlc ( DNXHDEncContext ctx)
static

Definition at line 210 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_init_qmat()

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

Definition at line 265 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_init_rc()

static av_cold int dnxhd_init_rc ( DNXHDEncContext ctx)
static

Definition at line 338 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

◆ dnxhd_encode_init()

static av_cold int dnxhd_encode_init ( AVCodecContext avctx)
static

Definition at line 355 of file dnxhdenc.c.

◆ dnxhd_write_header()

static int dnxhd_write_header ( AVCodecContext avctx,
uint8_t *  buf 
)
static

Definition at line 523 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

◆ dnxhd_encode_dc()

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

Definition at line 559 of file dnxhdenc.c.

Referenced by dnxhd_encode_block().

◆ dnxhd_encode_block()

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

Definition at line 574 of file dnxhdenc.c.

Referenced by dnxhd_encode_thread().

◆ dnxhd_unquantize_c()

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

Definition at line 600 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread().

◆ dnxhd_ssd_block()

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

Definition at line 648 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread().

◆ dnxhd_calc_ac_bits()

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

Definition at line 658 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread().

◆ dnxhd_get_blocks()

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

Definition at line 677 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread(), and dnxhd_encode_thread().

◆ dnxhd_switch_matrix()

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

Definition at line 805 of file dnxhdenc.c.

Referenced by dnxhd_calc_bits_thread(), and dnxhd_encode_thread().

◆ dnxhd_calc_bits_thread()

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

Definition at line 818 of file dnxhdenc.c.

Referenced by dnxhd_encode_rdo(), and dnxhd_find_qscale().

◆ dnxhd_encode_thread()

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

Definition at line 875 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

◆ dnxhd_setup_threads_slices()

static void dnxhd_setup_threads_slices ( DNXHDEncContext ctx)
static

Definition at line 913 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

◆ dnxhd_mb_var_thread()

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

Definition at line 932 of file dnxhdenc.c.

Referenced by dnxhd_encode_fast().

◆ dnxhd_encode_rdo()

static int dnxhd_encode_rdo ( AVCodecContext avctx,
DNXHDEncContext ctx 
)
static

Definition at line 1000 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

◆ dnxhd_find_qscale()

static int dnxhd_find_qscale ( DNXHDEncContext ctx)
static

Definition at line 1077 of file dnxhdenc.c.

Referenced by dnxhd_encode_fast().

◆ get_bucket()

static int get_bucket ( int  value,
int  shift 
)
inlinestatic

Definition at line 1137 of file dnxhdenc.c.

Referenced by radix_count(), and radix_sort_pass().

◆ radix_count()

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

Definition at line 1144 of file dnxhdenc.c.

Referenced by radix_sort().

◆ radix_sort_pass()

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

Definition at line 1165 of file dnxhdenc.c.

Referenced by radix_sort().

◆ radix_sort()

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

Definition at line 1177 of file dnxhdenc.c.

Referenced by dnxhd_encode_fast().

◆ dnxhd_encode_fast()

static int dnxhd_encode_fast ( AVCodecContext avctx,
DNXHDEncContext ctx 
)
static

Definition at line 1189 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

◆ dnxhd_load_picture()

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

Definition at line 1238 of file dnxhdenc.c.

Referenced by dnxhd_encode_picture().

◆ dnxhd_encode_picture()

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

Definition at line 1253 of file dnxhdenc.c.

◆ dnxhd_encode_end()

static av_cold int dnxhd_encode_end ( AVCodecContext avctx)
static

Definition at line 1316 of file dnxhdenc.c.

◆ ff_dnxhdenc_init()

void ff_dnxhdenc_init ( DNXHDEncContext ctx)

Definition at line 1377 of file dnxhdenc.c.

Referenced by dnxhd_encode_init().

Variable Documentation

◆ options

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 = AV_PROFILE_DNXHD },
AV_PROFILE_DNXHD, AV_PROFILE_DNXHR_444, VE, .unit = "profile" },
{ "dnxhd", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_DNXHD },
0, 0, VE, .unit = "profile" },
{ "dnxhr_444", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_DNXHR_444 },
0, 0, VE, .unit = "profile" },
{ "dnxhr_hqx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_DNXHR_HQX },
0, 0, VE, .unit = "profile" },
{ "dnxhr_hq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_DNXHR_HQ },
0, 0, VE, .unit = "profile" },
{ "dnxhr_sq", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_DNXHR_SQ },
0, 0, VE, .unit = "profile" },
{ "dnxhr_lb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_PROFILE_DNXHR_LB },
0, 0, VE, .unit = "profile" },
{ NULL }
}

Definition at line 51 of file dnxhdenc.c.

◆ dnxhd_class

const AVClass dnxhd_class
static
Initial value:
= {
.class_name = "dnxhd",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 75 of file dnxhdenc.c.

◆ dnxhd_defaults

const FFCodecDefault dnxhd_defaults[]
static
Initial value:
= {
{ "qmax", "1024" },
{ NULL },
}

Definition at line 1347 of file dnxhdenc.c.

◆ ff_dnxhd_encoder

const FFCodec ff_dnxhd_encoder
Initial value:

Definition at line 1352 of file dnxhdenc.c.

dnxhd_encode_init
static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
Definition: dnxhdenc.c:355
options
static const AVOption options[]
Definition: dnxhdenc.c:51
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
AV_PROFILE_DNXHR_444
#define AV_PROFILE_DNXHR_444
Definition: defs.h:85
dnxhd_defaults
static const FFCodecDefault dnxhd_defaults[]
Definition: dnxhdenc.c:1347
dnxhd_encode_end
static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
Definition: dnxhdenc.c:1316
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:518
AV_PROFILE_DNXHR_SQ
#define AV_PROFILE_DNXHR_SQ
Definition: defs.h:82
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
DNXHDEncContext
Definition: dnxhdenc.h:44
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
AV_PROFILE_DNXHR_LB
#define AV_PROFILE_DNXHR_LB
Definition: defs.h:81
AV_PROFILE_DNXHR_HQ
#define AV_PROFILE_DNXHR_HQ
Definition: defs.h:83
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
AV_PROFILE_DNXHR_HQX
#define AV_PROFILE_DNXHR_HQX
Definition: defs.h:84
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
ff_dnxhd_profiles
const AVProfile ff_dnxhd_profiles[]
Definition: profiles.c:62
VE
#define VE
Definition: dnxhdenc.c:50
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
dnxhd_class
static const AVClass dnxhd_class
Definition: dnxhdenc.c:75
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
dnxhd_encode_picture
static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: dnxhdenc.c:1253
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
AV_PROFILE_DNXHD
#define AV_PROFILE_DNXHD
Definition: defs.h:80
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AV_CODEC_ID_DNXHD
@ AV_CODEC_ID_DNXHD
Definition: codec_id.h:151