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 /= 2; |
366 |
|
uv_dy /= 2; |
367 |
|
} |
368 |
|
|
369 |
|
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
370 |
|
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
371 |
|
|
372 |
|
start_timer(); |
373 |
|
if(dec->quarterpel) { |
374 |
|
interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
375 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
376 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
377 |
|
} |
378 |
|
else { |
379 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, |
380 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
381 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
382 |
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
383 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
384 |
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
385 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
386 |
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
387 |
|
} |
388 |
|
|
389 |
|
interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos, |
390 |
|
uv_dx, uv_dy, stride2, rounding); |
391 |
|
interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos, |
392 |
|
uv_dx, uv_dy, stride2, rounding); |
393 |
|
stop_comp_timer(); |
394 |
|
|
395 |
} else { |
} else { |
396 |
int sum; |
int sum; |
397 |
|
|
398 |
|
if(dec->quarterpel) |
399 |
|
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
400 |
|
else |
401 |
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)); |
|
402 |
|
|
403 |
|
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
404 |
|
|
405 |
|
if(dec->quarterpel) |
406 |
|
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
407 |
|
else |
408 |
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; |
409 |
uv_dy = |
|
410 |
(sum == |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
|
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
|
(ABS(sum) / 16) * 2)); |
|
|
} |
|
411 |
|
|
412 |
start_timer(); |
start_timer(); |
413 |
|
if(dec->quarterpel) { |
414 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
415 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
416 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
417 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
418 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
419 |
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
420 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
421 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
422 |
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
423 |
|
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
424 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
425 |
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
426 |
|
} |
427 |
|
else { |
428 |
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, |
429 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
430 |
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, |
431 |
16 * y_pos, pMB->mvs[1].x, pMB->mvs[1].y, stride, |
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
432 |
rounding); |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
433 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos, |
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
434 |
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, |
435 |
rounding); |
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
436 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16 * x_pos + 8, |
} |
437 |
16 * y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, |
|
|
rounding); |
|
438 |
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, |
439 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
440 |
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, |
441 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
442 |
stop_comp_timer(); |
stop_comp_timer(); |
443 |
|
} |
444 |
|
|
445 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
446 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
447 |
|
|
448 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
449 |
{ |
{ |
450 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
451 |
|
|
452 |
start_timer(); |
start_timer(); |
453 |
get_inter_block(bs, &block[i * 64]); |
get_inter_block(bs, &block[i * 64], direction); |
454 |
stop_coding_timer(); |
stop_coding_timer(); |
455 |
|
|
456 |
start_timer(); |
start_timer(); |
623 |
|
|
624 |
start_timer(); |
start_timer(); |
625 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
626 |
dec->width, dec->height, dec->interlacing); |
dec->width, dec->height); |
627 |
stop_edges_timer(); |
stop_edges_timer(); |
628 |
|
|
629 |
bound = 0; |
bound = 0; |
691 |
mb->quant = quant; |
mb->quant = quant; |
692 |
|
|
693 |
if (dec->interlacing) { |
if (dec->interlacing) { |
694 |
|
if (cbp || intra) { |
695 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
696 |
DEBUG1("decp: field_dct: ", mb->field_dct); |
DEBUG1("decp: field_dct: ", mb->field_dct); |
697 |
|
} |
698 |
|
|
699 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
700 |
mb->field_pred = BitstreamGetBit(bs); |
mb->field_pred = BitstreamGetBit(bs); |
723 |
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
724 |
mb->mvs[0].y; |
mb->mvs[0].y; |
725 |
} |
} |
726 |
} else if (mb->mode == |
} else if (mb->mode == MODE_INTER4V ) { |
727 |
MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */ ) { |
|
728 |
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); |
729 |
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); |
730 |
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); |
744 |
rounding); |
rounding); |
745 |
} else // not coded |
} else // not coded |
746 |
{ |
{ |
|
//DEBUG2("P-frame MB at (X,Y)=",x,y); |
|
747 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED; |
748 |
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; |
749 |
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; |
913 |
stop_comp_timer(); |
stop_comp_timer(); |
914 |
|
|
915 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
916 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
917 |
|
|
918 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
919 |
{ |
{ |
920 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
921 |
|
|
922 |
start_timer(); |
start_timer(); |
923 |
get_inter_block(bs, &block[i * 64]); |
get_inter_block(bs, &block[i * 64], direction); |
924 |
stop_coding_timer(); |
stop_coding_timer(); |
925 |
|
|
926 |
start_timer(); |
start_timer(); |
958 |
stop_transfer_timer(); |
stop_transfer_timer(); |
959 |
} |
} |
960 |
|
|
|
|
|
961 |
// add by MinChen <chenm001@163.com> |
// add by MinChen <chenm001@163.com> |
962 |
// decode an B-frame direct & inter macroblock |
// decode an B-frame direct & inter macroblock |
963 |
void |
void |
1065 |
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, |
1066 |
b_uv_dx, b_uv_dy, stride2, 0); |
b_uv_dx, b_uv_dy, stride2, 0); |
1067 |
|
|
1068 |
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, |
1069 |
stride); |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1070 |
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, |
1071 |
stride); |
stride, 0); |
1072 |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos, 16 * y_pos + 8, |
|
1073 |
stride); |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1074 |
interpolate8x8_c(dec->cur.y, dec->refn[2].y, 16 * x_pos + 8, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1075 |
16 * y_pos + 8, stride); |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1076 |
interpolate8x8_c(dec->cur.u, dec->refn[2].u, 8 * x_pos, 8 * y_pos, |
stride, 0); |
1077 |
stride2); |
|
1078 |
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, |
1079 |
stride2); |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1080 |
|
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1081 |
|
stride, 0); |
1082 |
|
|
1083 |
|
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1084 |
|
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1085 |
|
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1086 |
|
stride, 0); |
1087 |
|
|
1088 |
|
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1089 |
|
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1090 |
|
dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos, |
1091 |
|
stride2, 0); |
1092 |
|
|
1093 |
|
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1094 |
|
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1095 |
|
dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos, |
1096 |
|
stride2, 0); |
1097 |
|
|
1098 |
stop_comp_timer(); |
stop_comp_timer(); |
1099 |
|
|
1100 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
1101 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
1102 |
|
|
1103 |
if (cbp & (1 << (5 - i))) // coded |
if (cbp & (1 << (5 - i))) // coded |
1104 |
{ |
{ |
1105 |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); // clear |
1106 |
|
|
1107 |
start_timer(); |
start_timer(); |
1108 |
get_inter_block(bs, &block[i * 64]); |
get_inter_block(bs, &block[i * 64], direction); |
1109 |
stop_coding_timer(); |
stop_coding_timer(); |
1110 |
|
|
1111 |
start_timer(); |
start_timer(); |
1200 |
|
|
1201 |
start_timer(); |
start_timer(); |
1202 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
1203 |
dec->width, dec->height, dec->interlacing); |
dec->width, dec->height); |
1204 |
image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, |
1205 |
dec->width, dec->height, dec->interlacing); |
dec->width, dec->height); |
1206 |
stop_edges_timer(); |
stop_edges_timer(); |
1207 |
|
|
1208 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1270 |
#ifdef BFRAMES_DEC_DEBUG |
#ifdef BFRAMES_DEC_DEBUG |
1271 |
BFRAME_DEBUG |
BFRAME_DEBUG |
1272 |
#endif |
#endif |
1273 |
|
|
1274 |
switch (mb->mb_type) { |
switch (mb->mb_type) { |
1275 |
case MODE_DIRECT: |
case MODE_DIRECT: |
1276 |
get_b_motion_vector(dec, bs, x, y, &mv, 1, zeromv); |
get_b_motion_vector(dec, bs, x, y, &mv, 1, zeromv); |
1277 |
|
|
1278 |
case MODE_DIRECT_NONE_MV: |
case MODE_DIRECT_NONE_MV: |
1279 |
{ // Because this file is a C file not C++ so I use '{' to define var |
{ |
1280 |
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; |
1281 |
int i; |
int i; |
1282 |
|
|
1336 |
break; |
break; |
1337 |
|
|
1338 |
default: |
default: |
1339 |
//DEBUG1("Not support B-frame mb_type =", mb->mb_type); |
DEBUG1("Not support B-frame mb_type =", mb->mb_type); |
|
; |
|
1340 |
} |
} |
1341 |
|
|
1342 |
} // end of FOR |
} // end of FOR |
1380 |
|
|
1381 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1382 |
|
|
1383 |
|
if(BitstreamShowBits(&bs, 8) == 0x7f) |
1384 |
|
return XVID_ERR_OK; |
1385 |
|
|
1386 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
1387 |
// for support B-frame to reference last 2 frame |
// for support B-frame to reference last 2 frame |
1388 |
dec->frames++; |
dec->frames++; |
1424 |
case N_VOP: // vop not coded |
case N_VOP: // vop not coded |
1425 |
// 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 |
1426 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
1427 |
|
#ifdef BFRAMES_DEC |
1428 |
|
DEBUG1("N_VOP Time=", dec->time); |
1429 |
|
#endif |
1430 |
break; |
break; |
1431 |
|
|
1432 |
default: |
default: |
1443 |
|
|
1444 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1445 |
// test if no B_VOP |
// test if no B_VOP |
1446 |
if (dec->low_delay) { |
if (dec->low_delay || dec->frames == 0) { |
1447 |
#endif |
#endif |
1448 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
1449 |
frame->image, frame->stride, frame->colorspace); |
frame->image, frame->stride, frame->colorspace); |
1450 |
|
|
1451 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1452 |
} else { |
} else { |
1453 |
if (dec->frames >= 0) { |
if (dec->frames >= 1) { |
1454 |
start_timer(); |
start_timer(); |
1455 |
if ((vop_type == I_VOP || vop_type == P_VOP)) { |
if ((vop_type == I_VOP || vop_type == P_VOP)) { |
1456 |
image_output(&dec->refn[0], dec->width, dec->height, |
image_output(&dec->refn[0], dec->width, dec->height, |