Parent Directory
|
Revision Log
Revision 12 - (view) (download)
1 : | Isibaar | 3 | /************************************************************************** |
2 : | * | ||
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * decoder main | ||
5 : | * | ||
6 : | * This program is an implementation of a part of one or more MPEG-4 | ||
7 : | * Video tools as specified in ISO/IEC 14496-2 standard. Those intending | ||
8 : | * to use this software module in hardware or software products are | ||
9 : | * advised that its use may infringe existing patents or copyrights, and | ||
10 : | * any such use would be at such party's own risk. The original | ||
11 : | * developer of this software module and his/her company, and subsequent | ||
12 : | * editors and their companies, will have no liability for use of this | ||
13 : | * software or modifications or derivatives thereof. | ||
14 : | * | ||
15 : | * This program is free software; you can redistribute it and/or modify | ||
16 : | * 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 | ||
18 : | * (at your option) any later version. | ||
19 : | * | ||
20 : | * This program is distributed in the hope that it will be useful, | ||
21 : | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 : | * GNU General Public License for more details. | ||
24 : | * | ||
25 : | * You should have received a copy of the GNU General Public License | ||
26 : | * along with this program; if not, write to the Free Software | ||
27 : | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 : | * | ||
29 : | *************************************************************************/ | ||
30 : | |||
31 : | /************************************************************************** | ||
32 : | * | ||
33 : | * History: | ||
34 : | * | ||
35 : | * 26.12.2001 decoder_mbinter: dequant/idct moved within if(coded) block | ||
36 : | * 22.12.2001 block based interpolation | ||
37 : | * 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> | ||
38 : | * | ||
39 : | *************************************************************************/ | ||
40 : | |||
41 : | #include <stdlib.h> | ||
42 : | #include <string.h> // memset | ||
43 : | |||
44 : | #include "xvid.h" | ||
45 : | #include "portab.h" | ||
46 : | |||
47 : | #include "decoder.h" | ||
48 : | #include "bitstream/bitstream.h" | ||
49 : | #include "bitstream/mbcoding.h" | ||
50 : | |||
51 : | #include "quant/quant_h263.h" | ||
52 : | #include "quant/quant_mpeg4.h" | ||
53 : | #include "dct/idct.h" | ||
54 : | #include "dct/fdct.h" | ||
55 : | #include "utils/mem_transfer.h" | ||
56 : | #include "image/interpolate8x8.h" | ||
57 : | |||
58 : | #include "bitstream/mbcoding.h" | ||
59 : | #include "prediction/mbprediction.h" | ||
60 : | #include "utils/timer.h" | ||
61 : | #include "utils/emms.h" | ||
62 : | |||
63 : | #include "image/image.h" | ||
64 : | #include "image/colorspace.h" | ||
65 : | |||
66 : | int decoder_create(XVID_DEC_PARAM * param) | ||
67 : | { | ||
68 : | DECODER * dec; | ||
69 : | |||
70 : | dec = malloc(sizeof(DECODER)); | ||
71 : | if (dec == NULL) | ||
72 : | { | ||
73 : | return XVID_ERR_MEMORY; | ||
74 : | } | ||
75 : | param->handle = dec; | ||
76 : | |||
77 : | dec->width = param->width; | ||
78 : | dec->height = param->height; | ||
79 : | |||
80 : | dec->mb_width = (dec->width + 15) / 16; | ||
81 : | dec->mb_height = (dec->height + 15) / 16; | ||
82 : | |||
83 : | dec->edged_width = 16 * dec->mb_width + 2 * EDGE_SIZE; | ||
84 : | dec->edged_height = 16 * dec->mb_height + 2 * EDGE_SIZE; | ||
85 : | |||
86 : | if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) | ||
87 : | { | ||
88 : | free(dec); | ||
89 : | return XVID_ERR_MEMORY; | ||
90 : | } | ||
91 : | |||
92 : | if (image_create(&dec->refn, dec->edged_width, dec->edged_height)) | ||
93 : | { | ||
94 : | image_destroy(&dec->cur, dec->edged_width, dec->edged_height); | ||
95 : | free(dec); | ||
96 : | return XVID_ERR_MEMORY; | ||
97 : | } | ||
98 : | |||
99 : | dec->mbs = malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); | ||
100 : | if (dec->mbs == NULL) | ||
101 : | { | ||
102 : | image_destroy(&dec->cur, dec->edged_width, dec->edged_height); | ||
103 : | free(dec); | ||
104 : | return XVID_ERR_MEMORY; | ||
105 : | } | ||
106 : | |||
107 : | init_timer(); | ||
108 : | create_vlc_tables(); | ||
109 : | |||
110 : | return XVID_ERR_OK; | ||
111 : | } | ||
112 : | |||
113 : | |||
114 : | int decoder_destroy(DECODER * dec) | ||
115 : | { | ||
116 : | free(dec->mbs); | ||
117 : | image_destroy(&dec->refn, dec->edged_width, dec->edged_height); | ||
118 : | image_destroy(&dec->cur, dec->edged_width, dec->edged_height); | ||
119 : | free(dec); | ||
120 : | |||
121 : | destroy_vlc_tables(); | ||
122 : | |||
123 : | write_timer(); | ||
124 : | return XVID_ERR_OK; | ||
125 : | } | ||
126 : | |||
127 : | |||
128 : | |||
129 : | static const int32_t dquant_table[4] = | ||
130 : | { | ||
131 : | -1, -2, 1, 2 | ||
132 : | }; | ||
133 : | |||
134 : | |||
135 : | // decode an intra macroblock | ||
136 : | |||
137 : | 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) | ||
138 : | { | ||
139 : | uint32_t k; | ||
140 : | |||
141 : | for (k = 0; k < 6; k++) | ||
142 : | { | ||
143 : | uint32_t dcscalar; | ||
144 : | int16_t block[64]; | ||
145 : | int16_t data[64]; | ||
146 : | int16_t predictors[8]; | ||
147 : | int start_coeff; | ||
148 : | |||
149 : | dcscalar = get_dc_scaler(mb->quant, k < 4); | ||
150 : | |||
151 : | start_timer(); | ||
152 : | predict_acdc(dec->mbs, x, y, dec->mb_width, k, block, mb->quant, dcscalar, predictors); | ||
153 : | if (!acpred_flag) | ||
154 : | { | ||
155 : | mb->acpred_directions[k] = 0; | ||
156 : | } | ||
157 : | stop_prediction_timer(); | ||
158 : | |||
159 : | memset(block, 0, 64*sizeof(int16_t)); // clear | ||
160 : | |||
161 : | if (quant < intra_dc_threshold) | ||
162 : | { | ||
163 : | int dc_size; | ||
164 : | int dc_dif; | ||
165 : | |||
166 : | dc_size = k < 4 ? get_dc_size_lum(bs) : get_dc_size_chrom(bs); | ||
167 : | dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0 ; | ||
168 : | |||
169 : | if (dc_size > 8) | ||
170 : | { | ||
171 : | BitstreamSkip(bs, 1); // marker | ||
172 : | } | ||
173 : | |||
174 : | block[0] = dc_dif; | ||
175 : | start_coeff = 1; | ||
176 : | } | ||
177 : | else | ||
178 : | { | ||
179 : | start_coeff = 0; | ||
180 : | } | ||
181 : | |||
182 : | start_timer(); | ||
183 : | if (cbp & (1 << (5-k))) // coded | ||
184 : | { | ||
185 : | get_intra_block(bs, block, mb->acpred_directions[k], start_coeff); | ||
186 : | } | ||
187 : | stop_coding_timer(); | ||
188 : | |||
189 : | start_timer(); | ||
190 : | add_acdc(mb, k, block, dcscalar, predictors); | ||
191 : | stop_prediction_timer(); | ||
192 : | |||
193 : | start_timer(); | ||
194 : | if (dec->quant_type == 0) | ||
195 : | { | ||
196 : | dequant_intra(data, block, mb->quant, dcscalar); | ||
197 : | } | ||
198 : | else | ||
199 : | { | ||
200 : | dequant4_intra(data, block, mb->quant, dcscalar); | ||
201 : | } | ||
202 : | stop_iquant_timer(); | ||
203 : | |||
204 : | start_timer(); | ||
205 : | idct(data); | ||
206 : | stop_idct_timer(); | ||
207 : | |||
208 : | start_timer(); | ||
209 : | if (k < 4) | ||
210 : | { | ||
211 : | 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); | ||
212 : | } | ||
213 : | else if (k == 4) | ||
214 : | { | ||
215 : | transfer_16to8copy(dec->cur.u+ 8*y*(dec->edged_width/2) + 8*x, data, (dec->edged_width/2)); | ||
216 : | } | ||
217 : | else // if (k == 5) | ||
218 : | { | ||
219 : | transfer_16to8copy(dec->cur.v + 8*y*(dec->edged_width/2) + 8*x, data, (dec->edged_width/2)); | ||
220 : | } | ||
221 : | stop_transfer_timer(); | ||
222 : | } | ||
223 : | } | ||
224 : | |||
225 : | |||
226 : | |||
227 : | |||
228 : | |||
229 : | #define SIGN(X) (((X)>0)?1:-1) | ||
230 : | #define ABS(X) (((X)>0)?(X):-(X)) | ||
231 : | static const uint32_t roundtab[16] = | ||
232 : | { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; | ||
233 : | |||
234 : | |||
235 : | // decode an inter macroblock | ||
236 : | |||
237 : | void decoder_mbinter(DECODER * dec, MACROBLOCK * mb, int x, int y, uint32_t acpred_flag, uint32_t cbp, Bitstream * bs, int quant, int rounding) | ||
238 : | { | ||
239 : | const uint32_t stride = dec->edged_width; | ||
240 : | const uint32_t stride2 = dec->edged_width / 2; | ||
241 : | int uv_dx, uv_dy; | ||
242 : | uint32_t k; | ||
243 : | |||
244 : | if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) | ||
245 : | { | ||
246 : | uv_dx = mb->mvs[0].x; | ||
247 : | uv_dy = mb->mvs[0].y; | ||
248 : | |||
249 : | uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; | ||
250 : | uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; | ||
251 : | } | ||
252 : | else | ||
253 : | { | ||
254 : | int sum; | ||
255 : | sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x; | ||
256 : | uv_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) ); | ||
257 : | |||
258 : | sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y; | ||
259 : | uv_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) ); | ||
260 : | } | ||
261 : | |||
262 : | start_timer(); | ||
263 : | interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x, 16*y , mb->mvs[0].x, mb->mvs[0].y, stride, rounding); | ||
264 : | interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x + 8, 16*y , mb->mvs[1].x, mb->mvs[1].y, stride, rounding); | ||
265 : | interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x, 16*y + 8, mb->mvs[2].x, mb->mvs[2].y, stride, rounding); | ||
266 : | interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x + 8, 16*y + 8, mb->mvs[3].x, mb->mvs[3].y, stride, rounding); | ||
267 : | interpolate8x8_switch(dec->cur.u, dec->refn.u, 8*x, 8*y, uv_dx, uv_dy, stride2, rounding); | ||
268 : | interpolate8x8_switch(dec->cur.v, dec->refn.v, 8*x, 8*y, uv_dx, uv_dy, stride2, rounding); | ||
269 : | stop_comp_timer(); | ||
270 : | |||
271 : | |||
272 : | for (k = 0; k < 6; k++) | ||
273 : | { | ||
274 : | int16_t block[64]; | ||
275 : | int16_t data[64]; | ||
276 : | |||
277 : | if (cbp & (1 << (5-k))) // coded | ||
278 : | { | ||
279 : | memset(block, 0, 64 * sizeof(int16_t)); // clear | ||
280 : | |||
281 : | start_timer(); | ||
282 : | get_inter_block(bs, block); | ||
283 : | stop_coding_timer(); | ||
284 : | |||
285 : | start_timer(); | ||
286 : | if (dec->quant_type == 0) | ||
287 : | { | ||
288 : | dequant_inter(data, block, mb->quant); | ||
289 : | } | ||
290 : | else | ||
291 : | { | ||
292 : | dequant4_inter(data, block, mb->quant); | ||
293 : | } | ||
294 : | stop_iquant_timer(); | ||
295 : | |||
296 : | start_timer(); | ||
297 : | idct(data); | ||
298 : | stop_idct_timer(); | ||
299 : | |||
300 : | start_timer(); | ||
301 : | if (k < 4) | ||
302 : | { | ||
303 : | transfer_16to8add(dec->cur.y + (16*y + 4*(k&2))*stride + 16*x + 8*(k&1), data, stride); | ||
304 : | } | ||
305 : | else if (k == 4) | ||
306 : | { | ||
307 : | transfer_16to8add(dec->cur.u + 8*y*stride2 + 8*x, data, stride2); | ||
308 : | } | ||
309 : | else // k == 5 | ||
310 : | { | ||
311 : | transfer_16to8add(dec->cur.v + 8*y*stride2 + 8*x, data, stride2); | ||
312 : | } | ||
313 : | stop_transfer_timer(); | ||
314 : | } | ||
315 : | } | ||
316 : | } | ||
317 : | |||
318 : | |||
319 : | |||
320 : | void decoder_iframe(DECODER * dec, Bitstream * bs, int quant, int intra_dc_threshold) | ||
321 : | { | ||
322 : | uint32_t x, y; | ||
323 : | |||
324 : | for (y = 0; y < dec->mb_height; y++) | ||
325 : | { | ||
326 : | for (x = 0; x < dec->mb_width; x++) | ||
327 : | { | ||
328 : | MACROBLOCK * mb = &dec->mbs[y*dec->mb_width + x]; | ||
329 : | |||
330 : | uint32_t mcbpc; | ||
331 : | uint32_t cbpc; | ||
332 : | uint32_t acpred_flag; | ||
333 : | uint32_t cbpy; | ||
334 : | uint32_t cbp; | ||
335 : | |||
336 : | mcbpc = get_mcbpc_intra(bs); | ||
337 : | mb->mode = mcbpc & 7; | ||
338 : | cbpc = (mcbpc >> 4); | ||
339 : | |||
340 : | acpred_flag = BitstreamGetBit(bs); | ||
341 : | |||
342 : | if (mb->mode == MODE_STUFFING) | ||
343 : | { | ||
344 : | DEBUG("-- STUFFING ?"); | ||
345 : | continue; | ||
346 : | } | ||
347 : | |||
348 : | cbpy = get_cbpy(bs, 1); | ||
349 : | cbp = (cbpy << 2) | cbpc; | ||
350 : | |||
351 : | if (mb->mode == MODE_INTRA_Q) | ||
352 : | { | ||
353 : | quant += dquant_table[BitstreamGetBits(bs,2)]; | ||
354 : | if (quant > 31) | ||
355 : | { | ||
356 : | quant = 31; | ||
357 : | } | ||
358 : | else if (quant < 1) | ||
359 : | { | ||
360 : | quant = 1; | ||
361 : | } | ||
362 : | } | ||
363 : | mb->quant = quant; | ||
364 : | |||
365 : | |||
366 : | decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, intra_dc_threshold); | ||
367 : | } | ||
368 : | } | ||
369 : | } | ||
370 : | |||
371 : | |||
372 : | void get_motion_vector(DECODER *dec, Bitstream *bs, int x, int y, int k, VECTOR * mv, int fcode) | ||
373 : | { | ||
374 : | int scale_fac = 1 << (fcode - 1); | ||
375 : | int high = (32 * scale_fac) - 1; | ||
376 : | int low = ((-32) * scale_fac); | ||
377 : | int range = (64 * scale_fac); | ||
378 : | |||
379 : | VECTOR pmv[4]; | ||
380 : | uint32_t psad[4]; | ||
381 : | |||
382 : | int mv_x, mv_y; | ||
383 : | int pmv_x, pmv_y; | ||
384 : | |||
385 : | |||
386 : | get_pmvdata(dec->mbs, x, y, dec->mb_width, k, pmv, psad); | ||
387 : | |||
388 : | pmv_x = pmv[0].x; | ||
389 : | pmv_y = pmv[0].y; | ||
390 : | |||
391 : | mv_x = get_mv(bs, fcode); | ||
392 : | mv_y = get_mv(bs, fcode); | ||
393 : | |||
394 : | mv_x += pmv_x; | ||
395 : | mv_y += pmv_y; | ||
396 : | |||
397 : | if (mv_x < low) | ||
398 : | { | ||
399 : | mv_x += range; | ||
400 : | } | ||
401 : | else if (mv_x > high) | ||
402 : | { | ||
403 : | mv_x -= range; | ||
404 : | } | ||
405 : | |||
406 : | if (mv_y < low) | ||
407 : | { | ||
408 : | mv_y += range; | ||
409 : | } | ||
410 : | else if (mv_y > high) | ||
411 : | { | ||
412 : | mv_y -= range; | ||
413 : | } | ||
414 : | |||
415 : | mv->x = mv_x; | ||
416 : | mv->y = mv_y; | ||
417 : | |||
418 : | } | ||
419 : | |||
420 : | |||
421 : | void decoder_pframe(DECODER * dec, Bitstream * bs, int rounding, int quant, int fcode, int intra_dc_threshold) | ||
422 : | { | ||
423 : | uint32_t x, y; | ||
424 : | |||
425 : | image_swap(&dec->cur, &dec->refn); | ||
426 : | |||
427 : | start_timer(); | ||
428 : | image_setedges(&dec->refn, dec->edged_width, dec->edged_height, dec->width, dec->height); | ||
429 : | stop_edges_timer(); | ||
430 : | |||
431 : | for (y = 0; y < dec->mb_height; y++) | ||
432 : | { | ||
433 : | for (x = 0; x < dec->mb_width; x++) | ||
434 : | { | ||
435 : | MACROBLOCK * mb = &dec->mbs[y*dec->mb_width + x]; | ||
436 : | |||
437 : | if (!BitstreamGetBit(bs)) // not_coded | ||
438 : | { | ||
439 : | uint32_t mcbpc; | ||
440 : | uint32_t cbpc; | ||
441 : | uint32_t acpred_flag; | ||
442 : | uint32_t cbpy; | ||
443 : | uint32_t cbp; | ||
444 : | uint32_t intra; | ||
445 : | |||
446 : | mcbpc = get_mcbpc_inter(bs); | ||
447 : | mb->mode = mcbpc & 7; | ||
448 : | cbpc = (mcbpc >> 4); | ||
449 : | edgomez | 12 | acpred_flag = 0; |
450 : | Isibaar | 3 | |
451 : | intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); | ||
452 : | |||
453 : | if (intra) | ||
454 : | { | ||
455 : | acpred_flag = BitstreamGetBit(bs); | ||
456 : | } | ||
457 : | |||
458 : | if (mb->mode == MODE_STUFFING) | ||
459 : | { | ||
460 : | DEBUG("-- STUFFING ?"); | ||
461 : | continue; | ||
462 : | } | ||
463 : | |||
464 : | cbpy = get_cbpy(bs, intra); | ||
465 : | cbp = (cbpy << 2) | cbpc; | ||
466 : | |||
467 : | if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) | ||
468 : | { | ||
469 : | quant += dquant_table[BitstreamGetBits(bs,2)]; | ||
470 : | if (quant > 31) | ||
471 : | { | ||
472 : | quant = 31; | ||
473 : | } | ||
474 : | else if (mb->quant < 1) | ||
475 : | { | ||
476 : | quant = 1; | ||
477 : | } | ||
478 : | } | ||
479 : | mb->quant = quant; | ||
480 : | |||
481 : | if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) | ||
482 : | { | ||
483 : | |||
484 : | get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); | ||
485 : | mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x; | ||
486 : | mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y; | ||
487 : | } | ||
488 : | else if (mb->mode == MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */) | ||
489 : | { | ||
490 : | get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode); | ||
491 : | get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode); | ||
492 : | get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode); | ||
493 : | get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode); | ||
494 : | } | ||
495 : | else // MODE_INTRA, MODE_INTRA_Q | ||
496 : | { | ||
497 : | mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0; | ||
498 : | mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0; | ||
499 : | decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, intra_dc_threshold); | ||
500 : | continue; | ||
501 : | } | ||
502 : | |||
503 : | decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant, rounding); | ||
504 : | } | ||
505 : | else // not coded | ||
506 : | { | ||
507 : | |||
508 : | mb->mode = MODE_NOT_CODED; | ||
509 : | mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0; | ||
510 : | mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0; | ||
511 : | |||
512 : | // copy macroblock directly from ref to cur | ||
513 : | |||
514 : | start_timer(); | ||
515 : | |||
516 : | transfer8x8_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x), | ||
517 : | dec->refn.y + (16*y)*dec->edged_width + (16*x), | ||
518 : | dec->edged_width); | ||
519 : | |||
520 : | transfer8x8_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x+8), | ||
521 : | dec->refn.y + (16*y)*dec->edged_width + (16*x+8), | ||
522 : | dec->edged_width); | ||
523 : | |||
524 : | transfer8x8_copy(dec->cur.y + (16*y+8)*dec->edged_width + (16*x), | ||
525 : | dec->refn.y + (16*y+8)*dec->edged_width + (16*x), | ||
526 : | dec->edged_width); | ||
527 : | |||
528 : | transfer8x8_copy(dec->cur.y + (16*y+8)*dec->edged_width + (16*x+8), | ||
529 : | dec->refn.y + (16*y+8)*dec->edged_width + (16*x+8), | ||
530 : | dec->edged_width); | ||
531 : | |||
532 : | transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x), | ||
533 : | dec->refn.u + (8*y)*dec->edged_width/2 + (8*x), | ||
534 : | dec->edged_width/2); | ||
535 : | |||
536 : | transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x), | ||
537 : | dec->refn.v + (8*y)*dec->edged_width/2 + (8*x), | ||
538 : | dec->edged_width/2); | ||
539 : | |||
540 : | stop_transfer_timer(); | ||
541 : | } | ||
542 : | } | ||
543 : | } | ||
544 : | } | ||
545 : | |||
546 : | int decoder_decode(DECODER * dec, XVID_DEC_FRAME * frame) | ||
547 : | { | ||
548 : | Bitstream bs; | ||
549 : | uint32_t rounding; | ||
550 : | uint32_t quant; | ||
551 : | uint32_t fcode; | ||
552 : | uint32_t intra_dc_threshold; | ||
553 : | |||
554 : | start_global_timer(); | ||
555 : | |||
556 : | BitstreamInit(&bs, frame->bitstream, frame->length); | ||
557 : | |||
558 : | switch (BitstreamReadHeaders(&bs, dec, &rounding, &quant, &fcode, &intra_dc_threshold)) | ||
559 : | { | ||
560 : | case P_VOP : | ||
561 : | decoder_pframe(dec, &bs, rounding, quant, fcode, intra_dc_threshold); | ||
562 : | break; | ||
563 : | |||
564 : | case I_VOP : | ||
565 : | //DEBUG1("",intra_dc_threshold); | ||
566 : | decoder_iframe(dec, &bs, quant, intra_dc_threshold); | ||
567 : | break; | ||
568 : | |||
569 : | case B_VOP : // ignore | ||
570 : | break; | ||
571 : | |||
572 : | case N_VOP : // vop not coded | ||
573 : | break; | ||
574 : | |||
575 : | default : | ||
576 : | return XVID_ERR_FAIL; | ||
577 : | } | ||
578 : | |||
579 : | frame->length = BitstreamPos(&bs) / 8; | ||
580 : | |||
581 : | start_timer(); | ||
582 : | image_output(&dec->cur, dec->width, dec->height, dec->edged_width, | ||
583 : | frame->image, frame->stride, frame->colorspace); | ||
584 : | stop_conv_timer(); | ||
585 : | |||
586 : | emms(); | ||
587 : | |||
588 : | stop_global_timer(); | ||
589 : | |||
590 : | return XVID_ERR_OK; | ||
591 : | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |