1 |
/************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Decoder main module - |
* - Decoder Module - |
5 |
* |
* |
6 |
* This program is an implementation of a part of one or more MPEG-4 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
|
|
* 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. |
|
7 |
* |
* |
8 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
9 |
* 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 |
19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
|
*************************************************************************/ |
|
|
|
|
|
/************************************************************************** |
|
|
* |
|
|
* History: |
|
|
* |
|
|
* 15.07.2002 fix a bug in B-frame decode at DIRECT mode |
|
|
* MinChen <chenm001@163.com> |
|
|
* 10.07.2002 added BFRAMES_DEC_DEBUG support |
|
|
* Fix a little bug for low_delay flage |
|
|
* MinChen <chenm001@163.com> |
|
|
* 28.06.2002 added basic resync support to iframe/pframe_decode() |
|
|
* 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> |
|
|
* |
|
22 |
* $Id$ |
* $Id$ |
23 |
* |
* |
24 |
*************************************************************************/ |
****************************************************************************/ |
25 |
|
|
26 |
|
#include <stdio.h> |
27 |
#include <stdlib.h> |
#include <stdlib.h> |
28 |
#include <string.h> |
#include <string.h> |
29 |
|
|
33 |
|
|
34 |
#include "xvid.h" |
#include "xvid.h" |
35 |
#include "portab.h" |
#include "portab.h" |
36 |
|
#include "global.h" |
37 |
|
|
38 |
#include "decoder.h" |
#include "decoder.h" |
39 |
#include "bitstream/bitstream.h" |
#include "bitstream/bitstream.h" |
57 |
#include "image/image.h" |
#include "image/image.h" |
58 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
59 |
#include "utils/mem_align.h" |
#include "utils/mem_align.h" |
60 |
|
#include "image/postprocessing.h" |
61 |
|
|
62 |
int |
int |
63 |
decoder_resize(DECODER * dec) |
decoder_resize(DECODER * dec) |
64 |
{ |
{ |
65 |
/* free existing */ |
/* free existing */ |
|
|
|
66 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
67 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
68 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
69 |
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
70 |
image_destroy(&dec->qtmp, dec->edged_width, dec->edged_height); |
image_destroy(&dec->qtmp, dec->edged_width, dec->edged_height); |
71 |
|
|
72 |
|
image_destroy(&dec->gmc, dec->edged_width, dec->edged_height); |
73 |
|
|
74 |
if (dec->last_mbs) |
if (dec->last_mbs) |
75 |
xvid_free(dec->last_mbs); |
xvid_free(dec->last_mbs); |
76 |
if (dec->mbs) |
if (dec->mbs) |
77 |
xvid_free(dec->mbs); |
xvid_free(dec->mbs); |
78 |
|
|
79 |
/* realloc */ |
/* realloc */ |
|
|
|
80 |
dec->mb_width = (dec->width + 15) / 16; |
dec->mb_width = (dec->width + 15) / 16; |
81 |
dec->mb_height = (dec->height + 15) / 16; |
dec->mb_height = (dec->height + 15) / 16; |
82 |
|
|
94 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
95 |
} |
} |
96 |
|
|
97 |
// add by chenm001 <chenm001@163.com> |
/* Support B-frame to reference last 2 frame */ |
|
// for support B-frame to reference last 2 frame |
|
98 |
if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height)) { |
if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height)) { |
99 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
100 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
118 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
119 |
} |
} |
120 |
|
|
121 |
|
if (image_create(&dec->gmc, dec->edged_width, dec->edged_height)) { |
122 |
|
image_destroy(&dec->qtmp, dec->edged_width, dec->edged_height); |
123 |
|
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
124 |
|
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
125 |
|
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
126 |
|
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
127 |
|
xvid_free(dec); |
128 |
|
return XVID_ERR_MEMORY; |
129 |
|
} |
130 |
|
|
131 |
dec->mbs = |
dec->mbs = |
132 |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
133 |
CACHE_LINE); |
CACHE_LINE); |
142 |
} |
} |
143 |
memset(dec->mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
memset(dec->mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
144 |
|
|
145 |
// add by chenm001 <chenm001@163.com> |
/* For skip MB flag */ |
|
// for skip MB flag |
|
146 |
dec->last_mbs = |
dec->last_mbs = |
147 |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
148 |
CACHE_LINE); |
CACHE_LINE); |
185 |
image_null(&dec->tmp); |
image_null(&dec->tmp); |
186 |
image_null(&dec->qtmp); |
image_null(&dec->qtmp); |
187 |
|
|
188 |
|
/* image based GMC */ |
189 |
|
image_null(&dec->gmc); |
190 |
|
|
191 |
|
|
192 |
dec->mbs = NULL; |
dec->mbs = NULL; |
193 |
dec->last_mbs = NULL; |
dec->last_mbs = NULL; |
194 |
|
|
195 |
init_timer(); |
init_timer(); |
196 |
|
|
197 |
// add by chenm001 <chenm001@163.com> |
/* For B-frame support (used to save reference frame's time */ |
|
// for support B-frame to save reference frame's time |
|
198 |
dec->frames = 0; |
dec->frames = 0; |
199 |
dec->time = dec->time_base = dec->last_time_base = 0; |
dec->time = dec->time_base = dec->last_time_base = 0; |
200 |
dec->low_delay = 0; |
dec->low_delay = 0; |
214 |
{ |
{ |
215 |
xvid_free(dec->last_mbs); |
xvid_free(dec->last_mbs); |
216 |
xvid_free(dec->mbs); |
xvid_free(dec->mbs); |
217 |
|
|
218 |
|
/* image based GMC */ |
219 |
|
image_destroy(&dec->gmc, dec->edged_width, dec->edged_height); |
220 |
|
|
221 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
222 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
223 |
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
image_destroy(&dec->tmp, dec->edged_width, dec->edged_height); |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
// decode an intra macroblock |
/* decode an intra macroblock */ |
|
|
|
242 |
void |
void |
243 |
decoder_mbintra(DECODER * dec, |
decoder_mbintra(DECODER * dec, |
244 |
MACROBLOCK * pMB, |
MACROBLOCK * pMB, |
273 |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
274 |
} |
} |
275 |
|
|
276 |
memset(block, 0, 6 * 64 * sizeof(int16_t)); // clear |
memset(block, 0, 6 * 64 * sizeof(int16_t)); /* clear */ |
277 |
|
|
278 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
279 |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
296 |
dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0; |
dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0; |
297 |
|
|
298 |
if (dc_size > 8) { |
if (dc_size > 8) { |
299 |
BitstreamSkip(bs, 1); // marker |
BitstreamSkip(bs, 1); /* marker */ |
300 |
} |
} |
301 |
|
|
302 |
block[i * 64 + 0] = dc_dif; |
block[i * 64 + 0] = dc_dif; |
308 |
} |
} |
309 |
|
|
310 |
start_timer(); |
start_timer(); |
311 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) /* coded */ |
312 |
{ |
{ |
313 |
int direction = dec->alternate_vertical_scan ? |
int direction = dec->alternate_vertical_scan ? |
314 |
2 : pMB->acpred_directions[i]; |
2 : pMB->acpred_directions[i]; |
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
/* decode an inter macroblock */ |
|
#define SIGN(X) (((X)>0)?1:-1) |
|
|
#define ABS(X) (((X)>0)?(X):-(X)) |
|
|
|
|
|
// decode an inter macroblock |
|
|
|
|
369 |
void |
void |
370 |
decoder_mbinter(DECODER * dec, |
decoder_mbinter(DECODER * dec, |
371 |
const MACROBLOCK * pMB, |
const MACROBLOCK * pMB, |
372 |
const uint32_t x_pos, |
const uint32_t x_pos, |
373 |
const uint32_t y_pos, |
const uint32_t y_pos, |
374 |
const uint32_t acpred_flag, |
const uint32_t fcode, |
375 |
const uint32_t cbp, |
const uint32_t cbp, |
376 |
Bitstream * bs, |
Bitstream * bs, |
377 |
const uint32_t quant, |
const uint32_t quant, |
409 |
} |
} |
410 |
|
|
411 |
if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) { |
if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) { |
|
uv_dx = mv[0].x; |
|
|
uv_dy = mv[0].y; |
|
412 |
|
|
413 |
if (dec->quarterpel) |
uv_dx = mv[0].x / (1 + dec->quarterpel); |
414 |
{ |
uv_dy = mv[0].y / (1 + dec->quarterpel); |
|
uv_dx /= 2; |
|
|
uv_dy /= 2; |
|
|
} |
|
415 |
|
|
416 |
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
417 |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
479 |
interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos, |
interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos, |
480 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
481 |
|
|
482 |
// set_block(pY_Cur, stride, 32, 32, 127); |
/* set_block(pY_Cur, stride, 32, 32, 127); */ |
483 |
} |
} |
484 |
else |
else |
485 |
{ |
{ |
519 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
520 |
int direction = dec->alternate_vertical_scan ? 2 : 0; |
int direction = dec->alternate_vertical_scan ? 2 : 0; |
521 |
|
|
522 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) /* coded */ |
523 |
{ |
{ |
524 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); /* clear */ |
525 |
|
|
526 |
start_timer(); |
start_timer(); |
527 |
get_inter_block(bs, &block[i * 64], direction); |
get_inter_block(bs, &block[i * 64], direction); |
580 |
stop_transfer_timer(); |
stop_transfer_timer(); |
581 |
} |
} |
582 |
|
|
583 |
|
static __inline int gmc_sanitize(int value, int quarterpel, int fcode) |
584 |
|
{ |
585 |
|
int length = 1 << (fcode+4); |
586 |
|
|
587 |
|
/* if (quarterpel) value *= 2; */ |
588 |
|
|
589 |
|
if (value < -length) |
590 |
|
return -length; |
591 |
|
else if (value >= length) |
592 |
|
return length-1; |
593 |
|
else return value; |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
|
static void |
598 |
|
decoder_mbgmc(DECODER * dec, |
599 |
|
MACROBLOCK * const pMB, |
600 |
|
const uint32_t x_pos, |
601 |
|
const uint32_t y_pos, |
602 |
|
const uint32_t fcode, |
603 |
|
const uint32_t cbp, |
604 |
|
Bitstream * bs, |
605 |
|
const uint32_t quant, |
606 |
|
const uint32_t rounding, |
607 |
|
const int reduced_resolution) /* no reduced res support */ |
608 |
|
{ |
609 |
|
|
610 |
|
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
611 |
|
DECLARE_ALIGNED_MATRIX(data, 6, 64, int16_t, CACHE_LINE); |
612 |
|
|
613 |
|
const uint32_t stride = dec->edged_width; |
614 |
|
const uint32_t stride2 = stride / 2; |
615 |
|
const uint32_t next_block = stride * (reduced_resolution ? 16 : 8); |
616 |
|
uint32_t i; |
617 |
|
const uint32_t iQuant = pMB->quant; |
618 |
|
uint8_t *const pY_Cur=dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
619 |
|
uint8_t *const pU_Cur=dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
620 |
|
uint8_t *const pV_Cur=dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
621 |
|
|
622 |
|
pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv; |
623 |
|
|
624 |
|
start_timer(); |
625 |
|
|
626 |
|
/* this is where the calculations are done */ |
627 |
|
|
628 |
|
{ |
629 |
|
pMB->amv = generate_GMCimageMB(&dec->gmc_data, &dec->refn[0], x_pos, y_pos, |
630 |
|
stride, stride2, dec->quarterpel, rounding, &dec->cur); |
631 |
|
|
632 |
|
pMB->amv.x = gmc_sanitize(pMB->amv.x, dec->quarterpel, fcode); |
633 |
|
pMB->amv.y = gmc_sanitize(pMB->amv.y, dec->quarterpel, fcode); |
634 |
|
} |
635 |
|
pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv; |
636 |
|
|
637 |
|
/* |
638 |
|
transfer16x16_copy(pY_Cur, dec->gmc.y + (y_pos << 4)*stride + (x_pos << 4), stride); |
639 |
|
transfer8x8_copy(pU_Cur, dec->gmc.u + (y_pos << 3)*stride2 + (x_pos << 3), stride2); |
640 |
|
transfer8x8_copy(pV_Cur, dec->gmc.v + (y_pos << 3)*stride2 + (x_pos << 3), stride2); |
641 |
|
*/ |
642 |
|
|
643 |
|
|
644 |
|
stop_transfer_timer(); |
645 |
|
|
646 |
|
if (!cbp) return; |
647 |
|
|
648 |
|
for (i = 0; i < 6; i++) { |
649 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
650 |
|
|
651 |
|
if (cbp & (1 << (5 - i))) /* coded */ |
652 |
|
{ |
653 |
|
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); /* clear */ |
654 |
|
|
655 |
|
start_timer(); |
656 |
|
get_inter_block(bs, &block[i * 64], direction); |
657 |
|
stop_coding_timer(); |
658 |
|
|
659 |
|
start_timer(); |
660 |
|
if (dec->quant_type == 0) { |
661 |
|
dequant_inter(&data[i * 64], &block[i * 64], iQuant); |
662 |
|
} else { |
663 |
|
dequant4_inter(&data[i * 64], &block[i * 64], iQuant); |
664 |
|
} |
665 |
|
stop_iquant_timer(); |
666 |
|
|
667 |
|
start_timer(); |
668 |
|
idct(&data[i * 64]); |
669 |
|
stop_idct_timer(); |
670 |
|
} |
671 |
|
} |
672 |
|
|
673 |
|
/* interlace + GMC is this possible ??? */ |
674 |
|
/* |
675 |
|
if (dec->interlacing && pMB->field_dct) { |
676 |
|
next_block = stride; |
677 |
|
stride *= 2; |
678 |
|
} |
679 |
|
*/ |
680 |
|
start_timer(); |
681 |
|
if (cbp & 32) |
682 |
|
transfer_16to8add(pY_Cur, &data[0 * 64], stride); |
683 |
|
if (cbp & 16) |
684 |
|
transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride); |
685 |
|
if (cbp & 8) |
686 |
|
transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride); |
687 |
|
if (cbp & 4) |
688 |
|
transfer_16to8add(pY_Cur + 8 + next_block, &data[3 * 64], stride); |
689 |
|
if (cbp & 2) |
690 |
|
transfer_16to8add(pU_Cur, &data[4 * 64], stride2); |
691 |
|
if (cbp & 1) |
692 |
|
transfer_16to8add(pV_Cur, &data[5 * 64], stride2); |
693 |
|
stop_transfer_timer(); |
694 |
|
} |
695 |
|
|
696 |
|
|
697 |
void |
void |
698 |
decoder_iframe(DECODER * dec, |
decoder_iframe(DECODER * dec, |
800 |
mv.x = get_mv(bs, fcode); |
mv.x = get_mv(bs, fcode); |
801 |
mv.y = get_mv(bs, fcode); |
mv.y = get_mv(bs, fcode); |
802 |
|
|
803 |
DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i)", mv.x, mv.y, pmv.x, pmv.y); |
DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)", mv.x, mv.y, pmv.x, pmv.y, mv.x+pmv.x, mv.y+pmv.y); |
804 |
|
|
805 |
mv.x += pmv.x; |
mv.x += pmv.x; |
806 |
mv.y += pmv.y; |
mv.y += pmv.y; |
823 |
|
|
824 |
|
|
825 |
|
|
|
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; |
|
|
} |
|
826 |
|
|
827 |
|
|
828 |
/* for P_VOP set gmc_mv to NULL */ |
/* for P_VOP set gmc_warp to NULL */ |
829 |
void |
void |
830 |
decoder_pframe(DECODER * dec, |
decoder_pframe(DECODER * dec, |
831 |
Bitstream * bs, |
Bitstream * bs, |
834 |
int quant, |
int quant, |
835 |
int fcode, |
int fcode, |
836 |
int intra_dc_threshold, |
int intra_dc_threshold, |
837 |
VECTOR * gmc_mv) |
const WARPPOINTS *const gmc_warp) |
838 |
{ |
{ |
839 |
|
|
840 |
uint32_t x, y; |
uint32_t x, y; |
854 |
dec->width, dec->height); |
dec->width, dec->height); |
855 |
stop_edges_timer(); |
stop_edges_timer(); |
856 |
|
|
857 |
|
if (gmc_warp) |
858 |
|
{ |
859 |
|
|
860 |
|
/* accuracy: 0==1/2, 1=1/4, 2=1/8, 3=1/16 */ |
861 |
|
if ( (dec->sprite_warping_accuracy != 3) || (dec->sprite_warping_points != 2) ) |
862 |
|
{ |
863 |
|
fprintf(stderr,"Wrong GMC parameters acc=%d(-> 1/%d), %d!!!\n", |
864 |
|
dec->sprite_warping_accuracy,(2<<dec->sprite_warping_accuracy), |
865 |
|
dec->sprite_warping_points); |
866 |
|
} |
867 |
|
|
868 |
|
generate_GMCparameters( dec->sprite_warping_points, |
869 |
|
(2 << dec->sprite_warping_accuracy), gmc_warp, |
870 |
|
dec->width, dec->height, &dec->gmc_data); |
871 |
|
|
872 |
|
/* image warping is done block-based in decoder_mbgmc(), now */ |
873 |
|
/* |
874 |
|
generate_GMCimage(&dec->gmc_data, &dec->refn[0], |
875 |
|
mb_width, mb_height, |
876 |
|
dec->edged_width, dec->edged_width/2, |
877 |
|
fcode, dec->quarterpel, 0, |
878 |
|
rounding, dec->mbs, &dec->gmc); |
879 |
|
*/ |
880 |
|
} |
881 |
|
|
882 |
bound = 0; |
bound = 0; |
883 |
|
|
884 |
for (y = 0; y < mb_height; y++) { |
for (y = 0; y < mb_height; y++) { |
886 |
for (x = 0; x < mb_width; x++) { |
for (x = 0; x < mb_width; x++) { |
887 |
MACROBLOCK *mb; |
MACROBLOCK *mb; |
888 |
|
|
889 |
// skip stuffing |
/* skip stuffing */ |
890 |
while (BitstreamShowBits(bs, 10) == 1) |
while (BitstreamShowBits(bs, 10) == 1) |
891 |
BitstreamSkip(bs, 10); |
BitstreamSkip(bs, 10); |
892 |
|
|
901 |
|
|
902 |
DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32)); |
DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32)); |
903 |
|
|
904 |
//if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs))) // not_coded |
/* if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs))) */ /* not_coded */ |
905 |
if (!(BitstreamGetBit(bs))) // not_coded |
if (!(BitstreamGetBit(bs))) /* block _is_ coded */ |
906 |
{ |
{ |
907 |
uint32_t mcbpc; |
uint32_t mcbpc; |
908 |
uint32_t cbpc; |
uint32_t cbpc; |
910 |
uint32_t cbpy; |
uint32_t cbpy; |
911 |
uint32_t cbp; |
uint32_t cbp; |
912 |
uint32_t intra; |
uint32_t intra; |
913 |
int mcsel = 0; // mcsel: '0'=local motion, '1'=GMC |
int mcsel = 0; /* mcsel: '0'=local motion, '1'=GMC */ |
914 |
|
|
915 |
cp_mb++; |
cp_mb++; |
916 |
mcbpc = get_mcbpc_inter(bs); |
mcbpc = get_mcbpc_inter(bs); |
927 |
acpred_flag = BitstreamGetBit(bs); |
acpred_flag = BitstreamGetBit(bs); |
928 |
} |
} |
929 |
|
|
930 |
if (gmc_mv && (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)) |
if (gmc_warp && (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)) |
931 |
{ |
{ |
932 |
mcsel = BitstreamGetBit(bs); |
mcsel = BitstreamGetBit(bs); |
933 |
} |
} |
934 |
|
|
935 |
cbpy = get_cbpy(bs, intra); |
cbpy = get_cbpy(bs, intra); |
936 |
DPRINTF(DPRINTF_MB, "cbpy %i", cbpy); |
DPRINTF(DPRINTF_MB, "cbpy %i mcsel %i ", cbpy,mcsel); |
937 |
|
|
938 |
cbp = (cbpy << 2) | cbpc; |
cbp = (cbpy << 2) | cbpc; |
939 |
|
|
969 |
} |
} |
970 |
} |
} |
971 |
|
|
972 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mcsel) { |
973 |
|
decoder_mbgmc(dec, mb, x, y, fcode, cbp, bs, quant, |
974 |
|
rounding, reduced_resolution); |
975 |
|
continue; |
976 |
|
|
977 |
if (mcsel) |
} else if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
|
{ |
|
|
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); |
|
978 |
|
|
979 |
} else if (dec->interlacing && mb->field_pred) { |
if (dec->interlacing && mb->field_pred) { |
980 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], |
981 |
fcode, bound); |
fcode, bound); |
982 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1], |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1], |
984 |
} else { |
} else { |
985 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], |
986 |
fcode, bound); |
fcode, bound); |
987 |
mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = |
mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
|
mb->mvs[0].x; |
|
|
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
|
|
mb->mvs[0].y; |
|
988 |
} |
} |
989 |
} else if (mb->mode == MODE_INTER4V ) { |
} else if (mb->mode == MODE_INTER4V ) { |
990 |
|
|
992 |
get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode, bound); |
get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode, bound); |
993 |
get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode, bound); |
get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode, bound); |
994 |
get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode, bound); |
get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode, bound); |
995 |
} else // MODE_INTRA, MODE_INTRA_Q |
} else /* MODE_INTRA, MODE_INTRA_Q */ |
996 |
{ |
{ |
997 |
mb->mvs[0].x = 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 = |
998 |
0; |
0; |
1003 |
continue; |
continue; |
1004 |
} |
} |
1005 |
|
|
1006 |
decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbinter(dec, mb, x, y, fcode, cbp, bs, quant, |
1007 |
rounding, reduced_resolution); |
rounding, reduced_resolution); |
1008 |
|
|
1009 |
} |
} |
1010 |
else if (gmc_mv) /* not coded S_VOP macroblock */ |
else if (gmc_warp) /* a not coded S(GMC)-VOP macroblock */ |
1011 |
{ |
{ |
1012 |
mb->mode = MODE_NOT_CODED_GMC; |
mb->mode = MODE_NOT_CODED_GMC; |
1013 |
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); |
|
1014 |
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); |
start_timer(); |
1015 |
decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution); |
|
1016 |
|
decoder_mbgmc(dec, mb, x, y, fcode, 0x00, bs, quant, |
1017 |
|
rounding, reduced_resolution); |
1018 |
|
|
1019 |
|
stop_transfer_timer(); |
1020 |
|
|
1021 |
|
if(dec->out_frm && cp_mb > 0) { |
1022 |
|
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb); |
1023 |
|
cp_mb = 0; |
1024 |
|
} |
1025 |
|
st_mb = x+1; |
1026 |
} |
} |
1027 |
else /* not coded P_VOP macroblock */ |
else /* not coded P_VOP macroblock */ |
1028 |
{ |
{ |
1030 |
|
|
1031 |
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; |
1032 |
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; |
1033 |
// copy macroblock directly from ref to cur |
/* copy macroblock directly from ref to cur */ |
1034 |
|
|
1035 |
start_timer(); |
start_timer(); |
1036 |
|
|
1078 |
} |
} |
1079 |
|
|
1080 |
|
|
1081 |
// add by MinChen <chenm001@163.com> |
/* decode B-frame motion vector */ |
|
// decode B-frame motion vector |
|
1082 |
void |
void |
1083 |
get_b_motion_vector(DECODER * dec, |
get_b_motion_vector(DECODER * dec, |
1084 |
Bitstream * bs, |
Bitstream * bs, |
1122 |
} |
} |
1123 |
|
|
1124 |
|
|
1125 |
// add by MinChen <chenm001@163.com> |
/* decode an B-frame forward & backward inter macroblock */ |
|
// decode an B-frame forward & backward inter macroblock |
|
1126 |
void |
void |
1127 |
decoder_bf_mbinter(DECODER * dec, |
decoder_bf_mbinter(DECODER * dec, |
1128 |
const MACROBLOCK * pMB, |
const MACROBLOCK * pMB, |
1206 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
1207 |
int direction = dec->alternate_vertical_scan ? 2 : 0; |
int direction = dec->alternate_vertical_scan ? 2 : 0; |
1208 |
|
|
1209 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) /* coded */ |
1210 |
{ |
{ |
1211 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); /* clear */ |
1212 |
|
|
1213 |
start_timer(); |
start_timer(); |
1214 |
get_inter_block(bs, &block[i * 64], direction); |
get_inter_block(bs, &block[i * 64], direction); |
1249 |
stop_transfer_timer(); |
stop_transfer_timer(); |
1250 |
} |
} |
1251 |
|
|
1252 |
// add by MinChen <chenm001@163.com> |
/* decode an B-frame direct & inter macroblock */ |
|
// decode an B-frame direct & inter macroblock |
|
1253 |
void |
void |
1254 |
decoder_bf_interpolate_mbinter(DECODER * dec, |
decoder_bf_interpolate_mbinter(DECODER * dec, |
1255 |
IMAGE forward, |
IMAGE forward, |
1446 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
1447 |
int direction = dec->alternate_vertical_scan ? 2 : 0; |
int direction = dec->alternate_vertical_scan ? 2 : 0; |
1448 |
|
|
1449 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) /* coded */ |
1450 |
{ |
{ |
1451 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); /* clear */ |
1452 |
|
|
1453 |
start_timer(); |
start_timer(); |
1454 |
get_inter_block(bs, &block[i * 64], direction); |
get_inter_block(bs, &block[i * 64], direction); |
1490 |
} |
} |
1491 |
|
|
1492 |
|
|
1493 |
// add by MinChen <chenm001@163.com> |
/* for decode B-frame dbquant */ |
|
// for decode B-frame dbquant |
|
1494 |
int32_t __inline |
int32_t __inline |
1495 |
get_dbquant(Bitstream * bs) |
get_dbquant(Bitstream * bs) |
1496 |
{ |
{ |
1497 |
if (!BitstreamGetBit(bs)) // '0' |
if (!BitstreamGetBit(bs)) /* '0' */ |
1498 |
return (0); |
return (0); |
1499 |
else if (!BitstreamGetBit(bs)) // '10' |
else if (!BitstreamGetBit(bs)) /* '10' */ |
1500 |
return (-2); |
return (-2); |
1501 |
else |
else /* '11' */ |
1502 |
return (2); // '11' |
return (2); |
1503 |
} |
} |
1504 |
|
|
1505 |
// add by MinChen <chenm001@163.com> |
/* |
1506 |
// for decode B-frame mb_type |
* For decode B-frame mb_type |
1507 |
// bit ret_value |
* bit ret_value |
1508 |
// 1 0 |
* 1 0 |
1509 |
// 01 1 |
* 01 1 |
1510 |
// 001 2 |
* 001 2 |
1511 |
// 0001 3 |
* 0001 3 |
1512 |
|
*/ |
1513 |
int32_t __inline |
int32_t __inline |
1514 |
get_mbtype(Bitstream * bs) |
get_mbtype(Bitstream * bs) |
1515 |
{ |
{ |
1558 |
#endif |
#endif |
1559 |
|
|
1560 |
for (y = 0; y < dec->mb_height; y++) { |
for (y = 0; y < dec->mb_height; y++) { |
1561 |
// Initialize Pred Motion Vector |
/* Initialize Pred Motion Vector */ |
1562 |
dec->p_fmv = dec->p_bmv = zeromv; |
dec->p_fmv = dec->p_bmv = zeromv; |
1563 |
for (x = 0; x < dec->mb_width; x++) { |
for (x = 0; x < dec->mb_width; x++) { |
1564 |
MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x]; |
MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x]; |
1568 |
mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = |
mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = |
1569 |
mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv; |
mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv; |
1570 |
|
|
1571 |
// skip if the co-located P_VOP macroblock is not coded |
/* |
1572 |
// note: gmc+not_coded isn't skipped |
* skip if the co-located P_VOP macroblock is not coded |
1573 |
|
* if not codec in co-located S_VOP macroblock is _not_ |
1574 |
|
* automatically skipped |
1575 |
|
*/ |
1576 |
|
|
1577 |
if (last_mb->mode == MODE_NOT_CODED) { |
if (last_mb->mode == MODE_NOT_CODED) { |
1578 |
//DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y); |
/* DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y); */ |
1579 |
mb->cbp = 0; |
mb->cbp = 0; |
1580 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1581 |
mb->mb_type = MODE_NOT_CODED; |
mb->mb_type = MODE_NOT_CODED; |
1583 |
#endif |
#endif |
1584 |
mb->mb_type = MODE_FORWARD; |
mb->mb_type = MODE_FORWARD; |
1585 |
mb->quant = last_mb->quant; |
mb->quant = last_mb->quant; |
1586 |
//mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x; |
/* |
1587 |
//mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y; |
mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x; |
1588 |
|
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y; |
1589 |
|
*/ |
1590 |
|
|
1591 |
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, mb->quant, 1); |
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, mb->quant, 1); |
1592 |
continue; |
continue; |
1593 |
} |
} |
1594 |
|
|
1595 |
if (!BitstreamGetBit(bs)) { // modb=='0' |
if (!BitstreamGetBit(bs)) { /* modb=='0' */ |
1596 |
const uint8_t modb2 = BitstreamGetBit(bs); |
const uint8_t modb2 = BitstreamGetBit(bs); |
1597 |
|
|
1598 |
mb->mb_type = get_mbtype(bs); |
mb->mb_type = get_mbtype(bs); |
1599 |
|
|
1600 |
if (!modb2) { // modb=='00' |
if (!modb2) { /* modb=='00' */ |
1601 |
mb->cbp = BitstreamGetBits(bs, 6); |
mb->cbp = BitstreamGetBits(bs, 6); |
1602 |
} else { |
} else { |
1603 |
mb->cbp = 0; |
mb->cbp = 0; |
1618 |
|
|
1619 |
mb->quant = quant; |
mb->quant = quant; |
1620 |
mb->mode = MODE_INTER4V; |
mb->mode = MODE_INTER4V; |
1621 |
//DEBUG1("Switch bm_type=",mb->mb_type); |
/* DEBUG1("Switch bm_type=",mb->mb_type); */ |
1622 |
|
|
1623 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1624 |
BFRAME_DEBUG |
BFRAME_DEBUG |
1647 |
/ TRD |
/ TRD |
1648 |
: mb->mvs[i].y - last_mb->mvs[i].y); |
: mb->mvs[i].y - last_mb->mvs[i].y); |
1649 |
} |
} |
1650 |
//DEBUG("B-frame Direct!\n"); |
/* DEBUG("B-frame Direct!\n"); */ |
1651 |
} |
} |
1652 |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
1653 |
mb, x, y, bs); |
mb, x, y, bs); |
1665 |
|
|
1666 |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
1667 |
mb, x, y, bs); |
mb, x, y, bs); |
1668 |
//DEBUG("B-frame Bidir!\n"); |
/* DEBUG("B-frame Bidir!\n"); */ |
1669 |
break; |
break; |
1670 |
|
|
1671 |
case MODE_BACKWARD: |
case MODE_BACKWARD: |
1675 |
|
|
1676 |
mb->mode = MODE_INTER; |
mb->mode = MODE_INTER; |
1677 |
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 0); |
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 0); |
1678 |
//DEBUG("B-frame Backward!\n"); |
/* DEBUG("B-frame Backward!\n"); */ |
1679 |
break; |
break; |
1680 |
|
|
1681 |
case MODE_FORWARD: |
case MODE_FORWARD: |
1685 |
|
|
1686 |
mb->mode = MODE_INTER; |
mb->mode = MODE_INTER; |
1687 |
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 1); |
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 1); |
1688 |
//DEBUG("B-frame Forward!\n"); |
/* DEBUG("B-frame Forward!\n"); */ |
1689 |
break; |
break; |
1690 |
|
|
1691 |
default: |
default: |
1692 |
DPRINTF(DPRINTF_ERROR,"Not support B-frame mb_type = %i", mb->mb_type); |
DPRINTF(DPRINTF_ERROR,"Not support B-frame mb_type = %i", mb->mb_type); |
1693 |
} |
} |
1694 |
|
} /* End of for */ |
|
} // end of FOR |
|
1695 |
} |
} |
1696 |
|
|
1697 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1698 |
if (!first){ |
if (!first){ |
1699 |
first=1; |
first=1; |
1703 |
#endif |
#endif |
1704 |
} |
} |
1705 |
|
|
1706 |
// swap two MACROBLOCK array |
/* swap two MACROBLOCK array */ |
1707 |
void |
void |
1708 |
mb_swap(MACROBLOCK ** mb1, |
mb_swap(MACROBLOCK ** mb1, |
1709 |
MACROBLOCK ** mb2) |
MACROBLOCK ** mb2) |
1724 |
{ |
{ |
1725 |
/* note: image is stored to tmp */ |
/* note: image is stored to tmp */ |
1726 |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
1727 |
image_deblock_rrv(&dec->tmp, dec->edged_width, |
image_deblock(&dec->tmp, dec->edged_width, |
1728 |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
1729 |
8, frame->general); |
frame->general); |
1730 |
img = &dec->tmp; |
img = &dec->tmp; |
1731 |
} |
} |
1732 |
|
|
1748 |
uint32_t fcode_forward; |
uint32_t fcode_forward; |
1749 |
uint32_t fcode_backward; |
uint32_t fcode_backward; |
1750 |
uint32_t intra_dc_threshold; |
uint32_t intra_dc_threshold; |
1751 |
VECTOR gmc_mv[5]; |
WARPPOINTS gmc_warp; |
1752 |
uint32_t vop_type; |
int vop_type; |
1753 |
int success = 0; |
int success = 0; |
1754 |
int output = 0; |
int output = 0; |
1755 |
int seen_something = 0; |
int seen_something = 0; |
1777 |
{ |
{ |
1778 |
stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING; |
stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING; |
1779 |
stats->data.vop.time_base = (int)dec->time_base; |
stats->data.vop.time_base = (int)dec->time_base; |
1780 |
stats->data.vop.time_increment = 0; //XXX: todo |
stats->data.vop.time_increment = 0; /* XXX: todo */ |
1781 |
} |
} |
1782 |
|
|
1783 |
emms(); |
emms(); |
1788 |
|
|
1789 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1790 |
|
|
1791 |
// XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's |
/* XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's */ |
1792 |
if(dec->low_delay_default && frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f) |
if(dec->low_delay_default && frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f) |
1793 |
{ |
{ |
1794 |
if (stats) |
if (stats) |
1803 |
repeat: |
repeat: |
1804 |
|
|
1805 |
vop_type = BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
vop_type = BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
1806 |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv); |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp); |
1807 |
|
|
1808 |
DPRINTF(DPRINTF_HEADER, "vop_type=%i, packed=%i, time=%i, time_pp=%i, time_bp=%i", |
DPRINTF(DPRINTF_HEADER, "vop_type=%i, packed=%i, time=%lli, time_pp=%i, time_bp=%i", |
1809 |
vop_type, dec->packed_mode, dec->time, dec->time_pp, dec->time_bp); |
vop_type, dec->packed_mode, dec->time, dec->time_pp, dec->time_bp); |
1810 |
|
|
1811 |
if (vop_type == - 1) |
if (vop_type == - 1) |
1838 |
goto repeat; |
goto repeat; |
1839 |
} |
} |
1840 |
|
|
1841 |
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 */ |
1842 |
|
|
1843 |
|
|
1844 |
/* packed_mode: special-N_VOP treament */ |
/* packed_mode: special-N_VOP treament */ |
1864 |
break; |
break; |
1865 |
case S_VOP : |
case S_VOP : |
1866 |
decoder_pframe(dec, &bs, rounding, reduced_resolution, quant, |
decoder_pframe(dec, &bs, rounding, reduced_resolution, quant, |
1867 |
fcode_forward, intra_dc_threshold, gmc_mv); |
fcode_forward, intra_dc_threshold, &gmc_warp); |
1868 |
break; |
break; |
1869 |
case N_VOP : |
case N_VOP : |
1870 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
1968 |
{ |
{ |
1969 |
stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING; |
stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING; |
1970 |
stats->data.vop.time_base = (int)dec->time_base; |
stats->data.vop.time_base = (int)dec->time_base; |
1971 |
stats->data.vop.time_increment = 0; //XXX: todo |
stats->data.vop.time_increment = 0; /* XXX: todo */ |
1972 |
} |
} |
1973 |
|
|
1974 |
emms(); |
emms(); |