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

Diff of /xvidcore/src/image/image.c

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

revision 1.20.2.1, Sun Sep 8 09:49:55 2002 UTC revision 1.23, Wed Sep 25 23:37:09 2002 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC   *      XVID MPEG-4 VIDEO CODEC
4   *      image stuff   *  - image module -
5     *
6     *  Copyright(C) 2002 Peter Ross <pross@xvid.org>
7     *
8     *  This program is an implementation of a part of one or more MPEG-4
9     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10     *  to use this software module in hardware or software products are
11     *  advised that its use may infringe existing patents or copyrights, and
12     *  any such use would be at such party's own risk.  The original
13     *  developer of this software module and his/her company, and subsequent
14     *  editors and their companies, will have no liability for use of this
15     *  software or modifications or derivatives thereof.
16   *   *
17   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
18   *      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 15  Line 26 
26   *   *
27   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
28   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
29   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
30   *   *
31   *************************************************************************/   ****************************************************************************/
   
 /**************************************************************************  
  *  
  *      History:  
  *  
  *      01.05.2002      BFRAME image-based u,v interpolation  
  *  22.04.2002  added some B-frame support  
  *      14.04.2002      added image_dump_yuvpgm(), added image_mad()  
  *              XVID_CSP_USER input support  
  *  09.04.2002  PSNR calculations  
  *      06.04.2002      removed interlaced edging from U,V blocks (as per spec)  
  *  26.03.2002  interlacing support (field-based edging in set_edges)  
  *      26.01.2002      rgb555, rgb565  
  *      07.01.2001      commented u,v interpolation (not required for uv-block-based)  
  *  23.12.2001  removed #ifdefs, added function pointers + init_common()  
  *      22.12.2001      cpu #ifdefs  
  *  19.12.2001  image_dump(); useful for debugging  
  *       6.12.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
  *  
  *************************************************************************/  
32    
33  #include <stdlib.h>  #include <stdlib.h>
34  #include <string.h>                             // memcpy, memset  #include <string.h>                             // memcpy, memset
# Line 151  Line 142 
142                             uint32_t edged_width,                             uint32_t edged_width,
143                             uint32_t edged_height,                             uint32_t edged_height,
144                             uint32_t width,                             uint32_t width,
145                             uint32_t height,                             uint32_t height)
                            uint32_t interlacing)  
146  {  {
147          const uint32_t edged_width2 = edged_width / 2;          const uint32_t edged_width2 = edged_width / 2;
148          const uint32_t width2 = width / 2;          const uint32_t width2 = width / 2;
# Line 165  Line 155 
155          src = image->y;          src = image->y;
156    
157          for (i = 0; i < EDGE_SIZE; i++) {          for (i = 0; i < EDGE_SIZE; i++) {
 /*              // if interlacing, edges contain top-most data from each field  
                 if (interlacing && (i & 1)) {  
                         memset(dst, *(src + edged_width), EDGE_SIZE);  
                         memcpy(dst + EDGE_SIZE, src + edged_width, width);  
                         memset(dst + edged_width - EDGE_SIZE,  
                                    *(src + edged_width + width - 1), EDGE_SIZE);  
                 } else {*/  
158                          memset(dst, *src, EDGE_SIZE);                          memset(dst, *src, EDGE_SIZE);
159                          memcpy(dst + EDGE_SIZE, src, width);                          memcpy(dst + EDGE_SIZE, src, width);
160                          memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),                          memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),
161                                     EDGE_SIZE);                                     EDGE_SIZE);
                 /*}*/  
162                  dst += edged_width;                  dst += edged_width;
163          }          }
164    
# Line 189  Line 171 
171    
172          src -= edged_width;          src -= edged_width;
173          for (i = 0; i < EDGE_SIZE; i++) {          for (i = 0; i < EDGE_SIZE; i++) {
 /*              // if interlacing, edges contain bottom-most data from each field  
                 if (interlacing && !(i & 1)) {  
                         memset(dst, *(src - edged_width), EDGE_SIZE);  
                         memcpy(dst + EDGE_SIZE, src - edged_width, width);  
                         memset(dst + edged_width - EDGE_SIZE,  
                                    *(src - edged_width + width - 1), EDGE_SIZE);  
                 } else {*/  
174                          memset(dst, *src, EDGE_SIZE);                          memset(dst, *src, EDGE_SIZE);
175                          memcpy(dst + EDGE_SIZE, src, width);                          memcpy(dst + EDGE_SIZE, src, width);
176                          memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),                          memset(dst + edged_width - EDGE_SIZE, *(src + width - 1),
177                                     EDGE_SIZE);                                     EDGE_SIZE);
                 /*}*/  
