You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.7KB

  1. /*
  2. Copyright (C) 2001-2002 Michael Niedermayer <michaelni@gmx.at>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. /* values for the flags, the stuff on the command line is different */
  16. #define SWS_FAST_BILINEAR 1
  17. #define SWS_BILINEAR 2
  18. #define SWS_BICUBIC 4
  19. #define SWS_X 8
  20. #define SWS_POINT 0x10
  21. #define SWS_AREA 0x20
  22. #define SWS_BICUBLIN 0x40
  23. #define SWS_GAUSS 0x80
  24. #define SWS_SINC 0x100
  25. #define SWS_LANCZOS 0x200
  26. #define SWS_SPLINE 0x400
  27. #define SWS_SRC_V_CHR_DROP_MASK 0x30000
  28. #define SWS_SRC_V_CHR_DROP_SHIFT 16
  29. #define SWS_PARAM_MASK 0x3FC0000
  30. #define SWS_PARAM_SHIFT 18
  31. #define SWS_PRINT_INFO 0x1000
  32. //the following 3 flags are not completly implemented
  33. //internal chrominace subsamling info
  34. #define SWS_FULL_CHR_H_INT 0x2000
  35. //input subsampling info
  36. #define SWS_FULL_CHR_H_INP 0x4000
  37. #define SWS_DIRECT_BGR 0x8000
  38. #define SWS_MAX_REDUCE_CUTOFF 0.002
  39. /* this struct should be aligned on at least 32-byte boundary */
  40. typedef struct SwsContext{
  41. int srcW, srcH, dstW, dstH;
  42. int chrSrcW, chrSrcH, chrDstW, chrDstH;
  43. int lumXInc, chrXInc;
  44. int lumYInc, chrYInc;
  45. int dstFormat, srcFormat;
  46. int chrSrcHSubSample, chrSrcVSubSample;
  47. int chrIntHSubSample, chrIntVSubSample;
  48. int chrDstHSubSample, chrDstVSubSample;
  49. int vChrDrop;
  50. int16_t **lumPixBuf;
  51. int16_t **chrPixBuf;
  52. int16_t *hLumFilter;
  53. int16_t *hLumFilterPos;
  54. int16_t *hChrFilter;
  55. int16_t *hChrFilterPos;
  56. int16_t *vLumFilter;
  57. int16_t *vLumFilterPos;
  58. int16_t *vChrFilter;
  59. int16_t *vChrFilterPos;
  60. // Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
  61. int16_t *lumMmxFilter;
  62. int16_t *chrMmxFilter;
  63. uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
  64. int hLumFilterSize;
  65. int hChrFilterSize;
  66. int vLumFilterSize;
  67. int vChrFilterSize;
  68. int vLumBufSize;
  69. int vChrBufSize;
  70. uint8_t __attribute__((aligned(32))) funnyYCode[10000];
  71. uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
  72. int32_t *lumMmx2FilterPos;
  73. int32_t *chrMmx2FilterPos;
  74. int16_t *lumMmx2Filter;
  75. int16_t *chrMmx2Filter;
  76. int canMMX2BeUsed;
  77. int lastInLumBuf;
  78. int lastInChrBuf;
  79. int lumBufIndex;
  80. int chrBufIndex;
  81. int dstY;
  82. int flags;
  83. void * yuvTable;
  84. void * table_rV[256];
  85. void * table_gU[256];
  86. int table_gV[256];
  87. void * table_bU[256];
  88. void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
  89. int srcSliceH, uint8_t* dst[], int dstStride[]);
  90. } SwsContext;
  91. //FIXME check init (where 0)
  92. // when used for filters they must have an odd number of elements
  93. // coeffs cannot be shared between vectors
  94. typedef struct {
  95. double *coeff;
  96. int length;
  97. } SwsVector;
  98. // vectors can be shared
  99. typedef struct {
  100. SwsVector *lumH;
  101. SwsVector *lumV;
  102. SwsVector *chrH;
  103. SwsVector *chrV;
  104. } SwsFilter;
  105. // *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
  106. // *** Note: it's called multiple times while decoding a frame, first time y==0
  107. // dstbpp == 12 -> yv12 output
  108. // will use sws_flags
  109. void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY,
  110. int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp,
  111. int srcW, int srcH, int dstW, int dstH);
  112. // Obsolete, will be removed soon
  113. void SwScale_Init();
  114. void freeSwsContext(SwsContext *swsContext);
  115. SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
  116. SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
  117. SwsFilter *srcFilter, SwsFilter *dstFilter);
  118. void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
  119. SwsVector *getGaussianVec(double variance, double quality);
  120. SwsVector *getConstVec(double c, int length);
  121. SwsVector *getIdentityVec(void);
  122. void scaleVec(SwsVector *a, double scalar);
  123. void normalizeVec(SwsVector *a, double height);
  124. void convVec(SwsVector *a, SwsVector *b);
  125. void addVec(SwsVector *a, SwsVector *b);
  126. void subVec(SwsVector *a, SwsVector *b);
  127. void shiftVec(SwsVector *a, int shift);
  128. SwsVector *cloneVec(SwsVector *a);
  129. void printVec(SwsVector *a);
  130. void freeVec(SwsVector *a);