46 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
47 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
48 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
|
#include "image/reduced.h" |
|
49 |
#include "image/font.h" |
#include "image/font.h" |
50 |
#include "image/qpel.h" |
#include "image/qpel.h" |
51 |
|
|
270 |
Bitstream * bs, |
Bitstream * bs, |
271 |
const uint32_t quant, |
const uint32_t quant, |
272 |
const uint32_t intra_dc_threshold, |
const uint32_t intra_dc_threshold, |
273 |
const unsigned int bound, |
const unsigned int bound) |
|
const int reduced_resolution) |
|
274 |
{ |
{ |
275 |
|
|
276 |
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
283 |
uint32_t iQuant = pMB->quant; |
uint32_t iQuant = pMB->quant; |
284 |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
285 |
|
|
|
if (reduced_resolution) { |
|
|
pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5); |
|
|
pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4); |
|
|
pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4); |
|
|
}else{ |
|
286 |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
287 |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
288 |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
|
} |
|
289 |
|
|
290 |
memset(block, 0, 6 * 64 * sizeof(int16_t)); /* clear */ |
memset(block, 0, 6 * 64 * sizeof(int16_t)); /* clear */ |
291 |
|
|
355 |
} |
} |
356 |
|
|
357 |
start_timer(); |
start_timer(); |
|
|
|
|
if (reduced_resolution) |
|
|
{ |
|
|
next_block*=2; |
|
|
copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
|
|
copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); |
|
|
copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride); |
|
|
copy_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride); |
|
|
copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2); |
|
|
copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2); |
|
|
}else{ |
|
358 |
transfer_16to8copy(pY_Cur, &data[0 * 64], stride); |
transfer_16to8copy(pY_Cur, &data[0 * 64], stride); |
359 |
transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride); |
transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride); |
360 |
transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride); |
transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride); |
361 |
transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride); |
transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride); |
362 |
transfer_16to8copy(pU_Cur, &data[4 * 64], stride2); |
transfer_16to8copy(pU_Cur, &data[4 * 64], stride2); |
363 |
transfer_16to8copy(pV_Cur, &data[5 * 64], stride2); |
transfer_16to8copy(pV_Cur, &data[5 * 64], stride2); |
|
} |
|
364 |
stop_transfer_timer(); |
stop_transfer_timer(); |
365 |
} |
} |
366 |
|
|
371 |
uint8_t * pY_Cur, |
uint8_t * pY_Cur, |
372 |
uint8_t * pU_Cur, |
uint8_t * pU_Cur, |
373 |
uint8_t * pV_Cur, |
uint8_t * pV_Cur, |
|
int reduced_resolution, |
|
374 |
const MACROBLOCK * pMB) |
const MACROBLOCK * pMB) |
375 |
{ |
{ |
376 |
DECLARE_ALIGNED_MATRIX(data, 1, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(data, 1, 64, int16_t, CACHE_LINE); |
377 |
|
|
378 |
int stride = dec->edged_width; |
int stride = dec->edged_width; |
379 |
int next_block = stride * (reduced_resolution ? 16 : 8); |
int next_block = stride * 8; |
380 |
int i; |
int i; |
381 |
const uint32_t iQuant = pMB->quant; |
const uint32_t iQuant = pMB->quant; |
382 |
const int direction = dec->alternate_vertical_scan ? 2 : 0; |
const int direction = dec->alternate_vertical_scan ? 2 : 0; |
395 |
? (get_inter_block_function_t)get_inter_block_h263 |
? (get_inter_block_function_t)get_inter_block_h263 |
396 |
: (get_inter_block_function_t)get_inter_block_mpeg; |
: (get_inter_block_function_t)get_inter_block_mpeg; |
397 |
|
|
|
const add_residual_function_t add_residual = (reduced_resolution) |
|
|
? (add_residual_function_t)add_upsampled_8x8_16to8 |
|
|
: (add_residual_function_t)transfer_16to8add; |
|
|
|
|
398 |
uint8_t *dst[6]; |
uint8_t *dst[6]; |
399 |
int strides[6]; |
int strides[6]; |
400 |
|
|
404 |
stride *= 2; |
stride *= 2; |
405 |
} |
} |
406 |
|
|
|
reduced_resolution = !!reduced_resolution; |
|
407 |
dst[0] = pY_Cur; |
dst[0] = pY_Cur; |
408 |
dst[2] = pY_Cur + next_block; |
dst[2] = pY_Cur + next_block; |
409 |
dst[1] = dst[0] + (8<<reduced_resolution); |
dst[1] = dst[0] + 8; |
410 |
dst[3] = dst[2] + (8<<reduced_resolution); |
dst[3] = dst[2] + 8; |
411 |
dst[4] = pU_Cur; |
dst[4] = pU_Cur; |
412 |
dst[5] = pV_Cur; |
dst[5] = pV_Cur; |
413 |
strides[0] = strides[1] = strides[2] = strides[3] = stride; |
strides[0] = strides[1] = strides[2] = strides[3] = stride; |
433 |
|
|
434 |
/* Add this residual to the predicted block */ |
/* Add this residual to the predicted block */ |
435 |
start_timer(); |
start_timer(); |
436 |
add_residual(dst[i], &data[0], strides[i]); |
transfer_16to8add(dst[i], &data[0], strides[i]); |
437 |
stop_transfer_timer(); |
stop_transfer_timer(); |
438 |
} |
} |
439 |
} |
} |
440 |
} |
} |
441 |
|
|
442 |
|
static void __inline |
443 |
|
validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec) |
444 |
|
{ |
445 |
|
/* clip a vector to valid range |
446 |
|
prevents crashes if bitstream is broken |
447 |
|
*/ |
448 |
|
int shift = 5 + dec->quarterpel; |
449 |
|
int xborder_high = (int)(dec->mb_width - x_pos) << shift; |
450 |
|
int xborder_low = (-(int)x_pos-1) << shift; |
451 |
|
int yborder_high = (int)(dec->mb_height - y_pos) << shift; |
452 |
|
int yborder_low = (-(int)y_pos-1) << shift; |
453 |
|
|
454 |
|
#define CHECK_MV(mv) \ |
455 |
|
do { \ |
456 |
|
if ((mv).x > xborder_high) { \ |
457 |
|
DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", (mv).x, xborder_high, x_pos, y_pos); \ |
458 |
|
(mv).x = xborder_high; \ |
459 |
|
} else if ((mv).x < xborder_low) { \ |
460 |
|
DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", (mv).x, xborder_low, x_pos, y_pos); \ |
461 |
|
(mv).x = xborder_low; \ |
462 |
|
} \ |
463 |
|
if ((mv).y > yborder_high) { \ |
464 |
|
DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", (mv).y, yborder_high, x_pos, y_pos); \ |
465 |
|
(mv).y = yborder_high; \ |
466 |
|
} else if ((mv).y < yborder_low) { \ |
467 |
|
DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", (mv).y, yborder_low, x_pos, y_pos); \ |
468 |
|
(mv).y = yborder_low; \ |
469 |
|
} \ |
470 |
|
} while (0) |
471 |
|
|
472 |
|
CHECK_MV(mv[0]); |
473 |
|
CHECK_MV(mv[1]); |
474 |
|
CHECK_MV(mv[2]); |
475 |
|
CHECK_MV(mv[3]); |
476 |
|
} |
477 |
|
|
478 |
/* decode an inter macroblock */ |
/* decode an inter macroblock */ |
479 |
static void |
static void |
480 |
decoder_mbinter(DECODER * dec, |
decoder_mbinter(DECODER * dec, |
484 |
const uint32_t cbp, |
const uint32_t cbp, |
485 |
Bitstream * bs, |
Bitstream * bs, |
486 |
const uint32_t rounding, |
const uint32_t rounding, |
|
const int reduced_resolution, |
|
487 |
const int ref) |
const int ref) |
488 |
{ |
{ |
489 |
uint32_t stride = dec->edged_width; |
uint32_t stride = dec->edged_width; |
495 |
int uv_dx, uv_dy; |
int uv_dx, uv_dy; |
496 |
VECTOR mv[4]; /* local copy of mvs */ |
VECTOR mv[4]; /* local copy of mvs */ |
497 |
|
|
|
if (reduced_resolution) { |
|
|
pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5); |
|
|
pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4); |
|
|
pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4); |
|
|
for (i = 0; i < 4; i++) { |
|
|
mv[i].x = RRV_MV_SCALEUP(pMB->mvs[i].x); |
|
|
mv[i].y = RRV_MV_SCALEUP(pMB->mvs[i].y); |
|
|
} |
|
|
} else { |
|
498 |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
499 |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
500 |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
501 |
for (i = 0; i < 4; i++) |
for (i = 0; i < 4; i++) |
502 |
mv[i] = pMB->mvs[i]; |
mv[i] = pMB->mvs[i]; |
|
} |
|
|
|
|
|
for (i = 0; i < 4; i++) { |
|
|
/* clip to valid range */ |
|
|
int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel); |
|
|
if (mv[i].x > border) { |
|
|
DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); |
|
|
mv[i].x = border; |
|
|
} else { |
|
|
border = (-(int)x_pos-1) << (5 + dec->quarterpel); |
|
|
if (mv[i].x < border) { |
|
|
DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); |
|
|
mv[i].x = border; |
|
|
} |
|
|
} |
|
503 |
|
|
504 |
border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel); |
validate_vector(mv, x_pos, y_pos, dec); |
|
if (mv[i].y > border) { |
|
|
DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); |
|
|
mv[i].y = border; |
|
|
} else { |
|
|
border = (-(int)y_pos-1) << (5 + dec->quarterpel); |
|
|
if (mv[i].y < border) { |
|
|
DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); |
|
|
mv[i].y = border; |
|
|
} |
|
|
} |
|
|
} |
|
505 |
|
|
506 |
start_timer(); |
start_timer(); |
507 |
|
|
516 |
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
517 |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
518 |
|
|
519 |
if (reduced_resolution) |
if (dec->quarterpel) |
|
interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos, |
|
|
mv[0].x, mv[0].y, stride, rounding); |
|
|
else if (dec->quarterpel) |
|
520 |
interpolate16x16_quarterpel(dec->cur.y, dec->refn[ref].y, dec->qtmp.y, dec->qtmp.y + 64, |
interpolate16x16_quarterpel(dec->cur.y, dec->refn[ref].y, dec->qtmp.y, dec->qtmp.y + 64, |
521 |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
522 |
mv[0].x, mv[0].y, stride, rounding); |
mv[0].x, mv[0].y, stride, rounding); |
537 |
uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf]; |
uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf]; |
538 |
uv_dy = (uv_dy >> 3) + roundtab_76[uv_dy & 0xf]; |
uv_dy = (uv_dy >> 3) + roundtab_76[uv_dy & 0xf]; |
539 |
|
|
540 |
if (reduced_resolution) { |
if (dec->quarterpel) { |
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos, |
|
|
mv[0].x, mv[0].y, stride, rounding); |
|
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos + 16, 32*y_pos, |
|
|
mv[1].x, mv[1].y, stride, rounding); |
|
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos, 32*y_pos + 16, |
|
|
mv[2].x, mv[2].y, stride, rounding); |
|
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos + 16, 32*y_pos + 16, |
|
|
mv[3].x, mv[3].y, stride, rounding); |
|
|
interpolate16x16_switch(dec->cur.u, dec->refn[0].u , 16 * x_pos, 16 * y_pos, |
|
|
uv_dx, uv_dy, stride2, rounding); |
|
|
interpolate16x16_switch(dec->cur.v, dec->refn[0].v , 16 * x_pos, 16 * y_pos, |
|
|
uv_dx, uv_dy, stride2, rounding); |
|
|
|
|
|
} else if (dec->quarterpel) { |
|
541 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64, |
542 |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
543 |
mv[0].x, mv[0].y, stride, rounding); |
mv[0].x, mv[0].y, stride, rounding); |
563 |
} |
} |
564 |
|
|
565 |
/* chroma */ |
/* chroma */ |
|
if (reduced_resolution) { |
|
|
interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos, |
|
|
uv_dx, uv_dy, stride2, rounding); |
|
|
interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos, |
|
|
uv_dx, uv_dy, stride2, rounding); |
|
|
} else { |
|
566 |
interpolate8x8_switch(dec->cur.u, dec->refn[ref].u, 8 * x_pos, 8 * y_pos, |
interpolate8x8_switch(dec->cur.u, dec->refn[ref].u, 8 * x_pos, 8 * y_pos, |
567 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
568 |
interpolate8x8_switch(dec->cur.v, dec->refn[ref].v, 8 * x_pos, 8 * y_pos, |
interpolate8x8_switch(dec->cur.v, dec->refn[ref].v, 8 * x_pos, 8 * y_pos, |
569 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
|
} |
|
570 |
|
|
571 |
stop_comp_timer(); |
stop_comp_timer(); |
572 |
|
|
573 |
if (cbp) |
if (cbp) |
574 |
decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, |
decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, pMB); |
|
reduced_resolution, pMB); |
|
575 |
} |
} |
576 |
|
|
577 |
static void |
static void |
618 |
stop_transfer_timer(); |
stop_transfer_timer(); |
619 |
|
|
620 |
if (cbp) |
if (cbp) |
621 |
decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, 0, pMB); |
decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, pMB); |
622 |
|
|
623 |
} |
} |
624 |
|
|
626 |
static void |
static void |
627 |
decoder_iframe(DECODER * dec, |
decoder_iframe(DECODER * dec, |
628 |
Bitstream * bs, |
Bitstream * bs, |
|
int reduced_resolution, |
|
629 |
int quant, |
int quant, |
630 |
int intra_dc_threshold) |
int intra_dc_threshold) |
631 |
{ |
{ |
632 |
uint32_t bound; |
uint32_t bound; |
633 |
uint32_t x, y; |
uint32_t x, y; |
634 |
uint32_t mb_width = dec->mb_width; |
const uint32_t mb_width = dec->mb_width; |
635 |
uint32_t mb_height = dec->mb_height; |
const uint32_t mb_height = dec->mb_height; |
|
|
|
|
if (reduced_resolution) { |
|
|
mb_width = (dec->width + 31) / 32; |
|
|
mb_height = (dec->height + 31) / 32; |
|
|
} |
|
636 |
|
|
637 |
bound = 0; |
bound = 0; |
638 |
|
|
688 |
} |
} |
689 |
|
|
690 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
691 |
intra_dc_threshold, bound, reduced_resolution); |
intra_dc_threshold, bound); |
692 |
|
|
693 |
} |
} |
694 |
if(dec->out_frm) |
if(dec->out_frm) |
746 |
decoder_pframe(DECODER * dec, |
decoder_pframe(DECODER * dec, |
747 |
Bitstream * bs, |
Bitstream * bs, |
748 |
int rounding, |
int rounding, |
|
int reduced_resolution, |
|
749 |
int quant, |
int quant, |
750 |
int fcode, |
int fcode, |
751 |
int intra_dc_threshold, |
int intra_dc_threshold, |
754 |
uint32_t x, y; |
uint32_t x, y; |
755 |
uint32_t bound; |
uint32_t bound; |
756 |
int cp_mb, st_mb; |
int cp_mb, st_mb; |
757 |
uint32_t mb_width = dec->mb_width; |
const uint32_t mb_width = dec->mb_width; |
758 |
uint32_t mb_height = dec->mb_height; |
const uint32_t mb_height = dec->mb_height; |
|
|
|
|
if (reduced_resolution) { |
|
|
mb_width = (dec->width + 31) / 32; |
|
|
mb_height = (dec->height + 31) / 32; |
|
|
} |
|
759 |
|
|
760 |
if (!dec->is_edged[0]) { |
if (!dec->is_edged[0]) { |
761 |
start_timer(); |
start_timer(); |
874 |
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; |
875 |
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; |
876 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
877 |
intra_dc_threshold, bound, reduced_resolution); |
intra_dc_threshold, bound); |
878 |
continue; |
continue; |
879 |
} |
} |
880 |
|
|
881 |
decoder_mbinter(dec, mb, x, y, cbp, bs, |
decoder_mbinter(dec, mb, x, y, cbp, bs, rounding, 0); |
|
rounding, reduced_resolution, 0); |
|
882 |
|
|
883 |
} else if (gmc_warp) { /* a not coded S(GMC)-VOP macroblock */ |
} else if (gmc_warp) { /* a not coded S(GMC)-VOP macroblock */ |
884 |
mb->mode = MODE_NOT_CODED_GMC; |
mb->mode = MODE_NOT_CODED_GMC; |
898 |
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; |
899 |
|
|
900 |
decoder_mbinter(dec, mb, x, y, 0, bs, |
decoder_mbinter(dec, mb, x, y, 0, bs, |
901 |
rounding, reduced_resolution, 0); |
rounding, 0); |
902 |
|
|
903 |
if(dec->out_frm && cp_mb > 0) { |
if(dec->out_frm && cp_mb > 0) { |
904 |
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); |
953 |
decoder_bf_interpolate_mbinter(DECODER * dec, |
decoder_bf_interpolate_mbinter(DECODER * dec, |
954 |
IMAGE forward, |
IMAGE forward, |
955 |
IMAGE backward, |
IMAGE backward, |
956 |
const MACROBLOCK * pMB, |
MACROBLOCK * pMB, |
957 |
const uint32_t x_pos, |
const uint32_t x_pos, |
958 |
const uint32_t y_pos, |
const uint32_t y_pos, |
959 |
Bitstream * bs, |
Bitstream * bs, |
970 |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
971 |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
972 |
|
|
973 |
|
validate_vector(pMB->mvs, x_pos, y_pos, dec); |
974 |
|
validate_vector(pMB->b_mvs, x_pos, y_pos, dec); |
975 |
|
|
976 |
if (!direct) { |
if (!direct) { |
977 |
uv_dx = pMB->mvs[0].x; |
uv_dx = pMB->mvs[0].x; |
978 |
uv_dy = pMB->mvs[0].y; |
uv_dy = pMB->mvs[0].y; |
1085 |
stop_comp_timer(); |
stop_comp_timer(); |
1086 |
|
|
1087 |
if (cbp) |
if (cbp) |
1088 |
decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, 0, pMB); |
decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, pMB); |
1089 |
} |
} |
1090 |
|
|
1091 |
/* for decode B-frame dbquant */ |
/* for decode B-frame dbquant */ |
1180 |
if (last_mb->mode == MODE_NOT_CODED) { |
if (last_mb->mode == MODE_NOT_CODED) { |
1181 |
mb->cbp = 0; |
mb->cbp = 0; |
1182 |
mb->mode = MODE_FORWARD; |
mb->mode = MODE_FORWARD; |
1183 |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 1); |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 1); |
1184 |
continue; |
continue; |
1185 |
} |
} |
1186 |
|
|
1263 |
get_b_motion_vector(bs, &mb->mvs[0], fcode_backward, dec->p_bmv, dec, x, y); |
get_b_motion_vector(bs, &mb->mvs[0], fcode_backward, dec->p_bmv, dec, x, y); |
1264 |
dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1265 |
|
|
1266 |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 0); |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0); |
1267 |
break; |
break; |
1268 |
|
|
1269 |
case MODE_FORWARD: |
case MODE_FORWARD: |
1270 |
get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv, dec, x, y); |
get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv, dec, x, y); |
1271 |
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1272 |
|
|
1273 |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 1); |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 1); |
1274 |
break; |
break; |
1275 |
|
|
1276 |
default: |
default: |
1320 |
} |
} |
1321 |
} |
} |
1322 |
|
|
|
|
|
1323 |
int |
int |
1324 |
decoder_decode(DECODER * dec, |
decoder_decode(DECODER * dec, |
1325 |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats) |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats) |
1327 |
|
|
1328 |
Bitstream bs; |
Bitstream bs; |
1329 |
uint32_t rounding; |
uint32_t rounding; |
|
uint32_t reduced_resolution; |
|
1330 |
uint32_t quant = 2; |
uint32_t quant = 2; |
1331 |
uint32_t fcode_forward; |
uint32_t fcode_forward; |
1332 |
uint32_t fcode_backward; |
uint32_t fcode_backward; |
1381 |
|
|
1382 |
repeat: |
repeat: |
1383 |
|
|
1384 |
coding_type = BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
coding_type = BitstreamReadHeaders(&bs, dec, &rounding, |
1385 |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp); |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp); |
1386 |
|
|
1387 |
DPRINTF(XVID_DEBUG_HEADER, "coding_type=%i, packed=%i, time=%lli, time_pp=%i, time_bp=%i\n", |
DPRINTF(XVID_DEBUG_HEADER, "coding_type=%i, packed=%i, time=%lli, time_pp=%i, time_bp=%i\n", |
1432 |
} else if (coding_type != B_VOP) { |
} else if (coding_type != B_VOP) { |
1433 |
switch(coding_type) { |
switch(coding_type) { |
1434 |
case I_VOP : |
case I_VOP : |
1435 |
decoder_iframe(dec, &bs, reduced_resolution, quant, intra_dc_threshold); |
decoder_iframe(dec, &bs, quant, intra_dc_threshold); |
1436 |
break; |
break; |
1437 |
case P_VOP : |
case P_VOP : |
1438 |
decoder_pframe(dec, &bs, rounding, reduced_resolution, quant, |
decoder_pframe(dec, &bs, rounding, quant, |
1439 |
fcode_forward, intra_dc_threshold, NULL); |
fcode_forward, intra_dc_threshold, NULL); |
1440 |
break; |
break; |
1441 |
case S_VOP : |
case S_VOP : |
1442 |
decoder_pframe(dec, &bs, rounding, reduced_resolution, quant, |
decoder_pframe(dec, &bs, rounding, quant, |
1443 |
fcode_forward, intra_dc_threshold, &gmc_warp); |
fcode_forward, intra_dc_threshold, &gmc_warp); |
1444 |
break; |
break; |
1445 |
case N_VOP : |
case N_VOP : |
1450 |
break; |
break; |
1451 |
} |
} |
1452 |
|
|
|
if (reduced_resolution) { |
|
|
image_deblock_rrv(&dec->cur, dec->edged_width, dec->mbs, |
|
|
(dec->width + 31) / 32, (dec->height + 31) / 32, dec->mb_width, |
|
|
16, 0); |
|
|
} |
|
|
|
|
1453 |
/* note: for packed_mode, output is performed when the special-N_VOP is decoded */ |
/* note: for packed_mode, output is performed when the special-N_VOP is decoded */ |
1454 |
if (!(dec->low_delay_default && dec->packed_mode)) { |
if (!(dec->low_delay_default && dec->packed_mode)) { |
1455 |
if (dec->low_delay) { |
if (dec->low_delay) { |
1467 |
image_swap(&dec->cur, &dec->refn[0]); |
image_swap(&dec->cur, &dec->refn[0]); |
1468 |
dec->is_edged[0] = 0; |
dec->is_edged[0] = 0; |
1469 |
SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs); |
SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs); |
|
dec->last_reduced_resolution = reduced_resolution; |
|
1470 |
dec->last_coding_type = coding_type; |
dec->last_coding_type = coding_type; |
1471 |
|
|
1472 |
dec->frames++; |
dec->frames++; |