home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Resize_old.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-06  |  3.3 KB  |  129 lines

  1. /* 
  2.  *  Resize.h 
  3.  *
  4.  *    Copyright (C) Alberto Vigata - January 2000 - ultraflask@yahoo.com
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24. #if !defined(AFX_RESIZE_H__D118E4A5_A507_11D3_8C3D_00000100CF13__INCLUDED_)
  25. #define AFX_RESIZE_H__D118E4A5_A507_11D3_8C3D_00000100CF13__INCLUDED_
  26.  
  27. #if _MSC_VER > 1000
  28. #pragma once
  29. #endif // _MSC_VER > 1000
  30.  
  31.  
  32.  
  33. #include <stdlib.h>
  34. #include <stdio.h>
  35. #include <string.h>
  36. #include <malloc.h>
  37. #include <math.h>
  38.  
  39. #define M_PI 3.14159265358979311
  40. #define CLAMP(A) ((A)<=(0) ? (0) : (A)<=(255) ? (A) : (255))
  41. #define SAR(DAR,hor,vert) (DAR*((double)hor/(double)vert))
  42.  
  43.  
  44. #define  WEIGHT_SCALE (int)32767
  45.  
  46.  
  47.  
  48. // YUV to RGB conversion constants
  49. #define CRV (int)117504
  50. #define CBU (int)138453
  51. #define CGU (int)13954
  52. #define CGV (int)34903
  53.  
  54. // Contribution struct
  55. typedef struct {
  56.     int        pixel;
  57.     double  weight;
  58.     short    weightShort;
  59. } CONTRIB;
  60.  
  61.  
  62. // List of contributions for a given pixel
  63. typedef struct {
  64.     int    n;            /* number of contributors */
  65.     CONTRIB    *p;        /* pointer to list of contributions */
  66. } CLIST;
  67.  
  68.  
  69.  
  70. #ifndef EXIT_SUCCESS
  71. #define    EXIT_SUCCESS    (0)
  72. #define    EXIT_FAILURE    (1)
  73. #endif
  74.  
  75. typedef    unsigned char    Pixel;
  76.  
  77.  
  78. #define    WHITE_PIXEL    (255)
  79. #define    BLACK_PIXEL    (0)
  80.  
  81.  
  82. typedef struct YUVImageTag
  83. {
  84.     unsigned char *Y;
  85.     int              Yxsize;
  86.     int              Yysize;
  87.     unsigned char *U;
  88.     unsigned char *V;
  89.     int              Cxsize;
  90.     int              Cysize;
  91. } YUVimage;
  92.  
  93. typedef struct {
  94.     int    xsize;        /* horizontal size of the image in Pixels */
  95.     int    ysize;        /* vertical size of the image in Pixels */
  96.     Pixel *    data;   /* pointer to first scanline of image */
  97.     int    span;        /* byte offset between two scanlines */
  98. } Image;
  99.  
  100. class CResize  
  101. {
  102. public:
  103.     Init(   int   filter,
  104.             int   oxsize,
  105.             int   oysize);    
  106.     CResize();
  107.     ~CResize();
  108.  
  109.  
  110.     int Crop(Pixel *image, Pixel *dispImage, int ixsize,int iysize,int topCrop,int bottomCrop);
  111.     ResRGBtoRGBA(  Image  *src, Pixel  *dst,Pixel  *dispimage);
  112.     ResYUVtoRGBA(YUVimage *src, Pixel  *dst,Pixel  *dispimage);
  113.     ResYUVtoRGBA_AR(YUVimage  *inp , Pixel  *dst,Pixel  *dispimage, bool doAR ,double iDAR);
  114. private:
  115.             DeAllocateContrib(CLIST *contrib,int size);
  116.     CLIST * AllocateContrib(int size);
  117.             WorkOutContributions(CLIST *contrib,int isize, int osize);
  118.  
  119.     int   oxsize;            /* output x size  */
  120.     int   oysize;
  121.  
  122.     int       filter;                    /* filter type */
  123.     double (*filterf)(double);        /* pointer to filter function */
  124.     double fwidth;                    /* filter width. Taps of filter */    
  125.      
  126. };
  127.  
  128. #endif // !defined(AFX_RESIZE_H__D118E4A5_A507_11D3_8C3D_00000100CF13__INCLUDED_)
  129.