[svn] / branches / release-1_3-branch / xvidcore / src / image / image.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/src/image/image.c

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

revision 1382, Mon Mar 22 22:36:25 2004 UTC revision 1631, Fri Sep 9 12:18:10 2005 UTC
# Line 3  Line 3 
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  - Image management functions -   *  - Image management functions -
5   *   *
6   *  Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>   *  Copyright(C) 2001-2004 Peter Ross <pross@xvid.org>
7   *   *
8   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
9   *  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
# Line 19  Line 19 
19   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $Id: image.c,v 1.27 2004-03-22 22:36:23 edgomez Exp $   * $Id: image.c,v 1.32 2005-09-09 12:18:10 suxen_drol Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
26  #include <stdlib.h>  #include <stdlib.h>
27  #include <string.h>                             /* memcpy, memset */  #include <string.h>                             /* memcpy, memset */
28  #include <math.h>  #include <math.h>
   
29  #include "../portab.h"  #include "../portab.h"
30  #include "../global.h"                  /* XVID_CSP_XXX's */  #include "../global.h"                  /* XVID_CSP_XXX's */
31  #include "../xvid.h"                    /* XVID_CSP_XXX's */  #include "../xvid.h"                    /* XVID_CSP_XXX's */
32  #include "image.h"  #include "image.h"
33  #include "colorspace.h"  #include "colorspace.h"
34  #include "interpolate8x8.h"  #include "interpolate8x8.h"
 #include "reduced.h"  
