22#include "config_components.h"
53#define MB_FLOOR(x) ((x) >> (MB_LSIZE))
54#define MB_CEIL(x) MB_FLOOR((x) + (MB_SIZE - 1))
149 memset(o, 0,
sizeof(*o));
153 const x264_nal_t *nals,
int nnal)
163 for (
int i = 0;
i < nnal;
i++) {
164 size += nals[
i].i_payload;
168#if INT_MAX > INT64_MAX / INT_MAX - 1
190 memcpy(p, nals[0].p_payload,
size);
202 if (x4->
params.vui.i_sar_height*
ctx->sample_aspect_ratio.num !=
ctx->sample_aspect_ratio.den * x4->
params.vui.i_sar_width) {
203 x4->
params.vui.i_sar_height =
ctx->sample_aspect_ratio.den;
204 x4->
params.vui.i_sar_width =
ctx->sample_aspect_ratio.num;
205 x264_encoder_reconfig(x4->
enc, &x4->
params);
208 if (x4->
params.rc.i_vbv_buffer_size !=
ctx->rc_buffer_size / 1000 ||
209 x4->
params.rc.i_vbv_max_bitrate !=
ctx->rc_max_rate / 1000) {
210 x4->
params.rc.i_vbv_buffer_size =
ctx->rc_buffer_size / 1000;
211 x4->
params.rc.i_vbv_max_bitrate =
ctx->rc_max_rate / 1000;
212 x264_encoder_reconfig(x4->
enc, &x4->
params);
215 if (x4->
params.rc.i_rc_method == X264_RC_ABR &&
216 x4->
params.rc.i_bitrate !=
ctx->bit_rate / 1000) {
217 x4->
params.rc.i_bitrate =
ctx->bit_rate / 1000;
218 x264_encoder_reconfig(x4->
enc, &x4->
params);
222 x4->
params.rc.i_rc_method == X264_RC_CRF &&
223 x4->
params.rc.f_rf_constant != x4->
crf) {
225 x264_encoder_reconfig(x4->
enc, &x4->
params);
228 if (x4->
params.rc.i_rc_method == X264_RC_CQP &&
230 x4->
params.rc.i_qp_constant != x4->
cqp) {
232 x264_encoder_reconfig(x4->
enc, &x4->
params);
238 x264_encoder_reconfig(x4->
enc, &x4->
params);
253 x264_encoder_reconfig(x4->
enc, &x4->
params);
262 switch (stereo->
type) {
292 "Ignoring unsupported inverted stereo value %d\n", fpa_type);
296 if (fpa_type != x4->
params.i_frame_packing) {
297 x4->
params.i_frame_packing = fpa_type;
298 x264_encoder_reconfig(x4->
enc, &x4->
params);
305 for (
int i = 0;
i < pic->extra_sei.num_payloads;
i++)
306 av_free(pic->extra_sei.payloads[
i].payload);
310 pic->extra_sei.num_payloads = 0;
373 mbinfo =
av_calloc(mb_width * mb_height,
sizeof(*mbinfo));
377#define COMPUTE_MBINFO(mbinfo_filler_, mbinfo_marker_, compute_coords_fn_) \
378 memset(mbinfo, mbinfo_filler_, sizeof(*mbinfo) * mb_width * mb_height); \
380 for (int i = 0; i < nb_rects; i++) { \
381 int min_x, max_x, min_y, max_y; \
383 compute_coords_fn_(mbinfo_rects, &min_x, &max_x, &min_y, &max_y); \
384 for (int mb_y = min_y; mb_y < max_y; ++mb_y) { \
385 memset(mbinfo + mb_y * mb_width + min_x, mbinfo_marker_, max_x - min_x); \
397 pic->prop.mb_info = mbinfo;
398 pic->prop.mb_info_free =
av_free;
410 int qp_range = 51 + 6 * (x4->
params.i_bitdepth - 8);
416 if (x4->
params.rc.i_aq_mode == X264_AQ_NONE) {
432 if (!roi_size ||
size % roi_size != 0) {
436 nb_rois =
size / roi_size;
438 qoffsets =
av_calloc(mbx * mby,
sizeof(*qoffsets));
444 for (
int i = nb_rois - 1;
i >= 0;
i--) {
445 int startx, endx, starty, endy;
461 qoffset =
av_clipf(qoffset * qp_range, -qp_range, +qp_range);
463 for (
int y = starty; y < endy; y++) {
464 for (
int x = startx; x < endx; x++) {
465 qoffsets[x + y*mbx] = qoffset;
470 pic->prop.quant_offsets = qoffsets;
471 pic->prop.quant_offsets_free =
av_free;
477 x264_picture_t **ppic)
481 x264_picture_t *pic = &x4->
pic;
482 x264_sei_t *
sei = &pic->extra_sei;
483 unsigned int sei_data_size = 0;
493 x264_picture_init(pic);
494 pic->img.i_csp = x4->
params.i_csp;
495 if (x4->
params.i_bitdepth > 8)
496 pic->img.i_csp |= X264_CSP_HIGH_DEPTH;
499 for (
int i = 0;
i < pic->img.i_plane;
i++) {
500 pic->img.plane[
i] =
frame->data[
i];
501 pic->img.i_stride[
i] =
frame->linesize[
i];
504 pic->i_pts =
frame->pts;
520 pic->opaque = opaque;
525 switch (
frame->pict_type) {
527 pic->i_type = x4->
forced_idr > 0 ? X264_TYPE_IDR : X264_TYPE_KEYFRAME;
530 pic->i_type = X264_TYPE_P;
533 pic->i_type = X264_TYPE_B;
536 pic->i_type = X264_TYPE_AUTO;
551 if (!
sei->payloads) {
559 sei->payloads[0].payload_size = sei_size;
560 sei->payloads[0].payload = sei_data;
562 sei->num_payloads = 1;
585 for (
int j = 0; j <
frame->nb_side_data; j++) {
625 x264_picture_t pic_out = {0}, *pic_in;
635 if (x264_encoder_encode(x4->
enc, &
nal, &nnal, pic_in, &pic_out) < 0)
646 "Unhandled reconstructed frame colorspace: %d\n",
653 for (
int i = 0;
i < pic_out.img.i_plane;
i++) {
668 }
while (!ret && !
frame && x264_encoder_delayed_frames(x4->
enc));
673 pkt->pts = pic_out.i_pts;
674 pkt->dts = pic_out.i_dts;
676 out_opaque = pic_out.opaque;
692 "this is a bug, please report it.\n");
695 switch (pic_out.i_type) {
720 double scale[3] = { 1,
732 double mse = (max_value * max_value) / pow(10, pic_out.prop.f_psnr[
i] / 10.0);
742 errors, error_count, pict_type);
757 x264_picture_t pic_out = {0};
760 ret = x264_encoder_encode(x4->
enc, &
nal, &nnal,
NULL, &pic_out);
761 }
while (ret > 0 && x264_encoder_delayed_frames(x4->
enc));
794 x264_param_cleanup(&x4->
params);
798 x264_encoder_close(x4->
enc);
810 if ((ret = x264_param_parse(&x4->
params, opt, param)) < 0) {
811 if (ret == X264_PARAM_BAD_NAME) {
813 "bad option '%s': '%s'\n", opt, param);
816 }
else if (ret == X264_PARAM_ALLOC_FAILED) {
818 "out of memory parsing option '%s': '%s'\n", opt, param);
823 "bad value for '%s': '%s'\n", opt, param);
846 return X264_CSP_BGRA;
876 memcpy(x4->
sei,
nal->p_payload,
nal->i_payload);
881#if CONFIG_LIBX264_ENCODER
884 x264_nal_t *sps_nal =
NULL;
885 x264_nal_t *pps_nal =
NULL;
892 for (
int i = 0;
i < nnal;
i++) {
893 switch (
nal[
i].i_type) {
907 if (!sps_nal || !pps_nal)
910 avctx->
extradata_size = sps_nal->i_payload + pps_nal->i_payload + 7;
918 sps = sps_nal->p_payload + 4;
925 memcpy(p, sps_nal->p_payload + 2, sps_nal->i_payload - 2);
929 p += sps_nal->i_payload - 2;
931 memcpy(p, pps_nal->p_payload + 2, pps_nal->i_payload - 2);
932 p += pps_nal->i_payload - 2;
934 if (
sps[3] != 66 &&
sps[3] != 77 &&
sps[3] != 88) {
936 int chroma_format_idc;
937 int bit_depth_luma_minus8, bit_depth_chroma_minus8;
952 if (chroma_format_idc == 3)
957 *
p++ = 0xFC | chroma_format_idc;
958 *
p++ = 0xF8 | bit_depth_luma_minus8;
959 *
p++ = 0xF8 | bit_depth_chroma_minus8;
976 s = x264_encoder_headers(x4->
enc, &
nal, &nnal);
980#if CONFIG_LIBX264_ENCODER
982 return set_avcc_extradata(avctx,
nal, nnal);
989 for (
int i = 0;
i < nnal;
i++) {
991 if (
nal[
i].i_type == NAL_SEI) {
997 memcpy(p,
nal[
i].p_payload,
nal[
i].i_payload);
998 p +=
nal[
i].i_payload;
1005#define PARSE_X264_OPT(name, var)\
1006 if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
1007 av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
1008 return AVERROR(EINVAL);\
1011#if CONFIG_LIBX264_HDR10
1018 params->mastering_display.b_mastering_display = 1;
1021 int *
const points[][2] = {
1023 &
params->mastering_display.i_red_x,
1024 &
params->mastering_display.i_red_y
1027 &
params->mastering_display.i_green_x,
1028 &
params->mastering_display.i_green_y
1031 &
params->mastering_display.i_blue_x,
1032 &
params->mastering_display.i_blue_y
1036 for (
int i = 0;
i < 3;
i++) {
1038 int *
dst[2] = { points[
i][0], points[
i][1] };
1044 params->mastering_display.i_white_x =
1046 params->mastering_display.i_white_y =
1051 params->mastering_display.i_display_max =
1053 params->mastering_display.i_display_min =
1061#if CONFIG_LIBX264_HDR10
1077 params->content_light_level.b_cll = 1;
1096#if CONFIG_LIBX262_ENCODER
1099 x264_param_default_mpeg2(&x4->
params);
1102 x264_param_default(&x4->
params);
1111 for (
i = 0; x264_preset_names[
i];
i++)
1115 for (
i = 0; x264_tune_names[
i];
i++)
1121 if (avctx->
level > 0)
1125 x4->
params.p_log_private = avctx;
1126 x4->
params.i_log_level = X264_LOG_DEBUG;
1134 av_log(avctx,
AV_LOG_ERROR,
"bit_rate and rc_max_rate > %d000 not supported by libx264\n", INT_MAX);
1138 x4->
params.rc.i_rc_method = X264_RC_ABR;
1144 x4->
params.rc.b_stat_read = 1;
1147 x4->
params.rc.i_rc_method = X264_RC_CRF;
1149 }
else if (x4->
cqp >= 0) {
1150 x4->
params.rc.i_rc_method = X264_RC_CQP;
1160 x4->
params.rc.f_vbv_buffer_init =
1182 if (avctx->
qmin >= 0)
1184 if (avctx->
qmax >= 0)
1188 if (avctx->
qblur >= 0)
1192 if (avctx->
refs >= 0)
1194 else if (x4->
params.i_level_idc > 0) {
1198 for (
i = 0;
i<x264_levels[
i].level_idc;
i++)
1200 x4->
params.i_frame_reference =
av_clip(x264_levels[
i].dpb / mbn, 1, x4->
params.i_frame_reference);
1241 x4->
params.b_vfr_input = 0;
1249 "x264 too old for AVC Intra 300/480, at least version 164 needed\n");
1253 x4->
params.i_avcintra_flavor = X264_AVCINTRA_FLAVOR_SONY;
1257 if (x4->
b_bias != INT_MIN)
1278 x264_param_apply_fastfirstpass(&x4->
params);
1319 if (x264_param_apply_profile(&x4->
params, x4->
profile) < 0) {
1323 for (
i = 0; x264_profile_names[
i];
i++)
1332 x4->
params.vui.i_sar_width = sw;
1333 x4->
params.vui.i_sar_height = sh;
1361 x4->
params.vui.b_fullrange = 1;
1375 x4->
params.b_repeat_headers = 0;
1378 x4->
params.b_full_recon = 1;
1383 char param[4096]={0},
val[4096]={0};
1384 if(sscanf(p,
"%4095[^:=]=%4095[^:]", param,
val) == 1){
1402 x4->
params.b_repeat_headers = 1;
1407 if ((ret = x264_param_parse(&x4->
params, en->
key, en->
value)) < 0) {
1409 "Error parsing option '%s = %s'.\n",
1411#if X264_BUILD >= 161
1412 if (ret == X264_PARAM_ALLOC_FAILED)
1423 x4->
params.i_bframe_pyramid ? 2 : 1 : 0;
1429 x4->
enc = x264_encoder_open(&x4->
params);
1507#if CONFIG_LIBX264RGB_ENCODER
1516#define OFFSET(x) offsetof(X264Context, x)
1517#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1518#define VER VE | AV_OPT_FLAG_RUNTIME_PARAM
1523 {
"fastfirstpass",
"Use fast settings when encoding first pass",
OFFSET(fastfirstpass),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
VE},
1530 {
"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,
VER },
1531 {
"qp",
"Constant quantization parameter rate control method",
OFFSET(cqp),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VER },
1532 {
"aq-mode",
"AQ method",
OFFSET(aq_mode),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE, .unit =
"aq_mode"},
1534 {
"variance",
"Variance AQ (complexity mask)", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_VARIANCE}, INT_MIN, INT_MAX,
VE, .unit =
"aq_mode" },
1535 {
"autovariance",
"Auto-variance AQ", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX,
VE, .unit =
"aq_mode" },
1536 {
"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, .unit =
"aq_mode" },
1537 {
"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},
1539 {
"psy-rd",
"Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.",
OFFSET(psy_rd),
AV_OPT_TYPE_STRING, {0 }, 0, 0,
VE},
1540 {
"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 },
1542 {
"weightp",
"Weighted prediction analysis method.",
OFFSET(weightp),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE, .unit =
"weightp" },
1544 {
"simple",
NULL, 0,
AV_OPT_TYPE_CONST, {.i64 = X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX,
VE, .unit =
"weightp" },
1545 {
"smart",
NULL, 0,
AV_OPT_TYPE_CONST, {.i64 = X264_WEIGHTP_SMART}, INT_MIN, INT_MAX,
VE, .unit =
"weightp" },
1547 {
"intra-refresh",
"Use Periodic Intra Refresh instead of IDR frames.",
OFFSET(intra_refresh),
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VE },
1548 {
"bluray-compat",
"Bluray compatibility workarounds.",
OFFSET(bluray_compat) ,
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VE },
1549 {
"b-bias",
"Influences how often B-frames are used",
OFFSET(b_bias),
AV_OPT_TYPE_INT, { .i64 = INT_MIN}, INT_MIN, INT_MAX,
VE },
1550 {
"b-pyramid",
"Keep some B-frames as references.",
OFFSET(b_pyramid),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE, .unit =
"b_pyramid" },
1551 {
"none",
NULL, 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX,
VE, .unit =
"b_pyramid" },
1552 {
"strict",
"Strictly hierarchical pyramid", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX,
VE, .unit =
"b_pyramid" },
1553 {
"normal",
"Non-strict (not Blu-ray compatible)", 0,
AV_OPT_TYPE_CONST, {.i64 = X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX,
VE, .unit =
"b_pyramid" },
1554 {
"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 },
1560 {
"cplxblur",
"Reduce fluctuations in QP (before curve compression)",
OFFSET(cplxblur),
AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX,
VE},
1561 {
"partitions",
"A comma-separated list of partitions to consider. "
1562 "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all",
OFFSET(partitions),
AV_OPT_TYPE_STRING, { 0 }, 0, 0,
VE},
1563 {
"direct-pred",
"Direct MV prediction mode",
OFFSET(direct_pred),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE, .unit =
"direct-pred" },
1565 {
"spatial",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = X264_DIRECT_PRED_SPATIAL }, 0, 0,
VE, .unit =
"direct-pred" },
1566 {
"temporal",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = X264_DIRECT_PRED_TEMPORAL }, 0, 0,
VE, .unit =
"direct-pred" },
1568 {
"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 },
1570 {
"nal-hrd",
"Signal HRD information (requires vbv-bufsize; "
1571 "cbr not allowed in .mp4)",
OFFSET(nal_hrd),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX,
VE, .unit =
"nal-hrd" },
1575 {
"avcintra-class",
"AVC-Intra class 50/100/200/300/480",
OFFSET(avcintra_class),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 480 ,
VE},
1576 {
"me_method",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA,
VE, .unit =
"motion-est"},
1577 {
"motion-est",
"Set motion estimation method",
OFFSET(motion_est),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA,
VE, .unit =
"motion-est"},
1583 {
"forced-idr",
"If forcing keyframes, force them as IDR frames.",
OFFSET(forced_idr),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, -1, 1,
VE },
1590 {
"b_strategy",
"Strategy to choose between I/P/B-frames",
OFFSET(b_frame_strategy),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 2,
VE },
1591 {
"chromaoffset",
"QP difference between chroma and luma",
OFFSET(chroma_offset),
AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX,
VE },
1592 {
"sc_threshold",
"Scene change threshold",
OFFSET(scenechange_threshold),
AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX,
VE },
1593 {
"noise_reduction",
"Noise reduction",
OFFSET(noise_reduction),
AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX,
VE },
1594 {
"udu_sei",
"Use user data unregistered SEI if available",
OFFSET(udu_sei),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VE },
1595 {
"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 },
1608 {
"i_qfactor",
"-1" },
1609 {
"b_qfactor",
"-1" },
1617 {
"trellis",
"-1" },
1618 {
"me_range",
"-1" },
1620 {
"keyint_min",
"-1" },
1623 {
"thread_type",
"0" },
1624 {
"flags",
"+cgop" },
1625 {
"rc_init_occupancy",
"-1" },
1629#if CONFIG_LIBX264_ENCODER
1630static const AVClass x264_class = {
1631 .class_name =
"libx264",
1638 .p.name =
"libx264",
1648 .p.priv_class = &x264_class,
1649 .p.wrapper_name =
"libx264",
1667#if CONFIG_LIBX264RGB_ENCODER
1668static const AVClass rgbclass = {
1669 .class_name =
"libx264rgb",
1676 .p.name =
"libx264rgb",
1677 CODEC_LONG_NAME(
"libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"),
1684 .p.priv_class = &rgbclass,
1685 .p.wrapper_name =
"libx264",
1699#if CONFIG_LIBX262_ENCODER
1700static const AVClass X262_class = {
1701 .class_name =
"libx262",
1708 .p.name =
"libx262",
1717 .p.priv_class = &X262_class,
1718 .p.wrapper_name =
"libx264",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
SwsAArch64OpImplParams params
static double val(void *priv, double ch)
const FFCodec ff_libx264_encoder
const FFCodec ff_libx262_encoder
const FFCodec ff_libx264rgb_encoder
static AVFormatContext * ctx
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.
static enum AVPixelFormat pix_fmts_8bit[2][2]
static enum AVPixelFormat pix_fmts_10bit[2][2]
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Libavcodec external API header.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
refcounted data buffer API
#define i(width, name, range_min, range_max)
static int FUNC sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC sei_payload(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawSEI *current, int payload_size)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define CODEC_PIXFMTS_ARRAY(array)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#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.
#define AV_CEIL_RSHIFT(a, b)
static __device__ float fabs(float a)
static __device__ float floor(float a)
#define AV_PROFILE_H264_MAIN
#define AV_PROFILE_H264_HIGH_444
#define AV_PROFILE_H264_HIGH
#define AV_PROFILE_H264_HIGH_10
#define AV_PROFILE_H264_HIGH_422
#define AV_PROFILE_H264_BASELINE
static enum AVPixelFormat pix_fmt
int(* init)(AVBSFContext *ctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
AVCPBProperties * ff_encode_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t error[], int error_count, enum AVPictureType pict_type)
av_cold int ff_encode_reconf_parse_dict(AVCodecContext *avctx, AVDictionary **dict)
static enum AVPixelFormat pix_fmts_9bit[NUM_CHROMA_FORMATS]
static CheckasmStats stats
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void skip_bits1(GetBitContext *s)
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
#define AV_OPT_FLAG_RUNTIME_PARAM
A generic parameter which can be set by the user at runtime.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_ENCODER_RECONF
Encoder can be reconfigured by passing new initialization parameters.
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
#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_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#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[?
#define AV_CODEC_CAP_ENCODER_RECON_FRAME
The encoder is able to output reconstructed frame data, i.e.
#define AV_CODEC_FLAG_COPY_OPAQUE
#define AV_CODEC_FLAG_RECON_FRAME
Request the encoder to output reconstructed frames, i.e. frames that would be produced by decoding th...
@ 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.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AVERROR_EXTERNAL
Generic error in an external library.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#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_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
static const AVFrameSideData * av_frame_side_data_get(AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conver...
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AV_FRAME_DATA_SEI_UNREGISTERED
User data unregistered metadata associated with a video frame.
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
@ AV_FRAME_DATA_VIDEO_HINT
Provide encoder-specific hinting information about changed/unchanged portions of a frame.
@ 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.
const char * av_default_item_name(void *ptr)
Return the context name.
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.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
@ 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.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static const uint8_t level_map[LCEVC_LogLevelCount]
common internal api header.
common internal API header
static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst, const AVMasteringDisplayMetadata *mdcv)
static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static void reconfig_encoder_from_frame(AVCodecContext *ctx, const AVFrame *frame)
static int setup_mb_info(AVCodecContext *ctx, x264_picture_t *pic, const AVFrame *frame, const AVVideoHint *info)
static void X264_flush(AVCodecContext *avctx)
static av_cold int X264_close(AVCodecContext *avctx)
#define PARSE_X264_OPT(name, var)
static av_cold int X264_init(AVCodecContext *avctx)
#define COMPUTE_MBINFO(mbinfo_filler_, mbinfo_marker_, compute_coords_fn_)
static int set_extradata(AVCodecContext *avctx)
static int parse_opts(AVCodecContext *avctx, const char *opt, const char *param)
static av_cold int X264_reconf(AVCodecContext *avctx, AVDictionary **dict)
static const FFCodecDefault x264_defaults[]
static void X264_log(void *p, int level, const char *fmt, va_list args)
static void opaque_uninit(X264Opaque *o)
static void handle_side_data(AVCodecContext *avctx, x264_param_t *params)
static void reconfig_encoder(AVCodecContext *ctx)
static void av_always_inline mbinfo_compute_constant_coords(const AVVideoRect *rect, int *min_x, int *max_x, int *min_y, int *max_y)
static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, const x264_nal_t *nals, int nnal)
static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, x264_picture_t **ppic)
static void free_picture(x264_picture_t *pic)
static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, const AVFrame *frame, const uint8_t *data, size_t size)
static enum AVPixelFormat csp_to_pixfmt(int csp)
static enum AVPixelFormat pix_fmts_all[]
static void av_always_inline mbinfo_compute_changed_coords(const AVVideoRect *rect, int *min_x, int *max_x, int *min_y, int *max_y)
static int save_sei(AVCodecContext *avctx, x264_nal_t *nal)
static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
static int sse(const MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV444P9
@ AVCHROMA_LOC_UNSPECIFIED
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ 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
static void deblock(const RV60Context *s, AVFrame *frame, int xpos, int ypos, int size, int dpos)
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
@ SEI_TYPE_USER_DATA_UNREGISTERED
A reference to a data buffer.
This structure describes the bitrate properties of an encoded bitstream.
int64_t avg_bitrate
Average bitrate of the stream, in bits per second.
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
Describe the class of an AVClass context structure.
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.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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 has_b_frames
Size of the frame reordering buffer in the decoder.
int level
Encoding level descriptor.
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_*.
AVFrameSideData ** decoded_side_data
Array containing static side data, such as HDR10 CLL / MDCV structures.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
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.
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.
AVFrame * recon_frame
When the AV_CODEC_FLAG_RECON_FRAME flag is used.
int depth
Number of bits in the component.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
Structure to hold side data for an AVFrame.
enum AVFrameSideDataType type
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This structure stores compressed data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
uint8_t nb_components
The number of components each pixel has, (1-4)
Rational number (pair of numerator and denominator).
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.
size_t nb_rects
Number of AVVideoRect present.
Copyright 2023 Elias Carotti <eliascrt at amazon dot it>
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.
AVBufferRef * frame_opaque_ref
static void dct8x8(int16_t *coef, int bit_depth)
int64_t av_gettime(void)
Get the current time in microseconds.
@ AV_VIDEO_HINT_TYPE_CHANGED
static av_always_inline AVVideoRect * av_video_hint_rects(const AVVideoHint *hints)