[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.18, Tue Dec 10 11:13:50 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 376  Line 398 
398                                  const uint32_t cbp,                                  const uint32_t cbp,
399                                  Bitstream * bs,                                  Bitstream * bs,
400                                  const uint32_t quant,                                  const uint32_t quant,
401                                  const uint32_t rounding)                                  const uint32_t rounding,
402                                    const int reduced_resolution)
403  {  {
404    
405          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
# Line 384  Line 407 
407    
408          uint32_t stride = dec->edged_width;          uint32_t stride = dec->edged_width;
409          uint32_t stride2 = stride / 2;          uint32_t stride2 = stride / 2;
410          uint32_t next_block = stride * 8;          uint32_t next_block = stride * (reduced_resolution ? 16 : 8);
411          uint32_t i;          uint32_t i;
412          uint32_t iQuant = pMB->quant;          uint32_t iQuant = pMB->quant;
413          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
414    
415          int uv_dx, uv_dy;          int uv_dx, uv_dy;
416            VECTOR mv[4];   /* local copy of mvs */
417    
418            if (reduced_resolution) {
419                    pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5);
420                    pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4);
421                    pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4);
422                    for (i = 0; i < 4; i++) {
423                            mv[i].x = RRV_MV_SCALEUP(pMB->mvs[i].x);
424                            mv[i].y = RRV_MV_SCALEUP(pMB->mvs[i].y);
425                    }
426            }else{
427          pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);          pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
428          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
429          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
430                    for (i = 0; i < 4; i++)
431                            mv[i] = pMB->mvs[i];
432            }
433    
434          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {
435                  uv_dx = pMB->mvs[0].x;                  uv_dx = mv[0].x;
436                  uv_dy = pMB->mvs[0].y;                  uv_dy = mv[0].y;
437    
438                  if (dec->quarterpel)                  if (dec->quarterpel)
439                  {                  {
# Line 408  Line 445 
445                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];
446    
447                  start_timer();                  start_timer();
448                    if (reduced_resolution)
449                    {
450                            interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
451                                                                      mv[0].x, mv[0].y, stride,  rounding);
452                            interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
453                                                                      uv_dx, uv_dy, stride2, rounding);
454                            interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
455                                                                      uv_dx, uv_dy, stride2, rounding);
456    
457                    }
458                    else
459                    {
460                  if(dec->quarterpel) {                  if(dec->quarterpel) {
461                          interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,                          interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,
462                                                                              dec->refh.y + 128, 16*x_pos, 16*y_pos,                                                                              dec->refh.y + 128, 16*x_pos, 16*y_pos,
463                                                                              pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                                          mv[0].x, mv[0].y, stride,  rounding);
464                  }                  }
465                  else {                  else {
466                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos,                                  interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos,
467                                                                    pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                            mv[0].x, mv[0].y, stride,  rounding);
                         interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos,  
                                                               pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);  
                         interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8,  
                                                                   pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);  
                         interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8,  
                                                                   pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);  
