[cvs] / xvidcore / src / decoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/decoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37.2.13, Wed Nov 20 19:52:45 2002 UTC revision 1.37.2.16, Sun Dec 8 06:43:33 2002 UTC
# Line 79  Line 79 
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"
# Line 218  Line 219 
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    
# Line 265  Line 267 
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);
# Line 278  Line 281 
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    
# Line 341  Line 350 
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) {
# Line 349  Line 359 
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    
# Line 367  Line 389 
389    
390  // decode an inter macroblock  // decode an inter macroblock
391    
392    static void
393    rrv_mv_scaleup(VECTOR * mv)
394    {
395            if (mv->x > 0) {
396                    mv->x = 2*mv->x - 1;
397            } else if (mv->x < 0) {
398                    mv->x = 2*mv->x + 1;
399            }
400    
401            if (mv->y > 0) {
402                    mv->y = 2*mv->y - 1;
403            } else if (mv->y < 0) {
404                    mv->y = 2*mv->y + 1;
405            }
406    }
407    
408    
409    
410  void  void
411  decoder_mbinter(DECODER * dec,  decoder_mbinter(DECODER * dec,
412                                  const MACROBLOCK * pMB,                                  const MACROBLOCK * pMB,
# Line 376  Line 416 
416                                  const uint32_t cbp,                                  const uint32_t cbp,
417                                  Bitstream * bs,                                  Bitstream * bs,
418                                  const uint32_t quant,                                  const uint32_t quant,
419                                  const uint32_t rounding)                                  const uint32_t rounding,
420                                    const int reduced_resolution)
421  {  {
422    
423          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
# Line 384  Line 425 
425    
426          uint32_t stride = dec->edged_width;          uint32_t stride = dec->edged_width;
427          uint32_t stride2 = stride / 2;          uint32_t stride2 = stride / 2;
428          uint32_t next_block = stride * 8;          uint32_t next_block = stride * (reduced_resolution ? 16 : 8);
429          uint32_t i;          uint32_t i;
430          uint32_t iQuant = pMB->quant;          uint32_t iQuant = pMB->quant;
431          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
432    
433          int uv_dx, uv_dy;          int uv_dx, uv_dy;
434            VECTOR mv[4];
435    
436            for (i = 0; i < 4; i++)
437            {
438                    mv[i] = pMB->mvs[i];
439                    //DPRINTF(DPRINTF_MB, "mv[%i]   orig=%i,%i   local=%i", i, pMB->mvs[i].x, pMB->mvs[i].y,                                                mv[i].x, mv[i].y);
440            }
441    
442            if (reduced_resolution) {
443                    pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5);
444                    pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4);
445                    pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4);
446                    DPRINTF(DPRINTF_MB,"[%i,%i] %i,%i  %i,%i  %i,%i  %i,%i",
447                            x_pos, y_pos,
448                            mv[0].x, mv[0].y,
449                            mv[1].x, mv[1].y,
450                            mv[2].x, mv[2].y,
451                            mv[3].x, mv[3].y);
452    
453                    rrv_mv_scaleup(&mv[0]);
454                    rrv_mv_scaleup(&mv[1]);
455                    rrv_mv_scaleup(&mv[2]);
456                    rrv_mv_scaleup(&mv[3]);
457    
458                    DPRINTF(DPRINTF_MB,"        %i,%i  %i,%i  %i,%i  %i,%i",
459                            mv[0].x, mv[0].y,
460                            mv[1].x, mv[1].y,
461                            mv[2].x, mv[2].y,
462                            mv[3].x, mv[3].y);
463            }else{
464          pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);          pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
465          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
466          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
467            }
468    
469          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {
470                  uv_dx = pMB->mvs[0].x;                  uv_dx = mv[0].x;
471                  uv_dy = pMB->mvs[0].y;                  uv_dy = mv[0].y;
472    
473                  if (dec->quarterpel)                  if (dec->quarterpel)
474                  {                  {
# Line 408  Line 480 
480                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];
481    
482                  start_timer();                  start_timer();
483                    if (reduced_resolution)
484                    {
485                            interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
486                                                                      mv[0].x, mv[0].y, stride,  rounding);
487                            interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
488                                                                      uv_dx, uv_dy, stride2, rounding);
489                            interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
490                                                                      uv_dx, uv_dy, stride2, rounding);
491    
492                    }
493                    else
494                    {
495                  if(dec->quarterpel) {                  if(dec->quarterpel) {
496                          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,
497                                                                              dec->refh.y + 128, 16*x_pos, 16*y_pos,                                                                              dec->refh.y + 128, 16*x_pos, 16*y_pos,
498                                                                              pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                                          mv[0].x, mv[0].y, stride,  rounding);
499                  }                  }
500                  else {                  else {
501                          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,
502                                                                    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);  
503                  }                  }
504    
505                  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,
506                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
507                  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,
508                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
509                    }
510                  stop_comp_timer();                  stop_comp_timer();
511    
512          } else {          } else {        /* MODE_INTER4V */
513                  int sum;                  int sum;
514    
515                  if(dec->quarterpel)                  if(dec->quarterpel)
516                          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);
517                  else                  else
518                          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;
519    
520                  uv_dx = (sum >> 3) + roundtab_76[sum & 0xf];                  uv_dx = (sum >> 3) + roundtab_76[sum & 0xf];
521    
522                  if(dec->quarterpel)                  if(dec->quarterpel)
523                          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);
524                  else                  else
525                          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;
526    
527                  uv_dy = (sum >> 3) + roundtab_76[sum & 0xf];                  uv_dy = (sum >> 3) + roundtab_76[sum & 0xf];
528    
529                  start_timer();                  start_timer();
530                    if (reduced_resolution)
531                    {
532                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
533                                                                      mv[0].x, mv[0].y, stride,  rounding);
534                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos,
535                                                                      mv[1].x, mv[1].y, stride,  rounding);
536                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos + 16,
537                                                                      mv[2].x, mv[2].y, stride,  rounding);
538                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos + 16,
539                                                                      mv[3].x, mv[3].y, stride,  rounding);
540                            interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
541                                                                      uv_dx, uv_dy, stride2, rounding);
542                            interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
543                                                                      uv_dx, uv_dy, stride2, rounding);
544    
545                            // set_block(pY_Cur, stride, 32, 32, 127);
546                    }
547                    else
548                    {
549                  if(dec->quarterpel) {                  if(dec->quarterpel) {
550                          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,
551                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos,                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos,
552                                                                            pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                                    mv[0].x, mv[0].y, stride,  rounding);
553                          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,
554                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos,                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos,
555                                                                            pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);                                                                                    mv[1].x, mv[1].y, stride,  rounding);
556                          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,
557                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos + 8,                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos + 8,
558                                                                            pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);                                                                                    mv[2].x, mv[2].y, stride,  rounding);
559                          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,
560                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8,                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8,
561                                                                            pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);                                                                                    mv[3].x, mv[3].y, stride,  rounding);
562                  }                  }
563                  else {                  else {
564                          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,
565                                                                    pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                            mv[0].x, mv[0].y, stride,  rounding);
566                          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,
567                                                                    pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);                                                                            mv[1].x, mv[1].y, stride,  rounding);
568                          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,
569                                                                    pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);                                                                            mv[2].x, mv[2].y, stride,  rounding);
570                          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,
571                                                                    pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);                                                                            mv[3].x, mv[3].y, stride,  rounding);
572                  }                  }
573    
574                  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,
575                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
576                  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,
577                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
578                    }
579                  stop_comp_timer();                  stop_comp_timer();
580          }          }
581    
# Line 511  Line 610 
610          }          }
611    
612          start_timer();          start_timer();
613            if (reduced_resolution)
614            {
615                    if (cbp & 32)
616                            add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
617                    if (cbp & 16)
618                            add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);
619                    if (cbp & 8)
620                            add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);
621                    if (cbp & 4)
622                            add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);
623                    if (cbp & 2)
624                            add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);
625                    if (cbp & 1)
626                            add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);
627            }
628            else
629            {
630          if (cbp & 32)          if (cbp & 32)
631                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);
632          if (cbp & 16)          if (cbp & 16)
# Line 523  Line 639 
639                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
640          if (cbp & 1)          if (cbp & 1)
641                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
642            }
643          stop_transfer_timer();          stop_transfer_timer();
644  }  }
645    
# Line 563  Line 680 
680                          {                          {
681                                  bound = read_video_packet_header(bs, dec, 0,                                  bound = read_video_packet_header(bs, dec, 0,
682                                                          &quant, NULL, NULL, &intra_dc_threshold);                                                          &quant, NULL, NULL, &intra_dc_threshold);
683                                  x = bound % dec->mb_width;                                  x = bound % mb_width;
684                                  y = bound / dec->mb_width;                                  y = bound / mb_width;
685                          }                          }
686                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
687    
# Line 599  Line 716 
716                          }                          }
717    
718                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
719                                                          intra_dc_threshold, bound);                                                          intra_dc_threshold, bound, reduced_resolution);
720    
721                  }                  }
722                  if(dec->out_frm)                  if(dec->out_frm)
723                    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);
724          }          }
725    
726  }  }
# Line 615  Line 732 
732                                    int x,                                    int x,
733                                    int y,                                    int y,
734                                    int k,                                    int k,
735                                    VECTOR * mv,                                    VECTOR * ret_mv,
736                                    int fcode,                                    int fcode,
737                                    const int bound)                                    const int bound)
738  {  {
# Line 626  Line 743 
743          int range = (64 * scale_fac);          int range = (64 * scale_fac);
744    
745          VECTOR pmv;          VECTOR pmv;
746          int mv_x, mv_y;          VECTOR mv;
747    
748          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);
749    
750          mv_x = get_mv(bs, fcode);          mv.x = get_mv(bs, fcode);
751          mv_y = get_mv(bs, fcode);          mv.y = get_mv(bs, fcode);
752    
753          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);
754    
755          mv_x += pmv.x;          mv.x += pmv.x;
756          mv_y += pmv.y;          mv.y += pmv.y;
757    
758          if (mv_x < low) {          if (mv.x < low) {
759                  mv_x += range;                  mv.x += range;
760          } else if (mv_x > high) {          } else if (mv.x > high) {
761                  mv_x -= range;                  mv.x -= range;
762          }          }
763    
764          if (mv_y < low) {          if (mv.y < low) {
765                  mv_y += range;                  mv.y += range;
766          } else if (mv_y > high) {          } else if (mv.y > high) {
767                  mv_y -= range;                  mv.y -= range;
768          }          }
769    
770          mv->x = mv_x;          ret_mv->x = mv.x;
771          mv->y = mv_y;          ret_mv->y = mv.y;
772  }  }
773    
774    
# Line 685  Line 802 
802          uint32_t x, y;          uint32_t x, y;
803          uint32_t bound;          uint32_t bound;
804          int cp_mb, st_mb;          int cp_mb, st_mb;
805            int mb_width = dec->mb_width;
806            int mb_height = dec->mb_height;
807    
808            if (reduced_resolution)
809            {
810                    mb_width /= 2;
811                    mb_height /= 2;
812            }
813    
814          start_timer();          start_timer();
815          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
# Line 693  Line 818 
818    
819          bound = 0;          bound = 0;
820    
821          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < mb_height; y++) {
822                  cp_mb = st_mb = 0;                  cp_mb = st_mb = 0;
823                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < mb_width; x++) {
824                          MACROBLOCK *mb;                          MACROBLOCK *mb;
825    
826                          // skip stuffing                          // skip stuffing
# Line 706  Line 831 
831                          {                          {
832                                  bound = read_video_packet_header(bs, dec, fcode - 1,                                  bound = read_video_packet_header(bs, dec, fcode - 1,
833                                          &quant, &fcode, NULL, &intra_dc_threshold);                                          &quant, &fcode, NULL, &intra_dc_threshold);
834                                  x = bound % dec->mb_width;                                  x = bound % mb_width;
835                                  y = bound / dec->mb_width;                                  y = bound / mb_width;
836                          }                          }
837                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
838    
# Line 814  Line 939 
939                                          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 =
940                                                  0;                                                  0;
941                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
942                                                                          intra_dc_threshold, bound);                                                                          intra_dc_threshold, bound, reduced_resolution);
943                                          continue;                                          continue;
944                                  }                                  }
945    
946                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,
947                                                                  rounding);                                                                  rounding, reduced_resolution);
948    
949                          }                          }
950                          else if (gmc_mv)        /* not coded S_VOP macroblock */                          else if (gmc_mv)        /* not coded S_VOP macroblock */
# Line 827  Line 952 
952                                  mb->mode = MODE_NOT_CODED;                                  mb->mode = MODE_NOT_CODED;
953                                  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);
954                                  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);
955                                  decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding);                                  decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution);
956                          }                          }
957                          else    /* not coded P_VOP macroblock */                          else    /* not coded P_VOP macroblock */
958                          {                          {
959                                  mb->mode = MODE_NOT_CODED;                                  mb->mode = MODE_NOT_CODED;
960    
961                                  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;
962                                  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;
963                                  // copy macroblock directly from ref to cur                                  // copy macroblock directly from ref to cur
964    
965                                  start_timer();                                  start_timer();
966    
967                                  transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width +                                  if (reduced_resolution)
968                                                                   (16 * x),                                  {
969                                                                   dec->refn[0].y + (16 * y) * dec->edged_width +                                          transfer32x32_copy(dec->cur.y + (32*y)*dec->edged_width + (32*x),
970                                                                   (16 * x), dec->edged_width);                                                                           dec->refn[0].y + (32*y)*dec->edged_width + (32*x),
971                                                                             dec->edged_width);
972                                  transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width +  
973                                                                   (16 * x + 8),                                          transfer16x16_copy(dec->cur.u + (16*y)*dec->edged_width/2 + (16*x),
974                                                                   dec->refn[0].y + (16 * y) * dec->edged_width +                                                                          dec->refn[0].u + (16*y)*dec->edged_width/2 + (16*x),
975                                                                   (16 * x + 8), dec->edged_width);                                                                          dec->edged_width/2);
976    
977                                  transfer8x8_copy(dec->cur.y + (16 * y + 8) * dec->edged_width +                                          transfer16x16_copy(dec->cur.v + (16*y)*dec->edged_width/2 + (16*x),
978                                                                   (16 * x),                                                                           dec->refn[0].v + (16*y)*dec->edged_width/2 + (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),  
979                                                                   dec->edged_width / 2);                                                                   dec->edged_width / 2);
980                                    }
981                                    else
982                                    {
983                                            transfer16x16_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x),
984                                                                             dec->refn[0].y + (16*y)*dec->edged_width + (16*x),
985                                                                             dec->edged_width);
986    
987                                  transfer8x8_copy(dec->cur.v + (8 * y) * dec->edged_width / 2 +                                          transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x),
988                                                                   (8 * x),                                                                          dec->refn[0].u + (8*y)*dec->edged_width/2 + (8*x),
                                                                  dec->refn[0].v +  
                                                                  (8 * y) * dec->edged_width / 2 + (8 * x),  
