12 |
* editors and their companies, will have no liability for use of this |
* editors and their companies, will have no liability for use of this |
13 |
* software or modifications or derivatives thereof. |
* software or modifications or derivatives thereof. |
14 |
* |
* |
15 |
* This program is free software; you can redistribute it and/or modify |
* This program is xvid_free software; you can redistribute it and/or modify |
16 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
17 |
* the Free Software Foundation; either version 2 of the License, or |
* the xvid_free Software Foundation; either version 2 of the License, or |
18 |
* (at your option) any later version. |
* (at your option) any later version. |
19 |
* |
* |
20 |
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
23 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
24 |
* |
* |
25 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the xvid_free Software |
27 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
28 |
* |
* |
29 |
*************************************************************************/ |
*************************************************************************/ |
32 |
* |
* |
33 |
* History: |
* History: |
34 |
* |
* |
35 |
|
* 26.03.2002 interlacing support - moved transfers outside decode loop |
36 |
* 26.12.2001 decoder_mbinter: dequant/idct moved within if(coded) block |
* 26.12.2001 decoder_mbinter: dequant/idct moved within if(coded) block |
37 |
* 22.12.2001 block based interpolation |
* 22.12.2001 block based interpolation |
38 |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
55 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
56 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
57 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
58 |
|
#include "utils/mbfunctions.h" |
59 |
|
|
60 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
61 |
#include "prediction/mbprediction.h" |
#include "prediction/mbprediction.h" |
64 |
|
|
65 |
#include "image/image.h" |
#include "image/image.h" |
66 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
67 |
|
#include "utils/mem_align.h" |
68 |
|
|
69 |
int decoder_create(XVID_DEC_PARAM * param) |
int decoder_create(XVID_DEC_PARAM * param) |
70 |
{ |
{ |
71 |
DECODER * dec; |
DECODER * dec; |
72 |
|
|
73 |
dec = malloc(sizeof(DECODER)); |
dec = xvid_malloc(sizeof(DECODER), CACHE_LINE); |
74 |
if (dec == NULL) |
if (dec == NULL) |
75 |
{ |
{ |
76 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
88 |
|
|
89 |
if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) |
if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) |
90 |
{ |
{ |
91 |
free(dec); |
xvid_free(dec); |
92 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
93 |
} |
} |
94 |
|
|
95 |
if (image_create(&dec->refn, dec->edged_width, dec->edged_height)) |
if (image_create(&dec->refn, dec->edged_width, dec->edged_height)) |
96 |
{ |
{ |
97 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
98 |
free(dec); |
xvid_free(dec); |
99 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
100 |
} |
} |
101 |
|
|
102 |
dec->mbs = malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
dec->mbs = xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, CACHE_LINE); |
103 |
if (dec->mbs == NULL) |
if (dec->mbs == NULL) |
104 |
{ |
{ |
105 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
106 |
free(dec); |
xvid_free(dec); |
107 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
108 |
} |
} |
109 |
|
|
116 |
|
|
117 |
int decoder_destroy(DECODER * dec) |
int decoder_destroy(DECODER * dec) |
118 |
{ |
{ |
119 |
free(dec->mbs); |
xvid_free(dec->mbs); |
120 |
image_destroy(&dec->refn, dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn, dec->edged_width, dec->edged_height); |
121 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
122 |
free(dec); |
xvid_free(dec); |
123 |
|
|
124 |
destroy_vlc_tables(); |
destroy_vlc_tables(); |
125 |
|
|
137 |
|
|
138 |
// decode an intra macroblock |
// decode an intra macroblock |
139 |
|
|
140 |
void decoder_mbintra(DECODER * dec, MACROBLOCK * mb, int x, int y, uint32_t acpred_flag, uint32_t cbp, Bitstream * bs, int quant, int intra_dc_threshold) |
void decoder_mbintra(DECODER * dec, |
141 |
{ |
MACROBLOCK * pMB, |
142 |
uint32_t k; |
const uint32_t x_pos, |
143 |
|
const uint32_t y_pos, |
144 |
|
const uint32_t acpred_flag, |
145 |
|
const uint32_t cbp, |
146 |
|
Bitstream * bs, |
147 |
|
const uint32_t quant, |
148 |
|
const uint32_t intra_dc_threshold) |
149 |
|
{ |
150 |
|
#ifdef LINUX |
151 |
|
DECLARE_ALIGNED_MATRIX(block,6,64,int16_t,16); |
152 |
|
DECLARE_ALIGNED_MATRIX(data,6,64,int16_t,16); |
153 |
|
#else |
154 |
|
CACHE_ALIGN int16_t block[6][64]; |
155 |
|
CACHE_ALIGN int16_t data[6][64]; |
156 |
|
#endif |
157 |
|
const uint32_t stride = dec->edged_width; |
158 |
|
uint32_t i; |
159 |
|
uint32_t iQuant = pMB->quant; |
160 |
|
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
161 |
|
|
162 |
|
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
163 |
|
pU_Cur = dec->cur.u + (y_pos << 3) * (stride >> 1) + (x_pos << 3); |
164 |
|
pV_Cur = dec->cur.v + (y_pos << 3) * (stride >> 1) + (x_pos << 3); |
165 |
|
|
166 |
|
#ifdef LINUX |
167 |
|
memset(block,0,sizeof(int16_t)*6*64); |
168 |
|
#else |
169 |
|
memset(block, 0, sizeof(block)); // clear |
170 |
|
#endif |
171 |
|
|
172 |
for (k = 0; k < 6; k++) |
for (i = 0; i < 6; i++) |
173 |
{ |
{ |
174 |
uint32_t dcscalar; |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
|
int16_t block[64]; |
|
|
int16_t data[64]; |
|
175 |
int16_t predictors[8]; |
int16_t predictors[8]; |
176 |
int start_coeff; |
int start_coeff; |
177 |
|
|
|
dcscalar = get_dc_scaler(mb->quant, k < 4); |
|
|
|
|
178 |
start_timer(); |
start_timer(); |
179 |
predict_acdc(dec->mbs, x, y, dec->mb_width, k, block, mb->quant, dcscalar, predictors); |
predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i, block[i], iQuant, iDcScaler, predictors); |
180 |
if (!acpred_flag) |
if (!acpred_flag) |
181 |
{ |
{ |
182 |
mb->acpred_directions[k] = 0; |
pMB->acpred_directions[i] = 0; |
183 |
} |
} |
184 |
stop_prediction_timer(); |
stop_prediction_timer(); |
185 |
|
|
|
memset(block, 0, 64*sizeof(int16_t)); // clear |
|
|
|
|
186 |
if (quant < intra_dc_threshold) |
if (quant < intra_dc_threshold) |
187 |
{ |
{ |
188 |
int dc_size; |
int dc_size; |
189 |
int dc_dif; |
int dc_dif; |
190 |
|
|
191 |
dc_size = k < 4 ? get_dc_size_lum(bs) : get_dc_size_chrom(bs); |
dc_size = i < 4 ? get_dc_size_lum(bs) : get_dc_size_chrom(bs); |
192 |
dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0 ; |
dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0 ; |
193 |
|
|
194 |
if (dc_size > 8) |
if (dc_size > 8) |
196 |
BitstreamSkip(bs, 1); // marker |
BitstreamSkip(bs, 1); // marker |
197 |
} |
} |
198 |
|
|
199 |
block[0] = dc_dif; |
block[i][0] = dc_dif; |
200 |
start_coeff = 1; |
start_coeff = 1; |
201 |
} |
} |
202 |
else |
else |
205 |
} |
} |
206 |
|
|
207 |
start_timer(); |
start_timer(); |
208 |
if (cbp & (1 << (5-k))) // coded |
if (cbp & (1 << (5-i))) // coded |
209 |
{ |
{ |
210 |
get_intra_block(bs, block, mb->acpred_directions[k], start_coeff); |
get_intra_block(bs, block[i], pMB->acpred_directions[i], start_coeff); |
211 |
} |
} |
212 |
stop_coding_timer(); |
stop_coding_timer(); |
213 |
|
|
214 |
start_timer(); |
start_timer(); |
215 |
add_acdc(mb, k, block, dcscalar, predictors); |
add_acdc(pMB, i, block[i], iDcScaler, predictors); |
216 |
stop_prediction_timer(); |
stop_prediction_timer(); |
217 |
|
|
218 |
start_timer(); |
start_timer(); |
219 |
if (dec->quant_type == 0) |
if (dec->quant_type == 0) |
220 |
{ |
{ |
221 |
dequant_intra(data, block, mb->quant, dcscalar); |
dequant_intra(data[i], block[i], iQuant, iDcScaler); |
222 |
} |
} |
223 |
else |
else |
224 |
{ |
{ |
225 |
dequant4_intra(data, block, mb->quant, dcscalar); |
dequant4_intra(data[i], block[i], iQuant, iDcScaler); |
226 |
} |
} |
227 |
stop_iquant_timer(); |
stop_iquant_timer(); |
228 |
|
|
229 |
start_timer(); |
start_timer(); |
230 |
idct(data); |
idct(data[i]); |
231 |
stop_idct_timer(); |
stop_idct_timer(); |
232 |
|
} |
233 |
|
|
234 |
start_timer(); |
start_timer(); |
235 |
if (k < 4) |
if (dec->interlacing && pMB->field_dct) |
|
{ |
|
|
transfer_16to8copy(dec->cur.y + (16*y*dec->edged_width) + 16*x + (4*(k&2)*dec->edged_width) + 8*(k&1), data, dec->edged_width); |
|
|
} |
|
|
else if (k == 4) |
|
|
{ |
|
|
transfer_16to8copy(dec->cur.u+ 8*y*(dec->edged_width/2) + 8*x, data, (dec->edged_width/2)); |
|
|
} |
|
|
else // if (k == 5) |
|
236 |
{ |
{ |
237 |
transfer_16to8copy(dec->cur.v + 8*y*(dec->edged_width/2) + 8*x, data, (dec->edged_width/2)); |
MBFieldToFrame(data); |
238 |
} |
} |
239 |
|
stop_interlacing_timer(); |
240 |
|
|
241 |
|
start_timer(); |
242 |
|
transfer_16to8copy(pY_Cur, data[0], stride); |
243 |
|
transfer_16to8copy(pY_Cur + 8, data[1], stride); |
244 |
|
transfer_16to8copy(pY_Cur + 8 * stride, data[2], stride); |
245 |
|
transfer_16to8copy(pY_Cur + 8 + 8 * stride, data[3], stride); |
246 |
|
transfer_16to8copy(pU_Cur, data[4], stride / 2); |
247 |
|
transfer_16to8copy(pV_Cur, data[5], stride / 2); |
248 |
stop_transfer_timer(); |
stop_transfer_timer(); |
249 |
} |
} |
|
} |
|
250 |
|
|
251 |
|
|
252 |
|
|
260 |
|
|
261 |
// decode an inter macroblock |
// decode an inter macroblock |
262 |
|
|
263 |
void decoder_mbinter(DECODER * dec, MACROBLOCK * mb, int x, int y, uint32_t acpred_flag, uint32_t cbp, Bitstream * bs, int quant, int rounding) |
void decoder_mbinter(DECODER * dec, |
264 |
{ |
const MACROBLOCK * pMB, |
265 |
|
const uint32_t x_pos, |
266 |
|
const uint32_t y_pos, |
267 |
|
const uint32_t acpred_flag, |
268 |
|
const uint32_t cbp, |
269 |
|
Bitstream * bs, |
270 |
|
const uint32_t quant, |
271 |
|
const uint32_t rounding) |
272 |
|
{ |
273 |
|
#ifdef LINUX |
274 |
|
DECLARE_ALIGNED_MATRIX(block,6,64,int16_t,16); |
275 |
|
DECLARE_ALIGNED_MATRIX(data,6,64,int16_t,16); |
276 |
|
#else |
277 |
|
CACHE_ALIGN int16_t block[6][64]; |
278 |
|
CACHE_ALIGN int16_t data[6][64]; |
279 |
|
#endif |
280 |
|
|
281 |
const uint32_t stride = dec->edged_width; |
const uint32_t stride = dec->edged_width; |
282 |
const uint32_t stride2 = dec->edged_width / 2; |
const uint32_t stride2 = dec->edged_width / 2; |
283 |
|
uint32_t i; |
284 |
|
uint32_t iQuant = pMB->quant; |
285 |
|
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
286 |
int uv_dx, uv_dy; |
int uv_dx, uv_dy; |
|
uint32_t k; |
|
287 |
|
|
288 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
289 |
|
pU_Cur = dec->cur.u + (y_pos << 3) * (stride >> 1) + (x_pos << 3); |
290 |
|
pV_Cur = dec->cur.v + (y_pos << 3) * (stride >> 1) + (x_pos << 3); |
291 |
|
|
292 |
|
if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) |
293 |
{ |
{ |
294 |
uv_dx = mb->mvs[0].x; |
uv_dx = pMB->mvs[0].x; |
295 |
uv_dy = mb->mvs[0].y; |
uv_dy = pMB->mvs[0].y; |
296 |
|
|
297 |
uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
298 |
uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
300 |
else |
else |
301 |
{ |
{ |
302 |
int sum; |
int sum; |
303 |
sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x; |
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
304 |
uv_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) ); |
uv_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) ); |
305 |
|
|
306 |
sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y; |
sum = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; |
307 |
uv_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) ); |
uv_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) ); |
308 |
} |
} |
309 |
|
|
310 |
start_timer(); |
start_timer(); |
311 |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x, 16*y , mb->mvs[0].x, mb->mvs[0].y, stride, rounding); |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x_pos, 16*y_pos , pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
312 |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x + 8, 16*y , mb->mvs[1].x, mb->mvs[1].y, stride, rounding); |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x_pos + 8, 16*y_pos , pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
313 |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x, 16*y + 8, mb->mvs[2].x, mb->mvs[2].y, stride, rounding); |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x_pos, 16*y_pos + 8, pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
314 |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x + 8, 16*y + 8, mb->mvs[3].x, mb->mvs[3].y, stride, rounding); |
interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x_pos + 8, 16*y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
315 |
interpolate8x8_switch(dec->cur.u, dec->refn.u, 8*x, 8*y, uv_dx, uv_dy, stride2, rounding); |
interpolate8x8_switch(dec->cur.u, dec->refn.u, 8*x_pos, 8*y_pos, uv_dx, uv_dy, stride2, rounding); |
316 |
interpolate8x8_switch(dec->cur.v, dec->refn.v, 8*x, 8*y, uv_dx, uv_dy, stride2, rounding); |
interpolate8x8_switch(dec->cur.v, dec->refn.v, 8*x_pos, 8*y_pos, uv_dx, uv_dy, stride2, rounding); |
317 |
stop_comp_timer(); |
stop_comp_timer(); |
318 |
|
|
319 |
|
for (i = 0; i < 6; i++) |
|
for (k = 0; k < 6; k++) |
|
320 |
{ |
{ |
321 |
int16_t block[64]; |
if (cbp & (1 << (5-i))) // coded |
|
int16_t data[64]; |
|
|
|
|
|
if (cbp & (1 << (5-k))) // coded |
|
322 |
{ |
{ |
323 |
memset(block, 0, 64 * sizeof(int16_t)); // clear |
memset(block[i], 0, 64 * sizeof(int16_t)); // clear |
324 |
|
|
325 |
start_timer(); |
start_timer(); |
326 |
get_inter_block(bs, block); |
get_inter_block(bs, block[i]); |
327 |
stop_coding_timer(); |
stop_coding_timer(); |
328 |
|
|
329 |
start_timer(); |
start_timer(); |
330 |
if (dec->quant_type == 0) |
if (dec->quant_type == 0) |
331 |
{ |
{ |
332 |
dequant_inter(data, block, mb->quant); |
dequant_inter(data[i], block[i], iQuant); |
333 |
} |
} |
334 |
else |
else |
335 |
{ |
{ |
336 |
dequant4_inter(data, block, mb->quant); |
dequant4_inter(data[i], block[i], iQuant); |
337 |
} |
} |
338 |
stop_iquant_timer(); |
stop_iquant_timer(); |
339 |
|
|
340 |
start_timer(); |
start_timer(); |
341 |
idct(data); |
idct(data[i]); |
342 |
stop_idct_timer(); |
stop_idct_timer(); |
|
|
|
|
start_timer(); |
|
|
if (k < 4) |
|
|
{ |
|
|
transfer_16to8add(dec->cur.y + (16*y + 4*(k&2))*stride + 16*x + 8*(k&1), data, stride); |
|
343 |
} |
} |
|
else if (k == 4) |
|
|
{ |
|
|
transfer_16to8add(dec->cur.u + 8*y*stride2 + 8*x, data, stride2); |
|
344 |
} |
} |
345 |
else // k == 5 |
|
346 |
|
start_timer(); |
347 |
|
if (pMB->field_dct) |
348 |
{ |
{ |
349 |
transfer_16to8add(dec->cur.v + 8*y*stride2 + 8*x, data, stride2); |
MBFieldToFrame(data); |
350 |
} |
} |
351 |
|
stop_interlacing_timer(); |
352 |
|
|
353 |
|
start_timer(); |
354 |
|
if (cbp & 32) |
355 |
|
transfer_16to8add(pY_Cur, data[0], stride); |
356 |
|
if (cbp & 16) |
357 |
|
transfer_16to8add(pY_Cur + 8, data[1], stride); |
358 |
|
if (cbp & 8) |
359 |
|
transfer_16to8add(pY_Cur + 8 * stride, data[2], stride); |
360 |
|
if (cbp & 4) |
361 |
|
transfer_16to8add(pY_Cur + 8 + 8 * stride, data[3], stride); |
362 |
|
if (cbp & 2) |
363 |
|
transfer_16to8add(pU_Cur, data[4], stride / 2); |
364 |
|
if (cbp & 1) |
365 |
|
transfer_16to8add(pV_Cur, data[5], stride / 2); |
366 |
stop_transfer_timer(); |
stop_transfer_timer(); |
367 |
} |
} |
|
} |
|
|
} |
|
|
|
|
368 |
|
|
369 |
|
|
370 |
void decoder_iframe(DECODER * dec, Bitstream * bs, int quant, int intra_dc_threshold) |
void decoder_iframe(DECODER * dec, Bitstream * bs, int quant, int intra_dc_threshold) |
412 |
} |
} |
413 |
mb->quant = quant; |
mb->quant = quant; |
414 |
|
|
415 |
|
if (dec->interlacing) |
416 |
|
{ |
417 |
|
mb->field_dct = BitstreamGetBit(bs); |
418 |
|
DEBUG1("deci: field_dct: ", mb->field_dct); |
419 |
|
} |
420 |
|
|
421 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, intra_dc_threshold); |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, intra_dc_threshold); |
422 |
} |
} |
480 |
image_swap(&dec->cur, &dec->refn); |
image_swap(&dec->cur, &dec->refn); |
481 |
|
|
482 |
start_timer(); |
start_timer(); |
483 |
image_setedges(&dec->refn, dec->edged_width, dec->edged_height, dec->width, dec->height); |
image_setedges(&dec->refn, dec->edged_width, dec->edged_height, dec->width, dec->height, dec->interlacing); |
484 |
stop_edges_timer(); |
stop_edges_timer(); |
485 |
|
|
486 |
for (y = 0; y < dec->mb_height; y++) |
for (y = 0; y < dec->mb_height; y++) |
533 |
} |
} |
534 |
mb->quant = quant; |
mb->quant = quant; |
535 |
|
|
536 |
|
if (dec->interlacing) |
537 |
|
{ |
538 |
|
mb->field_dct = BitstreamGetBit(bs); |
539 |
|
DEBUG1("decp: field_dct: ", mb->field_dct); |
540 |
|
|
541 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) |
542 |
{ |
{ |
543 |
|
mb->field_pred = BitstreamGetBit(bs); |
544 |
|
DEBUG1("decp: field_pred: ", mb->field_pred); |
545 |
|
|
546 |
|
if (mb->field_pred) |
547 |
|
{ |
548 |
|
mb->field_for_top = BitstreamGetBit(bs); |
549 |
|
DEBUG1("decp: field_for_top: ", mb->field_for_top); |
550 |
|
mb->field_for_bot = BitstreamGetBit(bs); |
551 |
|
DEBUG1("decp: field_for_bot: ", mb->field_for_bot); |
552 |
|
} |
553 |
|
} |
554 |
|
} |
555 |
|
|
556 |
|
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) |
557 |
|
{ |
558 |
|
if (dec->interlacing && mb->field_pred) |
559 |
|
{ |
560 |
|
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); |
561 |
|
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1], fcode); |
562 |
|
} |
563 |
|
else |
564 |
|
{ |
565 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); |
566 |
mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x; |
mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x; |
567 |
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y; |
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y; |
568 |
} |
} |
569 |
|
} |
570 |
else if (mb->mode == MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */) |
else if (mb->mode == MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */) |
571 |
{ |
{ |
572 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); |