[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.14, Wed Nov 20 22:28:25 2002 UTC revision 1.37.2.17, Mon Dec 9 10:47:05 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                    rrv_mv_scaleup(&mv[0]);
447                    rrv_mv_scaleup(&mv[1]);
448                    rrv_mv_scaleup(&mv[2]);
449                    rrv_mv_scaleup(&mv[3]);
450            }else{
451          pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);          pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
452          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
453          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
454            }
455    
456          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {
457                  uv_dx = pMB->mvs[0].x;                  uv_dx = mv[0].x;
458                  uv_dy = pMB->mvs[0].y;                  uv_dy = mv[0].y;
459    
460                  if (dec->quarterpel)                  if (dec->quarterpel)
461                  {                  {
# Line 408  Line 467 
467                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];
468    
469                  start_timer();                  start_timer();
470                    if (reduced_resolution)
471                    {
472                            interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
473                                                                      mv[0].x, mv[0].y, stride,  rounding);
474                            interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
475                                                                      uv_dx, uv_dy, stride2, rounding);
476                            interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
477                                                                      uv_dx, uv_dy, stride2, rounding);
478    
479                    }
480                    else
481                    {
482                  if(dec->quarterpel) {                  if(dec->quarterpel) {
483                          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,
484                                                                              dec->refh.y + 128, 16*x_pos, 16*y_pos,                                                                              dec->refh.y + 128, 16*x_pos, 16*y_pos,
485                                                                              pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                                          mv[0].x, mv[0].y, stride,  rounding);
486                  }                  }
487                  else {                  else {
488                          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,
489                                                                    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);  
490                  }                  }
491    
492                  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,
493                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
494                  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,
495                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
496                    }
497                  stop_comp_timer();                  stop_comp_timer();
498    
499          } else {          } else {        /* MODE_INTER4V */
500                  int sum;                  int sum;
501    
502                  if(dec->quarterpel)                  if(dec->quarterpel)
503                          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);
504                  else                  else
505                          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;
506    
507                  uv_dx = (sum >> 3) + roundtab_76[sum & 0xf];                  uv_dx = (sum >> 3) + roundtab_76[sum & 0xf];
508    
509                  if(dec->quarterpel)                  if(dec->quarterpel)
510                          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);
511                  else                  else
512                          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;
513    
514                  uv_dy = (sum >> 3) + roundtab_76[sum & 0xf];                  uv_dy = (sum >> 3) + roundtab_76[sum & 0xf];
515    
516                  start_timer();                  start_timer();
517                    if (reduced_resolution)
518                    {
519                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
520                                                                      mv[0].x, mv[0].y, stride,  rounding);
521                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos,
522                                                                      mv[1].x, mv[1].y, stride,  rounding);
523                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos + 16,
524                                                                      mv[2].x, mv[2].y, stride,  rounding);
525                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos + 16,
526                                                                      mv[3].x, mv[3].y, stride,  rounding);
527                            interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
528                                                                      uv_dx, uv_dy, stride2, rounding);
529                            interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
530                                                                      uv_dx, uv_dy, stride2, rounding);
531    
532                            // set_block(pY_Cur, stride, 32, 32, 127);
533                    }
534                    else
535                    {
536                  if(dec->quarterpel) {                  if(dec->quarterpel) {
537                          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,
538                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos,                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos,
539                                                                            pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                                    mv[0].x, mv[0].y, stride,  rounding);
540                          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,
541                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos,                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos,
542                                                                            pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);                                                                                    mv[1].x, mv[1].y, stride,  rounding);
543                          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,
544                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos + 8,                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos + 8,
545                                                                            pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);                                                                                    mv[2].x, mv[2].y, stride,  rounding);
546                          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,
547                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8,                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8,
548                                                                            pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);                                                                                    mv[3].x, mv[3].y, stride,  rounding);
549                  }                  }
550                  else {                  else {
551                          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,
552                                                                    pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                            mv[0].x, mv[0].y, stride,  rounding);
553                          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,
554                                                                    pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);                                                                            mv[1].x, mv[1].y, stride,  rounding);
555                          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,
556                                                                    pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);                                                                            mv[2].x, mv[2].y, stride,  rounding);
557                          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,
558                                                                    pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);                                                                            mv[3].x, mv[3].y, stride,  rounding);
559                  }                  }
560    
561                  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,
562                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
563                  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,
564                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
565                    }
566                  stop_comp_timer();                  stop_comp_timer();
567          }          }
568    
# Line 511  Line 597 
597          }          }
598    
599          start_timer();          start_timer();
600            if (reduced_resolution)
601            {
602                    if (cbp & 32)
603                            add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
604                    if (cbp & 16)
605                            add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);
606                    if (cbp & 8)
607                            add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);
608                    if (cbp & 4)
609                            add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);
610                    if (cbp & 2)
611                            add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);
612                    if (cbp & 1)
613                            add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);
614            }
615            else
616            {
617          if (cbp & 32)          if (cbp & 32)
618                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);
619          if (cbp & 16)          if (cbp & 16)
# Line 523  Line 626 
626                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
627          if (cbp & 1)          if (cbp & 1)
628                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
629            }
630          stop_transfer_timer();          stop_transfer_timer();
631  }  }
632    
# Line 541  Line 645 
645    
646          if (reduced_resolution)          if (reduced_resolution)
647          {          {
648                  mb_width /= 2;                  mb_width = (dec->width + 31) / 32;
649                  mb_height /= 2;                  mb_height = (dec->height + 31) / 32;
650          }          }
651    
652          bound = 0;          bound = 0;
# Line 563  Line 667 
667                          {                          {
668                                  bound = read_video_packet_header(bs, dec, 0,                                  bound = read_video_packet_header(bs, dec, 0,
669                                                          &quant, NULL, NULL, &intra_dc_threshold);                                                          &quant, NULL, NULL, &intra_dc_threshold);
670                                  x = bound % dec->mb_width;                                  x = bound % mb_width;
671                                  y = bound / dec->mb_width;                                  y = bound / mb_width;
672                          }                          }
673                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
674    
# Line 599  Line 703 
703                          }                          }
704    
705                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
706                                                          intra_dc_threshold, bound);                                                          intra_dc_threshold, bound, reduced_resolution);
707    
708                  }                  }
709                  if(dec->out_frm)                  if(dec->out_frm)
710                    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);
711          }          }
712    
713  }  }
# Line 615  Line 719 
719                                    int x,                                    int x,
720                                    int y,                                    int y,
721                                    int k,                                    int k,
722                                    VECTOR * mv,                                    VECTOR * ret_mv,
723                                    int fcode,                                    int fcode,
724                                    const int bound)                                    const int bound)
725  {  {
# Line 626  Line 730 
730          int range = (64 * scale_fac);          int range = (64 * scale_fac);
731    
732          VECTOR pmv;          VECTOR pmv;
733          int mv_x, mv_y;          VECTOR mv;
734    
735          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);
736    
737          mv_x = get_mv(bs, fcode);          mv.x = get_mv(bs, fcode);
738          mv_y = get_mv(bs, fcode);          mv.y = get_mv(bs, fcode);
739    
740          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);
741    
742          mv_x += pmv.x;          mv.x += pmv.x;
743          mv_y += pmv.y;          mv.y += pmv.y;
744    
745          if (mv_x < low) {          if (mv.x < low) {
746                  mv_x += range;                  mv.x += range;
747          } else if (mv_x > high) {          } else if (mv.x > high) {
748                  mv_x -= range;                  mv.x -= range;
749          }          }
750    
751          if (mv_y < low) {          if (mv.y < low) {
752                  mv_y += range;                  mv.y += range;
753          } else if (mv_y > high) {          } else if (mv.y > high) {
754                  mv_y -= range;                  mv.y -= range;
755          }          }
756    
757          mv->x = mv_x;          ret_mv->x = mv.x;
758          mv->y = mv_y;          ret_mv->y = mv.y;
759  }  }
760    
761    
# Line 685  Line 789 
789          uint32_t x, y;          uint32_t x, y;
790          uint32_t bound;          uint32_t bound;
791          int cp_mb, st_mb;          int cp_mb, st_mb;
792            int mb_width = dec->mb_width;
793            int mb_height = dec->mb_height;
794    
795            if (reduced_resolution)
796            {
797                    mb_width = (dec->width + 31) / 32;
798                    mb_height = (dec->height + 31) / 32;
799            }
800    
801          start_timer();          start_timer();
802          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 805 
805    
806          bound = 0;          bound = 0;
807    
808          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < mb_height; y++) {
809                  cp_mb = st_mb = 0;                  cp_mb = st_mb = 0;
810                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < mb_width; x++) {
811                          MACROBLOCK *mb;                          MACROBLOCK *mb;
812    
813                          // skip stuffing                          // skip stuffing
# Line 706  Line 818 
818                          {                          {
819                                  bound = read_video_packet_header(bs, dec, fcode - 1,                                  bound = read_video_packet_header(bs, dec, fcode - 1,
820                                          &quant, &fcode, NULL, &intra_dc_threshold);                                          &quant, &fcode, NULL, &intra_dc_threshold);
821                                  x = bound % dec->mb_width;                                  x = bound % mb_width;
822                                  y = bound / dec->mb_width;                                  y = bound / mb_width;
823                          }                          }
824                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
825    
# Line 814  Line 926 
926                                          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 =
927                                                  0;                                                  0;
928                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
929                                                                          intra_dc_threshold, bound);                                                                          intra_dc_threshold, bound, reduced_resolution);
930                                          continue;                                          continue;
931                                  }                                  }
932    
933                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,
934                                                                  rounding);                                                                  rounding, reduced_resolution);
935    
936                          }                          }
937                          else if (gmc_mv)        /* not coded S_VOP macroblock */                          else if (gmc_mv)        /* not coded S_VOP macroblock */
# Line 827  Line 939 
939                                  mb->mode = MODE_NOT_CODED;                                  mb->mode = MODE_NOT_CODED;
940                                  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);
941                                  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);
942                                  decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding);                                  decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution);
943                          }                          }
944                          else    /* not coded P_VOP macroblock */                          else    /* not coded P_VOP macroblock */
945                          {                          {
946                                  mb->mode = MODE_NOT_CODED;                                  mb->mode = MODE_NOT_CODED;
947    
948                                  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;
949                                  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;
950                                  // copy macroblock directly from ref to cur                                  // copy macroblock directly from ref to cur
951    
952                                  start_timer();                                  start_timer();
953    
954                                  transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width +                                  if (reduced_resolution)
955                                                                   (16 * x),                                  {
956                                                                   dec->refn[0].y + (16 * y) * dec->edged_width +                                          transfer32x32_copy(dec->cur.y + (32*y)*dec->edged_width + (32*x),
957                                                                   (16 * x), dec->edged_width);                                                                           dec->refn[0].y + (32*y)*dec->edged_width + (32*x),
958                                                                             dec->edged_width);
959                                  transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width +  
960                                                                   (16 * x + 8),                                          transfer16x16_copy(dec->cur.u + (16*y)*dec->edged_width/2 + (16*x),
961                                                                   dec->refn[0].y + (16 * y) * dec->edged_width +                                                                          dec->refn[0].u + (16*y)*dec->edged_width/2 + (16*x),
962                                                                   (16 * x + 8), dec->edged_width);                                                                          dec->edged_width/2);
963    
964                                  transfer8x8_copy(dec->cur.y + (16 * y + 8) * dec->edged_width +                                          transfer16x16_copy(dec->cur.v + (16*y)*dec->edged_width/2 + (16*x),
965                                                                   (16 * x),                                                                           dec->refn[0].v + (16*y)*dec->edged_width/2 + (16*x),
966                                                                   dec->refn[0].y + (16 * y +                                                                           dec->edged_width/2);
967                                                                                                     8) * dec->edged_width +                                  }
968                                                                   (16 * x), dec->edged_width);                                  else
969                                    {
970                                  transfer8x8_copy(dec->cur.y + (16 * y + 8) * dec->edged_width +                                          transfer16x16_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x),
971                                                                   (16 * x + 8),                                                                           dec->refn[0].y + (16*y)*dec->edged_width + (16*x),
972                                                                   dec->refn[0].y + (16 * y +                                                                           dec->edged_width);
973                                                                                                     8) * dec->edged_width +  
974                                                                   (16 * x + 8), dec->edged_width);                                          transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x),
975                                                                            dec->refn[0].u + (8*y)*dec->edged_width/2 + (8*x),
                                 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),  
