• 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

修订版df0b9f1615ca067dfb7c71dc08d720fda44e8437 (tree)
时间2013-05-28 17:46:48
作者Xiang, Haihao <haihao.xiang@inte...>
CommiterXiang, Haihao

Log Message

test/encode/avcenc: use new packed header interface

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>

更改概述

差异

--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -108,14 +108,6 @@ struct upload_thread_param
108108 static void
109109 upload_yuv_to_surface(FILE *yuv_fp, VASurfaceID surface_id);
110110
111-struct packed_data_format
112-{
113- unsigned int length_in_bits;
114- unsigned char flag;
115- unsigned char num_skip_bytes;
116- unsigned char pad[2];
117-};
118-
119111 struct {
120112 VAEncSequenceParameterBufferH264Ext seq_param;
121113 VAEncPictureParameterBufferH264Ext pic_param;
@@ -128,7 +120,9 @@ struct {
128120 VABufferID slice_param_buf_id[MAX_SLICES]; /* Slice level parameter, multil slices */
129121 VABufferID dec_ref_pic_marking_buf_id;
130122 VABufferID codedbuf_buf_id; /* Output buffer, compressed data */
123+ VABufferID packed_seq_header_param_buf_id;
131124 VABufferID packed_seq_buf_id;
125+ VABufferID packed_pic_header_param_buf_id;
132126 VABufferID packed_pic_buf_id;
133127 int num_slices;
134128 int codedbuf_i_size;
@@ -355,8 +349,8 @@ static void avcenc_update_slice_parameter(int slice_type)
355349 // Slice level
356350 i = 0;
357351 slice_param = &avcenc_context.slice_param[i];
358- slice_param->start_row_number = 0;
359- slice_param->slice_height = picture_height_in_mbs/16; /* Measured by MB */
352+ slice_param->starting_macroblock_address = 0;
353+ slice_param->number_of_mbs = picture_height_in_mbs * picture_width_in_mbs;
360354 slice_param->pic_parameter_set_id = 0;
361355 slice_param->slice_type = slice_type;
362356 slice_param->direct_spatial_mv_pred_flag = 0;
@@ -405,25 +399,55 @@ static int begin_picture(FILE *yuv_fp, int frame_num, int display_num, int slice
405399 avcenc_context.current_input_surface = SID_INPUT_PICTURE_0;
406400
407401 if (frame_num == 0) {
402+ VAEncPackedHeaderParameterBuffer packed_header_param_buffer;
403+ unsigned int length_in_bits, offset_in_bytes;
408404 unsigned char *packed_seq_buffer = NULL, *packed_pic_buffer = NULL;
409- int seq_length, pic_length;
410405
411406 assert(slice_type == SLICE_TYPE_I);
412- seq_length = build_packed_seq_buffer(&packed_seq_buffer);
407+ length_in_bits = build_packed_seq_buffer(&packed_seq_buffer);
408+ offset_in_bytes = 0;
409+ packed_header_param_buffer.type = VAEncPackedHeaderSPS;
410+ packed_header_param_buffer.insert_emulation_bytes = 1;
411+ packed_header_param_buffer.skip_emulation_check_count = 5; /* ignore start code & nal type for emulation prevetion check */
412+ packed_header_param_buffer.num_headers = 1;
413+ packed_header_param_buffer.length_in_bits = &length_in_bits;
414+ packed_header_param_buffer.offset_in_bytes = &offset_in_bytes;
413415 va_status = vaCreateBuffer(va_dpy,
414416 avcenc_context.context_id,
415- VAEncPackedSequenceParameterBufferType,
416- (seq_length + 7) / 8, 1, packed_seq_buffer,
417+ VAEncPackedHeaderParameterBufferType,
418+ sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer,
419+ &avcenc_context.packed_seq_header_param_buf_id);
420+ CHECK_VASTATUS(va_status,"vaCreateBuffer");
421+
422+ va_status = vaCreateBuffer(va_dpy,
423+ avcenc_context.context_id,
424+ VAEncPackedHeaderDataBufferType,
425+ (length_in_bits + 7) / 8, 1, packed_seq_buffer,
417426 &avcenc_context.packed_seq_buf_id);
418- CHECK_VASTATUS(va_status,"vaCreateBuffer");;
427+ CHECK_VASTATUS(va_status,"vaCreateBuffer");
428+
429+ length_in_bits = build_packed_pic_buffer(&packed_pic_buffer);
430+ offset_in_bytes = 0;
431+ packed_header_param_buffer.type = VAEncPackedHeaderPPS;
432+ packed_header_param_buffer.insert_emulation_bytes = 1;
433+ packed_header_param_buffer.skip_emulation_check_count = 5; /* ignore start code & nal type for emulation prevetion check */
434+ packed_header_param_buffer.num_headers = 1;
435+ packed_header_param_buffer.length_in_bits = &length_in_bits;
436+ packed_header_param_buffer.offset_in_bytes = &offset_in_bytes;
419437
420- pic_length = build_packed_pic_buffer(&packed_pic_buffer);
421438 va_status = vaCreateBuffer(va_dpy,
422439 avcenc_context.context_id,
423- VAEncPackedPictureParameterBufferType,
424- (pic_length + 7) / 8 , 1, packed_pic_buffer,
440+ VAEncPackedHeaderParameterBufferType,
441+ sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer,
442+ &avcenc_context.packed_pic_header_param_buf_id);
443+ CHECK_VASTATUS(va_status,"vaCreateBuffer");
444+
445+ va_status = vaCreateBuffer(va_dpy,
446+ avcenc_context.context_id,
447+ VAEncPackedHeaderDataBufferType,
448+ (length_in_bits + 7) / 8, 1, packed_pic_buffer,
425449 &avcenc_context.packed_pic_buf_id);
426- CHECK_VASTATUS(va_status,"vaCreateBuffer");;
450+ CHECK_VASTATUS(va_status,"vaCreateBuffer");
427451
428452 free(packed_seq_buffer);
429453 free(packed_pic_buffer);
@@ -456,9 +480,15 @@ int avcenc_render_picture()
456480 if (avcenc_context.dec_ref_pic_marking_buf_id != VA_INVALID_ID)
457481 va_buffers[num_va_buffers++] = avcenc_context.dec_ref_pic_marking_buf_id;
458482
483+ if (avcenc_context.packed_seq_header_param_buf_id != VA_INVALID_ID)
484+ va_buffers[num_va_buffers++] = avcenc_context.packed_seq_header_param_buf_id;
485+
459486 if (avcenc_context.packed_seq_buf_id != VA_INVALID_ID)
460487 va_buffers[num_va_buffers++] = avcenc_context.packed_seq_buf_id;
461488
489+ if (avcenc_context.packed_pic_header_param_buf_id != VA_INVALID_ID)
490+ va_buffers[num_va_buffers++] = avcenc_context.packed_pic_header_param_buf_id;
491+
462492 if (avcenc_context.packed_pic_buf_id != VA_INVALID_ID)
463493 va_buffers[num_va_buffers++] = avcenc_context.packed_pic_buf_id;
464494
@@ -527,7 +557,9 @@ static void end_picture(int slice_type, int next_is_bpic)
527557 avcenc_destroy_buffers(&avcenc_context.seq_param_buf_id, 1);
528558 avcenc_destroy_buffers(&avcenc_context.pic_param_buf_id, 1);
529559 avcenc_destroy_buffers(&avcenc_context.dec_ref_pic_marking_buf_id, 1);
560+ avcenc_destroy_buffers(&avcenc_context.packed_seq_header_param_buf_id, 1);
530561 avcenc_destroy_buffers(&avcenc_context.packed_seq_buf_id, 1);
562+ avcenc_destroy_buffers(&avcenc_context.packed_pic_header_param_buf_id, 1);
531563 avcenc_destroy_buffers(&avcenc_context.packed_pic_buf_id, 1);
532564 avcenc_destroy_buffers(&avcenc_context.slice_param_buf_id[0], avcenc_context.num_slices);
533565 avcenc_destroy_buffers(&avcenc_context.codedbuf_buf_id, 1);
@@ -579,7 +611,7 @@ bitstream_start(bitstream *bs)
579611 {
580612 bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING;
581613 bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1);
582- bs->bit_offset = sizeof(struct packed_data_format) * 8; /* the first 64 bits used for format */
614+ bs->bit_offset = 0;
583615 }
584616
585617 static void
@@ -588,16 +620,10 @@ bitstream_end(bitstream *bs)
588620 int pos = (bs->bit_offset >> 5);
589621 int bit_offset = (bs->bit_offset & 0x1f);
590622 int bit_left = 32 - bit_offset;
591- struct packed_data_format *format;
592623
593624 if (bit_offset) {
594625 bs->buffer[pos] = va_swap32((bs->buffer[pos] << bit_left));
595626 }
596-
597- format = (struct packed_data_format *)bs->buffer;
598- format->length_in_bits = bs->bit_offset - sizeof(struct packed_data_format) * 8;
599- format->flag |= 1;
600- format->num_skip_bytes = 5; /* ignore start code & nal type for emulation prevetion check */
601627 }
602628
603629 static void
@@ -1193,7 +1219,9 @@ static void avcenc_context_init(int width, int height)
11931219 avcenc_context.seq_param_buf_id = VA_INVALID_ID;
11941220 avcenc_context.pic_param_buf_id = VA_INVALID_ID;
11951221 avcenc_context.dec_ref_pic_marking_buf_id = VA_INVALID_ID;
1222+ avcenc_context.packed_seq_header_param_buf_id = VA_INVALID_ID;
11961223 avcenc_context.packed_seq_buf_id = VA_INVALID_ID;
1224+ avcenc_context.packed_pic_header_param_buf_id = VA_INVALID_ID;
11971225 avcenc_context.packed_pic_buf_id = VA_INVALID_ID;
11981226 avcenc_context.codedbuf_buf_id = VA_INVALID_ID;
11991227 avcenc_context.codedbuf_i_size = width * height;