55 |
* 22.12.2001 lock based interpolation |
* 22.12.2001 lock based interpolation |
56 |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
57 |
* |
* |
58 |
* $Id: decoder.c,v 1.31 2002-07-18 00:07:04 chenm001 Exp $ |
* $Id: decoder.c,v 1.37.2.6 2002-10-30 18:01:48 Isibaar Exp $ |
59 |
* |
* |
60 |
*************************************************************************/ |
*************************************************************************/ |
61 |
|
|
84 |
#include "prediction/mbprediction.h" |
#include "prediction/mbprediction.h" |
85 |
#include "utils/timer.h" |
#include "utils/timer.h" |
86 |
#include "utils/emms.h" |
#include "utils/emms.h" |
87 |
|
#include "motion/motion.h" |
88 |
|
|
89 |
#include "image/image.h" |
#include "image/image.h" |
90 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
137 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
138 |
} |
} |
139 |
|
|
140 |
|
if (image_create(&dec->refh, dec->edged_width, dec->edged_height)) { |
141 |
|
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
142 |
|
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
143 |
|
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
144 |
|
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
145 |
|
xvid_free(dec); |
146 |
|
return XVID_ERR_MEMORY; |
147 |
|
} |
148 |
|
|
149 |
dec->mbs = |
dec->mbs = |
150 |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height, |
151 |
CACHE_LINE); |
CACHE_LINE); |
154 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
155 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
156 |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
157 |
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
158 |
xvid_free(dec); |
xvid_free(dec); |
159 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
160 |
} |
} |
172 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
173 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
174 |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
175 |
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
176 |
xvid_free(dec); |
xvid_free(dec); |
177 |
return XVID_ERR_MEMORY; |
return XVID_ERR_MEMORY; |
178 |
} |
} |
198 |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height); |
199 |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height); |
200 |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
image_destroy(&dec->refn[2], dec->edged_width, dec->edged_height); |
201 |
|
image_destroy(&dec->refh, dec->edged_width, dec->edged_height); |
202 |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
image_destroy(&dec->cur, dec->edged_width, dec->edged_height); |
203 |
xvid_free(dec); |
xvid_free(dec); |
204 |
|
|
281 |
start_timer(); |
start_timer(); |
282 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
283 |
{ |
{ |
284 |
get_intra_block(bs, &block[i * 64], pMB->acpred_directions[i], |
int direction = dec->alternate_vertical_scan ? |
285 |
start_coeff); |
2 : pMB->acpred_directions[i]; |
286 |
|
|
287 |
|
get_intra_block(bs, &block[i * 64], direction, start_coeff); |
288 |
} |
} |
289 |
stop_coding_timer(); |
stop_coding_timer(); |
290 |
|
|
326 |
|
|
327 |
#define SIGN(X) (((X)>0)?1:-1) |
#define SIGN(X) (((X)>0)?1:-1) |
328 |
#define ABS(X) (((X)>0)?(X):-(X)) |
#define ABS(X) (((X)>0)?(X):-(X)) |
|
static const uint32_t roundtab[16] = |
|
|
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; |
|
|
|
|
329 |
|
|
330 |
// decode an inter macroblock |
// decode an inter macroblock |
331 |
|
|
360 |
uv_dx = pMB->mvs[0].x; |
uv_dx = pMB->mvs[0].x; |
361 |
uv_dy = pMB->mvs[0].y; |
uv_dy = pMB->mvs[0].y; |
362 |
|
|
363 |
uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
if (dec->quarterpel) |
364 |
uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
{ |
365 |
|
uv_dx = (uv_dx >> 2) + roundtab_78[uv_dx & 0x7]; |
366 |
|
uv_dy = (uv_dy >> 2) + roundtab_78[uv_dy & 0x7]; |
367 |
|
} |
368 |
|
else { |
369 |
|
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
370 |
|
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
371 |
|
} |
372 |
|
|
373 |
|
start_timer(); |
374 |
|
if(dec->quarterpel) { |
375 |
|
interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
376 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
377 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
378 |
|
} |
379 |
|
else { |
380 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, |
381 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
382 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
383 |
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
384 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
385 |
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
386 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
387 |
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
388 |
|
} |
389 |
|
|
390 |
|
interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, |
391 |
|
uv_dx, uv_dy, stride2, rounding); |
392 |
|
interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, |
393 |
|
uv_dx, uv_dy, stride2, rounding); |
394 |
|
stop_comp_timer(); |
395 |
|
|
396 |
} else { |
} else { |
397 |
int sum; |
int sum; |
398 |
|
|
399 |
|
if(dec->quarterpel) |
400 |
|
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
401 |
|
else |
402 |
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
|
uv_dx = |
|
|
(sum == |
|
|
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
|
(ABS(sum) / 16) * 2)); |
|
403 |
|
|
404 |
|
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
405 |
|
|
406 |
|
if(dec->quarterpel) |
407 |
|
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
408 |
|
else |
409 |
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; |
410 |
uv_dy = |
|
411 |
(sum == |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
|
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
|
(ABS(sum) / 16) * 2)); |
|
|
} |
|
412 |
|
|
413 |
start_timer(); |
start_timer(); |
414 |
|
if(dec->quarterpel) { |
415 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
416 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
417 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
418 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
419 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
420 |
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
421 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
422 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
423 |
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
424 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
425 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
426 |
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
427 |
|
} |
428 |
|
else { |
429 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos, 16 * y_pos, |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos, 16 * y_pos, |
430 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
431 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos + 8, |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
432 |
16 * y_pos, pMB->mvs[1].x, pMB->mvs[1].y, stride, |
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
433 |
rounding); |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
434 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos, |
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
435 |
16 * y_pos + 8, pMB->mvs[2].x, pMB->mvs[2].y, stride, |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
436 |
rounding); |
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
437 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos + 8, |
} |
438 |
16 * y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, |
|
|
rounding); |
|
439 |
interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, |
interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, |
440 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
441 |
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, |
442 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
443 |
stop_comp_timer(); |
stop_comp_timer(); |
444 |
|
} |
445 |
|
|
446 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
447 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
448 |
|
|
449 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
450 |
{ |
{ |
451 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
452 |
|
|
453 |
start_timer(); |
start_timer(); |
454 |
get_inter_block(bs, &block[i * 64]); |
get_inter_block(bs, &block[i * 64], direction); |
455 |
stop_coding_timer(); |
stop_coding_timer(); |
456 |
|
|
457 |
start_timer(); |
start_timer(); |
554 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
555 |
intra_dc_threshold, bound); |
intra_dc_threshold, bound); |
556 |
} |
} |
557 |
|
if(dec->out_frm) |
558 |
|
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,dec->mb_width); |
559 |
|
|
560 |
} |
} |
561 |
|
|
562 |
} |
} |
620 |
|
|
621 |
uint32_t x, y; |
uint32_t x, y; |
622 |
uint32_t bound; |
uint32_t bound; |
623 |
|
int cp_mb, st_mb; |
624 |
|
|
625 |
start_timer(); |
start_timer(); |
626 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
627 |
dec->width, dec->height, dec->interlacing); |
dec->width, dec->height); |
628 |
stop_edges_timer(); |
stop_edges_timer(); |
629 |
|
|
630 |
bound = 0; |
bound = 0; |
631 |
|
|
632 |
for (y = 0; y < dec->mb_height; y++) { |
for (y = 0; y < dec->mb_height; y++) { |
633 |
|
cp_mb = st_mb = 0; |
634 |
for (x = 0; x < dec->mb_width; x++) { |
for (x = 0; x < dec->mb_width; x++) { |
635 |
MACROBLOCK *mb; |
MACROBLOCK *mb; |
636 |
|
|
658 |
uint32_t cbp; |
uint32_t cbp; |
659 |
uint32_t intra; |
uint32_t intra; |
660 |
|
|
661 |
|
cp_mb++; |
662 |
mcbpc = get_mcbpc_inter(bs); |
mcbpc = get_mcbpc_inter(bs); |
663 |
mb->mode = mcbpc & 7; |
mb->mode = mcbpc & 7; |
664 |
cbpc = (mcbpc >> 4); |
cbpc = (mcbpc >> 4); |
692 |
mb->quant = quant; |
mb->quant = quant; |
693 |
|
|
694 |
if (dec->interlacing) { |
if (dec->interlacing) { |
695 |
|
if (cbp || intra) { |
696 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
697 |
DEBUG1("decp: field_dct: ", mb->field_dct); |
DEBUG1("decp: field_dct: ", mb->field_dct); |
698 |
|
} |
699 |
|
|
700 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
701 |
mb->field_pred = BitstreamGetBit(bs); |
mb->field_pred = BitstreamGetBit(bs); |
724 |
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
725 |
mb->mvs[0].y; |
mb->mvs[0].y; |
726 |
} |
} |
727 |
} else if (mb->mode == |
} else if (mb->mode == MODE_INTER4V ) { |
728 |
MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */ ) { |
|
729 |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode, bound); |
get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode, bound); |
730 |
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); |
731 |
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); |
745 |
rounding); |
rounding); |
746 |
} else // not coded |
} else // not coded |
747 |
{ |
{ |
|
//DEBUG2("P-frame MB at (X,Y)=",x,y); |
|
748 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED; |
749 |
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; |
750 |
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; |
786 |
dec->refn[0].v + |
dec->refn[0].v + |
787 |
(8 * y) * dec->edged_width / 2 + (8 * x), |
(8 * y) * dec->edged_width / 2 + (8 * x), |
788 |
dec->edged_width / 2); |
dec->edged_width / 2); |
|
|
|
789 |
stop_transfer_timer(); |
stop_transfer_timer(); |
790 |
|
if(dec->out_frm && cp_mb > 0) { |
791 |
|
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb); |
792 |
|
cp_mb = 0; |
793 |
|
} |
794 |
|
st_mb = x+1; |
795 |
} |
} |
796 |
} |
} |
797 |
|
if(dec->out_frm && cp_mb > 0) |
798 |
|
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb); |
799 |
} |
} |
800 |
} |
} |
801 |
|
|
914 |
stop_comp_timer(); |
stop_comp_timer(); |
915 |
|
|
916 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
917 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
918 |
|
|
919 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
920 |
{ |
{ |
921 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
922 |
|
|
923 |
start_timer(); |
start_timer(); |
924 |
get_inter_block(bs, &block[i * 64]); |
get_inter_block(bs, &block[i * 64], direction); |
925 |
stop_coding_timer(); |
stop_coding_timer(); |
926 |
|
|
927 |
start_timer(); |
start_timer(); |
959 |
stop_transfer_timer(); |
stop_transfer_timer(); |
960 |
} |
} |
961 |
|
|
|
|
|
962 |
// add by MinChen <chenm001@163.com> |
// add by MinChen <chenm001@163.com> |
963 |
// decode an B-frame direct & inter macroblock |
// decode an B-frame direct & inter macroblock |
964 |
void |
void |
1066 |
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, |
1067 |
b_uv_dx, b_uv_dy, stride2, 0); |
b_uv_dx, b_uv_dy, stride2, 0); |
1068 |
|
|
1069 |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos, |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1070 |
stride); |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1071 |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, 16 * y_pos, |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos, |
1072 |
stride); |
stride, 0); |
1073 |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos + 8, |
|
1074 |
stride); |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1075 |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1076 |
16 * y_pos + 8, stride); |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1077 |
interpolate8x8_c(dec->cur.u, dec->refn[2].u, 8 * x_pos, 8 * y_pos, |
stride, 0); |
1078 |
stride2); |
|
1079 |
interpolate8x8_c(dec->cur.v, dec->refn[2].v, 8 * x_pos, 8 * y_pos, |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1080 |
stride2); |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1081 |
|
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1082 |
|
stride, 0); |
1083 |
|
|
1084 |
|
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1085 |
|
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1086 |
|
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1087 |
|
stride, 0); |
1088 |
|
|
1089 |
|
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1090 |
|
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1091 |
|
dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos, |
1092 |
|
stride2, 0); |
1093 |
|
|
1094 |
|
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1095 |
|
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1096 |
|
dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos, |
1097 |
|
stride2, 0); |
1098 |
|
|
1099 |
stop_comp_timer(); |
stop_comp_timer(); |
1100 |
|
|
1101 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
1102 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
1103 |
|
|
1104 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
1105 |
{ |
{ |
1106 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
1107 |
|
|
1108 |
start_timer(); |
start_timer(); |
1109 |
get_inter_block(bs, &block[i * 64]); |
get_inter_block(bs, &block[i * 64], direction); |
1110 |
stop_coding_timer(); |
stop_coding_timer(); |
1111 |
|
|
1112 |
start_timer(); |
start_timer(); |
1201 |
|
|
1202 |
start_timer(); |
start_timer(); |
1203 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
1204 |
dec->width, dec->height, dec->interlacing); |
dec->width, dec->height); |
1205 |
image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, |
1206 |
dec->width, dec->height, dec->interlacing); |
dec->width, dec->height); |
1207 |
stop_edges_timer(); |
stop_edges_timer(); |
1208 |
|
|
1209 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1271 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1272 |
BFRAME_DEBUG |
BFRAME_DEBUG |
1273 |
#endif |
#endif |
1274 |
|
|
1275 |
switch (mb->mb_type) { |
switch (mb->mb_type) { |
1276 |
case MODE_DIRECT: |
case MODE_DIRECT: |
1277 |
get_b_motion_vector(dec, bs, x, y, &mv, 1, zeromv); |
get_b_motion_vector(dec, bs, x, y, &mv, 1, zeromv); |
1278 |
|
|
1279 |
case MODE_DIRECT_NONE_MV: |
case MODE_DIRECT_NONE_MV: |
1280 |
{ // Because this file is a C file not C++ so I use '{' to define var |
{ |
1281 |
const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp; |
const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp; |
1282 |
int i; |
int i; |
1283 |
|
|
1337 |
break; |
break; |
1338 |
|
|
1339 |
default: |
default: |
1340 |
//DEBUG1("Not support B-frame mb_type =", mb->mb_type); |
DEBUG1("Not support B-frame mb_type =", mb->mb_type); |
|
; |
|
1341 |
} |
} |
1342 |
|
|
1343 |
} // end of FOR |
} // end of FOR |
1377 |
|
|
1378 |
start_global_timer(); |
start_global_timer(); |
1379 |
|
|
1380 |
|
dec->out_frm = (frame->colorspace == XVID_CSP_EXTERN) ? frame->image : NULL; |
1381 |
|
|
1382 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1383 |
|
|
1384 |
|
if(BitstreamShowBits(&bs, 8) == 0x7f) |
1385 |
|
return XVID_ERR_OK; |
1386 |
|
|
1387 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
1388 |
// for support B-frame to reference last 2 frame |
// for support B-frame to reference last 2 frame |
1389 |
dec->frames++; |
dec->frames++; |
1425 |
case N_VOP: // vop not coded |
case N_VOP: // vop not coded |
1426 |
// 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 |
1427 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
1428 |
|
#ifdef BFRAMES_DEC |
1429 |
|
DEBUG1("N_VOP Time=", dec->time); |
1430 |
|
#endif |
1431 |
break; |
break; |
1432 |
|
|
1433 |
default: |
default: |
1444 |
|
|
1445 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1446 |
// test if no B_VOP |
// test if no B_VOP |
1447 |
if (dec->low_delay) { |
if (dec->low_delay || dec->frames == 0) { |
1448 |
#endif |
#endif |
1449 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
1450 |
frame->image, frame->stride, frame->colorspace); |
frame->image, frame->stride, frame->colorspace); |
1451 |
|
|
1452 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1453 |
} else { |
} else { |
1454 |
if (dec->frames >= 0) { |
if (dec->frames >= 1) { |
1455 |
start_timer(); |
start_timer(); |
1456 |
if ((vop_type == I_VOP || vop_type == P_VOP)) { |
if ((vop_type == I_VOP || vop_type == P_VOP)) { |
1457 |
image_output(&dec->refn[0], dec->width, dec->height, |
image_output(&dec->refn[0], dec->width, dec->height, |