989                                                                   dec->edged_width / 2);                                                                   dec->edged_width / 2);
990    
991                                            transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x),
992                                                                             dec->refn[0].v + (8*y)*dec->edged_width/2 + (8*x),
993                                                                             dec->edged_width/2);
994                                    }
995    
996                                  stop_transfer_timer();                                  stop_transfer_timer();
997    
998                                  if(dec->out_frm && cp_mb > 0) {                                  if(dec->out_frm && cp_mb > 0) {
# Line 1226  Line 1347 
1347          interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,          interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,
1348                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,
1349                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos,                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos,
1350                                                  stride, 0, 8);                                                  stride, 1, 8);
1351    
1352          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,
1353                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,
1354                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8,                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8,
1355                                                  stride, 0, 8);                                                  stride, 1, 8);
1356    
1357          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,
1358                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,
1359                                                  dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos,                                                  dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos,
1360                                                  stride, 0, 8);                                                  stride, 1, 8);
1361    
1362          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,
1363                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,
1364                                                  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,
1365                                                  stride, 0, 8);                                                  stride, 1, 8);
1366    
1367          interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,          interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,
1368                                                  dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,
1369                                                  dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos,
1370                                                  stride2, 0, 8);                                                  stride2, 1, 8);
1371    
1372          interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,          interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,
1373                                                  dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,
1374                                                  dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos,
1375                                                  stride2, 0, 8);                                                  stride2, 1, 8);
1376    
1377          stop_comp_timer();          stop_comp_timer();
1378    
# Line 1563  Line 1684 
1684                  BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,                  BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,
1685                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv);                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv);
1686    
1687          DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type);          //DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type);
1688    
1689          if (vop_type == -1 && success)          if (vop_type == -1 && success)
1690                  goto done;                  goto done;
# Line 1642  Line 1763 
1763                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1764          }          }
1765    
1766    
1767            /* reduced resolution deblocking filter */
1768    
1769            if (reduced_resolution)
1770            {
1771                    const int rmb_height = dec->mb_height / 2;
1772                    const int rmb_width = dec->mb_width / 2;
1773                    const int edged_width2 = dec->edged_width /2;
1774                    int i,j;
1775    
1776                    /* horizontal deblocking */
1777    
1778                    for (j = 1; j < rmb_height*2; j++)      // luma: j,i in block units
1779                    for (i = 0; i < rmb_width*2; i++)
1780                    {
1781                            if (dec->mbs[(j-1)/2*dec->mb_width + (i/2)].mode != MODE_NOT_CODED ||
1782                                    dec->mbs[(j+0)/2*dec->mb_width + (i/2)].mode != MODE_NOT_CODED)
1783                            {
1784                                    xvid_HFilter_31_C(dec->cur.y + (j*16 - 1)*dec->edged_width + i*16,
1785                                                                  dec->cur.y + (j*16 + 0)*dec->edged_width + i*16, 2);
1786                            }
1787                    }
1788    
1789                    for (j = 1; j < rmb_height; j++)        // chroma
1790                    for (i = 0; i < rmb_width; i++)
1791                    {
1792                            if (dec->mbs[(j-1)*dec->mb_width + i].mode != MODE_NOT_CODED ||
1793                                    dec->mbs[(j+0)*dec->mb_width + i].mode != MODE_NOT_CODED)
1794                            {
1795                                    hfilter_31(dec->cur.u + (j*16 - 1)*edged_width2 + i*16,
1796                                                                      dec->cur.u + (j*16 + 0)*edged_width2 + i*16, 2);
1797                                    hfilter_31(dec->cur.v + (j*16 - 1)*edged_width2 + i*16,
1798                                                                      dec->cur.v + (j*16 + 0)*edged_width2 + i*16, 2);
1799                            }
1800                    }
1801    
1802                    /* vertical deblocking */
1803    
1804                    for (j = 0; j < rmb_height*2; j++)              // luma: i,j in block units
1805                    for (i = 1; i < rmb_width*2; i++)
1806                    {
1807                            if (dec->mbs[(j/2)*dec->mb_width + (i-1)/2].mode != MODE_NOT_CODED ||
1808                                    dec->mbs[(j/2)*dec->mb_width + (i+0)/2].mode != MODE_NOT_CODED)
1809                            {
1810                                    vfilter_31(dec->cur.y + (j*16)*dec->edged_width + i*16 - 1,
1811                                                                  dec->cur.y + (j*16)*dec->edged_width + i*16 + 0,
1812                                                                      dec->edged_width, 2);
1813                            }
1814                    }
1815    
1816                    for (j = 0; j < rmb_height; j++)        // chroma
1817                    for (i = 1; i < rmb_width; i++)
1818                    {
1819                            if (dec->mbs[j*dec->mb_width + i - 1].mode != MODE_NOT_CODED ||
1820                                    dec->mbs[j*dec->mb_width + i + 0].mode != MODE_NOT_CODED)
1821                            {
1822                                    vfilter_31(dec->cur.u + (j*16)*edged_width2 + i*16 - 1,
1823                                                                      dec->cur.u + (j*16)*edged_width2 + i*16 + 0,
1824                                                                      edged_width2, 2);
1825                                    vfilter_31(dec->cur.v + (j*16)*edged_width2 + i*16 - 1,
1826                                                                      dec->cur.v + (j*16)*edged_width2 + i*16 + 0,
1827                                                                      edged_width2, 2);
1828                            }
1829                    }
1830            }
1831    
1832          BitstreamByteAlign(&bs);          BitstreamByteAlign(&bs);
1833    
1834  #ifdef BFRAMES_DEC  #ifdef BFRAMES_DEC
# Line 1685  Line 1872 
1872                          mb_swap(&dec->mbs, &dec->last_mbs);                          mb_swap(&dec->mbs, &dec->last_mbs);
1873          }          }
1874    
         success = 1;  
1875    
1876          if (frame->length > BitstreamPos(&bs) / 8)      // multiple vops packed together          if (success == 0 && dec->packed_mode)
1877            {
1878                    success = 1;
1879            //      if (frame->length > BitstreamPos(&bs) / 8)      // multiple vops packed together
1880                  goto start;                  goto start;
1881            }
1882    
1883  done :  done :
1884    

Legend:
Removed from v.1.37.2.13  
changed lines
  Added in v.1.37.2.16

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4