79 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
80 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
81 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
82 |
|
#include "image/reduced.h" |
83 |
|
|
84 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
85 |
#include "prediction/mbprediction.h" |
#include "prediction/mbprediction.h" |
219 |
dec->frames = -1; |
dec->frames = -1; |
220 |
dec->time = dec->time_base = dec->last_time_base = 0; |
dec->time = dec->time_base = dec->last_time_base = 0; |
221 |
dec->low_delay = 0; |
dec->low_delay = 0; |
222 |
|
dec->packed_mode = 0; |
223 |
|
|
224 |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
225 |
|
|
267 |
Bitstream * bs, |
Bitstream * bs, |
268 |
const uint32_t quant, |
const uint32_t quant, |
269 |
const uint32_t intra_dc_threshold, |
const uint32_t intra_dc_threshold, |
270 |
const unsigned int bound) |
const unsigned int bound, |
271 |
|
const int reduced_resolution) |
272 |
{ |
{ |
273 |
|
|
274 |
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
281 |
uint32_t iQuant = pMB->quant; |
uint32_t iQuant = pMB->quant; |
282 |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
283 |
|
|
284 |
|
if (reduced_resolution) { |
285 |
|
pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5); |
286 |
|
pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4); |
287 |
|
pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4); |
288 |
|
}else{ |
289 |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
290 |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
291 |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
292 |
|
} |
293 |
|
|
294 |
memset(block, 0, 6 * 64 * sizeof(int16_t)); // clear |
memset(block, 0, 6 * 64 * sizeof(int16_t)); // clear |
295 |
|
|
350 |
start_timer(); |
start_timer(); |
351 |
idct(&data[i * 64]); |
idct(&data[i * 64]); |
352 |
stop_idct_timer(); |
stop_idct_timer(); |
353 |
|
|
354 |
} |
} |
355 |
|
|
356 |
if (dec->interlacing && pMB->field_dct) { |
if (dec->interlacing && pMB->field_dct) { |
359 |
} |
} |
360 |
|
|
361 |
start_timer(); |
start_timer(); |
362 |
|
|
363 |
|
if (reduced_resolution) |
364 |
|
{ |
365 |
|
next_block*=2; |
366 |
|
copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
367 |
|
copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); |
368 |
|
copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride); |
369 |
|
copy_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride); |
370 |
|
copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2); |
371 |
|
copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2); |
372 |
|
}else{ |
373 |
transfer_16to8copy(pY_Cur, &data[0 * 64], stride); |
transfer_16to8copy(pY_Cur, &data[0 * 64], stride); |
374 |
transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride); |
transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride); |
375 |
transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride); |
transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride); |
376 |
transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride); |
transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride); |
377 |
transfer_16to8copy(pU_Cur, &data[4 * 64], stride2); |
transfer_16to8copy(pU_Cur, &data[4 * 64], stride2); |
378 |
transfer_16to8copy(pV_Cur, &data[5 * 64], stride2); |
transfer_16to8copy(pV_Cur, &data[5 * 64], stride2); |
379 |
|
} |
380 |
stop_transfer_timer(); |
stop_transfer_timer(); |
381 |
} |
} |
382 |
|
|
398 |
const uint32_t cbp, |
const uint32_t cbp, |
399 |
Bitstream * bs, |
Bitstream * bs, |
400 |
const uint32_t quant, |
const uint32_t quant, |
401 |
const uint32_t rounding) |
const uint32_t rounding, |
402 |
|
const int reduced_resolution) |
403 |
{ |
{ |
404 |
|
|
405 |
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
407 |
|
|
408 |
uint32_t stride = dec->edged_width; |
uint32_t stride = dec->edged_width; |
409 |
uint32_t stride2 = stride / 2; |
uint32_t stride2 = stride / 2; |
410 |
uint32_t next_block = stride * 8; |
uint32_t next_block = stride * (reduced_resolution ? 16 : 8); |
411 |
uint32_t i; |
uint32_t i; |
412 |
uint32_t iQuant = pMB->quant; |
uint32_t iQuant = pMB->quant; |
413 |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
414 |
|
|
415 |
int uv_dx, uv_dy; |
int uv_dx, uv_dy; |
416 |
|
VECTOR mv[4]; /* local copy of mvs */ |
417 |
|
|
418 |
|
if (reduced_resolution) { |
419 |
|
pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5); |
420 |
|
pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4); |
421 |
|
pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4); |
422 |
|
for (i = 0; i < 4; i++) { |
423 |
|
mv[i].x = RRV_MV_SCALEUP(pMB->mvs[i].x); |
424 |
|
mv[i].y = RRV_MV_SCALEUP(pMB->mvs[i].y); |
425 |
|
} |
426 |
|
}else{ |
427 |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4); |
428 |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3); |
429 |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
430 |
|
for (i = 0; i < 4; i++) |
431 |
|
mv[i] = pMB->mvs[i]; |
432 |
|
} |
433 |
|
|
434 |
if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) { |
if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) { |
435 |
uv_dx = pMB->mvs[0].x; |
uv_dx = mv[0].x; |
436 |
uv_dy = pMB->mvs[0].y; |
uv_dy = mv[0].y; |
437 |
|
|
438 |
if (dec->quarterpel) |
if (dec->quarterpel) |
439 |
{ |
{ |
445 |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
446 |
|
|
447 |
start_timer(); |
start_timer(); |
448 |
|
if (reduced_resolution) |
449 |
|
{ |
450 |
|
interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos, |
451 |
|
mv[0].x, mv[0].y, stride, rounding); |
452 |
|
interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos, |
453 |
|
uv_dx, uv_dy, stride2, rounding); |
454 |
|
interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos, |
455 |
|
uv_dx, uv_dy, stride2, rounding); |
456 |
|
|
457 |
|
} |
458 |
|
else |
459 |
|
{ |
460 |
if(dec->quarterpel) { |
if(dec->quarterpel) { |
461 |
interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
462 |
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
463 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
mv[0].x, mv[0].y, stride, rounding); |
464 |
} |
} |
465 |
else { |
else { |
466 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, |
interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos, |
467 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
mv[0].x, mv[0].y, stride, rounding); |
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
|
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
|
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
|
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
|
|
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
|
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
|
468 |
} |
} |
469 |
|
|
470 |
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, |
471 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
472 |
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, |
473 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
474 |
|
} |
475 |
stop_comp_timer(); |
stop_comp_timer(); |
476 |
|
|
477 |
} else { |
} else { /* MODE_INTER4V */ |
478 |
int sum; |
int sum; |
479 |
|
|
480 |
if(dec->quarterpel) |
if(dec->quarterpel) |
481 |
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
sum = (mv[0].x / 2) + (mv[1].x / 2) + (mv[2].x / 2) + (mv[3].x / 2); |
482 |
else |
else |
483 |
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
sum = mv[0].x + mv[1].x + mv[2].x + mv[3].x; |
484 |
|
|
485 |
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
486 |
|
|
487 |
if(dec->quarterpel) |
if(dec->quarterpel) |
488 |
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
sum = (mv[0].y / 2) + (mv[1].y / 2) + (mv[2].y / 2) + (mv[3].y / 2); |
489 |
else |
else |
490 |
sum = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; |
sum = mv[0].y + mv[1].y + mv[2].y + mv[3].y; |
491 |
|
|
492 |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
493 |
|
|
494 |
start_timer(); |
start_timer(); |
495 |
|
if (reduced_resolution) |
496 |
|
{ |
497 |
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos, |
498 |
|
mv[0].x, mv[0].y, stride, rounding); |
499 |
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos, |
500 |
|
mv[1].x, mv[1].y, stride, rounding); |
501 |
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos + 16, |
502 |
|
mv[2].x, mv[2].y, stride, rounding); |
503 |
|
interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos + 16, |
504 |
|
mv[3].x, mv[3].y, stride, rounding); |
505 |
|
interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos, |
506 |
|
uv_dx, uv_dy, stride2, rounding); |
507 |
|
interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos, |
508 |
|
uv_dx, uv_dy, stride2, rounding); |
509 |
|
|
510 |
|
// set_block(pY_Cur, stride, 32, 32, 127); |
511 |
|
} |
512 |
|
else |
513 |
|
{ |
514 |
if(dec->quarterpel) { |
if(dec->quarterpel) { |
515 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
516 |
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
517 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
mv[0].x, mv[0].y, stride, rounding); |
518 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
519 |
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
520 |
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
mv[1].x, mv[1].y, stride, rounding); |
521 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
522 |
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
523 |
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
mv[2].x, mv[2].y, stride, rounding); |
524 |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64, |
525 |
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
526 |
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
mv[3].x, mv[3].y, stride, rounding); |
527 |
} |
} |
528 |
else { |
else { |
529 |
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, |
530 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, rounding); |
mv[0].x, mv[0].y, stride, rounding); |
531 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos, |
532 |
pMB->mvs[1].x, pMB->mvs[1].y, stride, rounding); |
mv[1].x, mv[1].y, stride, rounding); |
533 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8, |
534 |
pMB->mvs[2].x, pMB->mvs[2].y, stride, rounding); |
mv[2].x, mv[2].y, stride, rounding); |
535 |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8, |
536 |
pMB->mvs[3].x, pMB->mvs[3].y, stride, rounding); |
mv[3].x, mv[3].y, stride, rounding); |
537 |
} |
} |
538 |
|
|
539 |
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, |
540 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
541 |
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, |
542 |
uv_dx, uv_dy, stride2, rounding); |
uv_dx, uv_dy, stride2, rounding); |
543 |
|
} |
544 |
stop_comp_timer(); |
stop_comp_timer(); |
545 |
} |
} |
546 |
|
|
575 |
} |
} |
576 |
|
|
577 |
start_timer(); |
start_timer(); |
578 |
|
if (reduced_resolution) |
579 |
|
{ |
580 |
|
if (cbp & 32) |
581 |
|
add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
582 |
|
if (cbp & 16) |
583 |
|
add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); |
584 |
|
if (cbp & 8) |
585 |
|
add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride); |
586 |
|
if (cbp & 4) |
587 |
|
add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride); |
588 |
|
if (cbp & 2) |
589 |
|
add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2); |
590 |
|
if (cbp & 1) |
591 |
|
add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2); |
592 |
|
} |
593 |
|
else |
594 |
|
{ |
595 |
if (cbp & 32) |
if (cbp & 32) |
596 |
transfer_16to8add(pY_Cur, &data[0 * 64], stride); |
transfer_16to8add(pY_Cur, &data[0 * 64], stride); |
597 |
if (cbp & 16) |
if (cbp & 16) |
604 |
transfer_16to8add(pU_Cur, &data[4 * 64], stride2); |
transfer_16to8add(pU_Cur, &data[4 * 64], stride2); |
605 |
if (cbp & 1) |
if (cbp & 1) |
606 |
transfer_16to8add(pV_Cur, &data[5 * 64], stride2); |
transfer_16to8add(pV_Cur, &data[5 * 64], stride2); |
607 |
|
} |
608 |
stop_transfer_timer(); |
stop_transfer_timer(); |
609 |
} |
} |
610 |
|
|
623 |
|
|
624 |
if (reduced_resolution) |
if (reduced_resolution) |
625 |
{ |
{ |
626 |
mb_width /= 2; |
mb_width = (dec->width + 31) / 32; |
627 |
mb_height /= 2; |
mb_height = (dec->height + 31) / 32; |
628 |
} |
} |
629 |
|
|
630 |
bound = 0; |
bound = 0; |
645 |
{ |
{ |
646 |
bound = read_video_packet_header(bs, dec, 0, |
bound = read_video_packet_header(bs, dec, 0, |
647 |
&quant, NULL, NULL, &intra_dc_threshold); |
&quant, NULL, NULL, &intra_dc_threshold); |
648 |
x = bound % dec->mb_width; |
x = bound % mb_width; |
649 |
y = bound / dec->mb_width; |
y = bound / mb_width; |
650 |
} |
} |
651 |
mb = &dec->mbs[y * dec->mb_width + x]; |
mb = &dec->mbs[y * dec->mb_width + x]; |
652 |
|
|
681 |
} |
} |
682 |
|
|
683 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
684 |
intra_dc_threshold, bound); |
intra_dc_threshold, bound, reduced_resolution); |
685 |
|
|
686 |
} |
} |
687 |
if(dec->out_frm) |
if(dec->out_frm) |
688 |
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,dec->mb_width); |
output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,mb_width); |
689 |
} |
} |
690 |
|
|
691 |
} |
} |
697 |
int x, |
int x, |
698 |
int y, |
int y, |
699 |
int k, |
int k, |
700 |
VECTOR * mv, |
VECTOR * ret_mv, |
701 |
int fcode, |
int fcode, |
702 |
const int bound) |
const int bound) |
703 |
{ |
{ |
708 |
int range = (64 * scale_fac); |
int range = (64 * scale_fac); |
709 |
|
|
710 |
VECTOR pmv; |
VECTOR pmv; |
711 |
int mv_x, mv_y; |
VECTOR mv; |
712 |
|
|
713 |
pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k); |
pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k); |
714 |
|
|
715 |
mv_x = get_mv(bs, fcode); |
mv.x = get_mv(bs, fcode); |
716 |
mv_y = get_mv(bs, fcode); |
mv.y = get_mv(bs, fcode); |
717 |
|
|
718 |
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)", mv.x, mv.y, pmv.x, pmv.y); |
719 |
|
|
720 |
mv_x += pmv.x; |
mv.x += pmv.x; |
721 |
mv_y += pmv.y; |
mv.y += pmv.y; |
722 |
|
|
723 |
if (mv_x < low) { |
if (mv.x < low) { |
724 |
mv_x += range; |
mv.x += range; |
725 |
} else if (mv_x > high) { |
} else if (mv.x > high) { |
726 |
mv_x -= range; |
mv.x -= range; |
727 |
} |
} |
728 |
|
|
729 |
if (mv_y < low) { |
if (mv.y < low) { |
730 |
mv_y += range; |
mv.y += range; |
731 |
} else if (mv_y > high) { |
} else if (mv.y > high) { |
732 |
mv_y -= range; |
mv.y -= range; |
733 |
} |
} |
734 |
|
|
735 |
mv->x = mv_x; |
ret_mv->x = mv.x; |
736 |
mv->y = mv_y; |
ret_mv->y = mv.y; |
737 |
} |
} |
738 |
|
|
739 |
|
|
767 |
uint32_t x, y; |
uint32_t x, y; |
768 |
uint32_t bound; |
uint32_t bound; |
769 |
int cp_mb, st_mb; |
int cp_mb, st_mb; |
770 |
|
int mb_width = dec->mb_width; |
771 |
|
int mb_height = dec->mb_height; |
772 |
|
|
773 |
|
if (reduced_resolution) |
774 |
|
{ |
775 |
|
mb_width = (dec->width + 31) / 32; |
776 |
|
mb_height = (dec->height + 31) / 32; |
777 |
|
} |
778 |
|
|
779 |
start_timer(); |
start_timer(); |
780 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
783 |
|
|
784 |
bound = 0; |
bound = 0; |
785 |
|
|
786 |
for (y = 0; y < dec->mb_height; y++) { |
for (y = 0; y < mb_height; y++) { |
787 |
cp_mb = st_mb = 0; |
cp_mb = st_mb = 0; |
788 |
for (x = 0; x < dec->mb_width; x++) { |
for (x = 0; x < mb_width; x++) { |
789 |
MACROBLOCK *mb; |
MACROBLOCK *mb; |
790 |
|
|
791 |
// skip stuffing |
// skip stuffing |
796 |
{ |
{ |
797 |
bound = read_video_packet_header(bs, dec, fcode - 1, |
bound = read_video_packet_header(bs, dec, fcode - 1, |
798 |
&quant, &fcode, NULL, &intra_dc_threshold); |
&quant, &fcode, NULL, &intra_dc_threshold); |
799 |
x = bound % dec->mb_width; |
x = bound % mb_width; |
800 |
y = bound / dec->mb_width; |
y = bound / mb_width; |
801 |
} |
} |
802 |
mb = &dec->mbs[y * dec->mb_width + x]; |
mb = &dec->mbs[y * dec->mb_width + x]; |
803 |
|
|
904 |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = |
905 |
0; |
0; |
906 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
907 |
intra_dc_threshold, bound); |
intra_dc_threshold, bound, reduced_resolution); |
908 |
continue; |
continue; |
909 |
} |
} |
910 |
|
|
911 |
decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
912 |
rounding); |
rounding, reduced_resolution); |
913 |
|
|
914 |
} |
} |
915 |
else if (gmc_mv) /* not coded S_VOP macroblock */ |
else if (gmc_mv) /* not coded S_VOP macroblock */ |
917 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED; |
918 |
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].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode); |
919 |
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); |
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); |
920 |
decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding); |
decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution); |
921 |
} |
} |
922 |
else /* not coded P_VOP macroblock */ |
else /* not coded P_VOP macroblock */ |
923 |
{ |
{ |
924 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED; |
925 |
|
|
926 |
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; |
927 |
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; |
928 |
// copy macroblock directly from ref to cur |
// copy macroblock directly from ref to cur |
929 |
|
|
930 |
start_timer(); |
start_timer(); |
931 |
|
|
932 |
transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width + |
if (reduced_resolution) |
933 |
(16 * x), |
{ |
934 |
dec->refn[0].y + (16 * y) * dec->edged_width + |
transfer32x32_copy(dec->cur.y + (32*y)*dec->edged_width + (32*x), |
935 |
(16 * x), dec->edged_width); |
dec->refn[0].y + (32*y)*dec->edged_width + (32*x), |
936 |
|
dec->edged_width); |
937 |
transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width + |
|
938 |
(16 * x + 8), |
transfer16x16_copy(dec->cur.u + (16*y)*dec->edged_width/2 + (16*x), |
939 |
dec->refn[0].y + (16 * y) * dec->edged_width + |
dec->refn[0].u + (16*y)*dec->edged_width/2 + (16*x), |
|
(16 * x + 8), dec->edged_width); |
|
|
|
|
|
transfer8x8_copy(dec->cur.y + (16 * y + 8) * dec->edged_width + |
|
|
(16 * x), |
|
|
dec->refn[0].y + (16 * y + |
|
|
8) * dec->edged_width + |
|
|
(16 * x), dec->edged_width); |
|
|
|
|
|
transfer8x8_copy(dec->cur.y + (16 * y + 8) * dec->edged_width + |
|
|
(16 * x + 8), |
|
|
dec->refn[0].y + (16 * y + |
|
|
8) * dec->edged_width + |
|
|
(16 * x + 8), dec->edged_width); |
|
|
|
|
|
transfer8x8_copy(dec->cur.u + (8 * y) * dec->edged_width / 2 + |
|
|
(8 * x), |
|
|
dec->refn[0].u + |
|
|
(8 * y) * dec->edged_width / 2 + (8 * x), |
|
940 |
dec->edged_width / 2); |
dec->edged_width / 2); |
941 |
|
|
942 |
transfer8x8_copy(dec->cur.v + (8 * y) * dec->edged_width / 2 + |
transfer16x16_copy(dec->cur.v + (16*y)*dec->edged_width/2 + (16*x), |
943 |
(8 * x), |
dec->refn[0].v + (16*y)*dec->edged_width/2 + (16*x), |
944 |
dec->refn[0].v + |
dec->edged_width/2); |
945 |
(8 * y) * dec->edged_width / 2 + (8 * x), |
} |
946 |
|
else |
947 |
|
{ |
948 |
|
transfer16x16_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x), |
949 |
|
dec->refn[0].y + (16*y)*dec->edged_width + (16*x), |
950 |
|
dec->edged_width); |
951 |
|
|
952 |
|
transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x), |
953 |
|
dec->refn[0].u + (8*y)*dec->edged_width/2 + (8*x), |
954 |
dec->edged_width / 2); |
dec->edged_width / 2); |
955 |
|
|
956 |
|
transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x), |
957 |
|
dec->refn[0].v + (8*y)*dec->edged_width/2 + (8*x), |
958 |
|
dec->edged_width/2); |
959 |
|
} |
960 |
|
|
961 |
stop_transfer_timer(); |
stop_transfer_timer(); |
962 |
|
|
963 |
if(dec->out_frm && cp_mb > 0) { |
if(dec->out_frm && cp_mb > 0) { |
1051 |
uv_dx = pMB->mvs[0].x; |
uv_dx = pMB->mvs[0].x; |
1052 |
uv_dy = pMB->mvs[0].y; |
uv_dy = pMB->mvs[0].y; |
1053 |
|
|
1054 |
uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
if (dec->quarterpel) |
1055 |
uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
{ |
1056 |
|
uv_dx /= 2; |
1057 |
|
uv_dy /= 2; |
1058 |
|
} |
1059 |
|
|
1060 |
|
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
1061 |
|
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
1062 |
} else { |
} else { |
1063 |
int sum; |
int sum; |
1064 |
|
|
1065 |
|
if(dec->quarterpel) |
1066 |
|
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
1067 |
|
else |
1068 |
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)); |
|
1069 |
|
|
1070 |
|
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
1071 |
|
|
1072 |
|
if(dec->quarterpel) |
1073 |
|
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
1074 |
|
else |
1075 |
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; |
1076 |
uv_dy = |
|
1077 |
(sum == |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
|
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
|
(ABS(sum) / 16) * 2)); |
|
1078 |
} |
} |
1079 |
|
|
1080 |
start_timer(); |
start_timer(); |
1081 |
|
if(dec->quarterpel) { |
1082 |
|
interpolate16x16_quarterpel(dec->cur.y, dec->refn[ref].y, dec->refh.y, dec->refh.y + 64, |
1083 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
1084 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1085 |
|
} |
1086 |
|
else { |
1087 |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16 * x_pos, 16 * y_pos, |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16 * x_pos, 16 * y_pos, |
1088 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1089 |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16 * x_pos + 8, |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos + 8, 16*y_pos, |
1090 |
16 * y_pos, pMB->mvs[1].x, pMB->mvs[1].y, stride, 0); |
pMB->mvs[1].x, pMB->mvs[1].y, stride, 0); |
1091 |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16 * x_pos, |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos, 16*y_pos + 8, |
1092 |
16 * y_pos + 8, pMB->mvs[2].x, pMB->mvs[2].y, stride, |
pMB->mvs[2].x, pMB->mvs[2].y, stride, 0); |
1093 |
0); |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos + 8, 16*y_pos + 8, |
1094 |
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16 * x_pos + 8, |
pMB->mvs[3].x, pMB->mvs[3].y, stride, 0); |
1095 |
16 * y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, |
} |
1096 |
0); |
|
1097 |
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, |
1098 |
uv_dx, uv_dy, stride2, 0); |
uv_dx, uv_dy, stride2, 0); |
1099 |
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, |
1180 |
uv_dx = pMB->mvs[0].x; |
uv_dx = pMB->mvs[0].x; |
1181 |
uv_dy = pMB->mvs[0].y; |
uv_dy = pMB->mvs[0].y; |
1182 |
|
|
|
uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
|
|
uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
|
|
|
|
1183 |
b_uv_dx = pMB->b_mvs[0].x; |
b_uv_dx = pMB->b_mvs[0].x; |
1184 |
b_uv_dy = pMB->b_mvs[0].y; |
b_uv_dy = pMB->b_mvs[0].y; |
1185 |
|
|
1186 |
b_uv_dx = (uv_dx & 3) ? (uv_dx >> 1) | 1 : uv_dx / 2; |
if (dec->quarterpel) |
1187 |
b_uv_dy = (uv_dy & 3) ? (uv_dy >> 1) | 1 : uv_dy / 2; |
{ |
1188 |
|
uv_dx /= 2; |
1189 |
|
uv_dy /= 2; |
1190 |
|
|
1191 |
|
b_uv_dx /= 2; |
1192 |
|
b_uv_dy /= 2; |
1193 |
|
} |
1194 |
|
|
1195 |
|
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
1196 |
|
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
1197 |
|
|
1198 |
|
b_uv_dx = (b_uv_dx >> 1) + roundtab_79[b_uv_dx & 0x3]; |
1199 |
|
b_uv_dy = (b_uv_dy >> 1) + roundtab_79[b_uv_dy & 0x3]; |
1200 |
} else { |
} else { |
1201 |
int sum; |
int sum; |
1202 |
|
|
1203 |
|
if(dec->quarterpel) |
1204 |
|
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
1205 |
|
else |
1206 |
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)); |
|
1207 |
|
|
1208 |
|
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
1209 |
|
|
1210 |
|
if(dec->quarterpel) |
1211 |
|
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
1212 |
|
else |
1213 |
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; |
1214 |
uv_dy = |
|
1215 |
(sum == |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
1216 |
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
1217 |
(ABS(sum) / 16) * 2)); |
|
1218 |
|
if(dec->quarterpel) |
1219 |
sum = |
sum = (pMB->b_mvs[0].x / 2) + (pMB->b_mvs[1].x / 2) + (pMB->b_mvs[2].x / 2) + (pMB->b_mvs[3].x / 2); |
1220 |
pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + |
else |
1221 |
pMB->b_mvs[3].x; |
sum = pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + pMB->b_mvs[3].x; |
1222 |
b_uv_dx = |
|
1223 |
(sum == |
b_uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
1224 |
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
1225 |
(ABS(sum) / 16) * 2)); |
if(dec->quarterpel) |
1226 |
|
sum = (pMB->b_mvs[0].y / 2) + (pMB->b_mvs[1].y / 2) + (pMB->b_mvs[2].y / 2) + (pMB->b_mvs[3].y / 2); |
1227 |
sum = |
else |
1228 |
pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + |
sum = pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + pMB->b_mvs[3].y; |
1229 |
pMB->b_mvs[3].y; |
|
1230 |
b_uv_dy = |
b_uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
|
(sum == |
|
|
0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + |
|
|
(ABS(sum) / 16) * 2)); |
|
1231 |
} |
} |
1232 |
|
|
1233 |
|
|
1234 |
start_timer(); |
start_timer(); |
1235 |
|
if(dec->quarterpel) { |
1236 |
|
if((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)) |
1237 |
|
interpolate16x16_quarterpel(dec->cur.y, forward.y, dec->refh.y, dec->refh.y + 64, |
1238 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
1239 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1240 |
|
else { |
1241 |
|
interpolate8x8_quarterpel(dec->cur.y, forward.y, dec->refh.y, dec->refh.y + 64, |
1242 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
1243 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1244 |
|
interpolate8x8_quarterpel(dec->cur.y, forward.y, dec->refh.y, dec->refh.y + 64, |
1245 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
1246 |
|
pMB->mvs[1].x, pMB->mvs[1].y, stride, 0); |
1247 |
|
interpolate8x8_quarterpel(dec->cur.y, forward.y, dec->refh.y, dec->refh.y + 64, |
1248 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
1249 |
|
pMB->mvs[2].x, pMB->mvs[2].y, stride, 0); |
1250 |
|
interpolate8x8_quarterpel(dec->cur.y, forward.y, dec->refh.y, dec->refh.y + 64, |
1251 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
1252 |
|
pMB->mvs[3].x, pMB->mvs[3].y, stride, 0); |
1253 |
|
} |
1254 |
|
} |
1255 |
|
else { |
1256 |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos, 16 * y_pos, |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos, 16 * y_pos, |
1257 |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1258 |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos + 8, 16 * y_pos, |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos + 8, 16 * y_pos, |
1262 |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos + 8, |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos + 8, |
1263 |
16 * y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, |
16 * y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, |
1264 |
0); |
0); |
1265 |
|
} |
1266 |
|
|
1267 |
interpolate8x8_switch(dec->cur.u, forward.u, 8 * x_pos, 8 * y_pos, uv_dx, |
interpolate8x8_switch(dec->cur.u, forward.u, 8 * x_pos, 8 * y_pos, uv_dx, |
1268 |
uv_dy, stride2, 0); |
uv_dy, stride2, 0); |
1269 |
interpolate8x8_switch(dec->cur.v, forward.v, 8 * x_pos, 8 * y_pos, uv_dx, |
interpolate8x8_switch(dec->cur.v, forward.v, 8 * x_pos, 8 * y_pos, uv_dx, |
1270 |
uv_dy, stride2, 0); |
uv_dy, stride2, 0); |
1271 |
|
|
1272 |
|
|
1273 |
|
if(dec->quarterpel) { |
1274 |
|
if((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)) |
1275 |
|
interpolate16x16_quarterpel(dec->refn[2].y, backward.y, dec->refh.y, dec->refh.y + 64, |
1276 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
1277 |
|
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1278 |
|
else { |
1279 |
|
interpolate8x8_quarterpel(dec->refn[2].y, backward.y, dec->refh.y, dec->refh.y + 64, |
1280 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos, |
1281 |
|
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1282 |
|
interpolate8x8_quarterpel(dec->refn[2].y, backward.y, dec->refh.y, dec->refh.y + 64, |
1283 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos, |
1284 |
|
pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0); |
1285 |
|
interpolate8x8_quarterpel(dec->refn[2].y, backward.y, dec->refh.y, dec->refh.y + 64, |
1286 |
|
dec->refh.y + 128, 16*x_pos, 16*y_pos + 8, |
1287 |
|
pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0); |
1288 |
|
interpolate8x8_quarterpel(dec->refn[2].y, backward.y, dec->refh.y, dec->refh.y + 64, |
1289 |
|
dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8, |
1290 |
|
pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0); |
1291 |
|
} |
1292 |
|
} |
1293 |
|
else { |
1294 |
interpolate8x8_switch(dec->refn[2].y, backward.y, 16 * x_pos, 16 * y_pos, |
interpolate8x8_switch(dec->refn[2].y, backward.y, 16 * x_pos, 16 * y_pos, |
1295 |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1296 |
interpolate8x8_switch(dec->refn[2].y, backward.y, 16 * x_pos + 8, |
interpolate8x8_switch(dec->refn[2].y, backward.y, 16 * x_pos + 8, |
1302 |
interpolate8x8_switch(dec->refn[2].y, backward.y, 16 * x_pos + 8, |
interpolate8x8_switch(dec->refn[2].y, backward.y, 16 * x_pos + 8, |
1303 |
16 * y_pos + 8, pMB->b_mvs[3].x, pMB->b_mvs[3].y, |
16 * y_pos + 8, pMB->b_mvs[3].x, pMB->b_mvs[3].y, |
1304 |
stride, 0); |
stride, 0); |
1305 |
|
} |
1306 |
|
|
1307 |
interpolate8x8_switch(dec->refn[2].u, backward.u, 8 * x_pos, 8 * y_pos, |
interpolate8x8_switch(dec->refn[2].u, backward.u, 8 * x_pos, 8 * y_pos, |
1308 |
b_uv_dx, b_uv_dy, stride2, 0); |
b_uv_dx, b_uv_dy, stride2, 0); |
1309 |
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, |
1312 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1313 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1314 |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos, |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos, |
1315 |
stride, 0); |
stride, 1, 8); |
1316 |
|
|
1317 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1318 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1319 |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8, |
dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1320 |
stride, 0); |
stride, 1, 8); |
1321 |
|
|
1322 |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1323 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1324 |
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1325 |
stride, 0); |
stride, 1, 8); |
1326 |
|
|
1327 |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1328 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1329 |
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1330 |
stride, 0); |
stride, 1, 8); |
1331 |
|
|
1332 |
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1333 |
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1334 |
dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos, |
dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos, |
1335 |
stride2, 0); |
stride2, 1, 8); |
1336 |
|
|
1337 |
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1338 |
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1339 |
dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos, |
dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos, |
1340 |
stride2, 0); |
stride2, 1, 8); |
1341 |
|
|
1342 |
stop_comp_timer(); |
stop_comp_timer(); |
1343 |
|
|
1619 |
uint32_t intra_dc_threshold; |
uint32_t intra_dc_threshold; |
1620 |
VECTOR gmc_mv[5]; |
VECTOR gmc_mv[5]; |
1621 |
uint32_t vop_type; |
uint32_t vop_type; |
1622 |
|
int success = 0; |
1623 |
|
|
1624 |
start_global_timer(); |
start_global_timer(); |
1625 |
|
|
1627 |
|
|
1628 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1629 |
|
|
|
#ifdef BFRAMES_DEC |
|
1630 |
// XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's |
// XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's |
1631 |
if(BitstreamShowBits(&bs, 8) == 0x7f) |
if(frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f) |
1632 |
{ |
{ |
1633 |
if (stats) |
if (stats) |
1634 |
stats->notify = XVID_DEC_VOP; |
stats->notify = XVID_DEC_VOP; |
1635 |
frame->length = 1; |
frame->length = 1; |
1636 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->refn[0], dec->width, dec->height, dec->edged_width, |
1637 |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
1638 |
|
emms(); |
1639 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
1640 |
} |
} |
|
#endif |
|
1641 |
|
|
1642 |
|
start: |
1643 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
1644 |
// for support B-frame to reference last 2 frame |
// for support B-frame to reference last 2 frame |
1645 |
dec->frames++; |
dec->frames++; |
1649 |
BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
1650 |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv); |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv); |
1651 |
|
|
1652 |
DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type); |
//DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type); |
1653 |
|
|
1654 |
|
if (vop_type == -1 && success) |
1655 |
|
goto done; |
1656 |
|
|
1657 |
if (vop_type == -2 || vop_type == -3) |
if (vop_type == -2 || vop_type == -3) |
1658 |
{ |
{ |
1723 |
default: |
default: |
1724 |
if (stats) |
if (stats) |
1725 |
stats->notify = 0; |
stats->notify = 0; |
1726 |
|
|
1727 |
|
emms(); |
1728 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
1729 |
} |
} |
1730 |
|
|
1731 |
#ifdef BFRAMES_DEC_DEBUG |
|
1732 |
if (frame->length != BitstreamPos(&bs) / 8){ |
if (reduced_resolution) |
1733 |
DEBUG2("InLen/UseLen",frame->length, BitstreamPos(&bs) / 8); |
{ |
1734 |
|
image_deblock_rrv(&dec->cur, dec->edged_width, dec->mbs, |
1735 |
|
(dec->width + 31) / 32, (dec->height + 31) / 32, dec->mb_width); |
1736 |
} |
} |
|
#endif |
|
|
frame->length = BitstreamPos(&bs) / 8; |
|
1737 |
|
|
1738 |
|
BitstreamByteAlign(&bs); |
1739 |
|
|
1740 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1741 |
// test if no B_VOP |
// test if no B_VOP |
1742 |
if (dec->low_delay || dec->frames == 0) { |
if (dec->low_delay || dec->frames == 0 || ((dec->packed_mode) && !(frame->length > BitstreamPos(&bs) / 8))) { |
1743 |
#endif |
#endif |
1744 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
1745 |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
1746 |
|
|
1747 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1748 |
} else { |
} else { |
1749 |
if (dec->frames >= 1) { |
if (dec->frames >= 1 && !(dec->packed_mode)) { |
1750 |
start_timer(); |
start_timer(); |
1751 |
if ((vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP)) { |
if ((vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP)) { |
1752 |
image_output(&dec->refn[0], dec->width, dec->height, |
image_output(&dec->refn[0], dec->width, dec->height, |
1778 |
mb_swap(&dec->mbs, &dec->last_mbs); |
mb_swap(&dec->mbs, &dec->last_mbs); |
1779 |
} |
} |
1780 |
|
|
1781 |
|
|
1782 |
|
if (success == 0 && dec->packed_mode) |
1783 |
|
{ |
1784 |
|
success = 1; |
1785 |
|
// if (frame->length > BitstreamPos(&bs) / 8) // multiple vops packed together |
1786 |
|
goto start; |
1787 |
|
} |
1788 |
|
|
1789 |
|
done : |
1790 |
|
|
1791 |
|
frame->length = BitstreamPos(&bs) / 8; |
1792 |
|
|
1793 |
if (stats) |
if (stats) |
1794 |
{ |
{ |
1795 |
stats->notify = XVID_DEC_VOP; |
stats->notify = XVID_DEC_VOP; |