Lines Matching refs:x4

140     X264Context *x4 = ctx->priv_data;
142 uint64_t size = x4->sei_size;
165 if (x4->sei_size > 0) {
166 memcpy(p, x4->sei, x4->sei_size);
167 p += x4->sei_size;
168 size -= x4->sei_size;
169 x4->sei_size = 0;
170 av_freep(&x4->sei);
204 X264Context *x4 = ctx->priv_data;
208 if (x4->avcintra_class < 0) {
209 if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) {
211 x4->params.b_tff = frame->top_field_first;
212 x264_encoder_reconfig(x4->enc, &x4->params);
214 if (x4->params.vui.i_sar_height*ctx->sample_aspect_ratio.num != ctx->sample_aspect_ratio.den * x4->params.vui.i_sar_width) {
215 x4->params.vui.i_sar_height = ctx->sample_aspect_ratio.den;
216 x4->params.vui.i_sar_width = ctx->sample_aspect_ratio.num;
217 x264_encoder_reconfig(x4->enc, &x4->params);
220 if (x4->params.rc.i_vbv_buffer_size != ctx->rc_buffer_size / 1000 ||
221 x4->params.rc.i_vbv_max_bitrate != ctx->rc_max_rate / 1000) {
222 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 x264_encoder_reconfig(x4->enc, &x4->params);
227 if (x4->params.rc.i_rc_method == X264_RC_ABR &&
228 x4->params.rc.i_bitrate != ctx->bit_rate / 1000) {
229 x4->params.rc.i_bitrate = ctx->bit_rate / 1000;
230 x264_encoder_reconfig(x4->enc, &x4->params);
233 if (x4->crf >= 0 &&
234 x4->params.rc.i_rc_method == X264_RC_CRF &&
235 x4->params.rc.f_rf_constant != x4->crf) {
236 x4->params.rc.f_rf_constant = x4->crf;
237 x264_encoder_reconfig(x4->enc, &x4->params);
240 if (x4->params.rc.i_rc_method == X264_RC_CQP &&
241 x4->cqp >= 0 &&
242 x4->params.rc.i_qp_constant != x4->cqp) {
243 x4->params.rc.i_qp_constant = x4->cqp;
244 x264_encoder_reconfig(x4->enc, &x4->params);
247 if (x4->crf_max >= 0 &&
248 x4->params.rc.f_rf_constant_max != x4->crf_max) {
249 x4->params.rc.f_rf_constant_max = x4->crf_max;
250 x264_encoder_reconfig(x4->enc, &x4->params);
295 if (fpa_type != x4->params.i_frame_packing) {
296 x4->params.i_frame_packing = fpa_type;
297 x264_encoder_reconfig(x4->enc, &x4->params);
304 X264Context *x4 = ctx->priv_data;
305 x264_picture_t *pic = &x4->pic;
317 X264Context *x4 = ctx->priv_data;
327 x264_picture_init( &x4->pic );
328 x4->pic.img.i_csp = x4->params.i_csp;
330 bit_depth = x4->params.i_bitdepth;
335 x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
336 x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
339 x264_sei_t *sei = &x4->pic.extra_sei;
342 for (i = 0; i < x4->pic.img.i_plane; i++) {
343 x4->pic.img.plane[i] = frame->data[i];
344 x4->pic.img.i_stride[i] = frame->linesize[i];
347 x4->pic.i_pts = frame->pts;
349 x4->reordered_opaque[x4->next_reordered_opaque].reordered_opaque = frame->reordered_opaque;
350 x4->reordered_opaque[x4->next_reordered_opaque].wallclock = wallclock;
352 x4->reordered_opaque[x4->next_reordered_opaque].wallclock = av_gettime();
353 x4->pic.opaque = &x4->reordered_opaque[x4->next_reordered_opaque];
354 x4->next_reordered_opaque++;
355 x4->next_reordered_opaque %= x4->nb_reordered_opaque;
359 x4->pic.i_type = x4->forced_idr > 0 ? X264_TYPE_IDR
363 x4->pic.i_type = X264_TYPE_P;
366 x4->pic.i_type = X264_TYPE_B;
369 x4->pic.i_type = X264_TYPE_AUTO;
374 if (x4->a53_cc) {
382 x4->pic.extra_sei.payloads = av_mallocz(sizeof(x4->pic.extra_sei.payloads[0]));
383 if (x4->pic.extra_sei.payloads == NULL) {
387 x4->pic.extra_sei.sei_free = av_free;
389 x4->pic.extra_sei.payloads[0].payload_size = sei_size;
390 x4->pic.extra_sei.payloads[0].payload = sei_data;
391 x4->pic.extra_sei.num_payloads = 1;
392 x4->pic.extra_sei.payloads[0].payload_type = 4;
399 if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
400 if (!x4->roi_warned) {
401 x4->roi_warned = 1;
457 x4->pic.prop.quant_offsets = qoffsets;
458 x4->pic.prop.quant_offsets_free = av_free;
460 if (!x4->roi_warned) {
461 x4->roi_warned = 1;
468 if (x4->udu_sei) {
496 if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
502 } while (!ret && !frame && x264_encoder_delayed_frames(x4->enc));
511 if (out_opaque >= x4->reordered_opaque &&
512 out_opaque < &x4->reordered_opaque[x4->nb_reordered_opaque]) {
550 X264Context *x4 = avctx->priv_data;
552 av_freep(&x4->sei);
553 av_freep(&x4->reordered_opaque);
556 x264_param_cleanup(&x4->params);
559 if (x4->enc) {
560 x264_encoder_close(x4->enc);
561 x4->enc = NULL;
569 X264Context *x4 = avctx->priv_data;
572 if ((ret = x264_param_parse(&x4->params, opt, param)) < 0) {
629 if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
630 av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
636 X264Context *x4 = avctx->priv_data;
646 x4->params.b_mpeg2 = 1;
647 x264_param_default_mpeg2(&x4->params);
650 x264_param_default(&x4->params);
652 x4->params.b_deblocking_filter = avctx->flags & AV_CODEC_FLAG_LOOP_FILTER;
654 if (x4->preset || x4->tune)
655 if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) {
657 av_log(avctx, AV_LOG_ERROR, "Error setting preset/tune %s/%s.\n", x4->preset, x4->tune);
670 x4->params.i_level_idc = avctx->level;
672 x4->params.pf_log = X264_log;
673 x4->params.p_log_private = avctx;
674 x4->params.i_log_level = X264_LOG_DEBUG;
675 x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt);
677 x4->params.i_bitdepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
687 x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
688 x4->params.rc.i_rc_method = X264_RC_ABR;
690 x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
691 x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
692 x4->params.rc.b_stat_write = avctx->flags & AV_CODEC_FLAG_PASS1;
694 x4->params.rc.b_stat_read = 1;
696 if (x4->crf >= 0) {
697 x4->params.rc.i_rc_method = X264_RC_CRF;
698 x4->params.rc.f_rf_constant = x4->crf;
699 } else if (x4->cqp >= 0) {
700 x4->params.rc.i_rc_method = X264_RC_CQP;
701 x4->params.rc.i_qp_constant = x4->cqp;
704 if (x4->crf_max >= 0)
705 x4->params.rc.f_rf_constant_max = x4->crf_max;
710 x4->params.rc.f_vbv_buffer_init =
717 x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
719 x4->params.rc.f_pb_factor = avctx->b_quant_factor;
721 if (x4->chroma_offset)
722 x4->params.analyse.i_chroma_qp_offset = x4->chroma_offset;
725 x4->params.i_keyint_max = avctx->gop_size;
727 x4->params.i_bframe = avctx->max_b_frames;
729 if (x4->scenechange_threshold >= 0)
730 x4->params.i_scenecut_threshold = x4->scenechange_threshold;
733 x4->params.rc.i_qp_min = avctx->qmin;
735 x4->params.rc.i_qp_max = avctx->qmax;
737 x4->params.rc.i_qp_step = avctx->max_qdiff;
739 x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
741 x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
743 x4->params.i_frame_reference = avctx->refs;
744 else if (x4->params.i_level_idc > 0) {
750 if (x264_levels[i].level_idc == x4->params.i_level_idc)
751 x4->params.i_frame_reference = av_clip(x264_levels[i].dpb / mbn / scale, 1, x4->params.i_frame_reference);
755 x4->params.analyse.i_trellis = avctx->trellis;
757 x4->params.analyse.i_me_range = avctx->me_range;
758 if (x4->noise_reduction >= 0)
759 x4->params.analyse.i_noise_reduction = x4->noise_reduction;
761 x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
763 x4->params.i_keyint_min = avctx->keyint_min;
765 x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
767 if (x4->aq_mode >= 0)
768 x4->params.rc.i_aq_mode = x4->aq_mode;
769 if (x4->aq_strength >= 0)
770 x4->params.rc.f_aq_strength = x4->aq_strength;
775 if (x4->psy >= 0)
776 x4->params.analyse.b_psy = x4->psy;
777 if (x4->rc_lookahead >= 0)
778 x4->params.rc.i_lookahead = x4->rc_lookahead;
779 if (x4->weightp >= 0)
780 x4->params.analyse.i_weighted_pred = x4->weightp;
781 if (x4->weightb >= 0)
782 x4->params.analyse.b_weighted_bipred = x4->weightb;
783 if (x4->cplxblur >= 0)
784 x4->params.rc.f_complexity_blur = x4->cplxblur;
786 if (x4->ssim >= 0)
787 x4->params.analyse.b_ssim = x4->ssim;
788 if (x4->intra_refresh >= 0)
789 x4->params.b_intra_refresh = x4->intra_refresh;
790 if (x4->bluray_compat >= 0) {
791 x4->params.b_bluray_compat = x4->bluray_compat;
792 x4->params.b_vfr_input = 0;
794 if (x4->avcintra_class >= 0)
796 x4->params.i_avcintra_class = x4->avcintra_class;
802 if (x4->avcintra_class > 200) {
809 x4->params.i_avcintra_flavor = X264_AVCINTRA_FLAVOR_SONY;
813 if (x4->b_bias != INT_MIN)
814 x4->params.i_bframe_bias = x4->b_bias;
815 if (x4->b_pyramid >= 0)
816 x4->params.i_bframe_pyramid = x4->b_pyramid;
817 if (x4->mixed_refs >= 0)
818 x4->params.analyse.b_mixed_references = x4->mixed_refs;
819 if (x4->dct8x8 >= 0)
820 x4->params.analyse.b_transform_8x8 = x4->dct8x8;
821 if (x4->fast_pskip >= 0)
822 x4->params.analyse.b_fast_pskip = x4->fast_pskip;
823 if (x4->aud >= 0)
824 x4->params.b_aud = x4->aud;
825 if (x4->mbtree >= 0)
826 x4->params.rc.b_mb_tree = x4->mbtree;
827 if (x4->direct_pred >= 0)
828 x4->params.analyse.i_direct_mv_pred = x4->direct_pred;
830 if (x4->slice_max_size >= 0)
831 x4->params.i_slice_max_size = x4->slice_max_size;
833 if (x4->fastfirstpass)
834 x264_param_apply_fastfirstpass(&x4->params);
836 x4->profile = x4->profile_opt;
838 if (!x4->profile)
841 x4->profile = "baseline";
844 x4->profile = "high";
847 x4->profile = "high10";
850 x4->profile = "high422";
853 x4->profile = "high444";
856 x4->profile = "main";
862 if (x4->nal_hrd >= 0)
863 x4->params.i_nal_hrd = x4->nal_hrd;
865 if (x4->motion_est >= 0)
866 x4->params.analyse.i_me_method = x4->motion_est;
868 if (x4->coder >= 0)
869 x4->params.b_cabac = x4->coder;
871 if (x4->b_frame_strategy >= 0)
872 x4->params.i_bframe_adaptive = x4->b_frame_strategy;
874 if (x4->profile)
875 if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
877 av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
885 x4->params.i_width = avctx->width;
886 x4->params.i_height = avctx->height;
888 x4->params.vui.i_sar_width = sw;
889 x4->params.vui.i_sar_height = sh;
890 x4->params.i_timebase_den = avctx->time_base.den;
891 x4->params.i_timebase_num = avctx->time_base.num;
893 x4->params.i_fps_num = avctx->framerate.num;
894 x4->params.i_fps_den = avctx->framerate.den;
896 x4->params.i_fps_num = avctx->time_base.den;
897 x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame;
900 x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
902 x4->params.i_threads = avctx->thread_count;
904 x4->params.b_sliced_threads = avctx->thread_type == FF_THREAD_SLICE;
906 x4->params.b_interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT;
908 x4->params.b_open_gop = !(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP);
910 x4->params.i_slice_count = avctx->slices;
913 x4->params.vui.b_fullrange = avctx->color_range == AVCOL_RANGE_JPEG;
917 x4->params.vui.b_fullrange = 1;
920 x4->params.vui.i_colmatrix = avctx->colorspace;
922 x4->params.vui.i_colorprim = avctx->color_primaries;
924 x4->params.vui.i_transfer = avctx->color_trc;
926 x4->params.vui.i_chroma_loc = avctx->chroma_sample_location - 1;
929 x4->params.b_repeat_headers = 0;
931 if(x4->x264opts){
932 const char *p= x4->x264opts;
953 if (x4->avcintra_class >= 0)
954 x4->params.b_repeat_headers = 1;
959 while (en = av_dict_get(x4->x264_params, "", en, AV_DICT_IGNORE_SUFFIX)) {
960 if ((ret = x264_param_parse(&x4->params, en->key, en->value)) < 0) {
973 avctx->has_b_frames = x4->params.i_bframe ?
974 x4->params.i_bframe_pyramid ? 2 : 1 : 0;
978 avctx->bit_rate = x4->params.rc.i_bitrate*1000LL;
980 x4->enc = x264_encoder_open(&x4->params);
981 if (!x4->enc)
989 s = x264_encoder_headers(x4->enc, &nal, &nnal);
998 x4->sei_size = nal[i].i_payload;
999 x4->sei = av_malloc(x4->sei_size);
1000 if (!x4->sei)
1002 memcpy(x4->sei, nal[i].p_payload, nal[i].i_payload);
1014 cpb_props->buffer_size = x4->params.rc.i_vbv_buffer_size * 1000;
1015 cpb_props->max_bitrate = x4->params.rc.i_vbv_max_bitrate * 1000LL;
1016 cpb_props->avg_bitrate = x4->params.rc.i_bitrate * 1000LL;
1020 x4->nb_reordered_opaque = x264_encoder_maximum_delayed_frames(x4->enc) + 17;
1021 x4->reordered_opaque = av_malloc_array(x4->nb_reordered_opaque,
1022 sizeof(*x4->reordered_opaque));
1023 if (!x4->reordered_opaque)