Presentation is loading. Please wait.

Presentation is loading. Please wait.

Parsex264_param_default x264_param_parse x264_param_apply_fastfirstpass x264_param_apply_profile select_output select_input x264_reduce_fraction.

Similar presentations


Presentation on theme: "Parsex264_param_default x264_param_parse x264_param_apply_fastfirstpass x264_param_apply_profile select_output select_input x264_reduce_fraction."— Presentation transcript:

1

2 Parsex264_param_default x264_param_parse x264_param_apply_fastfirstpass x264_param_apply_profile select_output select_input x264_reduce_fraction

3

4 Purposefill x264_param_t with default values and do CPU detection Inputparam is parameter of x264 Output none Callerx264.c=> Parse checkasm.c=> check_dct check_quan Calleecpu.c=> x264_cpu_detect

5 Clear all the parameter Detect cpu Set parameter Video property Encoder Rate control Analyse log x264_param_t

6 param->i_csp = X264_CSP_I420;// 設置 video property 色彩空間設置 param->i_width = 0; // 設定長度 param->i_height = 0; // 設定寬度 param->vui.i_sar_width = 0; // VUI:video usability information 寬度 param->vui.i_sar_height= 0; // 設定長度 param->vui.i_overscan = 0; /* undef( 不設置 ) 0=undef, 1=no overscan, 2=overscan 過掃描線 可選擇: show( 觀看 )/crop( 去除 )*/ param->vui.i_vidformat = 5; /* 視頻格式 undef */ param->vui.b_fullrange = 0; /* Specify full range samples setting 默認為 off */ param->vui.i_colorprim = 2; /* 原始色度格式 undef */ param->vui.i_transfer = 2; /* 轉換方式 undef */ param->vui.i_colmatrix = 2; /* 色度矩陣設置 undef */ param->vui.i_chroma_loc= 0; /* 色度樣本指定 left center */ param->i_fps_num = 25; // frame per second param->i_fps_den = 1; // 用兩個整數的比值,來表示 frame 率 param->i_level_idc = -1; //leve 值 param->i_slice_max_size = 0; //slice 的最大數 param->i_slice_max_mbs = 0; //slice 的最多 block 數 param->i_slice_count = 0; // 每 frame 的最大 slice 數

7 Clear all the parameter Detect cpu Set parameter Video property Encoder Rate control Analyse log x264_param_t

8 param->i_frame_reference = 3;// 參考 frame 的最大個數 param->i_keyint_max = 250;// 兩個 IDR 的最大間隔 param->i_keyint_min = 25;// 兩個 IDR 的最小間隔 param->i_bframe = 3;//IP frame 間 可插入 b frame 的最大值 param->i_scenecut_threshold = 40;// 多少 frame 強制插入一個 IDR frame param->i_bframe_adaptive = X264_B_ADAPT_FAST;//adaptive B frame 用哪一 種 param->i_bframe_bias = 0;// 範圍 -100~100 越高越容易插入 b frame param->i_bframe_pyramid = X264_B_PYRAMID_NORMAL; // 允許其他 frame 當參考 B frame param->b_interlaced = 0;// 隔行掃描 param->b_constrained_intra = 0;//Enable constrained intra prediction, param->b_deblocking_filter = 1;// 要不要做 de blocking filter param->i_deblocking_filter_alphac0 = 0;// 設定 deblock filter 的參數 alpha 為 deblocking strength beta 為 deblocking threshold param->i_deblocking_filter_beta = 0;// 值越大 deblocking 效果越好 畫面越 乾淨 但是會損失一些細節 param->b_cabac = 1;// 要不要用 CABAC param->i_cabac_init_idc = 0;// 決定 entropy 編碼初始化的表格

9 Clear all the parameter Detect cpu Set parameter Video property Encoder Rate control Analyse log x264_param_t

10 param->rc.i_rc_method = X264_RC_CRF;// 設置 bitrate 控制 param->rc.i_bitrate = 0;// 指定 bitrate 的值 param->rc.f_rate_tolerance = 1.0;// 允許的誤差 param->rc.i_vbv_max_bitrate = 0;//VBV(video buffering verifier) 模式的 最大 bitrate param->rc.i_vbv_buffer_size = 0;//VBV buff 的最大尺寸 一般由硬體設 備決定 param->rc.f_vbv_buffer_init = 0.9;//VBV buff 的初始尺寸 param->rc.i_qp_constant = 23;//qp 初始值 param->rc.f_rf_constant = 23;/* 1pass VBR Quality-based VBR (0- 51, 0=lossless)*/ param->rc.i_qp_min = 10;// 最小 qp 值 param->rc.i_qp_max = 51;// 最大 qp 值 param->rc.i_qp_step = 4;//Qpstep param->rc.f_ip_factor = 1.4;//I frame 和 P frame 的 qp factor param->rc.f_pb_factor = 1.3;//P frame 和 B frame 的 qp factor

11 Clear all the parameter Detect cpu Set parameter Video property Encoder Rate control Analyse log x264_param_t

