Go to the documentation of this file.
22 #include "config_components.h"
53 #define MB_FLOOR(x) ((x) >> (MB_LSIZE))
54 #define MB_CEIL(x) MB_FLOOR((x) + (MB_SIZE - 1))
57 #if FF_API_REORDERED_OPAQUE
58 int64_t reordered_opaque;
136 static const int level_map[] = {
143 if (level < 0 || level > X264_LOG_DEBUG)
152 memset(o, 0,
sizeof(*o));
156 const x264_nal_t *nals,
int nnal)
166 for (
int i = 0;
i < nnal;
i++) {
167 size += nals[
i].i_payload;
171 #if INT_MAX > INT64_MAX / INT_MAX - 1
172 if ((int64_t)
size < 0)
193 memcpy(p, nals[0].p_payload,
size);
208 x264_encoder_reconfig(x4->
enc, &x4->
params);
210 if (x4->
params.vui.i_sar_height*
ctx->sample_aspect_ratio.num !=
ctx->sample_aspect_ratio.den * x4->
params.vui.i_sar_width) {
211 x4->
params.vui.i_sar_height =
ctx->sample_aspect_ratio.den;
212 x4->
params.vui.i_sar_width =
ctx->sample_aspect_ratio.num;
213 x264_encoder_reconfig(x4->
enc, &x4->
params);
216 if (x4->
params.rc.i_vbv_buffer_size !=
ctx->rc_buffer_size / 1000 ||
217 x4->
params.rc.i_vbv_max_bitrate !=
ctx->rc_max_rate / 1000) {
218 x4->
params.rc.i_vbv_buffer_size =
ctx->rc_buffer_size / 1000;
219 x4->
params.rc.i_vbv_max_bitrate =
ctx->rc_max_rate / 1000;
220 x264_encoder_reconfig(x4->
enc, &x4->
params);
223 if (x4->
params.rc.i_rc_method == X264_RC_ABR &&
226 x264_encoder_reconfig(x4->
enc, &x4->
params);
230 x4->
params.rc.i_rc_method == X264_RC_CRF &&
231 x4->
params.rc.f_rf_constant != x4->
crf) {
233 x264_encoder_reconfig(x4->
enc, &x4->
params);
236 if (x4->
params.rc.i_rc_method == X264_RC_CQP &&
238 x4->
params.rc.i_qp_constant != x4->
cqp) {
240 x264_encoder_reconfig(x4->
enc, &x4->
params);
246 x264_encoder_reconfig(x4->
enc, &x4->
params);
255 switch (stereo->
type) {
274 #if X264_BUILD >= 145
287 "Ignoring unsupported inverted stereo value %d\n", fpa_type);
291 if (fpa_type != x4->
params.i_frame_packing) {
292 x4->
params.i_frame_packing = fpa_type;
293 x264_encoder_reconfig(x4->
enc, &x4->
params);
300 for (
int i = 0;
i < pic->extra_sei.num_payloads;
i++)
301 av_free(pic->extra_sei.payloads[
i].payload);
305 pic->extra_sei.num_payloads = 0;
366 nb_rects =
info->nb_rects;
368 mbinfo =
av_calloc(mb_width * mb_height,
sizeof(*mbinfo));
372 #define COMPUTE_MBINFO(mbinfo_filler_, mbinfo_marker_, compute_coords_fn_) \
373 memset(mbinfo, mbinfo_filler_, sizeof(*mbinfo) * mb_width * mb_height); \
375 for (int i = 0; i < nb_rects; i++) { \
376 int min_x, max_x, min_y, max_y; \
378 compute_coords_fn_(mbinfo_rects, &min_x, &max_x, &min_y, &max_y); \
379 for (int mb_y = min_y; mb_y < max_y; ++mb_y) { \
380 memset(mbinfo + mb_y * mb_width + min_x, mbinfo_marker_, max_x - min_x); \
392 pic->prop.mb_info = mbinfo;
393 pic->prop.mb_info_free =
av_free;
411 if (x4->
params.rc.i_aq_mode == X264_AQ_NONE) {
427 if (!roi_size ||
size % roi_size != 0) {
431 nb_rois =
size / roi_size;
433 qoffsets =
av_calloc(mbx * mby,
sizeof(*qoffsets));
439 for (
int i = nb_rois - 1;
i >= 0;
i--) {
440 int startx, endx, starty, endy;
456 qoffset =
av_clipf(qoffset * qp_range, -qp_range, +qp_range);
458 for (
int y = starty; y < endy; y++) {
459 for (
int x = startx; x < endx; x++) {
460 qoffsets[x + y*mbx] = qoffset;
465 pic->prop.quant_offsets = qoffsets;
466 pic->prop.quant_offsets_free =
av_free;
472 x264_picture_t **ppic)
476 x264_picture_t *pic = &x4->
pic;
477 x264_sei_t *
sei = &pic->extra_sei;
478 unsigned int sei_data_size = 0;
479 int64_t wallclock = 0;
488 x264_picture_init(pic);
489 pic->img.i_csp = x4->
params.i_csp;
490 #if X264_BUILD >= 153
496 pic->img.i_csp |= X264_CSP_HIGH_DEPTH;
499 for (
int i = 0;
i < pic->img.i_plane;
i++) {
515 #if FF_API_REORDERED_OPAQUE
525 pic->opaque = opaque;
532 pic->i_type = x4->
forced_idr > 0 ? X264_TYPE_IDR : X264_TYPE_KEYFRAME;
535 pic->i_type = X264_TYPE_P;
538 pic->i_type = X264_TYPE_B;
541 pic->i_type = X264_TYPE_AUTO;
556 if (!
sei->payloads) {
564 sei->payloads[0].payload_size = sei_size;
565 sei->payloads[0].payload = sei_data;
567 sei->num_payloads = 1;
593 x264_sei_payload_t *sei_payload;
603 sei_payload = &
sei->payloads[
sei->num_payloads];
605 if (!sei_payload->payload) {
609 sei_payload->payload_size = side_data->
size;
630 x264_picture_t pic_out = {0}, *pic_in;
632 int64_t wallclock = 0;
640 if (x264_encoder_encode(x4->
enc, &nal, &nnal, pic_in, &pic_out) < 0)
651 "Unhandled reconstructed frame colorspace: %d\n",
658 for (
int i = 0;
i < pic_out.img.i_plane;
i++) {
673 }
while (!
ret && !
frame && x264_encoder_delayed_frames(x4->
enc));
681 out_opaque = pic_out.opaque;
684 #if FF_API_REORDERED_OPAQUE
686 ctx->reordered_opaque = out_opaque->reordered_opaque;
702 "this is a bug, please report it.\n");
703 #if FF_API_REORDERED_OPAQUE
705 ctx->reordered_opaque = 0;
710 switch (pic_out.i_type) {
731 int64_t
sse[3] = {0};
735 double scale[3] = { 1,
747 double mse = (max_value * max_value) / pow(10, pic_out.prop.f_psnr[
i] / 10.0);
750 sse[
i] = (int64_t)
floor(mse * plane_size + .5);
757 errors, error_count, pict_type);
772 x264_picture_t pic_out = {0};
775 ret = x264_encoder_encode(x4->
enc, &nal, &nnal,
NULL, &pic_out);
776 }
while (
ret > 0 && x264_encoder_delayed_frames(x4->
enc));
795 #if X264_BUILD >= 161
796 x264_param_cleanup(&x4->
params);
800 x264_encoder_close(x4->
enc);
812 if ((
ret = x264_param_parse(&x4->
params, opt, param)) < 0) {
813 if (
ret == X264_PARAM_BAD_NAME) {
815 "bad option '%s': '%s'\n", opt, param);
817 #if X264_BUILD >= 161
818 }
else if (
ret == X264_PARAM_ALLOC_FAILED) {
820 "out of memory parsing option '%s': '%s'\n", opt, param);
825 "bad value for '%s': '%s'\n", opt, param);
848 return X264_CSP_BGRA;
868 #define PARSE_X264_OPT(name, var)\
869 if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
870 av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
871 return AVERROR(EINVAL);\
884 #if CONFIG_LIBX262_ENCODER
887 x264_param_default_mpeg2(&x4->
params);
890 x264_param_default(&x4->
params);
899 for (
i = 0; x264_preset_names[
i];
i++)
903 for (
i = 0; x264_tune_names[
i];
i++)
909 if (avctx->
level > 0)
913 x4->
params.p_log_private = avctx;
914 x4->
params.i_log_level = X264_LOG_DEBUG;
916 #if X264_BUILD >= 153
924 av_log(avctx,
AV_LOG_ERROR,
"bit_rate and rc_max_rate > %d000 not supported by libx264\n", INT_MAX);
928 x4->
params.rc.i_rc_method = X264_RC_ABR;
934 x4->
params.rc.b_stat_read = 1;
937 x4->
params.rc.i_rc_method = X264_RC_CRF;
939 }
else if (x4->
cqp >= 0) {
940 x4->
params.rc.i_rc_method = X264_RC_CQP;
950 x4->
params.rc.f_vbv_buffer_init =
972 if (avctx->
qmin >= 0)
974 if (avctx->
qmax >= 0)
978 if (avctx->
qblur >= 0)
982 if (avctx->
refs >= 0)
984 else if (x4->
params.i_level_idc > 0) {
987 int scale = X264_BUILD < 129 ? 384 : 1;
989 for (
i = 0;
i<x264_levels[
i].level_idc;
i++)
1032 x4->
params.b_vfr_input = 0;
1035 #if X264_BUILD >= 142
1039 "x264 too old for AVC Intra, at least version 142 needed\n");
1043 #if X264_BUILD < 164
1045 "x264 too old for AVC Intra 300/480, at least version 164 needed\n");
1049 x4->
params.i_avcintra_flavor = X264_AVCINTRA_FLAVOR_SONY;
1053 if (x4->
b_bias != INT_MIN)
1074 x264_param_apply_fastfirstpass(&x4->
params);
1115 if (x264_param_apply_profile(&x4->
params, x4->
profile) < 0) {
1119 for (
i = 0; x264_profile_names[
i];
i++)
1128 x4->
params.vui.i_sar_width = sw;
1129 x4->
params.vui.i_sar_height = sh;
1139 #if FF_API_TICKS_PER_FRAME
1163 x4->
params.vui.b_fullrange = 1;
1175 x4->
params.b_repeat_headers = 0;
1178 x4->
params.b_full_recon = 1;
1183 char param[4096]={0},
val[4096]={0};
1184 if(sscanf(p,
"%4095[^:=]=%4095[^:]", param,
val) == 1){
1200 #if X264_BUILD >= 142
1203 x4->
params.b_repeat_headers = 1;
1211 "Error parsing option '%s = %s'.\n",
1213 #if X264_BUILD >= 161
1214 if (
ret == X264_PARAM_ALLOC_FAILED)
1225 x4->
params.i_bframe_pyramid ? 2 : 1 : 0;
1231 x4->
enc = x264_encoder_open(&x4->
params);
1240 s = x264_encoder_headers(x4->
enc, &nal, &nnal);
1245 for (
i = 0;
i < nnal;
i++) {
1247 if (nal[
i].i_type == NAL_SEI) {
1253 memcpy(x4->
sei, nal[
i].p_payload, nal[
i].i_payload);
1256 memcpy(p, nal[
i].p_payload, nal[
i].i_payload);
1257 p += nal[
i].i_payload;
1291 #ifdef X264_CSP_NV21
1317 #ifdef X264_CSP_NV21
1324 #ifdef X264_CSP_I400
1330 #if CONFIG_LIBX264RGB_ENCODER
1339 #if X264_BUILD < 153
1342 if (x264_bit_depth == 8)
1344 else if (x264_bit_depth == 9)
1346 else if (x264_bit_depth == 10)
1351 #define OFFSET(x) offsetof(X264Context, x)
1352 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1357 {
"fastfirstpass",
"Use fast settings when encoding first pass",
OFFSET(fastfirstpass),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
VE},
1363 {
"crf",
"Select the quality for constant quality mode",
OFFSET(crf),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE },
1364 {
"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 },
1365 {
"qp",
"Constant quantization parameter rate control method",
OFFSET(cqp),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE },
1368 {
"variance",
"Variance AQ (complexity mask)", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_VARIANCE}, INT_MIN, INT_MAX,
VE,
"aq_mode" },
1369 {
"autovariance",
"Auto-variance AQ", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX,
VE,
"aq_mode" },
1370 #if X264_BUILD >= 144
1371 {
"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" },
1373 {
"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},
1375 {
"psy-rd",
"Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.",
OFFSET(psy_rd),
AV_OPT_TYPE_STRING, {0 }, 0, 0,
VE},
1376 {
"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 },
1378 {
"weightp",
"Weighted prediction analysis method.",
OFFSET(weightp),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE,
"weightp" },
1383 {
"intra-refresh",
"Use Periodic Intra Refresh instead of IDR frames.",
OFFSET(intra_refresh),
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VE },
1384 {
"bluray-compat",
"Bluray compatibility workarounds.",
OFFSET(bluray_compat) ,
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VE },
1385 {
"b-bias",
"Influences how often B-frames are used",
OFFSET(b_bias),
AV_OPT_TYPE_INT, { .i64 = INT_MIN}, INT_MIN, INT_MAX,
VE },
1386 {
"b-pyramid",
"Keep some B-frames as references.",
OFFSET(b_pyramid),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE,
"b_pyramid" },
1388 {
"strict",
"Strictly hierarchical pyramid", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX,
VE,
"b_pyramid" },
1389 {
"normal",
"Non-strict (not Blu-ray compatible)", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX,
VE,
"b_pyramid" },
1390 {
"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 },
1396 {
"cplxblur",
"Reduce fluctuations in QP (before curve compression)",
OFFSET(cplxblur),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE},
1397 {
"partitions",
"A comma-separated list of partitions to consider. "
1398 "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all",
OFFSET(partitions),
AV_OPT_TYPE_STRING, { 0 }, 0, 0,
VE},
1399 {
"direct-pred",
"Direct MV prediction mode",
OFFSET(direct_pred),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE,
"direct-pred" },
1404 {
"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 },
1406 {
"nal-hrd",
"Signal HRD information (requires vbv-bufsize; "
1411 {
"avcintra-class",
"AVC-Intra class 50/100/200/300/480",
OFFSET(avcintra_class),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 480 ,
VE},
1412 {
"me_method",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA,
VE,
"motion-est"},
1413 {
"motion-est",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA,
VE,
"motion-est"},
1419 {
"forced-idr",
"If forcing keyframes, force them as IDR frames.",
OFFSET(forced_idr),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, -1, 1,
VE },
1426 {
"b_strategy",
"Strategy to choose between I/P/B-frames",
OFFSET(b_frame_strategy),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2,
VE },
1427 {
"chromaoffset",
"QP difference between chroma and luma",
OFFSET(chroma_offset),
AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX,
VE },
1428 {
"sc_threshold",
"Scene change threshold",
OFFSET(scenechange_threshold),
AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX,
VE },
1429 {
"noise_reduction",
"Noise reduction",
OFFSET(noise_reduction),
AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX,
VE },
1430 {
"udu_sei",
"Use user data unregistered SEI if available",
OFFSET(udu_sei),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1431 {
"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 },
1441 {
"i_qfactor",
"-1" },
1442 {
"b_qfactor",
"-1" },
1450 {
"trellis",
"-1" },
1451 {
"me_range",
"-1" },
1453 {
"keyint_min",
"-1" },
1456 {
"thread_type",
"0" },
1457 {
"flags",
"+cgop" },
1458 {
"rc_init_occupancy",
"-1" },
1462 #if CONFIG_LIBX264_ENCODER
1463 static const AVClass x264_class = {
1470 #if X264_BUILD >= 153
1473 FFCodec ff_libx264_encoder = {
1474 .
p.
name =
"libx264",
1483 .p.priv_class = &x264_class,
1484 .p.wrapper_name =
"libx264",
1491 #if X264_BUILD < 153
1497 #if X264_BUILD < 158
1504 #if CONFIG_LIBX264RGB_ENCODER
1505 static const AVClass rgbclass = {
1513 .
p.
name =
"libx264rgb",
1514 CODEC_LONG_NAME(
"libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"),
1520 .p.pix_fmts = pix_fmts_8bit_rgb,
1521 .p.priv_class = &rgbclass,
1522 .p.wrapper_name =
"libx264",
1529 #if X264_BUILD < 158
1536 #if CONFIG_LIBX262_ENCODER
1537 static const AVClass X262_class = {
1545 .
p.
name =
"libx262",
1553 .p.priv_class = &X262_class,
1554 .p.wrapper_name =
"libx264",
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.
#define FF_ENABLE_DEPRECATION_WARNINGS
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int keyint_min
minimum GOP size
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test note that you must have installed it fate list List all fate regression test targets install Install libraries and programs examples Build all examples located in doc examples checkheaders Check headers dependencies alltools Build all tools in tools directory config Reconfigure the project with the current configuration tools target_dec_< decoder > _fuzzer Build fuzzer to fuzz the specified decoder tools target_bsf_< filter > _fuzzer Build fuzzer to fuzz the specified bitstream filter Useful standard make this is useful to reduce unneeded rebuilding when changing but note that you must force rebuilds of files that actually need it by hand then make j< num > Rebuild with multiple jobs at the same time Faster on multi processor systems make k Continue build in case of errors
enum AVColorSpace colorspace
YUV colorspace type.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
static void stats(AVPacket *const *in, int n_in, unsigned *_max, unsigned *_sum)
int64_t duration
Duration of the frame, in the same units as pts.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
#define AV_PROFILE_H264_MAIN
#define AV_CODEC_CAP_ENCODER_RECON_FRAME
The encoder is able to output reconstructed frame data, i.e.
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
void * opaque
Frame owner's private data.
static void X264_log(void *p, int level, const char *fmt, va_list args)
This structure describes decoded (raw) audio or video data.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
@ AVCOL_RANGE_JPEG
Full range content.
const FFCodec ff_libx264rgb_encoder
Copyright 2023 Elias Carotti <eliascrt at amazon dot it>
int depth
Number of bits in the component.
#define AV_PIX_FMT_YUV420P10
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
static void X264_flush(AVCodecContext *avctx)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
static void av_always_inline mbinfo_compute_changed_coords(const AVVideoRect *rect, int *min_x, int *max_x, int *min_y, int *max_y)
@ AV_VIDEO_HINT_TYPE_CHANGED
int qmax
maximum quantizer
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
int me_subpel_quality
subpel ME quality
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int roi_warned
If the encoder does not support ROI then warn the first time we encounter a frame with ROI side data.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
static av_cold int X264_init(AVCodecContext *avctx)
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
AVBufferRef * opaque_ref
Frame owner's private data.
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
static av_cold void X264_init_static(FFCodec *codec)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_CODEC_FLAG_COPY_OPAQUE
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
AVCodec p
The public AVCodec.
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
int refs
number of reference frames
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
static av_always_inline AVVideoRect * av_video_hint_rects(const AVVideoHint *hints)
static av_always_inline float scale(float x, float s)
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
#define FF_CODEC_ENCODE_CB(func)
#define AV_CODEC_FLAG_LOOP_FILTER
loop filter.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
#define AV_PIX_FMT_YUV444P10
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
@ AV_STEREO3D_FRAMESEQUENCE
Views are alternated temporally.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static enum AVPixelFormat pix_fmts_10bit[]
Structure describing a single Region Of Interest.
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
int has_b_frames
Size of the frame reordering buffer in the decoder.
attribute_deprecated int64_t reordered_opaque
reordered opaque 64 bits (generally an integer or a double precision float PTS but can be anything).
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
@ AV_STEREO3D_LINES
Views are packed per line, as if interlaced.
int global_quality
Global quality for codecs which cannot change it per frame.
#define AV_CEIL_RSHIFT(a, b)
int flags
Flags modifying the (de)muxer behaviour.
static __device__ float floor(float a)
static enum AVPixelFormat pix_fmt
#define AV_CODEC_EXPORT_DATA_PRFT
Export encoder Producer Reference Time through packet side data.
static enum AVPixelFormat pix_fmts_all[]
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_PROFILE_H264_HIGH_10
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
int thread_type
Which multithreading methods to use.
#define AV_PIX_FMT_YUV420P9
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
#define COMPUTE_MBINFO(mbinfo_filler_, mbinfo_marker_, compute_coords_fn_)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int64_t rc_max_rate
maximum bitrate
void * opaque
for some private data of the user
This structure describes the bitrate properties of an encoded bitstream.
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AV_PROFILE_H264_HIGH_422
static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth, const AVFrame *frame, const uint8_t *data, size_t size)
int flags
Additional information about the frame packing.
#define AV_PIX_FMT_GRAY10
int rc_buffer_size
decoder bitstream buffer size
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
static enum AVPixelFormat pix_fmts_9bit[]
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
uint8_t nb_components
The number of components each pixel has, (1-4)
float qblur
amount of qscale smoothing over time (0.0-1.0)
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int64_t bit_rate
the average bitrate
uint32_t self_size
Must be set to the size of this data structure (that is, sizeof(AVRegionOfInterest)).
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
int me_cmp
motion estimation comparison function
#define AV_PIX_FMT_YUV422P10
int trellis
trellis RD quantization
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
int level
Encoding level descriptor.
static void free_picture(x264_picture_t *pic)
@ AVCOL_RANGE_UNSPECIFIED
@ AV_FRAME_DATA_SEI_UNREGISTERED
User data unregistered metadata associated with a video frame.
static void dct8x8(int16_t *coef, int bit_depth)
AVDictionary * x264_params
#define PARSE_X264_OPT(name, var)
float qcompress
amount of qscale change between easy & hard scenes (0.0-1.0)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
static void av_always_inline mbinfo_compute_constant_coords(const AVVideoRect *rect, int *min_x, int *max_x, int *min_y, int *max_y)
enum AVPictureType pict_type
Picture type of the frame.
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
static enum AVPixelFormat pix_fmts_8bit[]
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_STEREO3D_CHECKERBOARD
Views are packed in a checkerboard-like structure per pixel.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
static av_cold int X264_close(AVCodecContext *avctx)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, const x264_nal_t *nals, int nnal)
int me_range
maximum motion estimation search range in subpel units If 0 then no limit.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
@ AVCHROMA_LOC_UNSPECIFIED
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static void opaque_uninit(X264Opaque *o)
#define AVERROR_EXTERNAL
Generic error in an external library.
int flags
A combination of AV_PKT_FLAG values.
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
#define AV_LOG_INFO
Standard information.
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...
AVBufferRef * frame_opaque_ref
#define AV_CODEC_FLAG_RECON_FRAME
Request the encoder to output reconstructed frames, i.e. frames that would be produced by decoding th...
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int top
Distance in pixels from the top edge of the frame to the top and bottom edges and from the left edge ...
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
static int setup_mb_info(AVCodecContext *ctx, x264_picture_t *pic, const AVFrame *frame, const AVVideoHint *info)
static const FFCodecDefault x264_defaults[]
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
AVFrameSideData ** side_data
static enum AVPixelFormat csp_to_pixfmt(int csp)
static const AVOption options[]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
void * av_calloc(size_t nmemb, size_t size)
#define AV_PIX_FMT_YUV444P9
#define AV_CODEC_FLAG_CLOSED_GOP
X264Opaque * reordered_opaque
@ 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...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
@ AV_STEREO3D_COLUMNS
Views are packed per column.
enum AVStereo3DType type
How views are packed within the video.
#define AV_PROFILE_H264_BASELINE
@ AV_FRAME_DATA_VIDEO_HINT
Provide encoder-specific hinting information about changed/unchanged portions of a frame.
const FFCodec ff_libx262_encoder
int next_reordered_opaque
AVFrame * recon_frame
When the AV_CODEC_FLAG_RECON_FRAME flag is used.
int scenechange_threshold
#define AV_INPUT_BUFFER_PADDING_SIZE
int max_qdiff
maximum quantizer difference between frames
main external API structure.
static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
#define AV_PROFILE_H264_HIGH
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
@ SEI_TYPE_USER_DATA_UNREGISTERED
int qmin
minimum quantizer
enum AVFrameSideDataType type
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
attribute_deprecated int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int64_t av_gettime(void)
Get the current time in microseconds.
#define FF_DISABLE_DEPRECATION_WARNINGS
@ AV_PICTURE_TYPE_P
Predicted.
#define AV_PROFILE_H264_HIGH_444
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
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...
A reference to a data buffer.
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, x264_picture_t **ppic)
Structure to hold side data for an AVFrame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int parse_opts(AVCodecContext *avctx, const char *opt, const char *param)
int slices
Number of slices.
This structure stores compressed data.
int width
picture width / height.
@ AV_FRAME_DATA_REGIONS_OF_INTEREST
Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is ...
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static int sse(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride)
AVCPBProperties * ff_encode_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
AVRational qoffset
Quantisation offset.
void * priv_data
Format private data.
static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.