976                                                                   dec->edged_width / 2);                                                                   dec->edged_width / 2);
977    
978                                  transfer8x8_copy(dec->cur.v + (8 * y) * dec->edged_width / 2 +                                          transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x),
979                                                                   (8 * x),                                                                           dec->refn[0].v + (8*y)*dec->edged_width/2 + (8*x),
                                                                  dec->refn[0].v +  
                                                                  (8 * y) * dec->edged_width / 2 + (8 * x),  
980                                                                   dec->edged_width / 2);                                                                   dec->edged_width / 2);
981                                    }
982    
983                                  stop_transfer_timer();                                  stop_transfer_timer();
984    
# Line 1563  Line 1671 
1671                  BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,                  BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,
1672                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv);                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv);
1673    
1674          DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type);          //DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type);
1675    
1676          if (vop_type == -1 && success)          if (vop_type == -1 && success)
1677                  goto done;                  goto done;
# Line 1642  Line 1750 
1750                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1751          }          }
1752    
1753    
1754            /* reduced resolution deblocking filter */
1755    
1756            if (reduced_resolution)
1757            {
1758                    const int rmb_width = (dec->width + 31) / 32;
1759                    const int rmb_height = (dec->height + 31) / 32;
1760                    const int edged_width2 = dec->edged_width /2;
1761                    int i,j;
1762    
1763                    /* horizontal deblocking */
1764    
1765                    for (j = 1; j < rmb_height*2; j++)      // luma: j,i in block units
1766                    for (i = 0; i < rmb_width*2; i++)
1767                    {
1768                            if (dec->mbs[(j-1)/2*dec->mb_width + (i/2)].mode != MODE_NOT_CODED ||
1769                                    dec->mbs[(j+0)/2*dec->mb_width + (i/2)].mode != MODE_NOT_CODED)
1770                            {
1771                                    xvid_HFilter_31_C(dec->cur.y + (j*16 - 1)*dec->edged_width + i*16,
1772                                                                  dec->cur.y + (j*16 + 0)*dec->edged_width + i*16, 2);
1773                            }
1774                    }
1775    
1776                    for (j = 1; j < rmb_height; j++)        // chroma
1777                    for (i = 0; i < rmb_width; i++)
1778                    {
1779                            if (dec->mbs[(j-1)*dec->mb_width + i].mode != MODE_NOT_CODED ||
1780                                    dec->mbs[(j+0)*dec->mb_width + i].mode != MODE_NOT_CODED)
1781                            {
1782                                    hfilter_31(dec->cur.u + (j*16 - 1)*edged_width2 + i*16,
1783                                                                      dec->cur.u + (j*16 + 0)*edged_width2 + i*16, 2);
1784                                    hfilter_31(dec->cur.v + (j*16 - 1)*edged_width2 + i*16,
1785                                                                      dec->cur.v + (j*16 + 0)*edged_width2 + i*16, 2);
1786                            }
1787                    }
1788    
1789                    /* vertical deblocking */
1790    
1791                    for (j = 0; j < rmb_height*2; j++)              // luma: i,j in block units
1792                    for (i = 1; i < rmb_width*2; i++)
1793                    {
1794                            if (dec->mbs[(j/2)*dec->mb_width + (i-1)/2].mode != MODE_NOT_CODED ||
1795                                    dec->mbs[(j/2)*dec->mb_width + (i+0)/2].mode != MODE_NOT_CODED)
1796                            {
1797                                    vfilter_31(dec->cur.y + (j*16)*dec->edged_width + i*16 - 1,
1798                                                                  dec->cur.y + (j*16)*dec->edged_width + i*16 + 0,
1799                                                                      dec->edged_width, 2);
1800                            }
1801                    }
1802    
1803                    for (j = 0; j < rmb_height; j++)        // chroma
1804                    for (i = 1; i < rmb_width; i++)
1805                    {
1806                            if (dec->mbs[j*dec->mb_width + i - 1].mode != MODE_NOT_CODED ||
1807                                    dec->mbs[j*dec->mb_width + i + 0].mode != MODE_NOT_CODED)
1808                            {
1809                                    vfilter_31(dec->cur.u + (j*16)*edged_width2 + i*16 - 1,
1810                                                                      dec->cur.u + (j*16)*edged_width2 + i*16 + 0,
1811                                                                      edged_width2, 2);
1812                                    vfilter_31(dec->cur.v + (j*16)*edged_width2 + i*16 - 1,
1813                                                                      dec->cur.v + (j*16)*edged_width2 + i*16 + 0,
1814                                                                      edged_width2, 2);
1815                            }
1816                    }
1817            }
1818    
1819          BitstreamByteAlign(&bs);          BitstreamByteAlign(&bs);
1820    
1821  #ifdef BFRAMES_DEC  #ifdef BFRAMES_DEC
# Line 1685  Line 1859 
1859                          mb_swap(&dec->mbs, &dec->last_mbs);                          mb_swap(&dec->mbs, &dec->last_mbs);
1860          }          }
1861    
         success = 1;  
1862    
1863          if (frame->length > BitstreamPos(&bs) / 8)      // multiple vops packed together          if (success == 0 && dec->packed_mode)
1864            {
1865                    success = 1;
1866            //      if (frame->length > BitstreamPos(&bs) / 8)      // multiple vops packed together
1867                  goto start;                  goto start;
1868            }
1869    
1870  done :  done :
1871    

Legend:
Removed from v.1.37.2.14  
changed lines
  Added in v.1.37.2.17

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