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.

153 lines
4.6KB

  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_SRC_V_CHR_DROP_MASK 0x300
  24. #define SWS_SRC_V_CHR_DROP_SHIFT 8
  25. //the following 4 flags are not completly implemented
  26. //internal chrominace subsamling info
  27. #define SWS_FULL_CHR_H_INT 0x2000
  28. //input subsampling info
  29. #define SWS_FULL_CHR_H_INP 0x4000
  30. #define SWS_DIRECT_BGR 0x8000
  31. #define SWS_PRINT_INFO 0x1000
  32. #define SWS_MAX_REDUCE_CUTOFF 0.002
  33. /* this struct should be aligned on at least 32-byte boundary */
  34. typedef struct SwsContext{
  35. int srcW, srcH, dstW, dstH;
  36. int chrSrcW, chrSrcH, chrDstW, chrDstH;
  37. int lumXInc, chrXInc;
  38. int lumYInc, chrYInc;
  39. int dstFormat, srcFormat;
  40. int chrSrcHSubSample, chrSrcVSubSample;
  41. int chrIntHSubSample, chrIntVSubSample;
  42. int chrDstHSubSample, chrDstVSubSample;
  43. int vChrDrop;
  44. int16_t **lumPixBuf;
  45. int16_t **chrPixBuf;
  46. int16_t *hLumFilter;
  47. int16_t *hLumFilterPos;
  48. int16_t *hChrFilter;
  49. int16_t *hChrFilterPos;
  50. int16_t *vLumFilter;
  51. int16_t *vLumFilterPos;
  52. int16_t *vChrFilter;
  53. int16_t *vChrFilterPos;
  54. // Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
  55. int16_t *lumMmxFilter;
  56. int16_t *chrMmxFilter;
  57. uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
  58. int hLumFilterSize;
  59. int hChrFilterSize;
  60. int vLumFilterSize;
  61. int vChrFilterSize;
  62. int vLumBufSize;
  63. int vChrBufSize;
  64. uint8_t __attribute__((aligned(32))) funnyYCode[10000];
  65. uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
  66. int32_t *lumMmx2FilterPos;
  67. int32_t *chrMmx2FilterPos;
  68. int16_t *lumMmx2Filter;
  69. int16_t *chrMmx2Filter;
  70. int canMMX2BeUsed;
  71. int lastInLumBuf;
  72. int lastInChrBuf;
  73. int lumBufIndex;
  74. int chrBufIndex;
  75. int dstY;
  76. int flags;
  77. void * yuvTable;
  78. void * table_rV[256];
  79. void * table_gU[256];
  80. int table_gV[256];
  81. void * table_bU[256];
  82. void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
  83. int srcSliceH, uint8_t* dst[], int dstStride[]);
  84. } SwsContext;
  85. //FIXME check init (where 0)
  86. // when used for filters they must have an odd number of elements
  87. // coeffs cannot be shared between vectors
  88. typedef struct {
  89. double *coeff;
  90. int length;
  91. } SwsVector;
  92. // vectors can be shared
  93. typedef struct {
  94. SwsVector *lumH;
  95. SwsVector *lumV;
  96. SwsVector *chrH;
  97. SwsVector *chrV;
  98. } SwsFilter;
  99. // *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
  100. // *** Note: it's called multiple times while decoding a frame, first time y==0
  101. // dstbpp == 12 -> yv12 output
  102. // will use sws_flags
  103. void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY,
  104. int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp,
  105. int srcW, int srcH, int dstW, int dstH);
  106. // Obsolete, will be removed soon
  107. void SwScale_Init();
  108. void freeSwsContext(SwsContext *swsContext);
  109. SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
  110. SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
  111. SwsFilter *srcFilter, SwsFilter *dstFilter);
  112. void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
  113. SwsVector *getGaussianVec(double variance, double quality);
  114. SwsVector *getConstVec(double c, int length);
  115. SwsVector *getIdentityVec(void);
  116. void scaleVec(SwsVector *a, double scalar);
  117. void normalizeVec(SwsVector *a, double height);
  118. void convVec(SwsVector *a, SwsVector *b);
  119. void addVec(SwsVector *a, SwsVector *b);
  120. void subVec(SwsVector *a, SwsVector *b);
  121. void shiftVec(SwsVector *a, int shift);
  122. SwsVector *cloneVec(SwsVector *a);
  123. void printVec(SwsVector *a);
  124. void freeVec(SwsVector *a);