178                  dst += edged_width;                  dst += edged_width;
179          }          }
180    
# Line 261  Line 235 
235          }          }
236  }  }
237    
238    // bframe encoding requires image-based u,v interpolation
 // image-based y,u,v interpolation  
239  void  void
240  image_interpolate(const IMAGE * refn,  image_interpolate(const IMAGE * refn,
241                                    IMAGE * refh,                                    IMAGE * refh,
# Line 275  Line 248 
248          const uint32_t offset = EDGE_SIZE * (edged_width + 1);          const uint32_t offset = EDGE_SIZE * (edged_width + 1);
249          const uint32_t stride_add = 7 * edged_width;          const uint32_t stride_add = 7 * edged_width;
250    
         /* --- u,v-image-based interpolation ---  
         const uint32_t edged_width2 = edged_width / 2;  
         const uint32_t edged_height2 = edged_height / 2;  
         const uint32_t offset2 = EDGE_SIZE2 * (edged_width2 + 1);  
         const uint32_t stride_add2 = 7 * edged_width2;  
         */  
   
251          uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr;          uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr;
252          uint32_t x, y;          uint32_t x, y;
253    
# Line 313  Line 279 
279                  n_ptr += stride_add;                  n_ptr += stride_add;
280          }          }
281    
282  /* --- u,v-image-based interpolation ---          /*
283          n_ptr = refn->u;             interpolate_halfpel_h(
284          h_ptr = refh->u;             refh->y - offset,
285          v_ptr = refv->u;             refn->y - offset,
286          hv_ptr = refhv->u;             edged_width, edged_height,
287               rounding);
288          n_ptr -= offset2;  
289          h_ptr -= offset2;             interpolate_halfpel_v(
290          v_ptr -= offset2;             refv->y - offset,
291          hv_ptr -= offset2;             refn->y - offset,
292               edged_width, edged_height,
293          for (y = 0; y < edged_height2; y = y + 8) {             rounding);
294                  for (x = 0; x < edged_width2; x = x + 8) {  
295                          interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width2, rounding);             interpolate_halfpel_hv(
296                          interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width2, rounding);             refhv->y - offset,
297                          interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width2, rounding);             refn->y - offset,
298               edged_width, edged_height,
299               rounding);
300             */
301    
302                          n_ptr += 8;          /* uv-image-based compensation
303                          h_ptr += 8;             offset = EDGE_SIZE2 * (edged_width / 2 + 1);
                         v_ptr += 8;  
                         hv_ptr += 8;  
                 }  
                 h_ptr += stride_add2;  
                 v_ptr += stride_add2;  
                 hv_ptr += stride_add2;  
                 n_ptr += stride_add2;  
         }  
   
         n_ptr = refn->v;  
         h_ptr = refh->v;  
         v_ptr = refv->v;  
         hv_ptr = refhv->v;  
   
         n_ptr -= offset2;  
         h_ptr -= offset2;  
         v_ptr -= offset2;  
         hv_ptr -= offset2;  
   
         for (y = 0; y < edged_height2; y = y + 8) {  
                 for (x = 0; x < edged_width2; x = x + 8) {  
                         interpolate8x8_halfpel_h(h_ptr, n_ptr, edged_width2, rounding);  
                         interpolate8x8_halfpel_v(v_ptr, n_ptr, edged_width2, rounding);  
                         interpolate8x8_halfpel_hv(hv_ptr, n_ptr, edged_width2, rounding);  
304    
305                          n_ptr += 8;             interpolate_halfpel_h(
306                          h_ptr += 8;             refh->u - offset,
307                          v_ptr += 8;             refn->u - offset,
308                          hv_ptr += 8;             edged_width / 2, edged_height / 2,
309                  }             rounding);
310                  h_ptr += stride_add2;  
311                  v_ptr += stride_add2;             interpolate_halfpel_v(
312                  hv_ptr += stride_add2;             refv->u - offset,
313                  n_ptr += stride_add2;             refn->u - offset,
314          }             edged_width / 2, edged_height / 2,
315               rounding);
316    
317               interpolate_halfpel_hv(
318               refhv->u - offset,
319               refn->u - offset,
320               edged_width / 2, edged_height / 2,
321               rounding);
322    
323    
324               interpolate_halfpel_h(
325               refh->v - offset,
326               refn->v - offset,
327               edged_width / 2, edged_height / 2,
328               rounding);
329    
330               interpolate_halfpel_v(
331               refv->v - offset,
332               refn->v - offset,
333               edged_width / 2, edged_height / 2,
334               rounding);
335    
336               interpolate_halfpel_hv(
337               refhv->v - offset,
338               refn->v - offset,
339               edged_width / 2, edged_height / 2,
340               rounding);
341  */  */
342  }  }
343    

Legend:
Removed from v.1.20.2.1  
changed lines
  Added in v.1.23

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