• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

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

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

hardware/intel/intel-driver


コミットメタ情報

リビジョン5d528baf61d392d84e846e22bc7c4474f02c4050 (tree)
日時2016-06-07 14:11:49
作者Zhao Yakui <yakui.zhao@inte...>
コミッターXiang, Haihao

ログメッセージ

Fix the potential NULL issue

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>

変更サマリ

差分

--- a/src/gen9_vp9_encoder.c
+++ b/src/gen9_vp9_encoder.c
@@ -272,6 +272,11 @@ gen9_vp9_init_check_surfaces(VADriverContextP ctx,
272272 &vp9_surface->scaled_4x_surface_id);
273273
274274 vp9_surface->scaled_4x_surface_obj = SURFACE(vp9_surface->scaled_4x_surface_id);
275+
276+ if (!vp9_surface->scaled_4x_surface_obj) {
277+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
278+ }
279+
275280 i965_check_alloc_surface_bo(ctx, vp9_surface->scaled_4x_surface_obj, 1,
276281 VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
277282
@@ -284,6 +289,11 @@ gen9_vp9_init_check_surfaces(VADriverContextP ctx,
284289 1,
285290 &vp9_surface->scaled_16x_surface_id);
286291 vp9_surface->scaled_16x_surface_obj = SURFACE(vp9_surface->scaled_16x_surface_id);
292+
293+ if (!vp9_surface->scaled_16x_surface_obj) {
294+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
295+ }
296+
287297 i965_check_alloc_surface_bo(ctx, vp9_surface->scaled_16x_surface_obj, 1,
288298 VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
289299
@@ -344,6 +354,11 @@ gen9_vp9_check_dys_surfaces(VADriverContextP ctx,
344354 1,
345355 &vp9_surface->dys_surface_id);
346356 vp9_surface->dys_surface_obj = SURFACE(vp9_surface->dys_surface_id);
357+
358+ if (!vp9_surface->dys_surface_obj) {
359+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
360+ }
361+
347362 i965_check_alloc_surface_bo(ctx, vp9_surface->dys_surface_obj, 1,
348363 VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
349364
@@ -358,6 +373,11 @@ gen9_vp9_check_dys_surfaces(VADriverContextP ctx,
358373 &vp9_surface->dys_4x_surface_id);
359374
360375 vp9_surface->dys_4x_surface_obj = SURFACE(vp9_surface->dys_4x_surface_id);
376+
377+ if (!vp9_surface->dys_4x_surface_obj) {
378+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
379+ }
380+
361381 i965_check_alloc_surface_bo(ctx, vp9_surface->dys_4x_surface_obj, 1,
362382 VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
363383
@@ -370,6 +390,11 @@ gen9_vp9_check_dys_surfaces(VADriverContextP ctx,
370390 1,
371391 &vp9_surface->dys_16x_surface_id);
372392 vp9_surface->dys_16x_surface_obj = SURFACE(vp9_surface->dys_16x_surface_id);
393+
394+ if (!vp9_surface->dys_16x_surface_obj) {
395+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
396+ }
397+
373398 i965_check_alloc_surface_bo(ctx, vp9_surface->dys_16x_surface_obj, 1,
374399 VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
375400
@@ -1135,6 +1160,10 @@ void gen9_vp9_set_curbe_brc(VADriverContextP ctx,
11351160 segment_param = param->psegment_param;
11361161
11371162 cmd = gen8p_gpe_context_map_curbe(gpe_context);
1163+
1164+ if (!cmd)
1165+ return;
1166+
11381167 memset(cmd, 0, sizeof(vp9_brc_curbe_data));
11391168
11401169 if (!vp9_state->dys_enabled)
@@ -1548,7 +1577,7 @@ intel_vp9enc_construct_picstate_batchbuf(VADriverContextP ctx,
15481577 pdata = i965_map_gpe_resource(gpe_resource);
15491578 vp9_state = (struct gen9_vp9_state *) encoder_context->enc_priv_state;
15501579
1551- if (!vp9_state || !vp9_state->pic_param)
1580+ if (!vp9_state || !vp9_state->pic_param || !pdata)
15521581 return;
15531582
15541583 pic_param = vp9_state->pic_param;
@@ -1954,6 +1983,10 @@ gen9_vp9_brc_update_kernel(VADriverContextP ctx,
19541983 {
19551984 char *brc_const_buffer;
19561985 brc_const_buffer = i965_map_gpe_resource(&vme_context->res_brc_const_data_buffer);
1986+
1987+ if (!brc_const_buffer)
1988+ return VA_STATUS_ERROR_OPERATION_FAILED;
1989+
19571990 if (vp9_state->picture_coding_type)
19581991 memcpy(brc_const_buffer, vp9_brc_const_data_p_g9,
19591992 sizeof(vp9_brc_const_data_p_g9));
@@ -2025,6 +2058,10 @@ void gen9_vp9_set_curbe_me(VADriverContextP ctx,
20252058 enc_media_state = VP9_MEDIA_STATE_4X_ME;
20262059
20272060 me_cmd = gen8p_gpe_context_map_curbe(gpe_context);
2061+
2062+ if (!me_cmd)
2063+ return;
2064+
20282065 memset(me_cmd, 0, sizeof(vp9_me_curbe_data));
20292066
20302067 me_cmd->dw1.max_num_mvs = 0x10;
@@ -2362,6 +2399,10 @@ gen9_vp9_set_curbe_scaling_cm(VADriverContextP ctx,
23622399 vp9_scaling4x_curbe_data_cm *curbe_cmd;
23632400
23642401 curbe_cmd = gen8p_gpe_context_map_curbe(gpe_context);
2402+
2403+ if (!curbe_cmd)
2404+ return;
2405+
23652406 memset(curbe_cmd, 0, sizeof(vp9_scaling4x_curbe_data_cm));
23662407
23672408 curbe_cmd->dw0.input_picture_width = curbe_param->input_picture_width;
@@ -2549,8 +2590,15 @@ static void
25492590 gen9_vp9_dys_set_sampler_state(struct i965_gpe_context *gpe_context)
25502591 {
25512592 struct gen9_sampler_8x8_avs *sampler_cmd;
2593+
2594+ if (!gpe_context)
2595+ return;
2596+
25522597 dri_bo_map(gpe_context->dynamic_state.bo, 1);
25532598
2599+ if (!gpe_context->dynamic_state.bo->virtual)
2600+ return;
2601+
25542602 sampler_cmd = (struct gen9_sampler_8x8_avs *)
25552603 (gpe_context->dynamic_state.bo->virtual + gpe_context->sampler_offset);
25562604
@@ -2623,6 +2671,10 @@ gen9_vp9_set_curbe_dys(VADriverContextP ctx,
26232671 vp9_dys_curbe_data *curbe_cmd;
26242672
26252673 curbe_cmd = gen8p_gpe_context_map_curbe(gpe_context);
2674+
2675+ if (!curbe_cmd)
2676+ return;
2677+
26262678 memset(curbe_cmd, 0, sizeof(vp9_dys_curbe_data));
26272679
26282680 curbe_cmd->dw0.input_frame_width = curbe_param->input_width;
@@ -2780,7 +2832,8 @@ gen9_vp9_run_dys_refframes(VADriverContextP ctx,
27802832 &dys_kernel_param);
27812833 }
27822834
2783- if (vp9_state->dys_ref_frame_flag & VP9_LAST_REF) {
2835+ if ((vp9_state->dys_ref_frame_flag & VP9_LAST_REF) &&
2836+ vp9_state->last_ref_obj) {
27842837 obj_surface = vp9_state->last_ref_obj;
27852838 vp9_priv_surface = (struct gen9_surface_vp9 *)(obj_surface->private_data);
27862839
@@ -2832,7 +2885,8 @@ gen9_vp9_run_dys_refframes(VADriverContextP ctx,
28322885 }
28332886 }
28342887
2835- if (vp9_state->dys_ref_frame_flag & VP9_GOLDEN_REF) {
2888+ if ((vp9_state->dys_ref_frame_flag & VP9_GOLDEN_REF) &&
2889+ vp9_state->golden_ref_obj) {
28362890 obj_surface = vp9_state->golden_ref_obj;
28372891 vp9_priv_surface = (struct gen9_surface_vp9 *)(obj_surface->private_data);
28382892
@@ -2884,7 +2938,8 @@ gen9_vp9_run_dys_refframes(VADriverContextP ctx,
28842938 }
28852939 }
28862940
2887- if (vp9_state->dys_ref_frame_flag & VP9_ALT_REF) {
2941+ if ((vp9_state->dys_ref_frame_flag & VP9_ALT_REF) &&
2942+ vp9_state->alt_ref_obj) {
28882943 obj_surface = vp9_state->alt_ref_obj;
28892944 vp9_priv_surface = (struct gen9_surface_vp9 *)(obj_surface->private_data);
28902945
@@ -2969,6 +3024,10 @@ gen9_vp9_set_curbe_mbenc(VADriverContextP ctx,
29693024 }
29703025
29713026 curbe_cmd = gen8p_gpe_context_map_curbe(gpe_context);
3027+
3028+ if (!curbe_cmd)
3029+ return;
3030+
29723031 memset(curbe_cmd, 0, sizeof(vp9_mbenc_curbe_data));
29733032
29743033 if (vp9_state->dys_in_use)
@@ -3843,6 +3902,10 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
38433902 encode_state->seq_param_ext->buffer)
38443903 seq_param = (VAEncSequenceParameterBufferVP9 *)encode_state->seq_param_ext->buffer;
38453904
3905+ if (!seq_param) {
3906+ seq_param = &vp9_state->bogus_seq_param;
3907+ }
3908+
38463909 vp9_state->pic_param = pic_param;
38473910 vp9_state->segment_param = seg_param;
38483911 vp9_state->seq_param = seq_param;
@@ -4051,7 +4114,8 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
40514114 !pic_param->pic_flags.bits.intra_only) {
40524115 vp9_state->dys_ref_frame_flag = vp9_state->ref_frame_flag;
40534116
4054- if (vp9_state->ref_frame_flag & VP9_LAST_REF) {
4117+ if ((vp9_state->ref_frame_flag & VP9_LAST_REF) &&
4118+ vp9_state->last_ref_obj) {
40554119 obj_surface = vp9_state->last_ref_obj;
40564120 vp9_priv_surface = (struct gen9_surface_vp9 *)(obj_surface->private_data);
40574121
@@ -4059,7 +4123,8 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
40594123 vp9_state->frame_height == vp9_priv_surface->frame_height)
40604124 vp9_state->dys_ref_frame_flag &= ~(VP9_LAST_REF);
40614125 }
4062- if (vp9_state->ref_frame_flag & VP9_GOLDEN_REF) {
4126+ if ((vp9_state->ref_frame_flag & VP9_GOLDEN_REF) &&
4127+ vp9_state->golden_ref_obj) {
40634128 obj_surface = vp9_state->golden_ref_obj;
40644129 vp9_priv_surface = (struct gen9_surface_vp9 *)(obj_surface->private_data);
40654130
@@ -4067,7 +4132,8 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx,
40674132 vp9_state->frame_height == vp9_priv_surface->frame_height)
40684133 vp9_state->dys_ref_frame_flag &= ~(VP9_GOLDEN_REF);
40694134 }
4070- if (vp9_state->ref_frame_flag & VP9_ALT_REF) {
4135+ if ((vp9_state->ref_frame_flag & VP9_ALT_REF) &&
4136+ vp9_state->alt_ref_obj) {
40714137 obj_surface = vp9_state->alt_ref_obj;
40724138 vp9_priv_surface = (struct gen9_surface_vp9 *)(obj_surface->private_data);
40734139
@@ -4214,7 +4280,8 @@ gen9_vme_gpe_kernel_prepare_vp9(VADriverContextP ctx,
42144280 }
42154281
42164282 if (vp9_state->dys_ref_frame_flag) {
4217- if (vp9_state->dys_ref_frame_flag & VP9_LAST_REF) {
4283+ if ((vp9_state->dys_ref_frame_flag & VP9_LAST_REF) &&
4284+ vp9_state->last_ref_obj) {
42184285 obj_surface = vp9_state->last_ref_obj;
42194286 surface_param.frame_width = vp9_state->frame_width;
42204287 surface_param.frame_height = vp9_state->frame_height;
@@ -4225,7 +4292,8 @@ gen9_vme_gpe_kernel_prepare_vp9(VADriverContextP ctx,
42254292 if (va_status)
42264293 return va_status;
42274294 }
4228- if (vp9_state->dys_ref_frame_flag & VP9_GOLDEN_REF) {
4295+ if ((vp9_state->dys_ref_frame_flag & VP9_GOLDEN_REF) &&
4296+ vp9_state->golden_ref_obj) {
42294297 obj_surface = vp9_state->golden_ref_obj;
42304298 surface_param.frame_width = vp9_state->frame_width;
42314299 surface_param.frame_height = vp9_state->frame_height;
@@ -4236,7 +4304,8 @@ gen9_vme_gpe_kernel_prepare_vp9(VADriverContextP ctx,
42364304 if (va_status)
42374305 return va_status;
42384306 }
4239- if (vp9_state->dys_ref_frame_flag & VP9_ALT_REF) {
4307+ if ((vp9_state->dys_ref_frame_flag & VP9_ALT_REF) &&
4308+ vp9_state->alt_ref_obj) {
42404309 obj_surface = vp9_state->alt_ref_obj;
42414310 surface_param.frame_width = vp9_state->frame_width;
42424311 surface_param.frame_height = vp9_state->frame_height;
@@ -4843,6 +4912,9 @@ intel_vp9enc_refresh_frame_internal_buffers(VADriverContextP ctx,
48434912 i965_zero_gpe_resource(&pak_context->res_compressed_input_buffer);
48444913 buffer = i965_map_gpe_resource(&pak_context->res_compressed_input_buffer);
48454914
4915+ if (!buffer)
4916+ return;
4917+
48464918 /* write tx_size */
48474919 if ((pic_param->luma_ac_qindex == 0) &&
48484920 (pic_param->luma_dc_qindex_delta == 0) &&
@@ -5357,6 +5429,9 @@ intel_vp9enc_construct_pak_insertobj_batchbuffer(VADriverContextP ctx,
53575429 uncompressed_header_length = vp9_state->header_length;
53585430 cmd_ptr = i965_map_gpe_resource(obj_batch_buffer);
53595431
5432+ if (!cmd_ptr)
5433+ return;
5434+
53605435 bits_in_last_dw = uncompressed_header_length % 4;
53615436 bits_in_last_dw *= 8;
53625437
@@ -5437,6 +5512,10 @@ gen9_vp9_pak_picture_level(VADriverContextP ctx,
54375512 uint8_t *prob_ptr;
54385513
54395514 prob_ptr = i965_map_gpe_resource(&pak_context->res_prob_buffer);
5515+
5516+ if (!prob_ptr)
5517+ return;
5518+
54405519 /* copy the current fc to vp9_prob buffer */
54415520 memcpy(prob_ptr, &vp9_state->vp9_current_fc, sizeof(FRAME_CONTEXT));
54425521 if ((pic_param->pic_flags.bits.frame_type == HCP_VP9_KEY_FRAME) ||
--- a/src/gen9_vp9_encoder.h
+++ b/src/gen9_vp9_encoder.h
@@ -1908,6 +1908,7 @@ struct gen9_vp9_state {
19081908 struct object_surface *alt_ref_obj;
19091909
19101910 VAEncSequenceParameterBufferVP9 *seq_param;
1911+ VAEncSequenceParameterBufferVP9 bogus_seq_param;
19111912 VAEncPictureParameterBufferVP9 *pic_param;
19121913 VAEncMiscParameterTypeVP9PerSegmantParam *segment_param;
19131914 double brc_init_current_target_buf_full_in_bits;