summaryrefslogtreecommitdiffstats
path: root/all_pairs/source/h264_dec/h264_dec.c
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
commit386b7d3366f1359a265da207a9cafa3edf553b64 (patch)
treec76120c2c138faed822e4ae386be6ef22a738a78 /all_pairs/source/h264_dec/h264_dec.c
parent54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff)
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'all_pairs/source/h264_dec/h264_dec.c')
-rw-r--r--all_pairs/source/h264_dec/h264_dec.c610
1 files changed, 610 insertions, 0 deletions
diff --git a/all_pairs/source/h264_dec/h264_dec.c b/all_pairs/source/h264_dec/h264_dec.c
new file mode 100644
index 0000000..76af705
--- /dev/null
+++ b/all_pairs/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
36void h264_dec_init ();
37int h264_dec_return ();
38void h264_dec_decode_one_macroblock( struct h264_dec_img_par *img );
39void h264_dec_main( void );
40//int main( void );
41
42
43/*
44 Declaration of global variables
45*/
46
47extern signed char h264_dec_mv_array[65][65][2];
48extern short h264_dec_list_imgUV[2][45][45];
49extern int h264_dec_img_m7[16][16];
50
51char h264_dec_img_mpr[7][7];
52char h264_dec_dec_picture_imgUV[2][64][54];
53struct h264_dec_img_par h264_dec_img;
54
55
56/*
57 Initialization- and return-value-related functions
58*/
59
60int 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
66void 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
108void 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;