/src/libmpeg2/decoder/impeg2d_mv_dec.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2015 The Android Open Source Project |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ***************************************************************************** |
18 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | #include <stdio.h> |
21 | | |
22 | | #include "iv_datatypedef.h" |
23 | | #include "iv.h" |
24 | | |
25 | | #include "impeg2_buf_mgr.h" |
26 | | #include "impeg2_disp_mgr.h" |
27 | | #include "impeg2_defs.h" |
28 | | #include "impeg2_platform_macros.h" |
29 | | #include "impeg2_inter_pred.h" |
30 | | #include "impeg2_idct.h" |
31 | | #include "impeg2_globals.h" |
32 | | #include "impeg2_format_conv.h" |
33 | | #include "impeg2_macros.h" |
34 | | |
35 | | #include "ivd.h" |
36 | | #include "impeg2d.h" |
37 | | #include "impeg2d_bitstream.h" |
38 | | #include "impeg2d_structs.h" |
39 | | #include "impeg2d_globals.h" |
40 | | #include "impeg2d_vld_tables.h" |
41 | | #include "impeg2d_pic_proc.h" |
42 | | #include "impeg2d_debug.h" |
43 | | #include "impeg2d_mv_dec.h" |
44 | | #include "impeg2d_mc.h" |
45 | | |
46 | | /******************************************************************************* |
47 | | * Function name : impeg2d_dec_1mv |
48 | | * |
49 | | * Description : Decodes a motion vector and updates the predictors |
50 | | * |
51 | | * Arguments : |
52 | | * stream : Bitstream |
53 | | * predMv : Prediction for the motion vectors |
54 | | * mv : Motion vectors |
55 | | * fCode : fcode to the used for the decoding |
56 | | * shift : Shift value to be used. This will be equal to |
57 | | * (mv_format == "field") && (picture_structure == "Frame picture") |
58 | | * i : 0 - MV_X and 1 - MV_Y |
59 | | * |
60 | | * Value Returned: None |
61 | | *******************************************************************************/ |
62 | | void impeg2d_dec_1mv(stream_t *ps_stream, WORD16 ai2_pred_mv[], WORD16 ai2_mv[],UWORD16 au2_fCode[], |
63 | | UWORD16 u2_mv_y_shift, WORD16 ai2_dmv[]) |
64 | 3.85M | { |
65 | 3.85M | WORD16 i2_f; |
66 | 3.85M | WORD16 i2_r_size; |
67 | 3.85M | WORD16 i2_high,i2_low,i2_range; |
68 | 3.85M | UWORD32 u4_mv_code; |
69 | 3.85M | WORD16 i2_delta; |
70 | 3.85M | UWORD16 u2_first_bit; |
71 | 3.85M | WORD32 i; |
72 | 3.85M | WORD32 ai2_shifts[2]; |
73 | 3.85M | UWORD32 u4_buf; |
74 | 3.85M | UWORD32 u4_buf_nxt; |
75 | 3.85M | UWORD32 u4_offset; |
76 | 3.85M | UWORD32 *pu4_buf_aligned; |
77 | | |
78 | 3.85M | ai2_shifts[0] = 0; |
79 | 3.85M | ai2_shifts[1] = u2_mv_y_shift; |
80 | | |
81 | | |
82 | 3.85M | GET_TEMP_STREAM_DATA(u4_buf,u4_buf_nxt,u4_offset,pu4_buf_aligned,ps_stream) |
83 | 11.5M | for(i = 0; i < 2; i++) |
84 | 7.69M | { |
85 | 7.69M | WORD32 i4_shift = ai2_shifts[i]; |
86 | | /* Decode the motion_code */ |
87 | 7.69M | IBITS_NXT(u4_buf, u4_buf_nxt, u4_offset, u4_mv_code, MV_CODE_LEN) |
88 | 7.69M | u2_first_bit = (u4_mv_code >> (MV_CODE_LEN - 1)) & 0x01; |
89 | 7.69M | if(u2_first_bit == 1) /* mvCode == 0 */ |
90 | 3.61M | { |
91 | 3.61M | i2_delta = 0; |
92 | 3.61M | FLUSH_BITS(u4_offset,u4_buf,u4_buf_nxt,1,pu4_buf_aligned) |
93 | | |
94 | 3.61M | ai2_mv[i] = (ai2_pred_mv[i] >> i4_shift); |
95 | | |
96 | 3.61M | ai2_pred_mv[i] = (ai2_mv[i] << i4_shift); |
97 | | |
98 | 3.61M | } |
99 | 4.08M | else |
100 | 4.08M | { |
101 | 4.08M | UWORD16 u2_index; |
102 | 4.08M | UWORD16 u2_value; |
103 | 4.08M | UWORD16 u2_mv_len; |
104 | 4.08M | UWORD16 u2_abs_mvcode_minus1; |
105 | 4.08M | UWORD16 u2_sign_bit; |
106 | | |
107 | 4.08M | i2_r_size = au2_fCode[i] - 1; |
108 | 4.08M | i2_f = 1 << i2_r_size; |
109 | 4.08M | i2_high = (16 * i2_f) - 1; |
110 | 4.08M | i2_low = ((-16) * i2_f); |
111 | 4.08M | i2_range = (32 * i2_f); |
112 | | |
113 | 4.08M | u2_index = (u4_mv_code >> 1) & 0x1FF; |
114 | 4.08M | u2_value = gau2_impeg2d_mv_code[u2_index]; |
115 | 4.08M | u2_mv_len = (u2_value & 0x0F); |
116 | 4.08M | u2_abs_mvcode_minus1 = (u2_value >> 8) & 0x0FF; |
117 | 4.08M | u4_mv_code >>= (MV_CODE_LEN - u2_mv_len - 1); |
118 | 4.08M | u2_sign_bit = u4_mv_code & 0x1; |
119 | | |
120 | 4.08M | FLUSH_BITS(u4_offset,u4_buf,u4_buf_nxt,(u2_mv_len + 1),pu4_buf_aligned) |
121 | 4.08M | i2_delta = u2_abs_mvcode_minus1 * i2_f + 1; |
122 | 4.08M | if(i2_r_size) |
123 | 3.84M | { |
124 | 3.84M | UWORD32 val; |
125 | 3.84M | IBITS_GET(u4_buf, u4_buf_nxt, u4_offset, val, pu4_buf_aligned, i2_r_size) |
126 | 3.84M | i2_delta += (WORD16)val; |
127 | 3.84M | } |
128 | | |
129 | 4.08M | if(u2_sign_bit) |
130 | 2.87M | i2_delta = -i2_delta; |
131 | | |
132 | 4.08M | ai2_mv[i] = (ai2_pred_mv[i] >> i4_shift) + i2_delta; |
133 | | |
134 | 4.08M | if(ai2_mv[i] < i2_low) |
135 | 89.0k | { |
136 | 89.0k | ai2_mv[i] += i2_range; |
137 | 89.0k | } |
138 | | |
139 | 4.08M | if(ai2_mv[i] > i2_high) |
140 | 62.0k | { |
141 | 62.0k | ai2_mv[i] -= i2_range; |
142 | 62.0k | } |
143 | 4.08M | ai2_pred_mv[i] = (ai2_mv[i] << i4_shift); |
144 | | |
145 | 4.08M | } |
146 | 7.69M | if(ai2_dmv) |
147 | 59.4k | { |
148 | 59.4k | UWORD32 u4_val; |
149 | 59.4k | ai2_dmv[i] = 0; |
150 | 59.4k | IBITS_GET(u4_buf, u4_buf_nxt, u4_offset, u4_val, pu4_buf_aligned, 1) |
151 | 59.4k | if(u4_val) |
152 | 51.4k | { |
153 | 51.4k | IBITS_GET(u4_buf, u4_buf_nxt, u4_offset, u4_val, pu4_buf_aligned, 1) |
154 | 51.4k | ai2_dmv[i] = gai2_impeg2d_dec_mv[u4_val]; |
155 | 51.4k | } |
156 | 59.4k | } |
157 | 7.69M | } |
158 | 3.85M | PUT_TEMP_STREAM_DATA(u4_buf, u4_buf_nxt, u4_offset, pu4_buf_aligned, ps_stream) |
159 | | |
160 | 3.85M | } |
161 | | /******************************************************************************* |
162 | | * Function name : impeg2d_dec_mv |
163 | | * |
164 | | * Description : Decodes a motion vector and updates the predictors |
165 | | * |
166 | | * Arguments : |
167 | | * stream : Bitstream |
168 | | * predMv : Prediction for the motion vectors |
169 | | * mv : Motion vectors |
170 | | * fCode : fcode to the used for the decoding |
171 | | * shift : Shift value to be used. This will be equal to |
172 | | * (mv_format == "field") && (picture_structure == "Frame picture") |
173 | | * |
174 | | * Value Returned: None |
175 | | *******************************************************************************/ |
176 | | e_field_t impeg2d_dec_mv(stream_t *ps_stream, WORD16 ai2_pred_mv[], WORD16 ai2_mv[],UWORD16 au2_f_code[], |
177 | | UWORD16 u2_shift, UWORD16 u2_fld_sel) |
178 | 3.82M | { |
179 | 3.82M | e_field_t e_fld; |
180 | 3.82M | if(u2_fld_sel) |
181 | 246k | { |
182 | 246k | e_fld = (e_field_t)impeg2d_bit_stream_get_bit(ps_stream); |
183 | 246k | } |
184 | 3.57M | else |
185 | 3.57M | { |
186 | 3.57M | e_fld = TOP; |
187 | 3.57M | } |
188 | | |
189 | 3.82M | impeg2d_dec_1mv(ps_stream,ai2_pred_mv,ai2_mv,au2_f_code,u2_shift,NULL); |
190 | | |
191 | 3.82M | return(e_fld); |
192 | 3.82M | } |
193 | | |
194 | | /***************************************************************************** |
195 | | * Function Name : impeg2d_dec_1mv_mb |
196 | | * |
197 | | * Description : Decodes mc params for 1 MV MB |
198 | | * |
199 | | * Arguments : |
200 | | * dec : Decoder state |
201 | | * |
202 | | * Values Returned : None |
203 | | *****************************************************************************/ |
204 | | void impeg2d_dec_1mv_mb(dec_state_t *ps_dec) |
205 | 3.26M | { |
206 | 3.26M | stream_t *ps_stream; |
207 | 3.26M | WORD16 *pi2_mv; |
208 | 3.26M | e_field_t e_fld; |
209 | 3.26M | mb_mc_params_t *ps_mc; |
210 | 3.26M | e_pred_direction_t e_ref_pic; |
211 | | |
212 | | |
213 | 3.26M | ps_stream = &ps_dec->s_bit_stream; |
214 | 3.26M | e_ref_pic = ps_dec->e_mb_pred; |
215 | | /************************************************************************/ |
216 | | /* Decode the motion vector */ |
217 | | /************************************************************************/ |
218 | 3.26M | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[FORW][FIRST]; |
219 | 3.26M | e_fld = impeg2d_dec_mv(ps_stream,ps_dec->ai2_pred_mv[e_ref_pic][FIRST],pi2_mv, |
220 | 3.26M | ps_dec->au2_f_code[e_ref_pic],0, ps_dec->u2_fld_pic); |
221 | | |
222 | 3.26M | ps_dec->ai2_pred_mv[e_ref_pic][SECOND][MV_X] = ps_dec->ai2_pred_mv[e_ref_pic][FIRST][MV_X]; |
223 | 3.26M | ps_dec->ai2_pred_mv[e_ref_pic][SECOND][MV_Y] = ps_dec->ai2_pred_mv[e_ref_pic][FIRST][MV_Y]; |
224 | | /************************************************************************/ |
225 | | /* Set the motion vector params */ |
226 | | /************************************************************************/ |
227 | 3.26M | ps_mc = &ps_dec->as_mb_mc_params[e_ref_pic][FIRST]; |
228 | 3.26M | ps_mc->s_ref = ps_dec->as_ref_buf[e_ref_pic][e_fld]; |
229 | 3.26M | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type, 0, |
230 | 3.26M | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
231 | | |
232 | 3.26M | } |
233 | | |
234 | | /***************************************************************************** |
235 | | * Function Name : impeg2d_dec_2mv_fw_or_bk_mb |
236 | | * |
237 | | * Description : Decodes first part of params for 2 MV Interpolated MB |
238 | | * |
239 | | * Arguments : |
240 | | * dec : Decoder state |
241 | | * |
242 | | * Values Returned : None |
243 | | *****************************************************************************/ |
244 | | void impeg2d_dec_2mv_fw_or_bk_mb(dec_state_t *ps_dec) |
245 | 58.1k | { |
246 | 58.1k | stream_t *ps_stream; |
247 | 58.1k | WORD16 *pi2_mv; |
248 | 58.1k | e_field_t e_fld; |
249 | 58.1k | mb_mc_params_t *ps_mc; |
250 | 58.1k | e_pred_direction_t e_ref_pic; |
251 | 58.1k | UWORD16 i; |
252 | | |
253 | 58.1k | ps_stream = &ps_dec->s_bit_stream; |
254 | 58.1k | e_ref_pic = ps_dec->e_mb_pred; |
255 | 174k | for(i = 0; i < 2; i++) |
256 | 116k | { |
257 | | /********************************************************************/ |
258 | | /* Decode the first motion vector */ |
259 | | /********************************************************************/ |
260 | 116k | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[FORW][i]; |
261 | 116k | e_fld = impeg2d_dec_mv(ps_stream,ps_dec->ai2_pred_mv[e_ref_pic][i],pi2_mv, |
262 | 116k | ps_dec->au2_f_code[e_ref_pic],ps_dec->u2_frm_pic, 1); |
263 | | |
264 | | /********************************************************************/ |
265 | | /* Set the motion vector params */ |
266 | | /********************************************************************/ |
267 | 116k | ps_mc = &ps_dec->as_mb_mc_params[FORW][i]; |
268 | 116k | ps_mc->s_ref = ps_dec->as_ref_buf[e_ref_pic][e_fld]; |
269 | 116k | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type, i, |
270 | 116k | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
271 | 116k | } |
272 | 58.1k | } |
273 | | |
274 | | /***************************************************************************** |
275 | | * Function Name : impeg2d_dec_frm_dual_prime |
276 | | * |
277 | | * Description : Decodes first part of params for 2 MV Interpolated MB |
278 | | * |
279 | | * Arguments : |
280 | | * dec : Decoder state |
281 | | * |
282 | | * Values Returned : None |
283 | | *****************************************************************************/ |
284 | | void impeg2d_dec_frm_dual_prime(dec_state_t *ps_dec) |
285 | 27.0k | { |
286 | 27.0k | stream_t *ps_stream; |
287 | 27.0k | WORD16 *pi2_mv; |
288 | 27.0k | mb_mc_params_t *ps_mc; |
289 | | |
290 | 27.0k | WORD16 ai2_dmv[2]; |
291 | 27.0k | WORD16 *pi2_mv1, *pi2_mv2, *pi2_mv3, *pi2_mv4; |
292 | 27.0k | UWORD16 i,j; |
293 | | |
294 | 27.0k | pi2_mv1 = (WORD16 *)&(ps_dec->ai2_mv[FORW][FIRST]); |
295 | 27.0k | pi2_mv2 = (WORD16 *)&(ps_dec->ai2_mv[FORW][SECOND]); |
296 | 27.0k | pi2_mv3 = (WORD16 *)&(ps_dec->ai2_mv[BACK][FIRST]); |
297 | 27.0k | pi2_mv4 = (WORD16 *)&(ps_dec->ai2_mv[BACK][SECOND]); |
298 | | |
299 | | |
300 | | |
301 | 27.0k | ps_stream = &ps_dec->s_bit_stream; |
302 | | |
303 | | /************************************************************************/ |
304 | | /* Decode the motion vector MV_X, MV_Y and dmv[0], dmv[1] */ |
305 | | /************************************************************************/ |
306 | 27.0k | impeg2d_dec_1mv(ps_stream,ps_dec->ai2_pred_mv[FORW][FIRST],pi2_mv1,ps_dec->au2_f_code[FORW],ps_dec->u2_frm_pic,ai2_dmv); |
307 | | |
308 | 27.0k | { |
309 | 27.0k | WORD16 ai2_m[2][2]; |
310 | | |
311 | 27.0k | if(ps_dec->u2_top_field_first) |
312 | 22.1k | { |
313 | 22.1k | ai2_m[1][0] = 1; |
314 | 22.1k | ai2_m[0][1] = 3; |
315 | 22.1k | } |
316 | 4.89k | else |
317 | 4.89k | { |
318 | 4.89k | ai2_m[1][0] = 3; |
319 | 4.89k | ai2_m[0][1] = 1; |
320 | 4.89k | } |
321 | | |
322 | 27.0k | pi2_mv2[MV_X] = pi2_mv1[MV_X]; |
323 | 27.0k | pi2_mv2[MV_Y] = pi2_mv1[MV_Y]; |
324 | | |
325 | 27.0k | pi2_mv3[MV_X] = ai2_dmv[0] + DIV_2_RND(pi2_mv1[MV_X] * ai2_m[1][0]); |
326 | 27.0k | pi2_mv4[MV_X] = ai2_dmv[0] + DIV_2_RND(pi2_mv1[MV_X] * ai2_m[0][1]); |
327 | | |
328 | 27.0k | pi2_mv3[MV_Y] = ai2_dmv[1] + DIV_2_RND(pi2_mv1[MV_Y] * ai2_m[1][0]) - 1; |
329 | 27.0k | pi2_mv4[MV_Y] = ai2_dmv[1] + DIV_2_RND(pi2_mv1[MV_Y] * ai2_m[0][1]) + 1; |
330 | 27.0k | } |
331 | | |
332 | 27.0k | ps_dec->ai2_pred_mv[FORW][SECOND][MV_X] = ps_dec->ai2_pred_mv[FORW][FIRST][MV_X]; |
333 | 27.0k | ps_dec->ai2_pred_mv[FORW][SECOND][MV_Y] = ps_dec->ai2_pred_mv[FORW][FIRST][MV_Y]; |
334 | | |
335 | | /************************************************************************/ |
336 | | /* Set the motion vector params */ |
337 | | /************************************************************************/ |
338 | 81.2k | for(j = 0; j < 2; j++) |
339 | 54.2k | { |
340 | 162k | for(i = 0; i < 2; i++) |
341 | 108k | { |
342 | 108k | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[j][i]; |
343 | 108k | ps_mc = &ps_dec->as_mb_mc_params[j][i]; |
344 | 108k | ps_mc->s_ref = ps_dec->as_ref_buf[FORW][(i ^ j) & 1]; |
345 | 108k | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type, i, |
346 | 108k | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
347 | 108k | } |
348 | 54.2k | } |
349 | | |
350 | 27.0k | } |
351 | | /***************************************************************************** |
352 | | * Function Name : impeg2d_dec_fld_dual_prime |
353 | | * |
354 | | * Description : Decodes first part of params for 2 MV Interpolated MB |
355 | | * |
356 | | * Arguments : |
357 | | * dec : Decoder state |
358 | | * |
359 | | * Values Returned : None |
360 | | *****************************************************************************/ |
361 | | void impeg2d_dec_fld_dual_prime(dec_state_t *ps_dec) |
362 | 2.64k | { |
363 | 2.64k | stream_t *ps_stream; |
364 | 2.64k | WORD16 *pi2_mv; |
365 | 2.64k | mb_mc_params_t *ps_mc; |
366 | | |
367 | 2.64k | WORD16 *pi2_mv1, *pi2_mv2; |
368 | 2.64k | WORD16 ai2_dmv[2]; |
369 | | |
370 | | |
371 | 2.64k | pi2_mv1 = (WORD16 *)&(ps_dec->ai2_mv[FORW][FIRST]); |
372 | 2.64k | pi2_mv2 = (WORD16 *)&(ps_dec->ai2_mv[FORW][SECOND]); |
373 | 2.64k | ps_stream = &ps_dec->s_bit_stream; |
374 | | |
375 | | /************************************************************************/ |
376 | | /* Decode the motion vector MV_X, MV_Y and dmv[0], dmv[1] */ |
377 | | /************************************************************************/ |
378 | 2.64k | impeg2d_dec_1mv(ps_stream,ps_dec->ai2_pred_mv[FORW][FIRST],pi2_mv1,ps_dec->au2_f_code[FORW],0,ai2_dmv); |
379 | | |
380 | | |
381 | 2.64k | pi2_mv2[MV_X] = ai2_dmv[0] + DIV_2_RND(pi2_mv1[MV_X]); |
382 | 2.64k | pi2_mv2[MV_Y] = ai2_dmv[1] + DIV_2_RND(pi2_mv1[MV_Y]); |
383 | | |
384 | 2.64k | if(ps_dec->u2_picture_structure == TOP_FIELD) |
385 | 2.11k | pi2_mv2[MV_Y] -= 1; |
386 | 535 | else |
387 | 535 | pi2_mv2[MV_Y] += 1; |
388 | | |
389 | 2.64k | ps_dec->ai2_pred_mv[FORW][SECOND][MV_X] = ps_dec->ai2_pred_mv[FORW][FIRST][MV_X]; |
390 | 2.64k | ps_dec->ai2_pred_mv[FORW][SECOND][MV_Y] = ps_dec->ai2_pred_mv[FORW][FIRST][MV_Y]; |
391 | | |
392 | | /************************************************************************/ |
393 | | /* Set the motion vector params */ |
394 | | /************************************************************************/ |
395 | 2.64k | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[FORW][0]; |
396 | 2.64k | ps_mc = &ps_dec->as_mb_mc_params[FORW][0]; |
397 | 2.64k | ps_mc->s_ref = ps_dec->as_ref_buf[FORW][ps_dec->u2_fld_parity]; |
398 | 2.64k | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type, 0, |
399 | 2.64k | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
400 | | |
401 | 2.64k | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[FORW][1]; |
402 | 2.64k | ps_mc = &ps_dec->as_mb_mc_params[FORW][1]; |
403 | 2.64k | ps_mc->s_ref = ps_dec->as_ref_buf[FORW][!ps_dec->u2_fld_parity]; |
404 | 2.64k | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type, 0, |
405 | 2.64k | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
406 | | |
407 | | |
408 | 2.64k | } |
409 | | /***************************************************************************** |
410 | | * Function Name : impeg2d_dec_4mv_mb |
411 | | * |
412 | | * Description : Decodes first part of params for 2 MV Interpolated MB |
413 | | * |
414 | | * Arguments : |
415 | | * dec : Decoder state |
416 | | * |
417 | | * Values Returned : None |
418 | | *****************************************************************************/ |
419 | | void impeg2d_dec_4mv_mb(dec_state_t *ps_dec) |
420 | 28.9k | { |
421 | 28.9k | stream_t *ps_stream; |
422 | 28.9k | WORD16 *pi2_mv; |
423 | 28.9k | e_field_t e_fld; |
424 | 28.9k | mb_mc_params_t *ps_mc; |
425 | | |
426 | 28.9k | UWORD16 i,j; |
427 | | |
428 | 28.9k | ps_stream = &ps_dec->s_bit_stream; |
429 | | |
430 | | /***********************************************/ |
431 | | /* loop for FW & BK */ |
432 | | /***********************************************/ |
433 | 86.9k | for(j = 0; j < 2; j++) |
434 | 57.9k | { |
435 | | /***********************************************/ |
436 | | /* loop for decoding 2 mvs of same reference frame*/ |
437 | | /***********************************************/ |
438 | 173k | for(i = 0; i < 2; i++) |
439 | 115k | { |
440 | | /****************************************************************/ |
441 | | /* Decode the first motion vector */ |
442 | | /****************************************************************/ |
443 | 115k | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[j][i]; |
444 | 115k | e_fld = impeg2d_dec_mv(ps_stream,ps_dec->ai2_pred_mv[j][i],pi2_mv, |
445 | 115k | ps_dec->au2_f_code[j],ps_dec->u2_frm_pic, 1); |
446 | | |
447 | | /****************************************************************/ |
448 | | /* Set the motion vector params */ |
449 | | /****************************************************************/ |
450 | 115k | ps_mc = &ps_dec->as_mb_mc_params[j][i]; |
451 | 115k | ps_mc->s_ref = ps_dec->as_ref_buf[j][e_fld]; |
452 | 115k | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type, i, |
453 | 115k | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
454 | 115k | } |
455 | 57.9k | } |
456 | | |
457 | 28.9k | } |
458 | | /******************************************************************************* |
459 | | * Function Name : impeg2d_dec_2mv_interp_mb |
460 | | * |
461 | | * Description : Decodes first part of params for 2 MV Interpolated MB |
462 | | * |
463 | | * Arguments : |
464 | | * dec : Decoder state |
465 | | * |
466 | | * Values Returned : None |
467 | | *******************************************************************************/ |
468 | | void impeg2d_dec_2mv_interp_mb(dec_state_t *ps_dec) |
469 | 62.6k | { |
470 | 62.6k | stream_t *ps_stream; |
471 | 62.6k | WORD16 *pi2_mv; |
472 | 62.6k | e_field_t e_fld; |
473 | 62.6k | mb_mc_params_t *ps_mc; |
474 | 62.6k | UWORD16 i; |
475 | | |
476 | 62.6k | ps_stream = &ps_dec->s_bit_stream; |
477 | | |
478 | 187k | for(i = 0; i < 2; i++) |
479 | 125k | { |
480 | | /********************************************************************/ |
481 | | /* Decode the first motion vector */ |
482 | | /********************************************************************/ |
483 | 125k | pi2_mv = (WORD16 *)&ps_dec->ai2_mv[i][FIRST]; |
484 | 125k | e_fld = impeg2d_dec_mv(ps_stream,ps_dec->ai2_pred_mv[i][FIRST],pi2_mv, |
485 | 125k | ps_dec->au2_f_code[i],0, ps_dec->u2_fld_pic); |
486 | | |
487 | 125k | ps_dec->ai2_pred_mv[i][SECOND][MV_X] = ps_dec->ai2_pred_mv[i][FIRST][MV_X]; |
488 | 125k | ps_dec->ai2_pred_mv[i][SECOND][MV_Y] = ps_dec->ai2_pred_mv[i][FIRST][MV_Y]; |
489 | | /********************************************************************/ |
490 | | /* Set the motion vector params */ |
491 | | /********************************************************************/ |
492 | 125k | ps_mc = &ps_dec->as_mb_mc_params[i][FIRST]; |
493 | 125k | ps_mc->s_ref = ps_dec->as_ref_buf[i][e_fld]; |
494 | 125k | impeg2d_set_mc_params(&ps_mc->s_luma, &ps_mc->s_chroma, ps_dec->s_mb_type,i, |
495 | 125k | pi2_mv, ps_dec->u2_mb_x, ps_dec->u2_mb_y, ps_dec->u2_frame_width, ps_dec->u2_frame_height,ps_dec->u2_picture_width); |
496 | 125k | } |
497 | | |
498 | 62.6k | } |