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

Diff of /trunk/xvidcore/src/decoder.c

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

revision 100, Thu Apr 4 13:58:18 2002 UTC revision 148, Sun Apr 28 23:35:25 2002 UTC
# Line 1  Line 1 
1  /**************************************************************************  /**************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC   *      XVID MPEG-4 VIDEO CODEC
4   *      decoder main   *  -  Decoder main module  -
5   *   *
6   *      This program is an implementation of a part of one or more MPEG-4   *      This program is an implementation of a part of one or more MPEG-4
7   *      Video tools as specified in ISO/IEC 14496-2 standard.  Those intending   *      Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
# Line 12  Line 12 
12   *      editors and their companies, will have no liability for use of this   *      editors and their companies, will have no liability for use of this
13   *      software or modifications or derivatives thereof.   *      software or modifications or derivatives thereof.
14   *   *
15   *      This program is xvid_free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
16   *      it under the terms of the GNU General Public License as published by   *      it under the terms of the GNU General Public License as published by
17   *      the xvid_free Software Foundation; either version 2 of the License, or   *  the Free Software Foundation; either version 2 of the License, or
18   *      (at your option) any later version.   *      (at your option) any later version.
19   *   *
20   *      This program is distributed in the hope that it will be useful,   *      This program is distributed in the hope that it will be useful,
# Line 23  Line 23 
23   *      GNU General Public License for more details.   *      GNU General Public License for more details.
24   *   *
25   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
26   *      along with this program; if not, write to the xvid_free Software   *  along with this program; if not, write to the Free Software
27   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
28   *   *
29   *************************************************************************/   *************************************************************************/
30    
# Line 32  Line 32 
32   *   *
33   *      History:   *      History:
34   *   *
35     *  22.04.2002  add some B-frame decode support;  chenm001 <chenm001@163.com>
36   *  29.03.2002  interlacing fix - compensated block wasn't being used when   *  29.03.2002  interlacing fix - compensated block wasn't being used when
37   *              reconstructing blocks, thus artifacts   *              reconstructing blocks, thus artifacts
38   *              interlacing speedup - used transfers to re-interlace   *              interlacing speedup - used transfers to re-interlace
39   *              interlaced decoding should be as fast as progressive now   *              interlaced decoding should be as fast as progressive now
40   *  26.03.2002  interlacing support - moved transfers outside decode loop   *  26.03.2002  interlacing support - moved transfers outside decode loop
41   *      26.12.2001      decoder_mbinter: dequant/idct moved within if(coded) block   *      26.12.2001      decoder_mbinter: dequant/idct moved within if(coded) block
42   *      22.12.2001      block based interpolation   *  22.12.2001  lock based interpolation
43   *      01.12.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>   *      01.12.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>
44   *   *
45     *  $Id: decoder.c,v 1.13 2002-04-28 23:35:25 edgomez Exp $
46     *
47   *************************************************************************/   *************************************************************************/
48    
49  #include <stdlib.h>  #include <stdlib.h>
50  #include <string.h>  // memset  #include <string.h>
51    
52  #include "xvid.h"  #include "xvid.h"
53  #include "portab.h"  #include "portab.h"
# Line 95  Line 98 
98                  return XVID_ERR_MEMORY;                  return XVID_ERR_MEMORY;
99          }          }
100    
101          if (image_create(&dec->refn, dec->edged_width, dec->edged_height))          if (image_create(&dec->refn[0], dec->edged_width, dec->edged_height))
102            {
103                    image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
104                    xvid_free(dec);
105                    return XVID_ERR_MEMORY;
106            }
107            // add by chenm001 <chenm001@163.com>
108            // for support B-frame to reference last 2 frame
109            if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height))
110          {          {
111                  image_destroy(&dec->cur, dec->edged_width, dec->edged_height);                  image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
112                    image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);
113                  xvid_free(dec);                  xvid_free(dec);
114                  return XVID_ERR_MEMORY;                  return XVID_ERR_MEMORY;
115          }          }
# Line 119  Line 131 
131  int decoder_destroy(DECODER * dec)  int decoder_destroy(DECODER * dec)
132  {  {
133          xvid_free(dec->mbs);          xvid_free(dec->mbs);
134          image_destroy(&dec->refn, dec->edged_width, dec->edged_height);          image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);
135          image_destroy(&dec->cur, dec->edged_width, dec->edged_height);          image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
136          xvid_free(dec);          xvid_free(dec);
137    
# Line 226  Line 238 
238                  stop_idct_timer();                  stop_idct_timer();
239          }          }
240    
241          if (pMB->field_dct)          if (dec->interlacing && pMB->field_dct)
242          {          {
243                  next_block = stride;                  next_block = stride;
244                  stride *= 2;                  stride *= 2;
# Line 299  Line 311 
311          }          }
312    
313          start_timer();          start_timer();
314          interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x_pos,     16*y_pos    , pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);          interpolate8x8_switch(dec->cur.y, dec->refn[0].y, 16*x_pos,     16*y_pos    , pMB->mvs[0].x, pMB->mvs[0].y, stride,  rounding);
315          interpolate8x8_switch(dec->cur.y, dec->refn.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 + 8, 16*y_pos    , pMB->mvs[1].x, pMB->mvs[1].y, stride,  rounding);
316          interpolate8x8_switch(dec->cur.y, dec->refn.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,     16*y_pos + 8, pMB->mvs[2].x, pMB->mvs[2].y, stride,  rounding);
317          interpolate8x8_switch(dec->cur.y, dec->refn.y, 16*x_pos + 8, 16*y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].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);
318          interpolate8x8_switch(dec->cur.u, dec->refn.u, 8*x_pos,      8*y_pos,      uv_dx,         uv_dy,         stride2, rounding);          interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8*x_pos,      8*y_pos,      uv_dx,         uv_dy,         stride2, rounding);
319          interpolate8x8_switch(dec->cur.v, dec->refn.v, 8*x_pos,      8*y_pos,      uv_dx,         uv_dy,         stride2, rounding);          interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8*x_pos,      8*y_pos,      uv_dx,         uv_dy,         stride2, rounding);
320          stop_comp_timer();          stop_comp_timer();
321    
322          for (i = 0; i < 6; i++)          for (i = 0; i < 6; i++)
# Line 334  Line 346 
346                  }                  }
347          }          }
348    
349          if (pMB->field_dct)          if (dec->interlacing && pMB->field_dct)
350          {          {
351                  next_block = stride;                  next_block = stride;
352                  stride *= 2;                  stride *= 2;
# Line 425  Line 437 
437          int range = (64 * scale_fac);          int range = (64 * scale_fac);
438    
439          VECTOR pmv[4];          VECTOR pmv[4];
440          uint32_t psad[4];          int32_t psad[4];
441    
442          int mv_x, mv_y;          int mv_x, mv_y;
443          int pmv_x, pmv_y;          int pmv_x, pmv_y;
# Line 471  Line 483 
483    
484          uint32_t x, y;          uint32_t x, y;
485    
         image_swap(&dec->cur, &dec->refn);  
   
486          start_timer();          start_timer();
487          image_setedges(&dec->refn, dec->edged_width, dec->edged_height, dec->width, dec->height, dec->interlacing);          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, dec->width, dec->height, dec->interlacing);
488          stop_edges_timer();          stop_edges_timer();
489    
490          for (y = 0; y < dec->mb_height; y++)          for (y = 0; y < dec->mb_height; y++)
# Line 590  Line 600 
600                                  start_timer();                                  start_timer();
601    
602                                  transfer8x8_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x),                                  transfer8x8_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x),
603                                                   dec->refn.y + (16*y)*dec->edged_width + (16*x),                                                   dec->refn[0].y + (16*y)*dec->edged_width + (16*x),
604                                                   dec->edged_width);                                                   dec->edged_width);
605    
606                                  transfer8x8_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x+8),                                  transfer8x8_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x+8),
607                                                   dec->refn.y + (16*y)*dec->edged_width + (16*x+8),                                                   dec->refn[0].y + (16*y)*dec->edged_width + (16*x+8),
608                                                   dec->edged_width);                                                   dec->edged_width);
609    
610                                  transfer8x8_copy(dec->cur.y + (16*y+8)*dec->edged_width + (16*x),                                  transfer8x8_copy(dec->cur.y + (16*y+8)*dec->edged_width + (16*x),
611                                                   dec->refn.y + (16*y+8)*dec->edged_width + (16*x),                                                   dec->refn[0].y + (16*y+8)*dec->edged_width + (16*x),
612                                                   dec->edged_width);                                                   dec->edged_width);
613    
614                                  transfer8x8_copy(dec->cur.y + (16*y+8)*dec->edged_width + (16*x+8),                                  transfer8x8_copy(dec->cur.y + (16*y+8)*dec->edged_width + (16*x+8),
615                                                   dec->refn.y + (16*y+8)*dec->edged_width + (16*x+8),                                                   dec->refn[0].y + (16*y+8)*dec->edged_width + (16*x+8),
616                                                   dec->edged_width);                                                   dec->edged_width);
617    
618                                  transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x),                                  transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x),
619                                                   dec->refn.u + (8*y)*dec->edged_width/2 + (8*x),                                                   dec->refn[0].u + (8*y)*dec->edged_width/2 + (8*x),
620                                                   dec->edged_width/2);                                                   dec->edged_width/2);
621    
622                                  transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x),                                  transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x),
623                                                   dec->refn.v + (8*y)*dec->edged_width/2 + (8*x),                                                   dec->refn[0].v + (8*y)*dec->edged_width/2 + (8*x),
624                                                   dec->edged_width/2);                                                   dec->edged_width/2);
625    
626                                  stop_transfer_timer();                                  stop_transfer_timer();
# Line 627  Line 637 
637          uint32_t quant;          uint32_t quant;
638          uint32_t fcode;          uint32_t fcode;
639          uint32_t intra_dc_threshold;          uint32_t intra_dc_threshold;
640            uint32_t vop_type;
641    
642          start_global_timer();          start_global_timer();
643    
644          BitstreamInit(&bs, frame->bitstream, frame->length);          BitstreamInit(&bs, frame->bitstream, frame->length);
645    
646          switch (BitstreamReadHeaders(&bs, dec, &rounding, &quant, &fcode, &intra_dc_threshold))          // add by chenm001 <chenm001@163.com>
647            // for support B-frame to reference last 2 frame
648            vop_type=BitstreamReadHeaders(&bs, dec, &rounding, &quant, &fcode, &intra_dc_threshold);
649    
650            if (vop_type==I_VOP || vop_type==P_VOP){
651                    image_swap(&dec->refn[0], &dec->refn[1]);
652                    image_swap(&dec->cur, &dec->refn[0]);
653            }
654    
655            switch (vop_type)
656          {          {
657          case P_VOP :          case P_VOP :
658                  decoder_pframe(dec, &bs, rounding, quant, fcode, intra_dc_threshold);                  decoder_pframe(dec, &bs, rounding, quant, fcode, intra_dc_threshold);

Legend:
Removed from v.100  
changed lines
  Added in v.148

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