35  #include "../utils/mem_align.h"  #include "../utils/mem_align.h"
36    #include "../motion/sad.h"
37    
38  #include "font.h"               /* XXX: remove later */  #include "font.h"               /* XXX: remove later */
39    
# Line 718  Line 717 
717                           int height,                           int height,
718                           uint32_t edged_width,                           uint32_t edged_width,
719                           uint8_t * dst[4],                           uint8_t * dst[4],
720                           uint32_t dst_stride[4],                           int dst_stride[4],
721                           int csp,                           int csp,
722                           int interlacing)                           int interlacing)
723  {  {
# Line 899  Line 898 
898                     uint16_t width,                     uint16_t width,
899                     uint16_t height)                     uint16_t height)
900  {  {
901          int diff, x, y;          int y, bwidth, bheight;
902          long sse=0;          long sse=0;
903    
904          for (y = 0; y < height; y++) {          bwidth  = width  & (~0x07);
905            bheight = height & (~0x07);
906    
907            /* Compute the 8x8 integer part */
908            for (y = 0; y<bheight; y += 8) {
909                    int x;
910    
911                    /* Compute sse for the band */
912                    for (x = 0; x<bwidth; x += 8)
913                            sse += sse8_8bit(orig  + x, recon + x, stride);
914    
915                    /* remaining pixels of the 8 pixels high band */
916                    for (x = bwidth; x < width; x++) {
917                            int diff;
918                            diff = *(orig + 0*stride + x) - *(recon + 0*stride + x);
919                            sse += diff * diff;
920                            diff = *(orig + 1*stride + x) - *(recon + 1*stride + x);
921                            sse += diff * diff;
922                            diff = *(orig + 2*stride + x) - *(recon + 2*stride + x);
923                            sse += diff * diff;
924                            diff = *(orig + 3*stride + x) - *(recon + 3*stride + x);
925                            sse += diff * diff;
926                            diff = *(orig + 4*stride + x) - *(recon + 4*stride + x);
927                            sse += diff * diff;
928                            diff = *(orig + 5*stride + x) - *(recon + 5*stride + x);
929                            sse += diff * diff;
930                            diff = *(orig + 6*stride + x) - *(recon + 6*stride + x);
931                            sse += diff * diff;
932                            diff = *(orig + 7*stride + x) - *(recon + 7*stride + x);
933                            sse += diff * diff;
934                    }
935    
936                    orig  += 8*stride;
937                    recon += 8*stride;
938            }
939    
940            /* Compute the down rectangle sse */
941            for (y = bheight; y < height; y++) {
942                    int x;
943                  for (x = 0; x < width; x++) {                  for (x = 0; x < width; x++) {
944                            int diff;
945                          diff = *(orig + x) - *(recon + x);                          diff = *(orig + x) - *(recon + x);
946                          sse += diff * diff;                          sse += diff * diff;
947                  }                  }
948                  orig += stride;                  orig += stride;
949                  recon += stride;                  recon += stride;
950          }          }
951          return sse;  
952            return (sse);
953  }  }
954    
955  #if 0  #if 0
# Line 1039  Line 1078 
1078  }  }
1079    
1080  void  void
1081  output_slice(IMAGE * cur, int std, int width, xvid_image_t* out_frm, int mbx, int mby,int mbl) {  output_slice(IMAGE * cur, int stride, int width, xvid_image_t* out_frm, int mbx, int mby,int mbl) {
1082    uint8_t *dY,*dU,*dV,*sY,*sU,*sV;    uint8_t *dY,*dU,*dV,*sY,*sU,*sV;
1083    int std2 = std >> 1;    int stride2 = stride >> 1;
1084    int w = mbl << 4, w2,i;    int w = mbl << 4, w2,i;
1085    
1086    if(w > width)    if(w > width)
# Line 1051  Line 1090 
1090    dY = (uint8_t*)out_frm->plane[0] + (mby << 4) * out_frm->stride[0] + (mbx << 4);    dY = (uint8_t*)out_frm->plane[0] + (mby << 4) * out_frm->stride[0] + (mbx << 4);
1091    dU = (uint8_t*)out_frm->plane[1] + (mby << 3) * out_frm->stride[1] + (mbx << 3);    dU = (uint8_t*)out_frm->plane[1] + (mby << 3) * out_frm->stride[1] + (mbx << 3);
1092    dV = (uint8_t*)out_frm->plane[2] + (mby << 3) * out_frm->stride[2] + (mbx << 3);    dV = (uint8_t*)out_frm->plane[2] + (mby << 3) * out_frm->stride[2] + (mbx << 3);
1093    sY = cur->y + (mby << 4) * std + (mbx << 4);    sY = cur->y + (mby << 4) * stride + (mbx << 4);
1094    sU = cur->u + (mby << 3) * std2 + (mbx << 3);    sU = cur->u + (mby << 3) * stride2 + (mbx << 3);
1095    sV = cur->v + (mby << 3) * std2 + (mbx << 3);    sV = cur->v + (mby << 3) * stride2 + (mbx << 3);
1096    
1097    for(i = 0 ; i < 16 ; i++) {    for(i = 0 ; i < 16 ; i++) {
1098      memcpy(dY,sY,w);      memcpy(dY,sY,w);
1099      dY += out_frm->stride[0];      dY += out_frm->stride[0];
1100      sY += std;      sY += stride;
1101    }    }
1102    for(i = 0 ; i < 8 ; i++) {    for(i = 0 ; i < 8 ; i++) {
1103      memcpy(dU,sU,w2);      memcpy(dU,sU,w2);
1104      dU += out_frm->stride[1];      dU += out_frm->stride[1];
1105      sU += std2;      sU += stride2;
1106    }    }
1107    for(i = 0 ; i < 8 ; i++) {    for(i = 0 ; i < 8 ; i++) {
1108      memcpy(dV,sV,w2);      memcpy(dV,sV,w2);
1109      dV += out_frm->stride[2];      dV += out_frm->stride[2];
1110      sV += std2;      sV += stride2;
1111    }    }
1112  }  }
1113    
# Line 1098  Line 1137 
1137                  p += edged_width/2;                  p += edged_width/2;
1138          }          }
1139  }  }
   
   
 /* reduced resolution deblocking filter  
         block = block size (16=rrv, 8=full resolution)  
         flags = XVID_DEC_YDEBLOCK|XVID_DEC_UVDEBLOCK  
 */  
 void  
 image_deblock_rrv(IMAGE * img, int edged_width,  
                                 const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride,  
                                 int block, int flags)  
 {  
         const int edged_width2 = edged_width /2;  
         const int nblocks = block / 8;  /* skals code uses 8pixel block uints */  
         int i,j;  
   
         /* luma: j,i in block units */  
   
                 for (j = 1; j < mb_height*2; j++)               /* horizontal deblocking */  
                 for (i = 0; i < mb_width*2; i++)  
                 {  
                         if (mbs[(j-1)/2*mb_stride + (i/2)].mode != MODE_NOT_CODED ||  
                                 mbs[(j+0)/2*mb_stride + (i/2)].mode != MODE_NOT_CODED)  
                         {  
                                 hfilter_31(img->y + (j*block - 1)*edged_width + i*block,  
                                                                   img->y + (j*block + 0)*edged_width + i*block, nblocks);  
                         }  
                 }  
   
                 for (j = 0; j < mb_height*2; j++)               /* vertical deblocking */  
                 for (i = 1; i < mb_width*2; i++)  
                 {  
                         if (mbs[(j/2)*mb_stride + (i-1)/2].mode != MODE_NOT_CODED ||  
                                 mbs[(j/2)*mb_stride + (i+0)/2].mode != MODE_NOT_CODED)  
                         {  
                                 vfilter_31(img->y + (j*block)*edged_width + i*block - 1,  
                                                    img->y + (j*block)*edged_width + i*block + 0,  
                                                    edged_width, nblocks);  
                         }  
                 }  
   
   
   
         /* chroma */  
   
                 for (j = 1; j < mb_height; j++)         /* horizontal deblocking */  
                 for (i = 0; i < mb_width; i++)  
                 {  
                         if (mbs[(j-1)*mb_stride + i].mode != MODE_NOT_CODED ||  
                                 mbs[(j+0)*mb_stride + i].mode != MODE_NOT_CODED)  
                         {  
                                 hfilter_31(img->u + (j*block - 1)*edged_width2 + i*block,  
                                                    img->u + (j*block + 0)*edged_width2 + i*block, nblocks);  
                                 hfilter_31(img->v + (j*block - 1)*edged_width2 + i*block,  
                                                    img->v + (j*block + 0)*edged_width2 + i*block, nblocks);  
                         }  
                 }  
   
                 for (j = 0; j < mb_height; j++)         /* vertical deblocking */  
                 for (i = 1; i < mb_width; i++)  
                 {  
                         if (mbs[j*mb_stride + i - 1].mode != MODE_NOT_CODED ||  
                                 mbs[j*mb_stride + i + 0].mode != MODE_NOT_CODED)  
                         {  
                                 vfilter_31(img->u + (j*block)*edged_width2 + i*block - 1,  
                                                    img->u + (j*block)*edged_width2 + i*block + 0,  
                                                    edged_width2, nblocks);  
                                 vfilter_31(img->v + (j*block)*edged_width2 + i*block - 1,  
                                                    img->v + (j*block)*edged_width2 + i*block + 0,  
                                                    edged_width2, nblocks);  
                         }  
                 }  
   
   
 }  
   

Legend:
Removed from v.1382  
changed lines
  Added in v.1631

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