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.

166 lines
5.0KB

  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. #ifndef SWSCALE_INTERNAL_H
  16. #define SWSCALE_INTERNAL_H
  17. #ifdef HAVE_ALTIVEC_H
  18. #include <altivec.h>
  19. #endif
  20. #ifdef CONFIG_DARWIN
  21. #define AVV(x...) (x)
  22. #else
  23. #define AVV(x...) {x}
  24. #endif
  25. #include "../mp_msg.h"
  26. #define MSG_WARN(args...) mp_msg(MSGT_SWS,MSGL_WARN, ##args )
  27. #define MSG_FATAL(args...) mp_msg(MSGT_SWS,MSGL_FATAL, ##args )
  28. #define MSG_ERR(args...) mp_msg(MSGT_SWS,MSGL_ERR, ##args )
  29. #define MSG_V(args...) mp_msg(MSGT_SWS,MSGL_V, ##args )
  30. #define MSG_DBG2(args...) mp_msg(MSGT_SWS,MSGL_DBG2, ##args )
  31. #define MSG_INFO(args...) mp_msg(MSGT_SWS,MSGL_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. double param[2];
  53. int16_t **lumPixBuf;
  54. int16_t **chrPixBuf;
  55. int16_t *hLumFilter;
  56. int16_t *hLumFilterPos;
  57. int16_t *hChrFilter;
  58. int16_t *hChrFilterPos;
  59. int16_t *vLumFilter;
  60. int16_t *vLumFilterPos;
  61. int16_t *vChrFilter;
  62. int16_t *vChrFilterPos;
  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; // pointer to the yuv->rgb table start so it can be freed()
  84. void * table_rV[256];
  85. void * table_gU[256];
  86. int table_gV[256];
  87. void * table_bU[256];
  88. //Colorspace stuff
  89. int contrast, brightness, saturation; // for sws_getColorspaceDetails
  90. int srcColorspaceTable[4];
  91. int dstColorspaceTable[4];
  92. int srcRange, dstRange;
  93. #define RED_DITHER "0*8"
  94. #define GREEN_DITHER "1*8"
  95. #define BLUE_DITHER "2*8"
  96. #define Y_COEFF "3*8"
  97. #define VR_COEFF "4*8"
  98. #define UB_COEFF "5*8"
  99. #define VG_COEFF "6*8"
  100. #define UG_COEFF "7*8"
  101. #define Y_OFFSET "8*8"
  102. #define U_OFFSET "9*8"
  103. #define V_OFFSET "10*8"
  104. #define LUM_MMX_FILTER_OFFSET "11*8"
  105. #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
  106. #define DSTW_OFFSET "11*8+4*4*256*2" //do not change, its hardcoded in the asm
  107. #define ESP_OFFSET "11*8+4*4*256*2+4"
  108. #define VROUNDER_OFFSET "11*8+4*4*256*2+8"
  109. uint64_t redDither __attribute__((aligned(8)));
  110. uint64_t greenDither __attribute__((aligned(8)));
  111. uint64_t blueDither __attribute__((aligned(8)));
  112. uint64_t yCoeff __attribute__((aligned(8)));
  113. uint64_t vrCoeff __attribute__((aligned(8)));
  114. uint64_t ubCoeff __attribute__((aligned(8)));
  115. uint64_t vgCoeff __attribute__((aligned(8)));
  116. uint64_t ugCoeff __attribute__((aligned(8)));
  117. uint64_t yOffset __attribute__((aligned(8)));
  118. uint64_t uOffset __attribute__((aligned(8)));
  119. uint64_t vOffset __attribute__((aligned(8)));
  120. int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
  121. int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
  122. int dstW;
  123. int esp;
  124. uint64_t vRounder __attribute__((aligned(8)));
  125. #ifdef HAVE_ALTIVEC
  126. vector signed short CY;
  127. vector signed short CRV;
  128. vector signed short CBU;
  129. vector signed short CGU;
  130. vector signed short CGV;
  131. vector signed short OY;
  132. vector unsigned short CSHIFT;
  133. #endif
  134. } SwsContext;
  135. //FIXME check init (where 0)
  136. SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
  137. int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
  138. #endif