3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Decoder main module - |
* - Decoder main module - |
5 |
* |
* |
6 |
* This program is an implementation of a part of one or more MPEG-4 |
* Copyright(C) 2002 MinChen <chenm001@163.com> |
7 |
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
* 2002 Peter Ross <pross@xvid.org> |
|
* to use this software module in hardware or software products are |
|
|
* advised that its use may infringe existing patents or copyrights, and |
|
|
* any such use would be at such party's own risk. The original |
|
|
* developer of this software module and his/her company, and subsequent |
|
|
* editors and their companies, will have no liability for use of this |
|
|
* software or modifications or derivatives thereof. |
|
8 |
* |
* |
9 |
* This program is free software; you can redistribute it and/or modify |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
10 |
* it under the terms of the GNU General Public License as published by |
* |
11 |
|
* XviD is free software; you can redistribute it and/or modify it |
12 |
|
* under the terms of the GNU General Public License as published by |
13 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
14 |
* (at your option) any later version. |
* (at your option) any later version. |
15 |
* |
* |
22 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
* |
* |
25 |
*************************************************************************/ |
* Under section 8 of the GNU General Public License, the copyright |
26 |
|
* holders of XVID explicitly forbid distribution in the following |
27 |
/************************************************************************** |
* countries: |
28 |
|
* |
29 |
|
* - Japan |
30 |
|
* - United States of America |
31 |
|
* |
32 |
|
* Linking XviD statically or dynamically with other modules is making a |
33 |
|
* combined work based on XviD. Thus, the terms and conditions of the |
34 |
|
* GNU General Public License cover the whole combination. |
35 |
* |
* |
36 |
* History: |
* As a special exception, the copyright holders of XviD give you |
37 |
|
* permission to link XviD with independent modules that communicate with |
38 |
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
39 |
|
* license terms of these independent modules, and to copy and distribute |
40 |
|
* the resulting combined work under terms of your choice, provided that |
41 |
|
* every copy of the combined work is accompanied by a complete copy of |
42 |
|
* the source code of XviD (the version of XviD used to produce the |
43 |
|
* combined work), being distributed under the terms of the GNU General |
44 |
|
* Public License plus this exception. An independent module is a module |
45 |
|
* which is not derived from or based on XviD. |
46 |
* |
* |
47 |
* 15.07.2002 fix a bug in B-frame decode at DIRECT mode |
* Note that people who make modified versions of XviD are not obligated |
48 |
* MinChen <chenm001@163.com> |
* to grant this special exception for their modified versions; it is |
49 |
* 10.07.2002 added BFRAMES_DEC_DEBUG support |
* their choice whether to do so. The GNU General Public License gives |
50 |
* Fix a little bug for low_delay flage |
* permission to release a modified version without this exception; this |
51 |
* MinChen <chenm001@163.com> |
* exception also makes it possible to release a modified version which |
52 |
* 28.06.2002 added basic resync support to iframe/pframe_decode() |
* carries forward this exception. |
|
* 22.06.2002 added primative N_VOP support |
|
|
* #define BFRAMES_DEC now enables Minchen's bframe decoder |
|
|
* 08.05.2002 add low_delay support for B_VOP decode |
|
|
* MinChen <chenm001@163.com> |
|
|
* 05.05.2002 fix some B-frame decode problem |
|
|
* 02.05.2002 add B-frame decode support(have some problem); |
|
|
* MinChen <chenm001@163.com> |
|
|
* 22.04.2002 add some B-frame decode support; chenm001 <chenm001@163.com> |
|
|
* 29.03.2002 interlacing fix - compensated block wasn't being used when |
|
|
* reconstructing blocks, thus artifacts |
|
|
* interlacing speedup - used transfers to re-interlace |
|
|
* interlaced decoding should be as fast as progressive now |
|
|
* 26.03.2002 interlacing support - moved transfers outside decode loop |
|
|
* 26.12.2001 decoder_mbinter: dequant/idct moved within if(coded) block |
|
|
* 22.12.2001 lock based interpolation |
|
|
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
53 |
* |
* |
54 |
* $Id$ |
* $Id$ |
55 |
* |
* |
80 |
#include "prediction/mbprediction.h" |
#include "prediction/mbprediction.h" |
81 |
#include "utils/timer.h" |
#include "utils/timer.h" |
82 |
#include "utils/emms.h" |
#include "utils/emms.h" |
|
#include "motion/motion.h" |
|
83 |
|
|
84 |
#include "image/image.h" |
#include "image/image.h" |
85 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
86 |
#include "utils/mem_align.h" |
#include "utils/mem_align.h" |
87 |
|
|
88 |
int |
int |
89 |
decoder_resize(DECODER * dec) |
decoder_create(XVID_DEC_PARAM * param) |
90 |
{ |
{ |
91 |
/* free existing */ |
DECODER *dec; |
|
|
|
|
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
|
92 |
|
|
93 |
if (dec->last_mbs) |
dec = xvid_malloc(sizeof(DECODER), CACHE_LINE); |
94 |
xvid_free(dec->last_mbs); |
if (dec == NULL) { |
95 |
if (dec->mbs) |
return XVID_ERR_MEMORY; |
96 |
xvid_free(dec->mbs); |
} |
97 |
|
param->handle = dec; |
98 |
|
|
99 |
/* realloc */ |
dec->width = param->width; |
100 |
|
dec->height = param->height; |
101 |
|
|
102 |
dec->mb_width = (dec->width + 15) / 16; |
dec->mb_width = (dec->width + 15) / 16; |
103 |
dec->mb_height = (dec->height + 15) / 16; |
dec->mb_height = (dec->height + 15) / 16; |
104 |
|
|
105 |
dec->edged_width = 16 * dec->mb_width + 2 * EDGE_SIZE; |
dec->edged_width = 16 * dec->mb_width + 2 * EDGE_SIZE; |
106 |
dec->edged_height = 16 * dec->mb_height + 2 * EDGE_SIZE; |
dec->edged_height = 16 * dec->mb_height + 2 * EDGE_SIZE; |
107 |
|
dec->low_delay = 0; |
108 |
|
|
109 |
if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) { |
if (image_create(&dec->cur, dec->edged_width, dec->edged_height)) { |
110 |
xvid_free(dec); |
xvid_free(dec); |
116 |
xvid_free(dec); |
xvid_free(dec); |
117 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
118 |
} |
} |
|
|
|
119 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
120 |
// for support B-frame to reference last 2 frame |
// for support B-frame to reference last 2 frame |
121 |
if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height)) { |
if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height)) { |
132 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
133 |
} |
} |
134 |
|
|
|
if (image_create(&dec->refh, dec->edged_width, dec->edged_height)) { |
|
|
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
|
|
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
|
|
xvid_free(dec); |
|
|
return XVID_ERR_MEMORY; |
|
|
} |
|
|
|
|
135 |
dec->mbs = |
dec->mbs = |
136 |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
137 |
CACHE_LINE); |
CACHE_LINE); |
140 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
141 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
142 |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
|
143 |
xvid_free(dec); |
xvid_free(dec); |
144 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
145 |
} |
} |
146 |
|
|
147 |
memset(dec->mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
memset(dec->mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
148 |
|
|
149 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
157 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
158 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
159 |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
|
160 |
xvid_free(dec); |
xvid_free(dec); |
161 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
162 |
} |
} |
163 |
|
|
164 |
memset(dec->last_mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
memset(dec->last_mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
165 |
|
|
|
return XVID_ERR_OK; |
|
|
} |
|
|
|
|
|
|
|
|
int |
|
|
decoder_create(XVID_DEC_PARAM * param) |
|
|
{ |
|
|
DECODER *dec; |
|
|
|
|
|
dec = xvid_malloc(sizeof(DECODER), CACHE_LINE); |
|
|
if (dec == NULL) { |
|
|
return XVID_ERR_MEMORY; |
|
|
} |
|
|
memset(dec, 0, sizeof(DECODER)); |
|
|
|
|
|
param->handle = dec; |
|
|
|
|
|
dec->width = param->width; |
|
|
dec->height = param->height; |
|
|
|
|
|
image_null(&dec->cur); |
|
|
image_null(&dec->refn[0]); |
|
|
image_null(&dec->refn[1]); |
|
|
image_null(&dec->refn[2]); |
|
|
image_null(&dec->refh); |
|
|
|
|
|
dec->mbs = NULL; |
|
|
dec->last_mbs = NULL; |
|
|
|
|
166 |
init_timer(); |
init_timer(); |
167 |
|
|
168 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
169 |
// for support B-frame to save reference frame's time |
// for support B-frame to save reference frame's time |
170 |
dec->frames = -1; |
dec->frames = -1; |
171 |
dec->time = dec->time_base = dec->last_time_base = 0; |
dec->time = dec->time_base = dec->last_time_base = 0; |
|
dec->low_delay = 0; |
|
|
|
|
|
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
|
172 |
|
|
|
if (dec->fixed_dimensions) |
|
|
return decoder_resize(dec); |
|
|
else |
|
173 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
174 |
} |
} |
175 |
|
|
182 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
183 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
184 |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
|
185 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
186 |
xvid_free(dec); |
xvid_free(dec); |
187 |
|
|
264 |
start_timer(); |
start_timer(); |
265 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
266 |
{ |
{ |
267 |
int direction = dec->alternate_vertical_scan ? |
get_intra_block(bs, &block[i * 64], pMB->acpred_directions[i], |
268 |
2 : pMB->acpred_directions[i]; |
start_coeff); |
|
|
|
|
get_intra_block(bs, &block[i * 64], direction, start_coeff); |
|
269 |
} |
} |
270 |
stop_coding_timer(); |
stop_coding_timer(); |
271 |
|
|
307 |
|
|
308 |
#define SIGN(X) (((X)>0)?1:-1) |
#define SIGN(X) (((X)>0)?1:-1) |
309 |
#define ABS(X) (((X)>0)?(X):-(X)) |
#define ABS(X) (((X)>0)?(X):-(X)) |
310 |
|
static const uint32_t roundtab[16] = |
311 |
|
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; |
312 |
|
|
313 |
|
|
314 |
// decode an inter macroblock |
// decode an inter macroblock |
315 |
|
|
346 |
|
|
347 |
if (dec->quarterpel) |
if (dec->quarterpel) |
348 |
{ |
{ |
349 |
uv_dx /= 2; |
uv_dx = (uv_dx >> 1) | (uv_dx & 1); |
350 |
uv_dy /= 2; |
uv_dy = (uv_dy >> 1) | (uv_dy & 1); |
|
} |
|
|
|
|
|
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
|
|
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
|
|
|
|
|
start_timer(); |
|
|
if(dec->quarterpel) { |
|
|
interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
|
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
|
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
|
|
} |
|
|
else { |
|
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, |
|
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
|
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
|
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
|
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
|
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
|
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
|
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
|
351 |
} |
} |
352 |
|
|
353 |
interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, |
uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
354 |
uv_dx, uv_dy, stride2, rounding); |
uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
|
interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, |
|
|
uv_dx, uv_dy, stride2, rounding); |
|
|
stop_comp_timer(); |
|
|
|
|
355 |
} else { |
} else { |
356 |
int sum; |
int sum; |
357 |
|
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
358 |
|
|
359 |
if(dec->quarterpel) |
if(dec->quarterpel) |
360 |
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
{ |
361 |
else |
sum /= 2; |
362 |
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
} |
363 |
|
|
364 |
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
uv_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); |
365 |
|
|
|
if(dec->quarterpel) |
|
|
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
|
|
else |
|
366 |
sum = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; |
sum = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; |
367 |
|
|
368 |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
if (dec->quarterpel) |
369 |
|
{ |
370 |
|
sum /= 2; |
371 |
|
} |
372 |
|
|
373 |
|
uv_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); |
374 |
|
} |
375 |
|
|
376 |
start_timer(); |
start_timer(); |
377 |
if(dec->quarterpel) { |
if(dec->quarterpel) { |
378 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
DPRINTF(DPRINTF_DEBUG, "QUARTERPEL\n"); |
379 |
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, |
380 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
381 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
|
382 |
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
383 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
|
384 |
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
385 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
|
386 |
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
387 |
} |
} |
388 |
else { |
else { |
401 |
interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, |
interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, |
402 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
403 |
stop_comp_timer(); |
stop_comp_timer(); |
|
} |
|
404 |
|
|
405 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
|
|
|
|
406 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
407 |
{ |
{ |
408 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
409 |
|
|
410 |
start_timer(); |
start_timer(); |
411 |
get_inter_block(bs, &block[i * 64], direction); |
get_inter_block(bs, &block[i * 64]); |
412 |
stop_coding_timer(); |
stop_coding_timer(); |
413 |
|
|
414 |
start_timer(); |
start_timer(); |
450 |
void |
void |
451 |
decoder_iframe(DECODER * dec, |
decoder_iframe(DECODER * dec, |
452 |
Bitstream * bs, |
Bitstream * bs, |
|
int reduced_resolution, |
|
453 |
int quant, |
int quant, |
454 |
int intra_dc_threshold) |
int intra_dc_threshold) |
455 |
{ |
{ |
456 |
uint32_t bound; |
uint32_t bound; |
457 |
uint32_t x, y; |
uint32_t x, y; |
|
int mb_width = dec->mb_width; |
|
|
int mb_height = dec->mb_height; |
|
|
|
|
|
if (reduced_resolution) |
|
|
{ |
|
|
mb_width /= 2; |
|
|
mb_height /= 2; |
|
|
} |
|
458 |
|
|
459 |
bound = 0; |
bound = 0; |
460 |
|
|
461 |
for (y = 0; y < mb_height; y++) { |
for (y = 0; y < dec->mb_height; y++) { |
462 |
for (x = 0; x < mb_width; x++) { |
for (x = 0; x < dec->mb_width; x++) { |
463 |
MACROBLOCK *mb; |
MACROBLOCK *mb; |
464 |
uint32_t mcbpc; |
uint32_t mcbpc; |
465 |
uint32_t cbpc; |
uint32_t cbpc; |
472 |
|
|
473 |
if (check_resync_marker(bs, 0)) |
if (check_resync_marker(bs, 0)) |
474 |
{ |
{ |
475 |
bound = read_video_packet_header(bs, dec, 0, |
bound = read_video_packet_header(bs, 0, &quant); |
|
&quant, NULL, NULL, &intra_dc_threshold); |
|
476 |
x = bound % dec->mb_width; |
x = bound % dec->mb_width; |
477 |
y = bound / dec->mb_width; |
y = bound / dec->mb_width; |
478 |
} |
} |
505 |
|
|
506 |
if (dec->interlacing) { |
if (dec->interlacing) { |
507 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
508 |
DEBUG1("deci: field_dct: ", mb->field_dct); |
DPRINTF(DPRINTF_DEBUG, "deci: field_dct: %d", mb->field_dct); |
509 |
} |
} |
510 |
|
|
511 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
512 |
intra_dc_threshold, bound); |
intra_dc_threshold, bound); |
|
|
|
513 |
} |
} |
514 |
if(dec->out_frm) |
if(dec->out_frm) |
515 |
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,dec->mb_width); |
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,dec->mb_width); |
516 |
|
|
517 |
} |
} |
518 |
|
|
519 |
} |
} |
562 |
|
|
563 |
mv->x = mv_x; |
mv->x = mv_x; |
564 |
mv->y = mv_y; |
mv->y = mv_y; |
|
} |
|
|
|
|
565 |
|
|
|
|
|
|
static __inline int gmc_sanitize(int value, int quarterpel, int fcode) |
|
|
{ |
|
|
int length = 1 << (fcode+4); |
|
|
|
|
|
if (quarterpel) value *= 2; |
|
|
|
|
|
if (value < -length) |
|
|
return -length; |
|
|
else if (value >= length) |
|
|
return length-1; |
|
|
else return value; |
|
566 |
} |
} |
567 |
|
|
568 |
|
|
|
/* for P_VOP set gmc_mv to NULL */ |
|
569 |
void |
void |
570 |
decoder_pframe(DECODER * dec, |
decoder_pframe(DECODER * dec, |
571 |
Bitstream * bs, |
Bitstream * bs, |
572 |
int rounding, |
int rounding, |
|
int reduced_resolution, |
|
573 |
int quant, |
int quant, |
574 |
int fcode, |
int fcode, |
575 |
int intra_dc_threshold, |
int intra_dc_threshold) |
|
VECTOR * gmc_mv) |
|
576 |
{ |
{ |
577 |
|
|
578 |
uint32_t x, y; |
uint32_t x, y; |
597 |
|
|
598 |
if (check_resync_marker(bs, fcode - 1)) |
if (check_resync_marker(bs, fcode - 1)) |
599 |
{ |
{ |
600 |
bound = read_video_packet_header(bs, dec, fcode - 1, |
bound = read_video_packet_header(bs, fcode - 1, &quant); |
|
&quant, &fcode, NULL, &intra_dc_threshold); |
|
601 |
x = bound % dec->mb_width; |
x = bound % dec->mb_width; |
602 |
y = bound / dec->mb_width; |
y = bound / dec->mb_width; |
603 |
} |
} |
614 |
uint32_t cbpy; |
uint32_t cbpy; |
615 |
uint32_t cbp; |
uint32_t cbp; |
616 |
uint32_t intra; |
uint32_t intra; |
|
int mcsel = 0; // mcsel: '0'=local motion, '1'=GMC |
|
617 |
|
|
618 |
cp_mb++; |
cp_mb++; |
619 |
mcbpc = get_mcbpc_inter(bs); |
mcbpc = get_mcbpc_inter(bs); |
630 |
acpred_flag = BitstreamGetBit(bs); |
acpred_flag = BitstreamGetBit(bs); |
631 |
} |
} |
632 |
|
|
|
if (gmc_mv && (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)) |
|
|
{ |
|
|
mcsel = BitstreamGetBit(bs); |
|
|
} |
|
|
|
|
633 |
cbpy = get_cbpy(bs, intra); |
cbpy = get_cbpy(bs, intra); |
634 |
DPRINTF(DPRINTF_MB, "cbpy %i", cbpy); |
DPRINTF(DPRINTF_MB, "cbpy %i", cbpy); |
635 |
|
|
651 |
if (dec->interlacing) { |
if (dec->interlacing) { |
652 |
if (cbp || intra) { |
if (cbp || intra) { |
653 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
654 |
DEBUG1("decp: field_dct: ", mb->field_dct); |
DPRINTF(DPRINTF_DEBUG, "decp: field_dct: %d", mb->field_dct); |
655 |
} |
} |
656 |
|
|
657 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
658 |
mb->field_pred = BitstreamGetBit(bs); |
mb->field_pred = BitstreamGetBit(bs); |
659 |
DEBUG1("decp: field_pred: ", mb->field_pred); |
DPRINTF(DPRINTF_DEBUG, "decp: field_pred: %d", mb->field_pred); |
660 |
|
|
661 |
if (mb->field_pred) { |
if (mb->field_pred) { |
662 |
mb->field_for_top = BitstreamGetBit(bs); |
mb->field_for_top = BitstreamGetBit(bs); |
663 |
DEBUG1("decp: field_for_top: ", mb->field_for_top); |
DPRINTF(DPRINTF_DEBUG, "decp: field_for_top: %d", mb->field_for_top); |
664 |
mb->field_for_bot = BitstreamGetBit(bs); |
mb->field_for_bot = BitstreamGetBit(bs); |
665 |
DEBUG1("decp: field_for_bot: ", mb->field_for_bot); |
DPRINTF(DPRINTF_DEBUG, "decp: field_for_bot: %d", mb->field_for_bot); |
666 |
} |
} |
667 |
} |
} |
668 |
} |
} |
669 |
|
|
670 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
671 |
|
if (dec->interlacing && mb->field_pred) { |
|
if (mcsel) |
|
|
{ |
|
|
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode); |
|
|
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = gmc_sanitize(gmc_mv[0].y, dec->quarterpel, fcode); |
|
|
|
|
|
} else if (dec->interlacing && mb->field_pred) { |
|
672 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], |
673 |
fcode, bound); |
fcode, bound); |
674 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1], |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1], |
700 |
|
|
701 |
decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
702 |
rounding); |
rounding); |
703 |
|
} else // not coded |
|
} |
|
|
else if (gmc_mv) /* not coded S_VOP macroblock */ |
|
|
{ |
|
|
mb->mode = MODE_NOT_CODED; |
|
|
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode); |
|
|
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = gmc_sanitize(gmc_mv[0].y, dec->quarterpel, fcode); |
|
|
decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding); |
|
|
} |
|
|
else /* not coded P_VOP macroblock */ |
|
704 |
{ |
{ |
705 |
|
DPRINTF(DPRINTF_DEBUG, "P-frame MB at (X,Y)=(%d,%d)", x, y); |
706 |
|
|
707 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED; |
708 |
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0; |
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0; |
709 |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0; |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0; |
710 |
|
|
711 |
// copy macroblock directly from ref to cur |
// copy macroblock directly from ref to cur |
712 |
|
|
713 |
start_timer(); |
start_timer(); |
745 |
dec->refn[0].v + |
dec->refn[0].v + |
746 |
(8 * y) * dec->edged_width / 2 + (8 * x), |
(8 * y) * dec->edged_width / 2 + (8 * x), |
747 |
dec->edged_width / 2); |
dec->edged_width / 2); |
|
|
|
748 |
stop_transfer_timer(); |
stop_transfer_timer(); |
|
|
|
749 |
if(dec->out_frm && cp_mb > 0) { |
if(dec->out_frm && cp_mb > 0) { |
750 |
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb); |
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb); |
751 |
cp_mb = 0; |
cp_mb = 0; |
873 |
stop_comp_timer(); |
stop_comp_timer(); |
874 |
|
|
875 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
|
|
|
|
876 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
877 |
{ |
{ |
878 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
879 |
|
|
880 |
start_timer(); |
start_timer(); |
881 |
get_inter_block(bs, &block[i * 64], direction); |
get_inter_block(bs, &block[i * 64]); |
882 |
stop_coding_timer(); |
stop_coding_timer(); |
883 |
|
|
884 |
start_timer(); |
start_timer(); |
916 |
stop_transfer_timer(); |
stop_transfer_timer(); |
917 |
} |
} |
918 |
|
|
919 |
|
|
920 |
// add by MinChen <chenm001@163.com> |
// add by MinChen <chenm001@163.com> |
921 |
// decode an B-frame direct & inter macroblock |
// decode an B-frame direct & inter macroblock |
922 |
void |
void |
1024 |
interpolate8x8_switch(dec->refn[2].v, backward.v, 8 * x_pos, 8 * y_pos, |
interpolate8x8_switch(dec->refn[2].v, backward.v, 8 * x_pos, 8 * y_pos, |
1025 |
b_uv_dx, b_uv_dy, stride2, 0); |
b_uv_dx, b_uv_dy, stride2, 0); |
1026 |
|
|
1027 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos, |
1028 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
stride); |
1029 |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos, |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, 16 * y_pos, |
1030 |
stride, 0); |
stride); |
1031 |
|
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos + 8, |
1032 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
stride); |
1033 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, |
1034 |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8, |
16 * y_pos + 8, stride); |
1035 |
stride, 0); |
interpolate8x8_c(dec->cur.u, dec->refn[2].u, 8 * x_pos, 8 * y_pos, |
1036 |
|
stride2); |
1037 |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
interpolate8x8_c(dec->cur.v, dec->refn[2].v, 8 * x_pos, 8 * y_pos, |
1038 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
stride2); |
|
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
|
|
stride, 0); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
|
|
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
|
|
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
|
|
stride, 0); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
stride2, 0); |
|
|
|
|
|
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos, |
|
|
stride2, 0); |
|
|
|
|
1039 |
stop_comp_timer(); |
stop_comp_timer(); |
1040 |
|
|
1041 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
|
|
|
|
1042 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
1043 |
{ |
{ |
1044 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
1045 |
|
|
1046 |
start_timer(); |
start_timer(); |
1047 |
get_inter_block(bs, &block[i * 64], direction); |
get_inter_block(bs, &block[i * 64]); |
1048 |
stop_coding_timer(); |
stop_coding_timer(); |
1049 |
|
|
1050 |
start_timer(); |
start_timer(); |
1275 |
break; |
break; |
1276 |
|
|
1277 |
default: |
default: |
1278 |
DEBUG1("Not support B-frame mb_type =", mb->mb_type); |
DPRINTF(DPRINTF_ERROR, "Not support B-frame mb_type = %d", mb->mb_type); |
1279 |
} |
} |
1280 |
|
|
1281 |
} // end of FOR |
} // end of FOR |
1302 |
|
|
1303 |
int |
int |
1304 |
decoder_decode(DECODER * dec, |
decoder_decode(DECODER * dec, |
1305 |
XVID_DEC_FRAME * frame, XVID_DEC_STATS * stats) |
XVID_DEC_FRAME * frame) |
1306 |
{ |
{ |
1307 |
|
|
1308 |
Bitstream bs; |
Bitstream bs; |
1309 |
uint32_t rounding; |
uint32_t rounding; |
|
uint32_t reduced_resolution; |
|
1310 |
uint32_t quant; |
uint32_t quant; |
1311 |
uint32_t fcode_forward; |
uint32_t fcode_forward; |
1312 |
uint32_t fcode_backward; |
uint32_t fcode_backward; |
1313 |
uint32_t intra_dc_threshold; |
uint32_t intra_dc_threshold; |
|
VECTOR gmc_mv[5]; |
|
1314 |
uint32_t vop_type; |
uint32_t vop_type; |
1315 |
|
|
1316 |
start_global_timer(); |
start_global_timer(); |
1319 |
|
|
1320 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1321 |
|
|
|
#ifdef BFRAMES_DEC |
|
|
// XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's |
|
|
if(BitstreamShowBits(&bs, 8) == 0x7f) |
|
|
{ |
|
|
if (stats) |
|
|
stats->notify = XVID_DEC_VOP; |
|
|
frame->length = 1; |
|
|
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
|
|
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
|
|
return XVID_ERR_OK; |
|
|
} |
|
|
#endif |
|
|
|
|
1322 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
1323 |
// for support B-frame to reference last 2 frame |
// for support B-frame to reference last 2 frame |
1324 |
dec->frames++; |
dec->frames++; |
|
|
|
|
xxx: |
|
1325 |
vop_type = |
vop_type = |
1326 |
BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
BitstreamReadHeaders(&bs, dec, &rounding, &quant, &fcode_forward, |
1327 |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv); |
&fcode_backward, &intra_dc_threshold); |
|
|
|
|
DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type); |
|
|
|
|
|
if (vop_type == -2 || vop_type == -3) |
|
|
{ |
|
|
if (vop_type == -3) |
|
|
decoder_resize(dec); |
|
|
|
|
|
if (stats) |
|
|
{ |
|
|
stats->notify = XVID_DEC_VOL; |
|
|
stats->data.vol.general = 0; |
|
|
if (dec->interlacing) |
|
|
stats->data.vol.general |= XVID_INTERLACING; |
|
|
stats->data.vol.width = dec->width; |
|
|
stats->data.vol.height = dec->height; |
|
|
stats->data.vol.aspect_ratio = dec->aspect_ratio; |
|
|
stats->data.vol.par_width = dec->par_width; |
|
|
stats->data.vol.par_height = dec->par_height; |
|
|
frame->length = BitstreamPos(&bs) / 8; |
|
|
return XVID_ERR_OK; |
|
|
} |
|
|
goto xxx; |
|
|
} |
|
1328 |
|
|
1329 |
dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0; // init pred vector to 0 |
dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0; // init pred vector to 0 |
1330 |
|
|
1331 |
switch (vop_type) { |
switch (vop_type) { |
1332 |
case P_VOP: |
case P_VOP: |
1333 |
decoder_pframe(dec, &bs, rounding, reduced_resolution, quant, |
decoder_pframe(dec, &bs, rounding, quant, fcode_forward, |
1334 |
fcode_forward, intra_dc_threshold, NULL); |
intra_dc_threshold); |
1335 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1336 |
DEBUG1("P_VOP Time=", dec->time); |
DPRINTF(DPRINTF_DEBUG, "P_VOP Time=%d", dec->time); |
1337 |
#endif |
#endif |
1338 |
break; |
break; |
1339 |
|
|
1340 |
case I_VOP: |
case I_VOP: |
1341 |
decoder_iframe(dec, &bs, reduced_resolution, quant, intra_dc_threshold); |
decoder_iframe(dec, &bs, quant, intra_dc_threshold); |
1342 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1343 |
DEBUG1("I_VOP Time=", dec->time); |
DPRINTF(DPRINTF_DEBUG, "I_VOP Time=%d", dec->time); |
1344 |
#endif |
#endif |
1345 |
break; |
break; |
1346 |
|
|
1347 |
case B_VOP: |
case B_VOP: |
1348 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1349 |
if (dec->time_pp > dec->time_bp) { |
if (dec->time_pp > dec->time_bp) { |
1350 |
DEBUG1("B_VOP Time=", dec->time); |
DPRINTF(DPRINTF_DEBUG, "B_VOP Time=%d", dec->time); |
1351 |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
1352 |
} else { |
} else { |
1353 |
DEBUG("broken B-frame!"); |
DPRINTF(DPRINTF_DEBUG, "Broken B_VOP"); |
1354 |
} |
} |
1355 |
#else |
#else |
1356 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
1357 |
#endif |
#endif |
1358 |
break; |
break; |
1359 |
|
|
|
case S_VOP : |
|
|
decoder_pframe(dec, &bs, rounding, reduced_resolution, quant, |
|
|
fcode_forward, intra_dc_threshold, gmc_mv); |
|
|
break; |
|
|
|
|
1360 |
case N_VOP: // vop not coded |
case N_VOP: // vop not coded |
1361 |
// when low_delay==0, N_VOP's should interpolate between the past and future frames |
// when low_delay==0, N_VOP's should interpolate between the past and future frames |
1362 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
|
#ifdef BFRAMES_DEC |
|
|
DEBUG1("N_VOP Time=", dec->time); |
|
|
#endif |
|
1363 |
break; |
break; |
1364 |
|
|
1365 |
default: |
default: |
|
if (stats) |
|
|
stats->notify = 0; |
|
1366 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
1367 |
} |
} |
1368 |
|
|
1369 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1370 |
if (frame->length != BitstreamPos(&bs) / 8){ |
if (frame->length != BitstreamPos(&bs) / 8){ |
1371 |
DEBUG2("InLen/UseLen",frame->length, BitstreamPos(&bs) / 8); |
DPRINTF(DPRINTF_DEBUG, "InLen: %d / UseLen: %d", frame->length, BitstreamPos(&bs) / 8); |
1372 |
} |
} |
1373 |
#endif |
#endif |
1374 |
frame->length = BitstreamPos(&bs) / 8; |
frame->length = BitstreamPos(&bs) / 8; |
1379 |
if (dec->low_delay || dec->frames == 0) { |
if (dec->low_delay || dec->frames == 0) { |
1380 |
#endif |
#endif |
1381 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
1382 |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
frame->image, frame->stride, frame->colorspace); |
1383 |
|
|
1384 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1385 |
} else { |
} else { |
1386 |
if (dec->frames >= 1) { |
if (dec->frames >= 1) { |
1387 |
start_timer(); |
start_timer(); |
1388 |
if ((vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP)) { |
if ((vop_type == I_VOP || vop_type == P_VOP)) { |
1389 |
image_output(&dec->refn[0], dec->width, dec->height, |
image_output(&dec->refn[0], dec->width, dec->height, |
1390 |
dec->edged_width, frame->image, frame->stride, |
dec->edged_width, frame->image, frame->stride, |
1391 |
frame->colorspace, dec->interlacing); |
frame->colorspace); |
1392 |
} else if (vop_type == B_VOP) { |
} else if (vop_type == B_VOP) { |
1393 |
image_output(&dec->cur, dec->width, dec->height, |
image_output(&dec->cur, dec->width, dec->height, |
1394 |
dec->edged_width, frame->image, frame->stride, |
dec->edged_width, frame->image, frame->stride, |
1395 |
frame->colorspace, dec->interlacing); |
frame->colorspace); |
1396 |
} |
} |
1397 |
stop_conv_timer(); |
stop_conv_timer(); |
1398 |
} |
} |
1399 |
} |
} |
1400 |
#endif |
#endif |
1401 |
|
|
1402 |
if (vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP) { |
if (vop_type == I_VOP || vop_type == P_VOP) { |
1403 |
image_swap(&dec->refn[0], &dec->refn[1]); |
image_swap(&dec->refn[0], &dec->refn[1]); |
1404 |
image_swap(&dec->cur, &dec->refn[0]); |
image_swap(&dec->cur, &dec->refn[0]); |
1405 |
|
|
1415 |
mb_swap(&dec->mbs, &dec->last_mbs); |
mb_swap(&dec->mbs, &dec->last_mbs); |
1416 |
} |
} |
1417 |
|
|
|
if (stats) |
|
|
{ |
|
|
stats->notify = XVID_DEC_VOP; |
|
|
stats->data.vop.time_base = (int)dec->time_base; |
|
|
stats->data.vop.time_increment = 0; //XXX: todo |
|
|
} |
|
|
|
|
1418 |
emms(); |
emms(); |
1419 |
|
|
1420 |
stop_global_timer(); |
stop_global_timer(); |