• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/libva


コミットメタ情報

リビジョンf47cb0027cdf7bc21a3d7bed595af102dddbb3a9 (tree)
日時2014-09-09 02:18:54
作者Zhao Yakui <yakui.zhao@inte...>
コミッターXiang, Haihao

ログメッセージ

test/avcenc: Fix the incorrect parameter setting for SPS under CBR mode

Currently the parameter setting is incorrect for CBR, which causes that
it will complain the underflow/overflow during encoding.

V1->V2: Follow Haihao's comment to update some incorrect usage about the
frame_bit_rate.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 5e10a246287fa2dd3fae2bf756a5b33087cc097c)

変更サマリ

差分

--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -88,6 +88,8 @@ static int qp_value = 26;
8888 static int intra_period = 30;
8989 static int pb_period = 5;
9090 static int frame_bit_rate = -1;
91+static int frame_rate = 30;
92+static int ip_period = 1;
9193
9294 #define MAX_SLICES 32
9395
@@ -596,8 +598,8 @@ static int begin_picture(FILE *yuv_fp, int frame_num, int display_num, int slice
596598 misc_hrd_param = (VAEncMiscParameterHRD *)misc_param->data;
597599
598600 if (frame_bit_rate > 0) {
599- misc_hrd_param->initial_buffer_fullness = frame_bit_rate * 1024 * 4;
600- misc_hrd_param->buffer_size = frame_bit_rate * 1024 * 8;
601+ misc_hrd_param->initial_buffer_fullness = frame_bit_rate * 1000 * 4;
602+ misc_hrd_param->buffer_size = frame_bit_rate * 1000 * 8;
601603 } else {
602604 misc_hrd_param->initial_buffer_fullness = 0;
603605 misc_hrd_param->buffer_size = 0;
@@ -943,19 +945,20 @@ static void sps_rbsp(bitstream *bs)
943945 bitstream_put_ui(bs, 0, 1); /* chroma_loc_info_present_flag */
944946 bitstream_put_ui(bs, 1, 1); /* timing_info_present_flag */
945947 {
946- bitstream_put_ui(bs, 15, 32);
947- bitstream_put_ui(bs, 900, 32);
948+ bitstream_put_ui(bs, 1, 32);
949+ bitstream_put_ui(bs, frame_rate * 2, 32);
948950 bitstream_put_ui(bs, 1, 1);
949951 }
950952 bitstream_put_ui(bs, 1, 1); /* nal_hrd_parameters_present_flag */
951953 {
952954 // hrd_parameters
953955 bitstream_put_ue(bs, 0); /* cpb_cnt_minus1 */
954- bitstream_put_ui(bs, 4, 4); /* bit_rate_scale */
955- bitstream_put_ui(bs, 6, 4); /* cpb_size_scale */
956+ bitstream_put_ui(bs, 0, 4); /* bit_rate_scale */
957+ bitstream_put_ui(bs, 2, 4); /* cpb_size_scale */
956958
957- bitstream_put_ue(bs, frame_bit_rate - 1); /* bit_rate_value_minus1[0] */
958- bitstream_put_ue(bs, frame_bit_rate*8 - 1); /* cpb_size_value_minus1[0] */
959+ /* the frame_bit_rate is in kbps */
960+ bitstream_put_ue(bs, (((frame_bit_rate * 1000)>> 6) - 1)); /* bit_rate_value_minus1[0] */
961+ bitstream_put_ue(bs, ((frame_bit_rate * 8000) >> 6) - 1); /* cpb_size_value_minus1[0] */
959962 bitstream_put_ui(bs, 1, 1); /* cbr_flag[0] */
960963
961964 bitstream_put_ui(bs, 23, 5); /* initial_cpb_removal_delay_length_minus1 */
@@ -1395,7 +1398,7 @@ static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_
13951398 seq_param->seq_parameter_set_id = 0;
13961399 seq_param->level_idc = 41;
13971400 seq_param->intra_period = intra_period;
1398- seq_param->ip_period = 0; /* FIXME: ??? */
1401+ seq_param->ip_period = ip_period;
13991402 seq_param->max_num_ref_frames = 4;
14001403 seq_param->picture_width_in_mbs = width_in_mbs;
14011404 seq_param->picture_height_in_mbs = height_in_mbs;
@@ -1404,12 +1407,12 @@ static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_
14041407
14051408
14061409 if (frame_bit_rate > 0)
1407- seq_param->bits_per_second = 1024 * frame_bit_rate; /* use kbps as input */
1410+ seq_param->bits_per_second = 1000 * frame_bit_rate; /* use kbps as input */
14081411 else
14091412 seq_param->bits_per_second = 0;
14101413
1411- seq_param->time_scale = 900;
1412- seq_param->num_units_in_tick = 15; /* Tc = num_units_in_tick / time_sacle */
1414+ seq_param->time_scale = frame_rate * 2;
1415+ seq_param->num_units_in_tick = 1; /* Tc = num_units_in_tick / time_sacle */
14131416
14141417 if (height_in_mbs * 16 - height) {
14151418 frame_cropping_flag = 1;
@@ -1581,14 +1584,18 @@ int main(int argc, char *argv[])
15811584 if ( mode_value == 0 ) {
15821585 i_frame_only = 1;
15831586 i_p_frame_only = 0;
1587+ ip_period = 0;
15841588 }
15851589 else if ( mode_value == 1) {
15861590 i_frame_only = 0;
15871591 i_p_frame_only = 1;
1592+ ip_period = 1;
15881593 }
15891594 else if ( mode_value == 2 ) {
15901595 i_frame_only = 0;
15911596 i_p_frame_only = 0;
1597+ /* Hack mechanism before adding the parameter of B-frame number */
1598+ ip_period = 3;
15921599 }
15931600 else {
15941601 printf("mode_value=%d\n",mode_value);