diff options
author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
---|---|---|
committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
commit | 386b7d3366f1359a265da207a9cafa3edf553b64 (patch) | |
tree | c76120c2c138faed822e4ae386be6ef22a738a78 /baseline/source/h264_dec/h264_dec.c | |
parent | 54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff) |
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'baseline/source/h264_dec/h264_dec.c')
-rw-r--r-- | baseline/source/h264_dec/h264_dec.c | 610 |
1 files changed, 610 insertions, 0 deletions
diff --git a/baseline/source/h264_dec/h264_dec.c b/baseline/source/h264_dec/h264_dec.c new file mode 100644 index 0000000..76af705 --- /dev/null +++ b/baseline/source/h264_dec/h264_dec.c | |||
@@ -0,0 +1,610 @@ | |||
1 | /* | ||
2 | |||
3 | This program is part of the TACLeBench benchmark suite. | ||
4 | Version V 2.0 | ||
5 | |||
6 | Name: h264_dec_ldecode_macroblock.c | ||
7 | |||
8 | Author: Inge Lille-Langoy et al. | ||
9 | |||
10 | Function: H.264 decoder | ||
11 | |||
12 | Source: MediaBench II | ||
13 | http://euler.slu.edu/~fritts/mediabench (mirror) | ||
14 | |||
15 | Original name: h264_dec_ldecode_macroblock.c | ||
16 | |||
17 | Changes: no functional changes | ||
18 | |||
19 | License: see copyright.txt | ||
20 | |||
21 | */ | ||
22 | |||
23 | |||
24 | /* | ||
25 | Include section | ||
26 | */ | ||
27 | |||
28 | #include "../extra.h" | ||
29 | #include "h264_dec.h" | ||
30 | |||
31 | |||
32 | /* | ||
33 | Forward declaration of functions | ||
34 | */ | ||
35 | |||
36 | void h264_dec_init (); | ||
37 | int h264_dec_return (); | ||
38 | void h264_dec_decode_one_macroblock( struct h264_dec_img_par *img ); | ||
39 | void h264_dec_main( void ); | ||
40 | //int main( void ); | ||
41 | |||
42 | |||
43 | /* | ||
44 | Declaration of global variables | ||
45 | */ | ||
46 | |||
47 | extern signed char h264_dec_mv_array[65][65][2]; | ||
48 | extern short h264_dec_list_imgUV[2][45][45]; | ||
49 | extern int h264_dec_img_m7[16][16]; | ||
50 | |||
51 | char h264_dec_img_mpr[7][7]; | ||
52 | char h264_dec_dec_picture_imgUV[2][64][54]; | ||
53 | struct h264_dec_img_par h264_dec_img; | ||
54 | |||
55 | |||
56 | /* | ||
57 | Initialization- and return-value-related functions | ||
58 | */ | ||
59 | |||
60 | int h264_dec_return () | ||
61 | { | ||
62 | return ( h264_dec_img_mpr[0][0] + h264_dec_dec_picture_imgUV[0][0][0] + 128 != | ||
63 | 0 ); | ||
64 | } | ||
65 | |||
66 | void h264_dec_init () | ||
67 | { | ||
68 | unsigned int i; | ||
69 | unsigned char *p; | ||
70 | volatile char bitmask = 0; | ||
71 | |||
72 | /* | ||
73 | Apply volatile XOR-bitmask to entire input array. | ||
74 | */ | ||
75 | p = ( unsigned char * ) &h264_dec_mv_array[ 0 ]; | ||
76 | _Pragma( "loopbound min 33800 max 33800" ) | ||
77 | for ( i = 0; i < sizeof( h264_dec_mv_array ); ++i, ++p ) | ||
78 | *p ^= bitmask; | ||
79 | |||
80 | p = ( unsigned char * ) &h264_dec_list_imgUV[ 0 ]; | ||
81 | _Pragma( "loopbound min 16200 max 16200" ) | ||
82 | for ( i = 0; i < sizeof( h264_dec_list_imgUV ); ++i, ++p ) | ||
83 | *p ^= bitmask; | ||
84 | |||
85 | p = ( unsigned char * ) &h264_dec_img_m7[ 0 ]; | ||
86 | _Pragma( "loopbound min 1024 max 1024" ) | ||
87 | for ( i = 0; i < sizeof( h264_dec_img_m7 ); ++i, ++p ) | ||
88 | *p ^= bitmask; | ||
89 | |||
90 | h264_dec_img.mb_cr_size_x = 8; | ||
91 | h264_dec_img.mb_cr_size_y = 8; | ||
92 | h264_dec_img.num_blk8x8_uv = 2; | ||
93 | h264_dec_img.pix_c_x = 256; | ||
94 | h264_dec_img.pix_c_y = 256; | ||
95 | h264_dec_img.width_cr = 352; | ||
96 | h264_dec_img.apply_weights = 0; | ||
97 | h264_dec_img.direct_spatial_mv_pred_flag = 1; | ||
98 | h264_dec_img.type = 1; | ||
99 | h264_dec_img.wp_round_chroma = 0; | ||
100 | h264_dec_img.chroma_log2_weight_denom = 0; | ||
101 | } | ||
102 | |||
103 | |||
104 | /* | ||
105 | Algorithm core functions | ||
106 | */ | ||
107 | |||
108 | void h264_dec_decode_one_macroblock( struct h264_dec_img_par *img ) | ||
109 | { | ||
110 | int i = 0, j = 0, ii = 0, jj = 0, i1 = 0, j1 = 0, j4 = 0, i4 = 0; | ||
111 | int uv; | ||
112 | int ioff, joff; | ||
113 | int bw_pred = 0, fw_pred = 0, ifx; | ||
114 | int ii0, jj0, ii1, jj1, if1, jf1, if0, jf0; | ||
115 | int f1_x, f1_y, f2_x, f2_y, f3, f4; | ||
116 | |||
117 | short fw_refframe = -1, bw_refframe = -1; | ||
118 | int mv_mode, pred_dir, intra_prediction; // = currMB->ref_frame; | ||
119 | short fw_ref_idx = -1, bw_ref_idx = -1; | ||
120 | |||
121 | int mb_nr = 0; | ||
122 | short dec_picture_ref_idx = 0; | ||
123 | |||
124 | short active_sps_chroma_format_idc = 1; | ||
125 | short active_pps_weighted_pred_flag = 0; | ||
126 | short active_pps_weighted_bipred_idc = 0; | ||
127 | |||
128 | int smb = 0; | ||
129 | int max_y_cr = 287; | ||
130 | |||
131 | int jf; | ||
132 | |||
133 | int direct_pdir = -1; | ||
134 | |||
135 | int curr_mb_field = 0; | ||
136 | |||
137 | int b8, b4; | ||
138 | |||
139 | int residue_transform_flag = 0; | ||
140 | |||
141 | if ( 1 ) { | ||
142 | f1_x = 64 / img->mb_cr_size_x; | ||
143 | f2_x = f1_x - 1; | ||
144 | |||
145 | f1_y = 64 / img->mb_cr_size_y; | ||
146 | f2_y = f1_y - 1; | ||
147 | |||
148 | f3 = f1_x * f1_y; | ||
149 | f4 = f3 >> 1; | ||
150 | |||
151 | _Pragma( "loopbound min 2 max 2" ) | ||
152 | for ( uv = 0; uv < 2; uv++ ) { | ||
153 | intra_prediction = 0; | ||
154 | |||
155 | |||
156 | _Pragma( "loopbound min 1 max 1" ) | ||
157 | for ( b8 = 0; b8 < ( img->num_blk8x8_uv / 2 ); b8++ ) { | ||
158 | _Pragma( "loopbound min 4 max 4" ) | ||
159 | for ( b4 = 0; b4 < 4; b4++ ) { | ||
160 | joff = 0; | ||
161 | j4 = img->pix_c_y + joff; | ||
162 | ioff = 0; | ||
163 | i4 = img->pix_c_x + ioff; | ||
164 | |||
165 | mv_mode = 1; | ||
166 | pred_dir = -1; | ||
167 | |||
168 | if ( !intra_prediction ) { | ||
169 | if ( pred_dir != 2 ) { | ||
170 | |||
171 | _Pragma( "loopbound min 4 max 4" ) | ||
172 | for ( jj = 0; jj < 4; jj++ ) { | ||
173 | jf = ( ( j4 + jj ) / ( img->mb_cr_size_y / 4 ) ) % 64; | ||
174 | _Pragma( "loopbound min 4 max 4" ) | ||
175 | for ( ii = 0; ii < 4; ii++ ) { | ||
176 | ifx = ( ( i4 + ii ) / ( img->mb_cr_size_x / 4 ) ) % 64; | ||
177 | i1 = ( i4 + ii ) * f1_x + h264_dec_mv_array[jf][ifx][0]; | ||
178 | |||
179 | if ( !curr_mb_field ) | ||
180 | j1 = ( j4 + jj ) * f1_y + h264_dec_mv_array[jf][ifx][1]; | ||
181 | else { | ||
182 | if ( mb_nr % 2 == 0 ) { | ||
183 | j1 = ( ( img->pix_c_y / 2 ) + jj + joff ) * f1_y + | ||
184 | h264_dec_mv_array[jf][ifx][1]; | ||
185 | } else { | ||
186 | j1 = ( ( img->pix_c_y - img->mb_cr_size_y ) / 2 | ||
187 | + jj + joff ) * f1_y + | ||
188 | h264_dec_mv_array[jf][ifx][1]; | ||
189 | } | ||
190 | ++mb_nr; | ||
191 | } | ||
192 | |||
193 | if ( active_sps_chroma_format_idc == 1 ) | ||
194 | j1 += 0; | ||
195 | |||
196 | ii0 = ( ( ( 0 < ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
197 | img->width_cr - 1 : i1 / f1_x ) ) ? | ||
198 | ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
199 | img->width_cr - 1 : i1 / f1_x ) : 0 ) ) % 45; | ||
200 | jj0 = ( ( ( 0 < ( ( j1 / f1_y > max_y_cr ) ? | ||
201 | max_y_cr : j1 / f1_y ) ) ? | ||
202 | ( ( j1 / f1_y > max_y_cr ) ? | ||
203 | max_y_cr : j1 / f1_y ) : 0 ) ) % 45; | ||
204 | ii1 = ( ( ( 0 < ( | ||
205 | ( ( i1 + f2_x ) / f1_x > img->width_cr - 1 ) | ||
206 | ? img->width_cr - 1 : ( i1 + f2_x ) / f1_x ) ) | ||
207 | ? ( ( ( i1 + f2_x ) / f1_x > img->width_cr - 1 ) | ||
208 | ? img->width_cr - 1 : | ||
209 | ( i1 + f2_x ) / f1_x ) : 0 ) ) % 45; | ||
210 | jj1 = ( ( ( 0 < ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) | ||
211 | ? max_y_cr : ( j1 + f2_y ) / f1_y ) ) ? | ||
212 | ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
213 | max_y_cr : ( j1 + f2_y ) / f1_y ) : 0 ) ) % 45; | ||
214 | |||
215 | if1 = ( i1 & f2_x ); | ||
216 | jf1 = ( j1 & f2_y ); | ||
217 | if0 = f1_x - if1; | ||
218 | jf0 = f1_y - jf1; | ||
219 | |||
220 | if ( img->apply_weights ) { | ||
221 | } else { | ||
222 | h264_dec_img_mpr[ii + ioff][jj + joff] | ||
223 | = ( if0 * jf0 * h264_dec_list_imgUV[uv][jj0][ii0] | ||
224 | + if1 * jf0 * h264_dec_list_imgUV[uv][jj0][ii1] | ||
225 | + if0 * jf1 * h264_dec_list_imgUV[uv][jj1][ii0] | ||
226 | + if1 * jf1 * h264_dec_list_imgUV[uv][jj1][ii1] | ||
227 | + f4 ) / f3; | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | } else { | ||
232 | |||
233 | _Pragma( "loopbound min 4 max 4" ) | ||
234 | for ( jj = 0; jj < 4; jj++ ) { | ||
235 | jf = ( j4 + jj ) / ( img->mb_cr_size_y / 4 ); | ||
236 | _Pragma( "loopbound min 4 max 4" ) | ||
237 | for ( ii = 0; ii < 4; ii++ ) { | ||
238 | ifx = ( i4 + ii ) / ( img->mb_cr_size_x / 4 ); | ||
239 | direct_pdir = 2; | ||
240 | |||
241 | if ( mv_mode == 0 && img->direct_spatial_mv_pred_flag ) { | ||
242 | if ( dec_picture_ref_idx != -1 ) { | ||
243 | fw_refframe = 0; | ||
244 | fw_ref_idx = fw_refframe; | ||
245 | } | ||
246 | if ( dec_picture_ref_idx != -1 ) { | ||
247 | bw_refframe = 0; | ||
248 | bw_ref_idx = bw_refframe; | ||
249 | } | ||
250 | |||
251 | if ( dec_picture_ref_idx == -1 ) direct_pdir = 0; | ||
252 | else | ||
253 | if ( dec_picture_ref_idx == -1 ) direct_pdir = 1; | ||
254 | |||
255 | if ( direct_pdir == 0 || direct_pdir == 2 ) { | ||
256 | i1 = ( img->pix_c_x + ii + ioff ) * f1_x + | ||
257 | h264_dec_mv_array[jf][ifx][0]; | ||
258 | |||
259 | if ( !curr_mb_field ) { | ||
260 | j1 = ( img->pix_c_y + jj + joff ) * f1_y + | ||
261 | h264_dec_mv_array[jf][ifx][1]; | ||
262 | } else { | ||
263 | if ( mb_nr % 2 == 0 ) { | ||
264 | j1 = ( ( img->pix_c_y ) / 2 + jj + joff ) * | ||
265 | f1_y + h264_dec_mv_array[jf][ifx][1]; | ||
266 | } else { | ||
267 | j1 = ( ( img->pix_c_y - img->mb_cr_size_y ) | ||
268 | / 2 + jj + joff ) * f1_y | ||
269 | + h264_dec_mv_array[jf][ifx][1]; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | if ( active_sps_chroma_format_idc == 1 ) | ||
274 | j1 += 0; | ||
275 | |||
276 | ii0 = ( ( | ||
277 | ( 0 < ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
278 | img->width_cr - 1 : i1 / f1_x ) ) ? | ||
279 | ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
280 | img->width_cr - 1 : i1 / f1_x ) : 0 ) ) % 45; | ||
281 | jj0 = ( ( | ||
282 | ( 0 < ( ( j1 / f1_y > max_y_cr ) ? | ||
283 | max_y_cr : j1 / f1_y ) ) ? ( ( | ||
284 | j1 / f1_y > max_y_cr ) ? | ||
285 | max_y_cr : j1 / f1_y ) : 0 ) | ||
286 | ) % 45; | ||
287 | ii1 = ( ( ( 0 < ( ( ( i1 + f2_x ) / | ||
288 | f1_x > img->width_cr - 1 ) ? | ||
289 | img->width_cr - 1 : | ||
290 | ( i1 + f2_x ) / f1_x ) ) ? | ||
291 | ( ( ( i1 + f2_x ) / f1_x > img->width_cr - 1 ) | ||
292 | ? img->width_cr - 1 : | ||
293 | ( i1 + f2_x ) / f1_x ) : 0 ) ) % 45; | ||
294 | jj1 = ( ( ( 0 < ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
295 | max_y_cr : ( j1 + f2_y ) / f1_y ) ) ? | ||
296 | ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
297 | max_y_cr : ( j1 + f2_y ) / f1_y ) : 0 ) | ||
298 | ) % 45; | ||
299 | |||
300 | |||
301 | if1 = ( i1 & f2_x ); | ||
302 | jf1 = ( j1 & f2_y ); | ||
303 | if0 = f1_x - if1; | ||
304 | jf0 = f1_y - jf1; | ||
305 | |||
306 | fw_pred = ( if0 * jf0 * | ||
307 | h264_dec_list_imgUV[uv][jj0][ii0] + | ||
308 | if1 * jf0 * | ||
309 | h264_dec_list_imgUV[uv][jj0][ii1] + | ||
310 | if0 * jf1 * | ||
311 | h264_dec_list_imgUV[uv][jj1][ii0] + | ||
312 | if1 * jf1 * | ||
313 | h264_dec_list_imgUV[uv][jj1][ii1] + | ||
314 | f4 ) / f3; | ||
315 | } | ||
316 | if ( direct_pdir == 1 || direct_pdir == 2 ) { | ||
317 | i1 = ( img->pix_c_x + ii + ioff ) * f1_x + | ||
318 | h264_dec_mv_array[jf][ifx][0]; | ||
319 | |||
320 | if ( !curr_mb_field ) { | ||
321 | j1 = ( img->pix_c_y + jj + joff ) * f1_y + | ||
322 | h264_dec_mv_array[jf][ifx][1]; | ||
323 | } else { | ||
324 | if ( mb_nr % 2 == 0 ) { | ||
325 | j1 = ( ( img->pix_c_y ) / 2 + jj + joff ) * f1_y | ||
326 | + h264_dec_mv_array[jf][ifx][1]; | ||
327 | } else { | ||
328 | j1 = ( ( img->pix_c_y - img->mb_cr_size_y ) / 2 | ||
329 | + jj + joff ) * f1_y | ||
330 | + h264_dec_mv_array[jf][ifx][1]; | ||
331 | } | ||
332 | } | ||
333 | if ( active_sps_chroma_format_idc == 1 ) | ||
334 | j1 += 0; | ||
335 | |||
336 | ii0 = ( ( ( 0 < ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
337 | img->width_cr - 1 : i1 / f1_x ) ) ? | ||
338 | ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
339 | img->width_cr - 1 : i1 / f1_x ) : 0 ) ) % 45; | ||
340 | jj0 = ( ( ( 0 < ( ( j1 / f1_y > max_y_cr ) ? | ||
341 | max_y_cr : j1 / f1_y ) ) ? | ||
342 | ( ( j1 / f1_y > max_y_cr ) ? | ||
343 | max_y_cr : j1 / f1_y ) : 0 ) ) % 45; | ||
344 | ii1 = ( ( ( 0 < ( ( ( i1 + f2_x ) / | ||
345 | f1_x > img->width_cr - 1 ) ? | ||
346 | img->width_cr - 1 : | ||
347 | ( i1 + f2_x ) / f1_x ) ) ? | ||
348 | ( ( ( i1 + f2_x ) / f1_x > img->width_cr - 1 ) | ||
349 | ? img->width_cr - 1 : | ||
350 | ( i1 + f2_x ) / f1_x ) : 0 ) ) % 45; | ||
351 | jj1 = ( ( ( 0 < ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
352 | max_y_cr : ( j1 + f2_y ) / f1_y ) ) ? | ||
353 | ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
354 | max_y_cr : ( j1 + f2_y ) / f1_y ) : 0 ) ) | ||
355 | % 45; | ||
356 | |||
357 | if1 = ( i1 & f2_x ); | ||
358 | jf1 = ( j1 & f2_y ); | ||
359 | if0 = f1_x - if1; | ||
360 | jf0 = f1_y - jf1; | ||
361 | |||
362 | bw_pred = ( if0 * jf0 * | ||
363 | h264_dec_list_imgUV[uv][jj0][ii0] + | ||
364 | if1 * jf0 * | ||
365 | h264_dec_list_imgUV[uv][jj0][ii1] + | ||
366 | if0 * jf1 * | ||
367 | h264_dec_list_imgUV[uv][jj1][ii0] + | ||
368 | if1 * jf1 * | ||
369 | h264_dec_list_imgUV[uv][jj1][ii1] + | ||
370 | f4 ) / f3; | ||
371 | } | ||
372 | |||
373 | } else { | ||
374 | fw_refframe = 0; | ||
375 | bw_refframe = 0; | ||
376 | |||
377 | fw_ref_idx = fw_refframe; | ||
378 | bw_ref_idx = bw_refframe; | ||
379 | |||
380 | i1 = ( img->pix_c_x + ii + ioff ) * f1_x + | ||
381 | h264_dec_mv_array[jf][ifx][0]; | ||
382 | |||
383 | if ( !curr_mb_field ) { | ||
384 | j1 = ( img->pix_c_y + jj + joff ) * f1_y + | ||
385 | h264_dec_mv_array[jf][ifx][1]; | ||
386 | } else { | ||
387 | if ( mb_nr % 2 == 0 ) { | ||
388 | j1 = ( ( img->pix_c_y ) / 2 + jj + joff ) * f1_y + | ||
389 | h264_dec_mv_array[jf][ifx][1]; | ||
390 | } else { | ||
391 | j1 = ( ( img->pix_c_y - img->mb_cr_size_y ) / 2 | ||
392 | + jj + joff ) * f1_y | ||
393 | + h264_dec_mv_array[jf][ifx][1]; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | if ( active_sps_chroma_format_idc == 1 ) | ||
398 | j1 += 0; | ||
399 | |||
400 | ii0 = ( ( ( 0 < ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
401 | img->width_cr - 1 : i1 / f1_x ) ) ? | ||
402 | ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
403 | img->width_cr - 1 : i1 / f1_x ) : 0 ) ) | ||
404 | % 45; | ||
405 | jj0 = ( ( ( 0 < ( ( j1 / f1_y > max_y_cr ) ? | ||
406 | max_y_cr : j1 / f1_y ) ) ? | ||
407 | ( ( j1 / f1_y > max_y_cr ) ? | ||
408 | max_y_cr : j1 / f1_y ) : 0 ) ) % 45; | ||
409 | ii1 = ( ( ( 0 < ( ( ( i1 + f2_x ) / | ||
410 | f1_x > img->width_cr - 1 ) ? | ||
411 | img->width_cr - 1 : | ||
412 | ( i1 + f2_x ) / f1_x ) ) ? | ||
413 | ( ( ( i1 + f2_x ) / f1_x > img->width_cr - 1 ) ? | ||
414 | img->width_cr - 1 : | ||
415 | ( i1 + f2_x ) / f1_x ) : 0 ) ) % 45; | ||
416 | jj1 = ( ( ( 0 < ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
417 | max_y_cr : ( j1 + f2_y ) / f1_y ) ) ? | ||
418 | ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
419 | max_y_cr : | ||
420 | ( j1 + f2_y ) / f1_y ) : 0 ) ) % 45; | ||
421 | |||
422 | if1 = ( i1 & f2_x ); | ||
423 | jf1 = ( j1 & f2_y ); | ||
424 | if0 = f1_x - if1; | ||
425 | jf0 = f1_y - jf1; | ||
426 | |||
427 | fw_pred = ( if0 * jf0 * h264_dec_list_imgUV[uv][jj0][ii0] + | ||
428 | if1 * jf0 * h264_dec_list_imgUV[uv][jj0][ii1] + | ||
429 | if0 * jf1 * h264_dec_list_imgUV[uv][jj1][ii0] + | ||
430 | if1 * jf1 * h264_dec_list_imgUV[uv][jj1][ii1] + | ||
431 | f4 ) / f3; | ||
432 | |||
433 | i1 = ( img->pix_c_x + ii + ioff ) * f1_x + | ||
434 | h264_dec_mv_array[jf][ifx][0]; | ||
435 | |||
436 | if ( !curr_mb_field ) { | ||
437 | j1 = ( img->pix_c_y + jj + joff ) * f1_y + | ||
438 | h264_dec_mv_array[jf][ifx][1]; | ||
439 | } else { | ||
440 | if ( mb_nr % 2 == 0 ) { | ||
441 | j1 = ( ( img->pix_c_y ) / 2 + jj + joff ) * f1_y | ||
442 | + h264_dec_mv_array[jf][ifx][1]; | ||
443 | } else { | ||
444 | j1 = ( ( img->pix_c_y - img->mb_cr_size_y ) / 2 + jj | ||
445 | + joff ) * f1_y | ||
446 | + h264_dec_mv_array[jf][ifx][1]; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | if ( active_sps_chroma_format_idc == 1 ) | ||
451 | j1 += 0; | ||
452 | |||
453 | ii0 = ( ( ( 0 < ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
454 | img->width_cr - 1 : i1 / f1_x ) ) ? | ||
455 | ( ( i1 / f1_x > img->width_cr - 1 ) ? | ||
456 | img->width_cr - 1 : i1 / f1_x ) : 0 ) ) % 45; | ||
457 | jj0 = ( ( ( 0 < ( ( j1 / f1_y > max_y_cr ) ? | ||
458 | max_y_cr : j1 / f1_y ) ) ? | ||
459 | ( ( j1 / f1_y > max_y_cr ) ? | ||
460 | max_y_cr : j1 / f1_y ) : 0 ) ) % 45; | ||
461 | ii1 = ( ( ( 0 < ( ( ( i1 + f2_x ) / | ||
462 | f1_x > img->width_cr - 1 ) ? | ||
463 | img->width_cr - 1 : | ||
464 | ( i1 + f2_x ) / f1_x ) ) ? | ||
465 | ( ( ( i1 + f2_x ) / f1_x > img->width_cr - 1 ) ? | ||
466 | img->width_cr - 1 : | ||
467 | ( i1 + f2_x ) / f1_x ) : 0 ) ) % 45; | ||
468 | jj1 = ( ( ( 0 < ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
469 | max_y_cr : ( j1 + f2_y ) / f1_y ) ) ? | ||
470 | ( ( ( j1 + f2_y ) / f1_y > max_y_cr ) ? | ||
471 | max_y_cr : ( j1 + f2_y ) / f1_y ) : 0 ) ) % 45; | ||
472 | |||
473 | if1 = ( i1 & f2_x ); | ||
474 | jf1 = ( j1 & f2_y ); | ||
475 | if0 = f1_x - if1; | ||
476 | jf0 = f1_y - jf1; | ||
477 | |||
478 | bw_pred = ( if0 * jf0 * h264_dec_list_imgUV[uv][jj0][ii0] + | ||
479 | if1 * jf0 * h264_dec_list_imgUV[uv][jj0][ii1] + | ||
480 | if0 * jf1 * h264_dec_list_imgUV[uv][jj1][ii0] + | ||
481 | if1 * jf1 * h264_dec_list_imgUV[uv][jj1][ii1] + | ||
482 | f4 ) / f3; | ||
483 | } | ||
484 | |||
485 | if ( img->apply_weights ) { | ||
486 | if ( ( ( active_pps_weighted_pred_flag && | ||
487 | ( img->type == P_SLICE || img->type == SP_SLICE ) ) | ||
488 | || ( active_pps_weighted_bipred_idc == 1 && | ||
489 | ( img->type == B_SLICE ) ) ) | ||
490 | && curr_mb_field ) { | ||
491 | fw_ref_idx >>= 1; | ||
492 | bw_ref_idx >>= 1; | ||
493 | } | ||
494 | |||
495 | if ( img->direct_spatial_mv_pred_flag | ||
496 | && direct_pdir == 1 ) { | ||
497 | img->mpr[ii + ioff][jj + joff] = | ||
498 | ( ( ( img->wp_round_chroma ) >> | ||
499 | img->chroma_log2_weight_denom ) < 0 ? 0 : | ||
500 | ( ( img->wp_round_chroma ) >> | ||
501 | img->chroma_log2_weight_denom ) ) + 0; | ||
502 | } else | ||
503 | if ( img->direct_spatial_mv_pred_flag | ||
504 | && direct_pdir == 0 ) { | ||
505 | img->mpr[ii + ioff][jj + joff] = | ||
506 | ( ( ( ( img->wp_round_chroma ) >> | ||
507 | img->chroma_log2_weight_denom ) ) < 0 ? | ||
508 | 0 : | ||
509 | ( ( ( img->wp_round_chroma ) >> | ||
510 | img->chroma_log2_weight_denom ) ) ) ; | ||
511 | } else { | ||
512 | |||
513 | int alpha_fw = 0; | ||
514 | int alpha_bw = 0; | ||
515 | |||
516 | img->mpr[ii + ioff][jj + joff] = | ||
517 | ( ( ( alpha_fw * fw_pred + alpha_bw * | ||
518 | bw_pred + | ||
519 | ( 1 << img->chroma_log2_weight_denom ) ) >> ( | ||
520 | img->chroma_log2_weight_denom + 1 ) ) < 0 ? | ||
521 | 0 : ( ( alpha_fw * fw_pred + alpha_bw * | ||
522 | bw_pred + | ||
523 | ( 1 << img->chroma_log2_weight_denom ) ) >> | ||
524 | ( img->chroma_log2_weight_denom + 1 ) ) ); | ||
525 | } | ||
526 | } else { | ||
527 | if ( img->direct_spatial_mv_pred_flag | ||
528 | && direct_pdir == 1 ) | ||
529 | img->mpr[ii + ioff][jj + joff] = bw_pred; | ||
530 | else | ||
531 | if ( img->direct_spatial_mv_pred_flag | ||
532 | && direct_pdir == 0 ) | ||
533 | img->mpr[ii + ioff][jj + joff] = fw_pred; | ||
534 | else { | ||
535 | img->mpr[ii + ioff][jj + joff] = ( fw_pred + bw_pred | ||
536 | + | ||
537 | 1 ) / 2; | ||
538 | } | ||
539 | } | ||
540 | } | ||
541 | } | ||
542 | } | ||
543 | } | ||
544 | |||
545 | if ( !smb ) { | ||
546 | _Pragma( "loopbound min 4 max 4" ) | ||
547 | for ( ii = 0; ii < 4; ii++ ) { | ||
548 | jj = 0; | ||
549 | _Pragma( "loopbound min 4 max 4" ) | ||
550 | for ( ; jj < 4; jj++ ) { | ||
551 | if ( !residue_transform_flag ) { | ||
552 | h264_dec_dec_picture_imgUV[uv][( j4 + jj ) % 64] | ||
553 | [( i4 + ii ) % 54] | ||
554 | = h264_dec_img_m7[ii][jj]; | ||
555 | } | ||
556 | } | ||
557 | } | ||
558 | } | ||
559 | } | ||
560 | } | ||
561 | |||
562 | if ( smb ) { | ||
563 | _Pragma( "loopbound min 2 max 2" ) | ||
564 | for ( j = 4; j < 6; j++ ) { | ||
565 | joff = ( j - 4 ) * 4; | ||
566 | j4 = img->pix_c_y + joff; | ||
567 | _Pragma( "loopbound min 2 max 2" ) | ||
568 | for ( i = 0; i < 2; i++ ) { | ||
569 | ioff = i * 4; | ||
570 | i4 = img->pix_c_x + ioff; | ||
571 | |||
572 | _Pragma( "loopbound min 4 max 4" ) | ||
573 | for ( ii = 0; ii < 4; ii++ ) | ||
574 | _Pragma( "loopbound min 4 max 4" ) | ||
575 | for ( jj = 0; jj < 4; jj++ ) { | ||
576 | h264_dec_dec_picture_imgUV[uv][( j4 + jj ) % 64] | ||
577 | [( i4 + ii ) % 54] | ||
578 | = h264_dec_img_m7[ii][jj]; | ||
579 | } | ||
580 | } | ||
581 | } | ||
582 | } | ||
583 | } | ||
584 | } | ||
585 | } | ||
586 | |||
587 | |||
588 | /* | ||
589 | Main functions | ||
590 | */ | ||
591 | |||
592 | void _Pragma( "entrypoint" ) h264_dec_main( void ) | ||
593 | { | ||
594 | h264_dec_decode_one_macroblock( &h264_dec_img ); | ||
595 | } | ||
596 | |||
597 | |||
598 | int main( int argc, char** argv ) | ||
599 | { | ||
600 | SET_UP | ||
601 | for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){ | ||
602 | START_LOOP | ||
603 | h264_dec_init(); | ||
604 | h264_dec_main(); | ||
605 | STOP_LOOP | ||
606 | } | ||
607 | WRITE_TO_FILE | ||
608 | |||
609 | return ( h264_dec_return() ); | ||
610 | } | ||