swscale_internal.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. Copyright (C) 2001-2003 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. #ifndef SWSCALE_INTERNAL_H
  16. #define SWSCALE_INTERNAL_H
  17. #ifdef HAVE_ALTIVEC_H
  18. #include <altivec.h>
  19. #endif
  20. #include "avutil.h"
  21. #ifdef CONFIG_DARWIN
  22. #define AVV(x...) (x)
  23. #else
  24. #define AVV(x...) {x}
  25. #endif
  26. #define MSG_WARN(args...) av_log(NULL, AV_LOG_DEBUG, ##args )
  27. #define MSG_FATAL(args...) av_log(NULL, AV_LOG_ERROR, ##args )
  28. #define MSG_ERR(args...) av_log(NULL, AV_LOG_ERROR, ##args )
  29. #define MSG_V(args...) av_log(NULL, AV_LOG_INFO, ##args )
  30. #define MSG_DBG2(args...) av_log(NULL, AV_LOG_DEBUG, ##args )
  31. #define MSG_INFO(args...) av_log(NULL, AV_LOG_INFO, ##args )
  32. #define MAX_FILTER_SIZE 256
  33. typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
  34. int srcSliceH, uint8_t* dst[], int dstStride[]);
  35. /* this struct should be aligned on at least 32-byte boundary */
  36. typedef struct SwsContext{
  37. /**
  38. *
  39. * Note the src,dst,srcStride,dstStride will be copied, in the sws_scale() warper so they can freely be modified here
  40. */
  41. SwsFunc swScale;
  42. int srcW, srcH, dstH;
  43. int chrSrcW, chrSrcH, chrDstW, chrDstH;
  44. int lumXInc, chrXInc;
  45. int lumYInc, chrYInc;
  46. int dstFormat, srcFormat; ///< format 4:2:0 type is allways YV12
  47. int origDstFormat, origSrcFormat; ///< format
  48. int chrSrcHSubSample, chrSrcVSubSample;
  49. int chrIntHSubSample, chrIntVSubSample;
  50. int chrDstHSubSample, chrDstVSubSample;
  51. int vChrDrop;
  52. int sliceDir;
  53. double param[2];
  54. int16_t **lumPixBuf;
  55. int16_t **chrPixBuf;
  56. int16_t *hLumFilter;
  57. int16_t *hLumFilterPos;
  58. int16_t *hChrFilter;
  59. int16_t *hChrFilterPos;
  60. int16_t *vLumFilter;
  61. int16_t *vLumFilterPos;
  62. int16_t *vChrFilter;
  63. int16_t *vChrFilterPos;
  64. uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
  65. int hLumFilterSize;
  66. int hChrFilterSize;
  67. int vLumFilterSize;
  68. int vChrFilterSize;
  69. int vLumBufSize;
  70. int vChrBufSize;
  71. uint8_t *funnyYCode;
  72. uint8_t *funnyUVCode;
  73. int32_t *lumMmx2FilterPos;
  74. int32_t *chrMmx2FilterPos;
  75. int16_t *lumMmx2Filter;
  76. int16_t *chrMmx2Filter;
  77. int canMMX2BeUsed;
  78. int lastInLumBuf;
  79. int lastInChrBuf;
  80. int lumBufIndex;
  81. int chrBufIndex;
  82. int dstY;
  83. int flags;
  84. void * yuvTable; // pointer to the yuv->rgb table start so it can be freed()
  85. void * table_rV[256];
  86. void * table_gU[256];
  87. int table_gV[256];
  88. void * table_bU[256];
  89. //Colorspace stuff
  90. int contrast, brightness, saturation; // for sws_getColorspaceDetails
  91. int srcColorspaceTable[4];
  92. int dstColorspaceTable[4];
  93. int srcRange, dstRange;
  94. #define RED_DITHER "0*8"
  95. #define GREEN_DITHER "1*8"
  96. #define BLUE_DITHER "2*8"
  97. #define Y_COEFF "3*8"
  98. #define VR_COEFF "4*8"
  99. #define UB_COEFF "5*8"
  100. #define VG_COEFF "6*8"
  101. #define UG_COEFF "7*8"
  102. #define Y_OFFSET "8*8"
  103. #define U_OFFSET "9*8"
  104. #define V_OFFSET "10*8"
  105. #define LUM_MMX_FILTER_OFFSET "11*8"
  106. #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
  107. #define DSTW_OFFSET "11*8+4*4*256*2" //do not change, its hardcoded in the asm
  108. #define ESP_OFFSET "11*8+4*4*256*2+8"
  109. #define VROUNDER_OFFSET "11*8+4*4*256*2+16"
  110. uint64_t redDither __attribute__((aligned(8)));
  111. uint64_t greenDither __attribute__((aligned(8)));
  112. uint64_t blueDither __attribute__((aligned(8)));
  113. uint64_t yCoeff __attribute__((aligned(8)));
  114. uint64_t vrCoeff __attribute__((aligned(8)));
  115. uint64_t ubCoeff __attribute__((aligned(8)));
  116. uint64_t vgCoeff __attribute__((aligned(8)));
  117. uint64_t ugCoeff __attribute__((aligned(8)));
  118. uint64_t yOffset __attribute__((aligned(8)));
  119. uint64_t uOffset __attribute__((aligned(8)));
  120. uint64_t vOffset __attribute__((aligned(8)));
  121. int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
  122. int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
  123. int dstW;
  124. uint64_t esp __attribute__((aligned(8)));
  125. uint64_t vRounder __attribute__((aligned(8)));
  126. #ifdef HAVE_ALTIVEC
  127. vector signed short CY;
  128. vector signed short CRV;
  129. vector signed short CBU;
  130. vector signed short CGU;
  131. vector signed short CGV;
  132. vector signed short OY;
  133. vector unsigned short CSHIFT;
  134. vector signed short *vYCoeffsBank, *vCCoeffsBank;
  135. #endif
  136. } SwsContext;
  137. //FIXME check init (where 0)
  138. SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
  139. int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
  140. char *sws_format_name(int format);
  141. #endif