36 #define X264_API_IMPORTS 1
120 static const int level_map[] = {
127 if (level < 0 || level > X264_LOG_DEBUG)
135 const x264_nal_t *nals,
int nnal)
146 for (
int i = 0;
i < nnal;
i++) {
147 size += nals[
i].i_payload;
151 #if INT_MAX > INT64_MAX / INT_MAX - 1
174 for (
i = 0;
i < nnal;
i++){
175 memcpy(p, nals[
i].p_payload, nals[
i].i_payload);
176 p += nals[
i].i_payload;
214 x264_encoder_reconfig(x4->
enc, &x4->
params);
216 if (x4->
params.vui.i_sar_height*
ctx->sample_aspect_ratio.num !=
ctx->sample_aspect_ratio.den * x4->
params.vui.i_sar_width) {
217 x4->
params.vui.i_sar_height =
ctx->sample_aspect_ratio.den;
218 x4->
params.vui.i_sar_width =
ctx->sample_aspect_ratio.num;
219 x264_encoder_reconfig(x4->
enc, &x4->
params);
222 if (x4->
params.rc.i_vbv_buffer_size !=
ctx->rc_buffer_size / 1000 ||
223 x4->
params.rc.i_vbv_max_bitrate !=
ctx->rc_max_rate / 1000) {
224 x4->
params.rc.i_vbv_buffer_size =
ctx->rc_buffer_size / 1000;
225 x4->
params.rc.i_vbv_max_bitrate =
ctx->rc_max_rate / 1000;
226 x264_encoder_reconfig(x4->
enc, &x4->
params);
229 if (x4->
params.rc.i_rc_method == X264_RC_ABR &&
232 x264_encoder_reconfig(x4->
enc, &x4->
params);
236 x4->
params.rc.i_rc_method == X264_RC_CRF &&
237 x4->
params.rc.f_rf_constant != x4->
crf) {
239 x264_encoder_reconfig(x4->
enc, &x4->
params);
242 if (x4->
params.rc.i_rc_method == X264_RC_CQP &&
244 x4->
params.rc.i_qp_constant != x4->
cqp) {
246 x264_encoder_reconfig(x4->
enc, &x4->
params);
252 x264_encoder_reconfig(x4->
enc, &x4->
params);
261 switch (stereo->
type) {
280 #if X264_BUILD >= 145
293 "Ignoring unsupported inverted stereo value %d\n", fpa_type);
297 if (fpa_type != x4->
params.i_frame_packing) {
298 x4->
params.i_frame_packing = fpa_type;
299 x264_encoder_reconfig(x4->
enc, &x4->
params);
310 x264_picture_t pic_out = {0};
317 x264_picture_init( &x4->
pic );
319 #if X264_BUILD >= 153
325 x4->
pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
329 for (
i = 0;
i < x4->
pic.img.i_plane;
i++) {
347 : X264_TYPE_KEYFRAME;
350 x4->
pic.i_type = X264_TYPE_P;
353 x4->
pic.i_type = X264_TYPE_B;
356 x4->
pic.i_type = X264_TYPE_AUTO;
368 }
else if (sei_data) {
369 x4->
pic.extra_sei.payloads =
av_mallocz(
sizeof(x4->
pic.extra_sei.payloads[0]));
370 if (x4->
pic.extra_sei.payloads ==
NULL) {
376 x4->
pic.extra_sei.payloads[0].payload_size = sei_size;
377 x4->
pic.extra_sei.payloads[0].payload = sei_data;
378 x4->
pic.extra_sei.num_payloads = 1;
379 x4->
pic.extra_sei.payloads[0].payload_type = 4;
386 if (x4->
params.rc.i_aq_mode == X264_AQ_NONE) {
403 if (!roi_size || sd->
size % roi_size != 0) {
407 nb_rois = sd->
size / roi_size;
415 for (
int i = nb_rois - 1;
i >= 0;
i--) {
416 int startx, endx, starty, endy;
432 qoffset =
av_clipf(qoffset * qp_range, -qp_range, +qp_range);
434 for (
int y = starty; y < endy; y++) {
435 for (
int x = startx; x < endx; x++) {
436 qoffsets[x + y*mbx] = qoffset;
441 x4->
pic.prop.quant_offsets = qoffsets;
454 if (x264_encoder_encode(x4->
enc, &nal, &nnal,
frame? &x4->
pic:
NULL, &pic_out) < 0)
460 }
while (!ret && !
frame && x264_encoder_delayed_frames(x4->
enc));
468 out_opaque = pic_out.opaque;
475 ctx->reordered_opaque = 0;
478 switch (pic_out.i_type) {
494 #if FF_API_CODED_FRAME
496 ctx->coded_frame->pict_type = pict_type;
506 #if FF_API_CODED_FRAME
525 #if X264_BUILD >= 161
526 x264_param_cleanup(&x4->
params);
530 x264_encoder_close(x4->
enc);
542 if ((ret = x264_param_parse(&x4->
params, opt, param)) < 0) {
543 if (ret == X264_PARAM_BAD_NAME) {
545 "bad option '%s': '%s'\n", opt, param);
547 #if X264_BUILD >= 161
548 }
else if (ret == X264_PARAM_ALLOC_FAILED) {
550 "out of memory parsing option '%s': '%s'\n", opt, param);
555 "bad value for '%s': '%s'\n", opt, param);
577 #if CONFIG_LIBX264RGB_ENCODER
579 return X264_CSP_BGRA;
600 #define PARSE_X264_OPT(name, var)\
601 if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
602 av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
603 return AVERROR(EINVAL);\
616 #if CONFIG_LIBX262_ENCODER
619 x264_param_default_mpeg2(&x4->
params);
622 x264_param_default(&x4->
params);
631 for (
i = 0; x264_preset_names[
i];
i++)
635 for (
i = 0; x264_tune_names[
i];
i++)
641 if (avctx->
level > 0)
645 x4->
params.p_log_private = avctx;
646 x4->
params.i_log_level = X264_LOG_DEBUG;
648 #if X264_BUILD >= 153
656 av_log(avctx,
AV_LOG_ERROR,
"bit_rate and rc_max_rate > %d000 not supported by libx264\n", INT_MAX);
660 x4->
params.rc.i_rc_method = X264_RC_ABR;
666 x4->
params.rc.b_stat_read = 1;
669 x4->
params.rc.i_rc_method = X264_RC_CRF;
671 }
else if (x4->
cqp >= 0) {
672 x4->
params.rc.i_rc_method = X264_RC_CQP;
682 x4->
params.rc.f_vbv_buffer_init =
693 #if FF_API_PRIVATE_OPT
707 #if FF_API_PRIVATE_OPT
716 if (avctx->
qmin >= 0)
718 if (avctx->
qmax >= 0)
722 if (avctx->
qblur >= 0)
726 if (avctx->
refs >= 0)
728 else if (x4->
params.i_level_idc > 0) {
731 int scale = X264_BUILD < 129 ? 384 : 1;
733 for (
i = 0;
i<x264_levels[
i].level_idc;
i++)
735 x4->
params.i_frame_reference =
av_clip(x264_levels[
i].dpb / mbn / scale, 1, x4->
params.i_frame_reference);
742 #if FF_API_PRIVATE_OPT
752 #if FF_API_PRIVATE_OPT
760 #if FF_API_CODER_TYPE
794 x4->
params.b_vfr_input = 0;
797 #if X264_BUILD >= 142
801 "x264 too old for AVC Intra, at least version 142 needed\n");
803 if (x4->
b_bias != INT_MIN)
824 x264_param_apply_fastfirstpass(&x4->
params);
864 if (x264_param_apply_profile(&x4->
params, x4->
profile) < 0) {
868 for (
i = 0; x264_profile_names[
i];
i++)
877 x4->
params.vui.i_sar_width = sw;
878 x4->
params.vui.i_sar_height = sh;
906 x4->
params.vui.b_fullrange = 1;
916 x4->
params.b_repeat_headers = 0;
921 char param[4096]={0},
val[4096]={0};
922 if(sscanf(p,
"%4095[^:=]=%4095[^:]", param,
val) == 1){
940 if ((ret = x264_param_parse(&x4->
params, en->
key, en->
value)) < 0) {
942 "Error parsing option '%s = %s'.\n",
944 #if X264_BUILD >= 161
945 if (ret == X264_PARAM_ALLOC_FAILED)
954 x4->
params.i_bframe_pyramid ? 2 : 1 : 0;
960 x4->
enc = x264_encoder_open(&x4->
params);
969 s = x264_encoder_headers(x4->
enc, &nal, &nnal);
974 for (
i = 0;
i < nnal;
i++) {
976 if (nal[
i].i_type == NAL_SEI) {
982 memcpy(x4->
sei, nal[
i].p_payload, nal[
i].i_payload);
985 memcpy(p, nal[
i].p_payload, nal[
i].i_payload);
986 p += nal[
i].i_payload;
1018 #ifdef X264_CSP_NV21
1044 #ifdef X264_CSP_NV21
1051 #ifdef X264_CSP_I400
1057 #if CONFIG_LIBX264RGB_ENCODER
1066 #if X264_BUILD < 153
1069 if (x264_bit_depth == 8)
1071 else if (x264_bit_depth == 9)
1073 else if (x264_bit_depth == 10)
1078 #define OFFSET(x) offsetof(X264Context, x)
1079 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1084 {
"fastfirstpass",
"Use fast settings when encoding first pass",
OFFSET(fastfirstpass),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
VE},
1090 {
"crf",
"Select the quality for constant quality mode",
OFFSET(crf),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE },
1091 {
"crf_max",
"In CRF mode, prevents VBV from lowering quality beyond this point.",
OFFSET(crf_max),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE },
1092 {
"qp",
"Constant quantization parameter rate control method",
OFFSET(cqp),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE },
1095 {
"variance",
"Variance AQ (complexity mask)", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_VARIANCE}, INT_MIN, INT_MAX,
VE,
"aq_mode" },
1096 {
"autovariance",
"Auto-variance AQ", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX,
VE,
"aq_mode" },
1097 #if X264_BUILD >= 144
1098 {
"autovariance-biased",
"Auto-variance AQ with bias to dark scenes", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE_BIASED}, INT_MIN, INT_MAX,
VE,
"aq_mode" },
1100 {
"aq-strength",
"AQ strength. Reduces blocking and blurring in flat and textured areas.",
OFFSET(aq_strength),
AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX,
VE},
1102 {
"psy-rd",
"Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.",
OFFSET(psy_rd),
AV_OPT_TYPE_STRING, {0 }, 0, 0,
VE},
1103 {
"rc-lookahead",
"Number of frames to look ahead for frametype and ratecontrol",
OFFSET(rc_lookahead),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE },
1105 {
"weightp",
"Weighted prediction analysis method.",
OFFSET(weightp),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE,
"weightp" },
1110 {
"intra-refresh",
"Use Periodic Intra Refresh instead of IDR frames.",
OFFSET(intra_refresh),
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VE },
1111 {
"bluray-compat",
"Bluray compatibility workarounds.",
OFFSET(bluray_compat) ,
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VE },
1112 {
"b-bias",
"Influences how often B-frames are used",
OFFSET(b_bias),
AV_OPT_TYPE_INT, { .i64 = INT_MIN}, INT_MIN, INT_MAX,
VE },
1113 {
"b-pyramid",
"Keep some B-frames as references.",
OFFSET(b_pyramid),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE,
"b_pyramid" },
1115 {
"strict",
"Strictly hierarchical pyramid", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX,
VE,
"b_pyramid" },
1116 {
"normal",
"Non-strict (not Blu-ray compatible)", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX,
VE,
"b_pyramid" },
1117 {
"mixed-refs",
"One reference per partition, as opposed to one reference per macroblock",
OFFSET(mixed_refs),
AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1,
VE },
1123 {
"cplxblur",
"Reduce fluctuations in QP (before curve compression)",
OFFSET(cplxblur),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE},
1124 {
"partitions",
"A comma-separated list of partitions to consider. "
1125 "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all",
OFFSET(partitions),
AV_OPT_TYPE_STRING, { 0 }, 0, 0,
VE},
1126 {
"direct-pred",
"Direct MV prediction mode",
OFFSET(direct_pred),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE,
"direct-pred" },
1131 {
"slice-max-size",
"Limit the size of each slice in bytes",
OFFSET(slice_max_size),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE },
1133 {
"nal-hrd",
"Signal HRD information (requires vbv-bufsize; "
1138 {
"avcintra-class",
"AVC-Intra class 50/100/200",
OFFSET(avcintra_class),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 200 ,
VE},
1139 {
"me_method",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA,
VE,
"motion-est"},
1140 {
"motion-est",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA,
VE,
"motion-est"},
1146 {
"forced-idr",
"If forcing keyframes, force them as IDR frames.",
OFFSET(forced_idr),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, -1, 1,
VE },
1153 {
"b_strategy",
"Strategy to choose between I/P/B-frames",
OFFSET(b_frame_strategy),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2,
VE },
1154 {
"chromaoffset",
"QP difference between chroma and luma",
OFFSET(chroma_offset),
AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX,
VE },
1155 {
"sc_threshold",
"Scene change threshold",
OFFSET(scenechange_threshold),
AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX,
VE },
1156 {
"noise_reduction",
"Noise reduction",
OFFSET(noise_reduction),
AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX,
VE },
1158 {
"x264-params",
"Override the x264 configuration using a :-separated list of key=value parameters",
OFFSET(x264_params),
AV_OPT_TYPE_DICT, { 0 }, 0, 0,
VE },
1167 {
"i_qfactor",
"-1" },
1168 {
"b_qfactor",
"-1" },
1176 #if FF_API_PRIVATE_OPT
1177 {
"sc_threshold",
"-1" },
1179 {
"trellis",
"-1" },
1180 #if FF_API_PRIVATE_OPT
1183 {
"me_range",
"-1" },
1185 #if FF_API_PRIVATE_OPT
1186 {
"b_strategy",
"-1" },
1188 {
"keyint_min",
"-1" },
1189 #if FF_API_CODER_TYPE
1194 {
"thread_type",
"0" },
1195 {
"flags",
"+cgop" },
1196 {
"rc_init_occupancy",
"-1" },
1200 #if CONFIG_LIBX264_ENCODER
1201 static const AVClass x264_class = {
1220 .priv_class = &x264_class,
1222 #
if X264_BUILD < 153
1228 #
if X264_BUILD >= 158
1232 .wrapper_name =
"libx264",
1236 #if CONFIG_LIBX264RGB_ENCODER
1237 static const AVClass rgbclass = {
1245 .
name =
"libx264rgb",
1255 .priv_class = &rgbclass,
1259 #
if X264_BUILD >= 158
1263 .wrapper_name =
"libx264",
1267 #if CONFIG_LIBX262_ENCODER
1268 static const AVClass X262_class = {
1286 .priv_class = &X262_class,
1290 .wrapper_name =
"libx264",
static double val(void *priv, double ch)
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
AVCodec ff_libx262_encoder
AVCodec ff_libx264_encoder
AVCodec ff_libx264rgb_encoder
static const AVCodecDefault defaults[]
int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, void **data, size_t *sei_size)
Check AVFrame for A53 side data and allocate and fill SEI message with A53 info.
Libavcodec external API header.
#define FF_PROFILE_H264_HIGH
#define FF_PROFILE_H264_HIGH_444
#define FF_PROFILE_H264_HIGH_422
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
#define FF_PROFILE_H264_MAIN
#define FF_PROFILE_H264_HIGH_10
#define FF_PROFILE_H264_BASELINE
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
static av_cold int init(AVCodecContext *avctx)
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
#define AV_CEIL_RSHIFT(a, b)
static __device__ float fabs(float a)
static enum AVPixelFormat pix_fmt
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
simple arithmetic expression evaluator
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This codec takes the reordered_opaque field from input AVFrames and returns it in the corresponding f...
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_EXPORT_DATA_PRFT
Export encoder Producer Reference Time through packet side data.
#define AV_CODEC_FLAG_CLOSED_GOP
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
#define AV_CODEC_FLAG_LOOP_FILTER
loop filter.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AVERROR_EXTERNAL
Generic error in an external library.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
@ AV_FRAME_DATA_REGIONS_OF_INTEREST
Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * av_strdup(const char *s)
Duplicate a string.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
#define LIBAVUTIL_VERSION_INT
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
@ AV_STEREO3D_COLUMNS
Views are packed per column.
@ AV_STEREO3D_LINES
Views are packed per line, as if interlaced.
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
@ AV_STEREO3D_CHECKERBOARD
Views are packed in a checkerboard-like structure per pixel.
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
@ AV_STEREO3D_FRAMESEQUENCE
Views are alternated temporally.
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static enum AVPixelFormat pix_fmts[]
static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static enum AVPixelFormat pix_fmts_10bit[]
static av_cold int X264_close(AVCodecContext *avctx)
static enum AVPixelFormat pix_fmts_9bit[]
static const AVOption options[]
#define PARSE_X264_OPT(name, var)
static av_cold int X264_init(AVCodecContext *avctx)
static av_cold void X264_init_static(AVCodec *codec)
static int parse_opts(AVCodecContext *avctx, const char *opt, const char *param)
static const AVCodecDefault x264_defaults[]
static void X264_log(void *p, int level, const char *fmt, va_list args)
static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
static enum AVPixelFormat pix_fmts_8bit[]
static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, const x264_nal_t *nals, int nnal)
static enum AVPixelFormat pix_fmts_all[]
static int avfmt2_num_planes(int avfmt)
static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
Memory handling functions.
static av_cold void init_static_data(void)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV420P9
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_YUV444P10
This structure describes the bitrate properties of an encoded bitstream.
int avg_bitrate
Average bitrate of the stream, in bits per second.
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
int max_bitrate
Maximum bitrate of the stream, in bits per second.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
int trellis
trellis RD quantization
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int max_qdiff
maximum quantizer difference between frames
int width
picture width / height.
int rc_buffer_size
decoder bitstream buffer size
int me_cmp
motion estimation comparison function
int global_quality
Global quality for codecs which cannot change it per frame.
attribute_deprecated int coder_type
attribute_deprecated int scenechange_threshold
enum AVColorRange color_range
MPEG vs JPEG YUV range.
attribute_deprecated int chromaoffset
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
int me_subpel_quality
subpel ME quality
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int qmin
minimum quantizer
int keyint_min
minimum GOP size
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int64_t bit_rate
the average bitrate
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
int thread_type
Which multithreading methods to use.
enum AVColorSpace colorspace
YUV colorspace type.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
int refs
number of reference frames
int64_t rc_max_rate
maximum bitrate
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int qmax
maximum quantizer
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
float qblur
amount of qscale smoothing over time (0.0-1.0)
int me_range
maximum motion estimation search range in subpel units If 0 then no limit.
attribute_deprecated int noise_reduction
attribute_deprecated int b_frame_strategy
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
int slices
Number of slices.
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
const char * name
Name of the codec implementation.
int depth
Number of bits in the component.
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
void * priv_data
Format private data.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int top_field_first
If the content is interlaced, is top field displayed first.
int interlaced_frame
The content of the picture is interlaced.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int64_t reordered_opaque
reordered opaque 64 bits (generally an integer or a double precision float PTS but can be anything).
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Structure describing a single Region Of Interest.
uint32_t self_size
Must be set to the size of this data structure (that is, sizeof(AVRegionOfInterest)).
AVRational qoffset
Quantisation offset.
int top
Distance in pixels from the top edge of the frame to the top and bottom edges and from the left edge ...
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
enum AVStereo3DType type
How views are packed within the video.
int flags
Additional information about the frame packing.
int next_reordered_opaque
AVDictionary * x264_params
X264Opaque * reordered_opaque
int scenechange_threshold
int roi_warned
If the encoder does not support ROI then warn the first time we encounter a frame with ROI side data.
static void dct8x8(int16_t *coef, int bit_depth)
int64_t av_gettime(void)
Get the current time in microseconds.
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)