12 param->analyse.intra = X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8; //intra 分析的方法 param->analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8 | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_BSUB16x16; //inter 分析的方法 param->analyse.i_direct_mv_pred = X264_DIRECT_PRED_SPATIAL; //direct 預測方法 : 空間預測模式 param->analyse.i_me_method = X264_ME_HEX;//motion estimation 的方法 param->analyse.f_psy_rd = 1.0;//Strength of psychovisual rate distortion param->analyse.b_psy = 1;/* Toggle all psy optimizations */ param->analyse.f_psy_trellis = 0;/* Psy trellis strength */ param->analyse.i_me_range = 16;// 最大動態像量範圍 (Maximum motion vector search range) 值越大編碼速度越慢 param->analyse.i_subpel_refine = 7;//sub ME 子動態預測 值越大效果越 param->analyse.b_mixed_references = 1;// 對每個 block 進行 reference 判斷 param->analyse.b_chroma_me = 1;// 在動態預測中 忽略 chroma param->analyse.i_mv_range = -1; // 最大 motion vector 長度

13

14 Purposemodify the encoder settings to disable options generally not useful on the first pass. Inputparam is basic parameter of x264 Output none Callerx264.c=> Parse Calleenone

15 param->rc.b_stat_write && !param->rc.b_stat_read yes param->i_frame_reference = 1; param->analyse.b_transform_8x8 = 0; param->analyse.inter = 0; param->analyse.i_me_method = X264_ME_DIA; param->analyse.i_subpel_refine = X264_MIN( 2, param->analyse.i_subpel_refine ); param->analyse.i_trellis = 0;

16

17 Purposeset one parameter by name. returns 0 on success, or returns one of the following errors. Inputp:the basic parameter in x264 name:the parameter's name value: the name's value (string) Output b_error (0:success ERROR) Caller ratecontrol.c=> parse_zone x264.c=> Parse Calleecommon.c=> parse_enum common.c=> parse_cqm

18 char *name_buf = NULL; int b_error = 0; int name_was_bool; int value_was_null = !value; int I; if( !name ) return X264_PARAM_BAD_NAME; if( !value ) value = "true"; if( value[0] == '=' ) value++; value[0]== ‘=’ return

19 if( strchr( name, '_' ) { char *p; name_buf = strdup(name); while( (p = strchr( name_buf, '_' )) ) *p = '-'; name = name_buf; } if( (!strncmp( name, "no-", 3 ) && (i = 3)) || (!strncmp( name, "no", 2 ) && (i = 2)) ) { name += i; value = atobool(value) ? "false" : "true"; } 判斷 name 前面有沒有 no or no- strchr( name, '_' )

20 slicesvideoformat 、 、 、、 、 、 cqm8p atoi(value) atobool(value) atof(value) #define OPT(STR) else if( !strcmp( name, STR ) ) STR= “slices” or “videoformat” or “cqm8p”…

21 slicesvideoformat 、 、 、、 、 、 cqm8p atoi(value) atobool(value) atof(value) #define OPT(STR) else if( !strcmp( name, STR ) ) STR= “slices” or “videoformat” or “cqm8p”… OPT("slices")// 每 frame 的最大 slice 數 p->i_slice_count = atoi(value);

22 slicesvideoformat 、 、 、、 、 、 cqm8p atoi(value) atobool(value) atof(value) #define OPT(STR) else if( !strcmp( name, STR ) ) STR= “slices” or “videoformat” or “cqm8p”…

23 slicesvideoformat 、 、 、、 、 、 parse_cqm atoi(value) atobool(value) atof(value) static int parse_enum( const char *arg, const char * const *names, int *dst ) { int i; for( i = 0; names[i]; i++ ) if( !strcmp( arg, names[i] ) ) { *dst = i; return 0; } return -1; } #define OPT(STR) else if( !strcmp( name, STR ) ) STR= “slices” or “videoformat” or “cqm8p”… OPT("videoformat") b_error |= parse_enum( value, x264_vidformat_names, &p->vui.i_vidformat );

24 slicesvideoformat 、 、 、、 、 、 cqm8p atoi(value) atobool(value) atof(value) #define OPT(STR) else if( !strcmp( name, STR ) ) STR= “slices” or “videoformat” or “cqm8p”…

25 slicesvideoformat 、 、 、、 、 、 cqm8p atoi(value) atobool(value) atof(value) static int parse_cqm( const char *str, uint8_t *cqm, int length ) { int i = 0; do { int coef; if( !sscanf( str, "%d", &coef ) || coef 255 ) return -1; cqm[i++] = coef; } while( i < length && (str = strchr( str, ',' )) && str++ ); return (i == length) ? 0 : -1; } #define OPT(STR) else if( !strcmp( name, STR ) ) STR= “slices” or “videoformat” or “cqm8p”…

26


Download ppt "Parsex264_param_default x264_param_parse x264_param_apply_fastfirstpass x264_param_apply_profile select_output select_input x264_reduce_fraction."

Similar presentations


Ads by Google