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.

140 lines
4.2KB

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