• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

hardware/intel/libva


Commit MetaInfo

修訂51b2f0062d5cfc9eec181ef08396c50d898cfb3c (tree)
時間2013-05-28 17:46:48
作者Xiang, Haihao <haihao.xiang@inte...>
CommiterXiang, Haihao

Log Message

test: use the new H264 encoding and VPP interfaces

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

Change Summary

差異

--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -45,6 +45,7 @@
4545 #include <pthread.h>
4646
4747 #include <va/va.h>
48+#include <va/va_enc_h264.h>
4849 #include "va_display.h"
4950
5051 #define NAL_REF_IDC_NONE 0
@@ -87,10 +88,6 @@ static int intra_period = 30;
8788 static int pb_period = 5;
8889 static int frame_bit_rate = -1;
8990
90-#define BR_CBR 0
91-#define BR_VBR 1
92-#define BR_CQP 2
93-
9491 #define MAX_SLICES 32
9592
9693 static int
@@ -108,26 +105,28 @@ struct upload_thread_param
108105 static void
109106 upload_yuv_to_surface(FILE *yuv_fp, VASurfaceID surface_id);
110107
111-struct {
108+static struct {
109+ VAProfile profile;
112110 VAEncSequenceParameterBufferH264 seq_param;
113111 VAEncPictureParameterBufferH264 pic_param;
114112 VAEncSliceParameterBufferH264 slice_param[MAX_SLICES];
115- VAEncH264DecRefPicMarkingBuffer dec_ref_pic_marking;
116113 VAContextID context_id;
117114 VAConfigID config_id;
118115 VABufferID seq_param_buf_id; /* Sequence level parameter */
119116 VABufferID pic_param_buf_id; /* Picture level parameter */
120117 VABufferID slice_param_buf_id[MAX_SLICES]; /* Slice level parameter, multil slices */
121- VABufferID dec_ref_pic_marking_buf_id;
122118 VABufferID codedbuf_buf_id; /* Output buffer, compressed data */
123119 VABufferID packed_seq_header_param_buf_id;
124120 VABufferID packed_seq_buf_id;
125121 VABufferID packed_pic_header_param_buf_id;
126122 VABufferID packed_pic_buf_id;
123+ VABufferID misc_parameter_hrd_buf_id;
124+
127125 int num_slices;
128126 int codedbuf_i_size;
129127 int codedbuf_pb_size;
130128 int current_input_surface;
129+ int rate_control_method;
131130 struct upload_thread_param upload_thread_param;
132131 pthread_t upload_thread_id;
133132 int upload_thread_value;
@@ -145,7 +144,7 @@ static void create_encode_pipe()
145144 va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
146145 CHECK_VASTATUS(va_status, "vaInitialize");
147146
148- vaQueryConfigEntrypoints(va_dpy, VAProfileH264Baseline, entrypoints,
147+ vaQueryConfigEntrypoints(va_dpy, avcenc_context.profile, entrypoints,
149148 &num_entrypoints);
150149
151150 for (slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++) {
@@ -161,7 +160,7 @@ static void create_encode_pipe()
161160 /* find out the format for the render target, and rate control mode */
162161 attrib[0].type = VAConfigAttribRTFormat;
163162 attrib[1].type = VAConfigAttribRateControl;
164- vaGetConfigAttributes(va_dpy, VAProfileH264Baseline, VAEntrypointEncSlice,
163+ vaGetConfigAttributes(va_dpy, avcenc_context.profile, VAEntrypointEncSlice,
165164 &attrib[0], 2);
166165
167166 if ((attrib[0].value & VA_RT_FORMAT_YUV420) == 0) {
@@ -169,16 +168,16 @@ static void create_encode_pipe()
169168 assert(0);
170169 }
171170
172- if ((attrib[1].value & VA_RC_VBR) == 0) {
171+ if ((attrib[1].value & avcenc_context.rate_control_method) == 0) {
173172 /* Can't find matched RC mode */
174- printf("VBR mode doesn't found, exit\n");
173+ printf("Can't find the desired RC mode, exit\n");
175174 assert(0);
176175 }
177176
178177 attrib[0].value = VA_RT_FORMAT_YUV420; /* set to desired RT format */
179- attrib[1].value = VA_RC_VBR; /* set to desired RC mode */
178+ attrib[1].value = avcenc_context.rate_control_method; /* set to desired RC mode */
180179
181- va_status = vaCreateConfig(va_dpy, VAProfileH264Baseline, VAEntrypointEncSlice,
180+ va_status = vaCreateConfig(va_dpy, avcenc_context.profile, VAEntrypointEncSlice,
182181 &attrib[0], 2,&avcenc_context.config_id);
183182 CHECK_VASTATUS(va_status, "vaCreateConfig");
184183
@@ -270,7 +269,7 @@ static void avcenc_update_picture_parameter(int slice_type, int frame_num, int d
270269 pic_param->ReferenceFrames[1].picture_id = surface_ids[SID_REFERENCE_PICTURE_L1];
271270 pic_param->ReferenceFrames[2].picture_id = VA_INVALID_ID;
272271 assert(avcenc_context.codedbuf_buf_id != VA_INVALID_ID);
273- pic_param->CodedBuf = avcenc_context.codedbuf_buf_id;
272+ pic_param->coded_buf = avcenc_context.codedbuf_buf_id;
274273 pic_param->frame_num = frame_num;
275274 pic_param->pic_fields.bits.idr_pic_flag = !!is_idr;
276275 pic_param->pic_fields.bits.reference_pic_flag = (slice_type != SLICE_TYPE_B);
@@ -366,8 +365,8 @@ static void avcenc_update_slice_parameter(int slice_type)
366365 // Slice level
367366 i = 0;
368367 slice_param = &avcenc_context.slice_param[i];
369- slice_param->starting_macroblock_address = 0;
370- slice_param->number_of_mbs = picture_height_in_mbs * picture_width_in_mbs;
368+ slice_param->macroblock_address = 0;
369+ slice_param->num_macroblocks = picture_height_in_mbs * picture_width_in_mbs;
371370 slice_param->pic_parameter_set_id = 0;
372371 slice_param->slice_type = slice_type;
373372 slice_param->direct_spatial_mv_pred_flag = 0;
@@ -380,9 +379,6 @@ static void avcenc_update_slice_parameter(int slice_type)
380379 slice_param->slice_beta_offset_div2 = 2;
381380 slice_param->idr_pic_id = 0;
382381
383- /* ref_pic_list_modification() */
384- slice_param->ref_pic_list_modification_flag_l0 = 0;
385- slice_param->ref_pic_list_modification_flag_l1 = 0;
386382 /* FIXME: fill other fields */
387383
388384 va_status = vaCreateBuffer(va_dpy,
@@ -395,8 +391,8 @@ static void avcenc_update_slice_parameter(int slice_type)
395391
396392 #if 0
397393 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;
394+ slice_param->macroblock_address = picture_height_in_mbs * picture_width_in_mbs / 2;
395+ slice_param->num_macroblocks = picture_height_in_mbs * picture_width_in_mbs / 2;
400396 slice_param->pic_parameter_set_id = 0;
401397 slice_param->slice_type = slice_type;
402398 slice_param->direct_spatial_mv_pred_flag = 0;
@@ -409,9 +405,6 @@ static void avcenc_update_slice_parameter(int slice_type)
409405 slice_param->slice_beta_offset_div2 = 2;
410406 slice_param->idr_pic_id = 0;
411407
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;
415408 /* FIXME: fill other fields */
416409
417410 va_status = vaCreateBuffer(va_dpy,
@@ -452,12 +445,9 @@ static int begin_picture(FILE *yuv_fp, int frame_num, int display_num, int slice
452445 assert(slice_type == SLICE_TYPE_I);
453446 length_in_bits = build_packed_seq_buffer(&packed_seq_buffer);
454447 offset_in_bytes = 0;
455- packed_header_param_buffer.type = VAEncPackedHeaderSPS;
456- packed_header_param_buffer.insert_emulation_bytes = 1;
457- packed_header_param_buffer.skip_emulation_check_count = 5; /* ignore start code & nal type for emulation prevetion check */
458- packed_header_param_buffer.num_headers = 1;
459- packed_header_param_buffer.length_in_bits = &length_in_bits;
460- packed_header_param_buffer.offset_in_bytes = &offset_in_bytes;
448+ packed_header_param_buffer.type = VAEncPackedHeaderSequence;
449+ packed_header_param_buffer.bit_length = length_in_bits;
450+ packed_header_param_buffer.has_emulation_bytes = 0;
461451 va_status = vaCreateBuffer(va_dpy,
462452 avcenc_context.context_id,
463453 VAEncPackedHeaderParameterBufferType,
@@ -474,12 +464,9 @@ static int begin_picture(FILE *yuv_fp, int frame_num, int display_num, int slice
474464
475465 length_in_bits = build_packed_pic_buffer(&packed_pic_buffer);
476466 offset_in_bytes = 0;
477- packed_header_param_buffer.type = VAEncPackedHeaderPPS;
478- packed_header_param_buffer.insert_emulation_bytes = 1;
479- packed_header_param_buffer.skip_emulation_check_count = 5; /* ignore start code & nal type for emulation prevetion check */
480- packed_header_param_buffer.num_headers = 1;
481- packed_header_param_buffer.length_in_bits = &length_in_bits;
482- packed_header_param_buffer.offset_in_bytes = &offset_in_bytes;
467+ packed_header_param_buffer.type = VAEncPackedHeaderPicture;
468+ packed_header_param_buffer.bit_length = length_in_bits;
469+ packed_header_param_buffer.has_emulation_bytes = 0;
483470
484471 va_status = vaCreateBuffer(va_dpy,
485472 avcenc_context.context_id,
@@ -506,7 +493,36 @@ static int begin_picture(FILE *yuv_fp, int frame_num, int display_num, int slice
506493 VAEncSequenceParameterBufferType,
507494 sizeof(*seq_param), 1, seq_param,
508495 &avcenc_context.seq_param_buf_id);
509- CHECK_VASTATUS(va_status,"vaCreateBuffer");;
496+ CHECK_VASTATUS(va_status,"vaCreateBuffer");
497+
498+
499+ /* hrd parameter */
500+ VAEncMiscParameterBuffer *misc_param;
501+ VAEncMiscParameterHRD *misc_hrd_param;
502+ vaCreateBuffer(va_dpy,
503+ avcenc_context.context_id,
504+ VAEncMiscParameterBufferType,
505+ sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl),
506+ 1,
507+ NULL,
508+ &avcenc_context.misc_parameter_hrd_buf_id);
509+ CHECK_VASTATUS(va_status, "vaCreateBuffer");
510+
511+ vaMapBuffer(va_dpy,
512+ avcenc_context.misc_parameter_hrd_buf_id,
513+ (void **)&misc_param);
514+ misc_param->type = VAEncMiscParameterTypeHRD;
515+ misc_hrd_param = (VAEncMiscParameterHRD *)misc_param->data;
516+
517+ if (frame_bit_rate > 0) {
518+ misc_hrd_param->initial_buffer_fullness = frame_bit_rate * 1024 * 4;
519+ misc_hrd_param->buffer_size = frame_bit_rate * 1024 * 8;
520+ } else {
521+ misc_hrd_param->initial_buffer_fullness = 0;
522+ misc_hrd_param->buffer_size = 0;
523+ }
524+
525+ vaUnmapBuffer(va_dpy, avcenc_context.misc_parameter_hrd_buf_id);
510526
511527 /* slice parameter */
512528 avcenc_update_slice_parameter(slice_type);
@@ -524,9 +540,6 @@ int avcenc_render_picture()
524540 va_buffers[num_va_buffers++] = avcenc_context.seq_param_buf_id;
525541 va_buffers[num_va_buffers++] = avcenc_context.pic_param_buf_id;
526542
527- if (avcenc_context.dec_ref_pic_marking_buf_id != VA_INVALID_ID)
528- va_buffers[num_va_buffers++] = avcenc_context.dec_ref_pic_marking_buf_id;
529-
530543 if (avcenc_context.packed_seq_header_param_buf_id != VA_INVALID_ID)
531544 va_buffers[num_va_buffers++] = avcenc_context.packed_seq_header_param_buf_id;
532545
@@ -539,6 +552,9 @@ int avcenc_render_picture()
539552 if (avcenc_context.packed_pic_buf_id != VA_INVALID_ID)
540553 va_buffers[num_va_buffers++] = avcenc_context.packed_pic_buf_id;
541554
555+ if (avcenc_context.misc_parameter_hrd_buf_id != VA_INVALID_ID)
556+ va_buffers[num_va_buffers++] = avcenc_context.misc_parameter_hrd_buf_id;
557+
542558 va_status = vaBeginPicture(va_dpy,
543559 avcenc_context.context_id,
544560 surface_ids[avcenc_context.current_input_surface]);
@@ -605,13 +621,14 @@ static void end_picture(int slice_type, int next_is_bpic)
605621
606622 avcenc_destroy_buffers(&avcenc_context.seq_param_buf_id, 1);
607623 avcenc_destroy_buffers(&avcenc_context.pic_param_buf_id, 1);
608- avcenc_destroy_buffers(&avcenc_context.dec_ref_pic_marking_buf_id, 1);
609624 avcenc_destroy_buffers(&avcenc_context.packed_seq_header_param_buf_id, 1);
610625 avcenc_destroy_buffers(&avcenc_context.packed_seq_buf_id, 1);
611626 avcenc_destroy_buffers(&avcenc_context.packed_pic_header_param_buf_id, 1);
612627 avcenc_destroy_buffers(&avcenc_context.packed_pic_buf_id, 1);
613628 avcenc_destroy_buffers(&avcenc_context.slice_param_buf_id[0], avcenc_context.num_slices);
614629 avcenc_destroy_buffers(&avcenc_context.codedbuf_buf_id, 1);
630+ avcenc_destroy_buffers(&avcenc_context.misc_parameter_hrd_buf_id, 1);
631+
615632 memset(avcenc_context.slice_param, 0, sizeof(avcenc_context.slice_param));
616633 avcenc_context.num_slices = 0;
617634 }
@@ -773,8 +790,14 @@ static void nal_header(bitstream *bs, int nal_ref_idc, int nal_unit_type)
773790 static void sps_rbsp(bitstream *bs)
774791 {
775792 VAEncSequenceParameterBufferH264 *seq_param = &avcenc_context.seq_param;
793+ int profile_idc = PROFILE_IDC_BASELINE;
794+
795+ if (avcenc_context.profile == VAProfileH264High)
796+ profile_idc = PROFILE_IDC_HIGH;
797+ else if (avcenc_context.profile == VAProfileH264Main)
798+ profile_idc = PROFILE_IDC_MAIN;
776799
777- bitstream_put_ui(bs, seq_param->profile_idc, 8); /* profile_idc */
800+ bitstream_put_ui(bs, profile_idc, 8); /* profile_idc */
778801 bitstream_put_ui(bs, 0, 1); /* constraint_set0_flag */
779802 bitstream_put_ui(bs, 1, 1); /* constraint_set1_flag */
780803 bitstream_put_ui(bs, 0, 1); /* constraint_set2_flag */
@@ -783,16 +806,11 @@ static void sps_rbsp(bitstream *bs)
783806 bitstream_put_ui(bs, seq_param->level_idc, 8); /* level_idc */
784807 bitstream_put_ue(bs, seq_param->seq_parameter_set_id); /* seq_parameter_set_id */
785808
786- if (seq_param->profile_idc >= PROFILE_IDC_HIGH) {
787- /* FIXME: fix for high profile */
788- assert(0);
789- }
809+ bitstream_put_ue(bs, seq_param->seq_fields.bits.log2_max_frame_num_minus4); /* log2_max_frame_num_minus4 */
810+ bitstream_put_ue(bs, seq_param->seq_fields.bits.pic_order_cnt_type); /* pic_order_cnt_type */
790811
791- bitstream_put_ue(bs, seq_param->log2_max_frame_num_minus4); /* log2_max_frame_num_minus4 */
792- bitstream_put_ue(bs, seq_param->pic_order_cnt_type); /* pic_order_cnt_type */
793-
794- if (seq_param->pic_order_cnt_type == 0)
795- bitstream_put_ue(bs, seq_param->log2_max_pic_order_cnt_lsb_minus4); /* log2_max_pic_order_cnt_lsb_minus4 */
812+ if (seq_param->seq_fields.bits.pic_order_cnt_type == 0)
813+ bitstream_put_ue(bs, seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4); /* log2_max_pic_order_cnt_lsb_minus4 */
796814 else {
797815 assert(0);
798816 }
@@ -802,13 +820,13 @@ static void sps_rbsp(bitstream *bs)
802820
803821 bitstream_put_ue(bs, seq_param->picture_width_in_mbs - 1); /* pic_width_in_mbs_minus1 */
804822 bitstream_put_ue(bs, seq_param->picture_height_in_mbs - 1); /* pic_height_in_map_units_minus1 */
805- bitstream_put_ui(bs, seq_param->frame_mbs_only_flag, 1); /* frame_mbs_only_flag */
823+ bitstream_put_ui(bs, seq_param->seq_fields.bits.frame_mbs_only_flag, 1); /* frame_mbs_only_flag */
806824
807- if (!seq_param->frame_mbs_only_flag) {
825+ if (!seq_param->seq_fields.bits.frame_mbs_only_flag) {
808826 assert(0);
809827 }
810828
811- bitstream_put_ui(bs, seq_param->direct_8x8_inference_flag, 1); /* direct_8x8_inference_flag */
829+ bitstream_put_ui(bs, seq_param->seq_fields.bits.direct_8x8_inference_flag, 1); /* direct_8x8_inference_flag */
812830 bitstream_put_ui(bs, seq_param->frame_cropping_flag, 1); /* frame_cropping_flag */
813831
814832 if (seq_param->frame_cropping_flag) {
@@ -968,10 +986,10 @@ slice_header(bitstream *bs, int frame_num, int display_frame, int slice_type, in
968986 bitstream_put_ue(bs, 0); /* first_mb_in_slice: 0 */
969987 bitstream_put_ue(bs, slice_type); /* slice_type */
970988 bitstream_put_ue(bs, 0); /* pic_parameter_set_id: 0 */
971- bitstream_put_ui(bs, frame_num & 0x0F, seq_param->log2_max_frame_num_minus4 + 4); /* frame_num */
989+ bitstream_put_ui(bs, frame_num & 0x0F, seq_param->seq_fields.bits.log2_max_frame_num_minus4 + 4); /* frame_num */
972990
973991 /* frame_mbs_only_flag == 1 */
974- if (!seq_param->frame_mbs_only_flag) {
992+ if (!seq_param->seq_fields.bits.frame_mbs_only_flag) {
975993 /* FIXME: */
976994 assert(0);
977995 }
@@ -979,8 +997,8 @@ slice_header(bitstream *bs, int frame_num, int display_frame, int slice_type, in
979997 if (is_idr)
980998 bitstream_put_ue(bs, 0); /* idr_pic_id: 0 */
981999
982- if (seq_param->pic_order_cnt_type == 0) {
983- bitstream_put_ui(bs, (display_frame*2) & 0x3F, seq_param->log2_max_pic_order_cnt_lsb_minus4 + 4);
1000+ if (seq_param->seq_fields.bits.pic_order_cnt_type == 0) {
1001+ bitstream_put_ui(bs, (display_frame*2) & 0x3F, seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 + 4);
9841002 /* only support frame */
9851003 } else {
9861004 /* FIXME: */
@@ -1224,50 +1242,26 @@ static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_
12241242 int frame_crop_bottom_offset = 0;
12251243
12261244 seq_param->seq_parameter_set_id = 0;
1227- seq_param->profile_idc = PROFILE_IDC_MAIN;
12281245 seq_param->level_idc = 41;
12291246 seq_param->intra_period = intra_period;
12301247 seq_param->ip_period = 0; /* FIXME: ??? */
12311248 seq_param->max_num_ref_frames = 4;
12321249 seq_param->picture_width_in_mbs = width_in_mbs;
12331250 seq_param->picture_height_in_mbs = height_in_mbs;
1234- seq_param->frame_mbs_only_flag = 1;
1235- seq_param->target_usage = 1;
1251+ seq_param->seq_fields.bits.frame_mbs_only_flag = 1;
12361252
1237- /* 0:CBR, 1:VBR, 2:Constant QP */
1238- if (qp_value == -1)
1239- seq_param->rate_control_method = BR_CBR;
1240- else if (qp_value == -2)
1241- seq_param->rate_control_method = BR_VBR;
1242- else {
1243- assert(qp_value >= 0 && qp_value <= 51);
1244- seq_param->rate_control_method = BR_CQP;
1245- }
1246-
12471253 if (frame_bit_rate > 0)
12481254 seq_param->bits_per_second = 1024 * frame_bit_rate; /* use kbps as input */
12491255 else
12501256 seq_param->bits_per_second = 0;
1251-
1252- if (seq_param->rate_control_method == BR_VBR) {
1253- seq_param->max_bits_per_second = 0; /* FIXME: set it later */
1254- seq_param->min_bits_per_second = 0;
1255- }
1256-
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- }
1257+
12641258 seq_param->time_scale = 900;
12651259 seq_param->num_units_in_tick = 15; /* Tc = num_units_in_tick / time_sacle */
12661260
12671261 if (height_in_mbs * 16 - height) {
12681262 frame_cropping_flag = 1;
12691263 frame_crop_bottom_offset =
1270- (height_in_mbs * 16 - height) / (2 * (!seq_param->frame_mbs_only_flag + 1));
1264+ (height_in_mbs * 16 - height) / (2 * (!seq_param->seq_fields.bits.frame_mbs_only_flag + 1));
12711265 }
12721266
12731267 seq_param->frame_cropping_flag = frame_cropping_flag;
@@ -1276,16 +1270,16 @@ static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_
12761270 seq_param->frame_crop_top_offset = 0;
12771271 seq_param->frame_crop_bottom_offset = frame_crop_bottom_offset;
12781272
1279- seq_param->pic_order_cnt_type = 0;
1280- seq_param->direct_8x8_inference_flag = 0;
1273+ seq_param->seq_fields.bits.pic_order_cnt_type = 0;
1274+ seq_param->seq_fields.bits.direct_8x8_inference_flag = 0;
12811275
1282- seq_param->log2_max_frame_num_minus4 = 0;
1283- seq_param->log2_max_pic_order_cnt_lsb_minus4 = 2;
1276+ seq_param->seq_fields.bits.log2_max_frame_num_minus4 = 0;
1277+ seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = 2;
12841278
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;
1279+ if (frame_bit_rate > 0)
1280+ seq_param->vui_parameters_present_flag = 1; //HRD info located in vui
1281+ else
1282+ seq_param->vui_parameters_present_flag = 0;
12891283 }
12901284
12911285 static void avcenc_context_pic_param_init(VAEncPictureParameterBufferH264 *pic_param)
@@ -1295,7 +1289,6 @@ static void avcenc_context_pic_param_init(VAEncPictureParameterBufferH264 *pic_p
12951289
12961290 pic_param->last_picture = 0;
12971291 pic_param->frame_num = 0;
1298- pic_param->coding_type = 0;
12991292
13001293 pic_param->pic_init_qp = (qp_value >= 0 ? qp_value : 26);
13011294 pic_param->num_ref_idx_l0_active_minus1 = 0;
@@ -1314,19 +1307,29 @@ static void avcenc_context_init(int width, int height)
13141307 {
13151308 int i;
13161309 memset(&avcenc_context, 0, sizeof(avcenc_context));
1310+ avcenc_context.profile = VAProfileH264Main;
13171311 avcenc_context.seq_param_buf_id = VA_INVALID_ID;
13181312 avcenc_context.pic_param_buf_id = VA_INVALID_ID;
1319- avcenc_context.dec_ref_pic_marking_buf_id = VA_INVALID_ID;
13201313 avcenc_context.packed_seq_header_param_buf_id = VA_INVALID_ID;
13211314 avcenc_context.packed_seq_buf_id = VA_INVALID_ID;
13221315 avcenc_context.packed_pic_header_param_buf_id = VA_INVALID_ID;
13231316 avcenc_context.packed_pic_buf_id = VA_INVALID_ID;
13241317 avcenc_context.codedbuf_buf_id = VA_INVALID_ID;
1318+ avcenc_context.misc_parameter_hrd_buf_id = VA_INVALID_ID;
13251319 avcenc_context.codedbuf_i_size = width * height;
13261320 avcenc_context.codedbuf_pb_size = 0;
13271321 avcenc_context.current_input_surface = SID_INPUT_PICTURE_0;
13281322 avcenc_context.upload_thread_value = -1;
13291323
1324+ if (qp_value == -1)
1325+ avcenc_context.rate_control_method = VA_RC_CBR;
1326+ else if (qp_value == -2)
1327+ avcenc_context.rate_control_method = VA_RC_VBR;
1328+ else {
1329+ assert(qp_value >= 0 && qp_value <= 51);
1330+ avcenc_context.rate_control_method = VA_RC_CQP;
1331+ }
1332+
13301333 for (i = 0; i < MAX_SLICES; i++) {
13311334 avcenc_context.slice_param_buf_id[i] = VA_INVALID_ID;
13321335 }