• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

hardware/intel/libva


Commit MetaInfo

修订版6cc4260780cc2a9ce102a43e523e0f06e2341004 (tree)
时间2013-05-28 17:46:48
作者Zhou Chang <chang.zhou@inte...>
CommiterXiang, Haihao

Log Message

test/encode/avcenc: Add HRD support in avcenc demo application.

Signed-off-by: Zhou Chang <chang.zhou@intel.com>

更改概述

差异

--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -367,7 +367,7 @@ static void avcenc_update_slice_parameter(int slice_type)
367367 i = 0;
368368 slice_param = &avcenc_context.slice_param[i];
369369 slice_param->starting_macroblock_address = 0;
370- slice_param->number_of_mbs = picture_height_in_mbs * picture_width_in_mbs;
370+ slice_param->number_of_mbs = picture_height_in_mbs * picture_width_in_mbs;
371371 slice_param->pic_parameter_set_id = 0;
372372 slice_param->slice_type = slice_type;
373373 slice_param->direct_spatial_mv_pred_flag = 0;
@@ -391,8 +391,37 @@ static void avcenc_update_slice_parameter(int slice_type)
391391 sizeof(*slice_param), 1, slice_param,
392392 &avcenc_context.slice_param_buf_id[i]);
393393 CHECK_VASTATUS(va_status,"vaCreateBuffer");;
394+ i++;
394395
396+#if 0
397+ slice_param = &avcenc_context.slice_param[i];
398+ slice_param->starting_macroblock_address = picture_height_in_mbs * picture_width_in_mbs / 2;
399+ slice_param->number_of_mbs = picture_height_in_mbs * picture_width_in_mbs / 2;
400+ slice_param->pic_parameter_set_id = 0;
401+ slice_param->slice_type = slice_type;
402+ slice_param->direct_spatial_mv_pred_flag = 0;
403+ slice_param->num_ref_idx_l0_active_minus1 = 0; /* FIXME: ??? */
404+ slice_param->num_ref_idx_l1_active_minus1 = 0;
405+ slice_param->cabac_init_idc = 0;
406+ slice_param->slice_qp_delta = 0;
407+ slice_param->disable_deblocking_filter_idc = 0;
408+ slice_param->slice_alpha_c0_offset_div2 = 2;
409+ slice_param->slice_beta_offset_div2 = 2;
410+ slice_param->idr_pic_id = 0;
411+
412+ /* ref_pic_list_modification() */
413+ slice_param->ref_pic_list_modification_flag_l0 = 0;
414+ slice_param->ref_pic_list_modification_flag_l1 = 0;
415+ /* FIXME: fill other fields */
416+
417+ va_status = vaCreateBuffer(va_dpy,
418+ avcenc_context.context_id,
419+ VAEncSliceParameterBufferType,
420+ sizeof(*slice_param), 1, slice_param,
421+ &avcenc_context.slice_param_buf_id[i]);
422+ CHECK_VASTATUS(va_status,"vaCreateBuffer");;
395423 i++;
424+#endif
396425
397426 avcenc_context.num_slices = i;
398427 }
@@ -490,6 +519,7 @@ int avcenc_render_picture()
490519 VAStatus va_status;
491520 VABufferID va_buffers[8];
492521 unsigned int num_va_buffers = 0;
522+ int i;
493523
494524 va_buffers[num_va_buffers++] = avcenc_context.seq_param_buf_id;
495525 va_buffers[num_va_buffers++] = avcenc_context.pic_param_buf_id;
@@ -513,18 +543,20 @@ int avcenc_render_picture()
513543 avcenc_context.context_id,
514544 surface_ids[avcenc_context.current_input_surface]);
515545 CHECK_VASTATUS(va_status,"vaBeginPicture");
516-
546+
517547 va_status = vaRenderPicture(va_dpy,
518548 avcenc_context.context_id,
519549 va_buffers,
520550 num_va_buffers);
521551 CHECK_VASTATUS(va_status,"vaRenderPicture");
522-
523- va_status = vaRenderPicture(va_dpy,
552+
553+ for(i = 0; i < avcenc_context.num_slices; i++) {
554+ va_status = vaRenderPicture(va_dpy,
524555 avcenc_context.context_id,
525- &avcenc_context.slice_param_buf_id[0],
526- avcenc_context.num_slices);
527- CHECK_VASTATUS(va_status,"vaRenderPicture");
556+ &avcenc_context.slice_param_buf_id[i],
557+ 1);
558+ CHECK_VASTATUS(va_status,"vaRenderPicture");
559+ }
528560
529561 va_status = vaEndPicture(va_dpy, avcenc_context.context_id);
530562 CHECK_VASTATUS(va_status,"vaEndPicture");
@@ -785,8 +817,44 @@ static void sps_rbsp(bitstream *bs)
785817 bitstream_put_ue(bs, seq_param->frame_crop_top_offset); /* frame_crop_top_offset */
786818 bitstream_put_ue(bs, seq_param->frame_crop_bottom_offset); /* frame_crop_bottom_offset */
787819 }
820+
821+ if ( frame_bit_rate < 0 ) {
822+ bitstream_put_ui(bs, 0, 1); /* vui_parameters_present_flag */
823+ } else {
824+ bitstream_put_ui(bs, 1, 1); /* vui_parameters_present_flag */
825+ bitstream_put_ui(bs, 0, 1); /* aspect_ratio_info_present_flag */
826+ bitstream_put_ui(bs, 0, 1); /* overscan_info_present_flag */
827+ bitstream_put_ui(bs, 0, 1); /* video_signal_type_present_flag */
828+ bitstream_put_ui(bs, 0, 1); /* chroma_loc_info_present_flag */
829+ bitstream_put_ui(bs, 1, 1); /* timing_info_present_flag */
830+ {
831+ bitstream_put_ui(bs, 15, 32);
832+ bitstream_put_ui(bs, 900, 32);
833+ bitstream_put_ui(bs, 1, 1);
834+ }
835+ bitstream_put_ui(bs, 1, 1); /* nal_hrd_parameters_present_flag */
836+ {
837+ // hrd_parameters
838+ bitstream_put_ue(bs, 0); /* cpb_cnt_minus1 */
839+ bitstream_put_ui(bs, 4, 4); /* bit_rate_scale */
840+ bitstream_put_ui(bs, 6, 4); /* cpb_size_scale */
841+
842+ bitstream_put_ue(bs, frame_bit_rate - 1); /* bit_rate_value_minus1[0] */
843+ bitstream_put_ue(bs, frame_bit_rate*8 - 1); /* cpb_size_value_minus1[0] */
844+ bitstream_put_ui(bs, 1, 1); /* cbr_flag[0] */
845+
846+ bitstream_put_ui(bs, 23, 5); /* initial_cpb_removal_delay_length_minus1 */
847+ bitstream_put_ui(bs, 23, 5); /* cpb_removal_delay_length_minus1 */
848+ bitstream_put_ui(bs, 23, 5); /* dpb_output_delay_length_minus1 */
849+ bitstream_put_ui(bs, 23, 5); /* time_offset_length */
850+ }
851+ bitstream_put_ui(bs, 0, 1); /* vcl_hrd_parameters_present_flag */
852+ bitstream_put_ui(bs, 0, 1); /* low_delay_hrd_flag */
853+
854+ bitstream_put_ui(bs, 0, 1); /* pic_struct_present_flag */
855+ bitstream_put_ui(bs, 0, 1); /* bitstream_restriction_flag */
856+ }
788857
789- bitstream_put_ui(bs, 0, 1); /* vui_parameters_present_flag */
790858 rbsp_trailing_bits(bs); /* rbsp_trailing_bits */
791859 }
792860
@@ -1186,10 +1254,15 @@ static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_
11861254 seq_param->min_bits_per_second = 0;
11871255 }
11881256
1189- seq_param->initial_hrd_buffer_fullness = 0; /* FIXME: ??? */
1190- seq_param->hrd_buffer_size = 0; /* FIXME: ??? */
1257+ if ( frame_bit_rate > 0) {
1258+ seq_param->initial_hrd_buffer_fullness = frame_bit_rate * 1024 * 4;
1259+ seq_param->hrd_buffer_size = frame_bit_rate * 1024 * 8;
1260+ } else {
1261+ seq_param->initial_hrd_buffer_fullness = 0;
1262+ seq_param->hrd_buffer_size = 0;
1263+ }
11911264 seq_param->time_scale = 900;
1192- seq_param->num_units_in_tick = 15;
1265+ seq_param->num_units_in_tick = 15; /* Tc = num_units_in_tick / time_sacle */
11931266
11941267 if (height_in_mbs * 16 - height) {
11951268 frame_cropping_flag = 1;
@@ -1208,8 +1281,11 @@ static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_
12081281
12091282 seq_param->log2_max_frame_num_minus4 = 0;
12101283 seq_param->log2_max_pic_order_cnt_lsb_minus4 = 2;
1211-
1212- seq_param->vui_flag = 0;
1284+
1285+ if ( frame_bit_rate > 0)
1286+ seq_param->vui_flag = 1; //HRD info located in vui
1287+ else
1288+ seq_param->vui_flag = 0;
12131289 }
12141290
12151291 static void avcenc_context_pic_param_init(VAEncPictureParameterBufferH264 *pic_param)