468                  }                  }
469    
470                  interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos,                  interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos,
471                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
472                  interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos,                  interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos,
473                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
474                    }
475                  stop_comp_timer();                  stop_comp_timer();
476    
477          } else {          } else {        /* MODE_INTER4V */
478                  int sum;                  int sum;
479    
480                  if(dec->quarterpel)                  if(dec->quarterpel)
481                          sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2);                          sum = (mv[0].x / 2) + (mv[1].x / 2) + (mv[2].x / 2) + (mv[3].x / 2);
482                  else                  else
483                          sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x;                          sum = mv[0].x + mv[1].x + mv[2].x + mv[3].x;
484    
485                  uv_dx = (sum >> 3) + roundtab_76[sum & 0xf];                  uv_dx = (sum >> 3) + roundtab_76[sum & 0xf];
486    
487                  if(dec->quarterpel)                  if(dec->quarterpel)
488                          sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2);                          sum = (mv[0].y / 2) + (mv[1].y / 2) + (mv[2].y / 2) + (mv[3].y / 2);
489                  else                  else
490                          sum = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y;                          sum = mv[0].y + mv[1].y + mv[2].y + mv[3].y;
491    
492                  uv_dy = (sum >> 3) + roundtab_76[sum & 0xf];                  uv_dy = (sum >> 3) + roundtab_76[sum & 0xf];
493    
494                  start_timer();                  start_timer();
495                    if (reduced_resolution)
496                    {
497                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
498                                                                      mv[0].x, mv[0].y, stride,  rounding);
499                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos,
500                                                                      mv[1].x, mv[1].y, stride,  rounding);
501                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos + 16,
502                                                                      mv[2].x, mv[2].y, stride,  rounding);
503                            interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos + 16, 32*y_pos + 16,
504                                                                      mv[3].x, mv[3].y, stride,  rounding);
505                            interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
506                                                                      uv_dx, uv_dy, stride2, rounding);
507                            interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
508                                                                      uv_dx, uv_dy, stride2, rounding);
509    
510                            // set_block(pY_Cur, stride, 32, 32, 127);
511                    }
512                    else
513                    {
514                  if(dec->quarterpel) {                  if(dec->quarterpel) {
515                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,
516                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos,                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos,
517                                                                            pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                                    mv[0].x, mv[0].y, stride,  rounding);
518                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,
519                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos,                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos,
520                                                                            pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);                                                                                    mv[1].x, mv[1].y, stride,  rounding);
521                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,
522                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos + 8,                                                                            dec->refh.y + 128, 16*x_pos, 16*y_pos + 8,
523                                                                            pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);                                                                                    mv[2].x, mv[2].y, stride,  rounding);
524                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y, dec->refh.y, dec->refh.y + 64,
525                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8,                                                                            dec->refh.y + 128, 16*x_pos + 8, 16*y_pos + 8,
526                                                                            pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);                                                                                    mv[3].x, mv[3].y, stride,  rounding);
527                  }                  }
528                  else {                  else {
529                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos,                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos,
530                                                                    pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);                                                                            mv[0].x, mv[0].y, stride,  rounding);
531                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos,                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos,
532                                                                    pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);                                                                            mv[1].x, mv[1].y, stride,  rounding);
533                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8,                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos + 8,
534                                                                    pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);                                                                            mv[2].x, mv[2].y, stride,  rounding);
535                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8,                          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos + 8, 16*y_pos + 8,
536                                                                    pMB->mvs[3].x, pMB->mvs[3].y, stride,  rounding);                                                                            mv[3].x, mv[3].y, stride,  rounding);
537                  }                  }
538    
539                  interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos,                  interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos,
540                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
541                  interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos,                  interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos,
542                                                            uv_dx, uv_dy, stride2, rounding);                                                            uv_dx, uv_dy, stride2, rounding);
543                    }
544                  stop_comp_timer();                  stop_comp_timer();
545          }          }
546    
# Line 511  Line 575 
575          }          }
576    
577          start_timer();          start_timer();
578            if (reduced_resolution)
579            {
580                    if (cbp & 32)
581                            add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
582                    if (cbp & 16)
583                            add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);
584                    if (cbp & 8)
585                            add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);
586                    if (cbp & 4)
587                            add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);
588                    if (cbp & 2)
589                            add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);
590                    if (cbp & 1)
591                            add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);
592            }
593            else
594            {
595          if (cbp & 32)          if (cbp & 32)
596                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);
597          if (cbp & 16)          if (cbp & 16)
# Line 523  Line 604 
604                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
605          if (cbp & 1)          if (cbp & 1)
606                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
607            }
608          stop_transfer_timer();          stop_transfer_timer();
609  }  }
610    
# Line 541  Line 623 
623    
624          if (reduced_resolution)          if (reduced_resolution)
625          {          {
626                  mb_width /= 2;                  mb_width = (dec->width + 31) / 32;
627                  mb_height /= 2;                  mb_height = (dec->height + 31) / 32;
628          }          }
629    
630          bound = 0;          bound = 0;
# Line 563  Line 645 
645                          {                          {
646                                  bound = read_video_packet_header(bs, dec, 0,                                  bound = read_video_packet_header(bs, dec, 0,
647                                                          &quant, NULL, NULL, &intra_dc_threshold);                                                          &quant, NULL, NULL, &intra_dc_threshold);
648                                  x = bound % dec->mb_width;                                  x = bound % mb_width;
649                                  y = bound / dec->mb_width;                                  y = bound / mb_width;
650                          }                          }
651                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
652    
# Line 599  Line 681 
681                          }                          }
682    
683                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
684                                                          intra_dc_threshold, bound);                                                          intra_dc_threshold, bound, reduced_resolution);
685    
686                  }                  }
687                  if(dec->out_frm)                  if(dec->out_frm)
688                    output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,dec->mb_width);                    output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,0,y,mb_width);
689          }          }
690    
691  }  }
# Line 615  Line 697 
697                                    int x,                                    int x,
698                                    int y,                                    int y,
699                                    int k,                                    int k,
700                                    VECTOR * mv,                                    VECTOR * ret_mv,
701                                    int fcode,                                    int fcode,
702                                    const int bound)                                    const int bound)
703  {  {
# Line 626  Line 708 
708          int range = (64 * scale_fac);          int range = (64 * scale_fac);
709    
710          VECTOR pmv;          VECTOR pmv;
711          int mv_x, mv_y;          VECTOR mv;
712    
713          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);
714    
715          mv_x = get_mv(bs, fcode);          mv.x = get_mv(bs, fcode);
716          mv_y = get_mv(bs, fcode);          mv.y = get_mv(bs, fcode);
717    
718          DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i)", mv_x, mv_y, pmv.x, pmv.y);          DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i)", mv.x, mv.y, pmv.x, pmv.y);
719    
720          mv_x += pmv.x;          mv.x += pmv.x;
721          mv_y += pmv.y;          mv.y += pmv.y;
722    
723          if (mv_x < low) {          if (mv.x < low) {
724                  mv_x += range;                  mv.x += range;
725          } else if (mv_x > high) {          } else if (mv.x > high) {
726                  mv_x -= range;                  mv.x -= range;
727          }          }
728    
729          if (mv_y < low) {          if (mv.y < low) {
730                  mv_y += range;                  mv.y += range;
731          } else if (mv_y > high) {          } else if (mv.y > high) {
732                  mv_y -= range;                  mv.y -= range;
733          }          }
734    
735          mv->x = mv_x;          ret_mv->x = mv.x;
736          mv->y = mv_y;          ret_mv->y = mv.y;
737  }  }
738    
739    
# Line 685  Line 767 
767          uint32_t x, y;          uint32_t x, y;
768          uint32_t bound;          uint32_t bound;
769          int cp_mb, st_mb;          int cp_mb, st_mb;
770            int mb_width = dec->mb_width;
771            int mb_height = dec->mb_height;
772    
773            if (reduced_resolution)
774            {
775                    mb_width = (dec->width + 31) / 32;
776                    mb_height = (dec->height + 31) / 32;
777            }
778    
779          start_timer();          start_timer();
780          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
# Line 693  Line 783 
783    
784          bound = 0;          bound = 0;
785    
786          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < mb_height; y++) {
787                  cp_mb = st_mb = 0;                  cp_mb = st_mb = 0;
788                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < mb_width; x++) {
789                          MACROBLOCK *mb;                          MACROBLOCK *mb;
790    
791                          // skip stuffing                          // skip stuffing
# Line 706  Line 796 
796                          {                          {
797                                  bound = read_video_packet_header(bs, dec, fcode - 1,                                  bound = read_video_packet_header(bs, dec, fcode - 1,
798                                          &quant, &fcode, NULL, &intra_dc_threshold);                                          &quant, &fcode, NULL, &intra_dc_threshold);
799                                  x = bound % dec->mb_width;                                  x = bound % mb_width;
800                                  y = bound / dec->mb_width;                                  y = bound / mb_width;
801                          }                          }
802                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
803    
# Line 814  Line 904 
904                                          mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =                                          mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =
905                                                  0;                                                  0;
906                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
907                                                                          intra_dc_threshold, bound);                                                                          intra_dc_threshold, bound, reduced_resolution);
908                                          continue;                                          continue;
909                                  }                                  }
910    
911                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,
912                                                                  rounding);                                                                  rounding, reduced_resolution);
913    
914                          }                          }
915                          else if (gmc_mv)        /* not coded S_VOP macroblock */                          else if (gmc_mv)        /* not coded S_VOP macroblock */
# Line 827  Line 917 
917                                  mb->mode = MODE_NOT_CODED;                                  mb->mode = MODE_NOT_CODED;
918                                  mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode);                                  mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode);
919                                  mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = gmc_sanitize(gmc_mv[0].y, dec->quarterpel, fcode);                                  mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = gmc_sanitize(gmc_mv[0].y, dec->quarterpel, fcode);
920                                  decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding);                                  decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution);
921                          }                          }
922                          else    /* not coded P_VOP macroblock */                          else    /* not coded P_VOP macroblock */
923                          {                          {
924                                  mb->mode = MODE_NOT_CODED;                                  mb->mode = MODE_NOT_CODED;
925    
926                                  mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0;                                  mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0;
927                                  mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0;                                  mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0;
928                                  // copy macroblock directly from ref to cur                                  // copy macroblock directly from ref to cur
929    
930                                  start_timer();                                  start_timer();
931    
932                                  transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width +                                  if (reduced_resolution)
933                                                                   (16 * x),                                  {
934                                                                   dec->refn[0].y + (16 * y) * dec->edged_width +                                          transfer32x32_copy(dec->cur.y + (32*y)*dec->edged_width + (32*x),
935                                                                   (16 * x), dec->edged_width);                                                                           dec->refn[0].y + (32*y)*dec->edged_width + (32*x),
936                                                                             dec->edged_width);
937                                  transfer8x8_copy(dec->cur.y + (16 * y) * dec->edged_width +  
938                                                                   (16 * x + 8),                                          transfer16x16_copy(dec->cur.u + (16*y)*dec->edged_width/2 + (16*x),
939                                                                   dec->refn[0].y + (16 * y) * dec->edged_width +                                                                          dec->refn[0].u + (16*y)*dec->edged_width/2 + (16*x),
940                                                                   (16 * x + 8), dec->edged_width);                                                                          dec->edged_width/2);
941    
942                                  transfer8x8_copy(dec->cur.y + (16 * y + 8) * dec->edged_width +                                          transfer16x16_copy(dec->cur.v + (16*y)*dec->edged_width/2 + (16*x),
943                                                                   (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),  
944                                                                   dec->edged_width / 2);                                                                   dec->edged_width / 2);
945                                    }
946                                    else
947                                    {
948                                            transfer16x16_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x),
949                                                                             dec->refn[0].y + (16*y)*dec->edged_width + (16*x),
950                                                                             dec->edged_width);
951    
952                                  transfer8x8_copy(dec->cur.v + (8 * y) * dec->edged_width / 2 +                                          transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x),
953                                                                   (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),  
954                                                                   dec->edged_width / 2);                                                                   dec->edged_width / 2);
955    
956                                            transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x),
957                                                                             dec->refn[0].v + (8*y)*dec->edged_width/2 + (8*x),
958                                                                             dec->edged_width/2);
959                                    }
960    
961                                  stop_transfer_timer();                                  stop_transfer_timer();
962    
963                                  if(dec->out_frm && cp_mb > 0) {                                  if(dec->out_frm && cp_mb > 0) {
# Line 1226  Line 1312 
1312          interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,          interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,
1313                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,
1314                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos,                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos,
1315                                                  stride, 0, 8);                                                  stride, 1, 8);
1316    
1317          interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,          interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,
1318                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,                                                  dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,
1319                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8,                                                  dec->refn[2].y + (16 * y_pos * stride) + 16 * x_pos + 8,
1320                                                  stride, 0, 8);                                                  stride, 1, 8);
1321    
1322          interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,          interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,
1323                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,
1324                                                  dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos,                                                  dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos,
1325                                                  stride, 0, 8);                                                  stride, 1, 8);
1326    
1327          interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,          interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,
1328                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,                                                  dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,
1329                                                  dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,                                                  dec->refn[2].y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,
1330                                                  stride, 0, 8);                                                  stride, 1, 8);
1331    
1332          interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,          interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,
1333                                                  dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,
1334                                                  dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->refn[2].u + (8 * y_pos * stride2) + 8 * x_pos,
1335                                                  stride2, 0, 8);                                                  stride2, 1, 8);
1336    
1337          interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,          interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,
1338                                                  dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,
1339                                                  dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos,                                                  dec->refn[2].v + (8 * y_pos * stride2) + 8 * x_pos,
1340                                                  stride2, 0, 8);                                                  stride2, 1, 8);
1341    
1342          stop_comp_timer();          stop_comp_timer();
1343    
# Line 1563  Line 1649 
1649                  BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,                  BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,
1650                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv);                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, gmc_mv);
1651    
1652          DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type);          //DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type);
1653    
1654          if (vop_type == -1 && success)          if (vop_type == -1 && success)
1655                  goto done;                  goto done;
# Line 1642  Line 1728 
1728                  return XVID_ERR_FAIL;                  return XVID_ERR_FAIL;
1729          }          }
1730    
1731    
1732            if (reduced_resolution)
1733            {
1734                    image_deblock_rrv(&dec->cur, dec->edged_width, dec->mbs,
1735                            (dec->width + 31) / 32, (dec->height + 31) / 32, dec->mb_width);
1736            }
1737    
1738          BitstreamByteAlign(&bs);          BitstreamByteAlign(&bs);
1739    
1740  #ifdef BFRAMES_DEC  #ifdef BFRAMES_DEC
# Line 1685  Line 1778 
1778                          mb_swap(&dec->mbs, &dec->last_mbs);                          mb_swap(&dec->mbs, &dec->last_mbs);
1779          }          }
1780    
         success = 1;  
1781    
1782          if (frame->length > BitstreamPos(&bs) / 8)      // multiple vops packed together          if (success == 0 && dec->packed_mode)
1783            {
1784                    success = 1;
1785            //      if (frame->length > BitstreamPos(&bs) / 8)      // multiple vops packed together
1786                  goto start;                  goto start;
1787            }
1788    
1789  done :  done :
1790    

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

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