11/*
2- * Copyright (c) 2017, Intel Corporation
2+ * Copyright (c) 2017 - 2018 , Intel Corporation
33 *
44 * Permission is hereby granted, free of charge, to any person obtaining a
55 * copy of this software and associated documentation files (the "Software"),
@@ -82,7 +82,9 @@ block_advanced_motion_estimate_check_intel(
8282 get_global_offset(1); // 16 pixels tall MBs (globally scalar)
8383
8484 uint curMB = gid_0 + gid_1 * width; // current MB id
85- short2 count = count_motion_vector_buffer[curMB];
85+ short2 count = 0;
86+ if(count_motion_vector_buffer != NULL)
87+ count = count_motion_vector_buffer[curMB];
8688
8789 int countPredMVs = count.x;
8890 if (countPredMVs != 0) {
@@ -94,11 +96,12 @@ block_advanced_motion_estimate_check_intel(
9496
9597 int2 predMV = 0;
9698 if (get_local_id(0) < countPredMVs) {
99+ if(predictors_buffer != NULL){
97100 predMV =
98101 convert_int2(predictors_buffer[offset]); // one MV per work-item
99102 predMV.x /= 4;
100103 predMV.y /= 4;
101- predMV.y &= 0xFFFE;
104+ predMV.y &= 0xFFFE;}
102105 }
103106
104107 // Do up to 8 IMEs, get the best MVs and their distortions, and optionally
@@ -152,9 +155,10 @@ block_advanced_motion_estimate_check_intel(
152155 if ((skip_block_type == 0x0) | ((doIntra) & (countSkipMVs == 0))) {
153156 int skipMVs = 0;
154157 if (get_local_id(0) < countSkipMVs) {
158+ if(skip_motion_vector_buffer != NULL ) {
155159 __global int *skip1_motion_vector_buffer =
156160 (__global int *)skip_motion_vector_buffer;
157- skipMVs = skip1_motion_vector_buffer[offset]; // one packed MV for one
161+ skipMVs = skip1_motion_vector_buffer[offset]; } // one packed MV for one
158162 // work-item
159163 }
160164 intel_work_group_vme_mb_multi_check_16x16(
@@ -174,9 +178,10 @@ block_advanced_motion_estimate_check_intel(
174178 if ((skip_block_type == 0x1) & (countSkipMVs > 0)) {
175179 int4 skipMVs = 0;
176180 if (get_local_id(0) < countSkipMVs) {
181+ if(skip_motion_vector_buffer != NULL){
177182 __global int4 *skip4_motion_vector_buffer =
178183 (__global int4 *)(skip_motion_vector_buffer);
179- skipMVs = skip4_motion_vector_buffer[offset]; // four component MVs
184+ skipMVs = skip4_motion_vector_buffer[offset]; } // four component MVs
180185 // per work-item
181186 }
182187 intel_work_group_vme_mb_multi_check_8x8(
@@ -221,11 +226,10 @@ block_advanced_motion_estimate_check_intel(
221226 // offset index.
222227
223228 short2 val = as_short2(dstSearch[8 + get_local_id(0) * 2]);
229+ if(motion_vector_buffer != NULL)
224230 motion_vector_buffer[index] = val;
225231
226- #ifndef HW_NULL_CHECK
227232 if (residuals != NULL)
228- #endif
229233 {
230234 residuals[index] = distSearch[get_local_id(0)];
231235 }
@@ -250,11 +254,10 @@ block_advanced_motion_estimate_check_intel(
250254 // with offset index.
251255
252256 short2 val = as_short2(dstSearch[8 + get_local_id(0) * 4 * 2]);
257+ if(motion_vector_buffer != NULL)
253258 motion_vector_buffer[index] = val;
254259
255- #ifndef HW_NULL_CHECK
256260 if (residuals != NULL)
257- #endif
258261 {
259262 residuals[index] = distSearch[get_local_id(0) * 4];
260263 }
@@ -276,11 +279,10 @@ block_advanced_motion_estimate_check_intel(
276279 // location 0 of search_residuals with offset index.
277280
278281 short2 val = as_short2(dstSearch[8]);
282+ if(motion_vector_buffer != NULL)
279283 motion_vector_buffer[index] = val;
280284
281- #ifndef HW_NULL_CHECK
282285 if (residuals != NULL)
283- #endif
284286 {
285287 residuals[index] = distSearch[0];
286288 }
@@ -307,6 +309,7 @@ block_advanced_motion_estimate_check_intel(
307309 // 2. The work-item gathers distSkip locations 0, 16*1, .., 16*7 and
308310 // copies them to contiguous skip_residual locations 0, 1, 2, ..,
309311 // 7.
312+ if(skip_residuals != NULL)
310313 skip_residuals[index] = distSkip[get_local_id(0) * 16];
311314 }
312315 } else {
@@ -322,9 +325,9 @@ block_advanced_motion_estimate_check_intel(
322325 // 2. The work-item gathers distSkip locations 0, 4*1, .., 4*31 and
323326 // copies them to contiguous skip_residual locations 0, 1, 2, ..,
324327 // 31.
325-
328+ if(skip_resiudals != NULL){
326329 skip_residuals[index] = distSkip[get_local_id(0) * 4];
327- skip_residuals[index + 16] = distSkip[(get_local_id(0) + 16) * 4];
330+ skip_residuals[index + 16] = distSkip[(get_local_id(0) + 16) * 4];}
328331 }
329332 }
330333 }
@@ -345,8 +348,9 @@ block_advanced_motion_estimate_check_intel(
345348 char value = dstIntra_4x4[get_local_id(0)];
346349 char value_low = (value)&0xf;
347350 char value_high = (value >> 4) & 0xf;
351+ if(intra_search_predictor_modes != NULL){
348352 intra_search_predictor_modes[index_low + 5] = value_low;
349- intra_search_predictor_modes[index_high + 5] = value_high;
353+ intra_search_predictor_modes[index_high + 5] = value_high;}
350354 }
351355
352356 // Write out the 8x8 intra modes
@@ -356,6 +360,7 @@ block_advanced_motion_estimate_check_intel(
356360 char value = dstIntra_8x8[get_local_id(0) * 2];
357361 char value_low = (value)&0xf;
358362 int index = (gid_0 * 22) + (get_local_id(0)) + (gid_1 * 22 * width);
363+ if(intra_search_predictor_modes != NULL)
359364 intra_search_predictor_modes[index + 1] = value_low;
360365 }
361366
@@ -365,13 +370,12 @@ block_advanced_motion_estimate_check_intel(
365370 (__local char *)(&dstSkipIntra[64 + 0 + 4]);
366371 char value = dstIntra_16x16[get_local_id(0)];
367372 char value_low = (value)&0xf;
373+ if(intra_search_predictor_modes != NULL)
368374 intra_search_predictor_modes[index_low] = value_low;
369375 }
370376
371377// Get the intra residuals.
372- #ifndef HW_NULL_CHECK
373378 if (intra_residuals != NULL)
374- #endif
375379 {
376380 int index = (gid_0 * 4) + (gid_1 * 4 * width);
377381
0 commit comments