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.

142 lines
4.6KB

  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. #include "../mp_msg.h"
  18. #define MSG_WARN(args...) mp_msg(MSGT_SWS,MSGL_WARN, ##args )
  19. #define MSG_FATAL(args...) mp_msg(MSGT_SWS,MSGL_FATAL, ##args )
  20. #define MSG_ERR(args...) mp_msg(MSGT_SWS,MSGL_ERR, ##args )
  21. #define MSG_V(args...) mp_msg(MSGT_SWS,MSGL_V, ##args )
  22. #define MSG_DBG2(args...) mp_msg(MSGT_SWS,MSGL_DBG2, ##args )
  23. #define MSG_INFO(args...) mp_msg(MSGT_SWS,MSGL_INFO, ##args )
  24. #define MAX_FILTER_SIZE 256
  25. typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
  26. int srcSliceH, uint8_t* dst[], int dstStride[]);
  27. /* this struct should be aligned on at least 32-byte boundary */
  28. typedef struct SwsContext{
  29. /**
  30. *
  31. * Note the src,dst,srcStride,dstStride will be copied, in the sws_scale() warper so they can freely be modified here
  32. */
  33. SwsFunc swScale;
  34. int srcW, srcH, dstH;
  35. int chrSrcW, chrSrcH, chrDstW, chrDstH;
  36. int lumXInc, chrXInc;
  37. int lumYInc, chrYInc;
  38. int dstFormat, srcFormat; ///< format 4:2:0 type is allways YV12
  39. int origDstFormat, origSrcFormat; ///< format
  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. uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
  55. int hLumFilterSize;
  56. int hChrFilterSize;
  57. int vLumFilterSize;
  58. int vChrFilterSize;
  59. int vLumBufSize;
  60. int vChrBufSize;
  61. uint8_t __attribute__((aligned(32))) funnyYCode[10000];
  62. uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
  63. int32_t *lumMmx2FilterPos;
  64. int32_t *chrMmx2FilterPos;
  65. int16_t *lumMmx2Filter;
  66. int16_t *chrMmx2Filter;
  67. int canMMX2BeUsed;
  68. int lastInLumBuf;
  69. int lastInChrBuf;
  70. int lumBufIndex;
  71. int chrBufIndex;
  72. int dstY;
  73. int flags;
  74. void * yuvTable; // pointer to the yuv->rgb table start so it can be freed()
  75. void * table_rV[256];
  76. void * table_gU[256];
  77. int table_gV[256];
  78. void * table_bU[256];
  79. //Colorspace stuff
  80. int contrast, brightness, saturation; // for sws_getColorspaceDetails
  81. int srcColorspaceTable[4];
  82. int dstColorspaceTable[4];
  83. int srcRange, dstRange;
  84. #define RED_DITHER "0*8"
  85. #define GREEN_DITHER "1*8"
  86. #define BLUE_DITHER "2*8"
  87. #define Y_COEFF "3*8"
  88. #define VR_COEFF "4*8"
  89. #define UB_COEFF "5*8"
  90. #define VG_COEFF "6*8"
  91. #define UG_COEFF "7*8"
  92. #define Y_OFFSET "8*8"
  93. #define U_OFFSET "9*8"
  94. #define V_OFFSET "10*8"
  95. #define LUM_MMX_FILTER_OFFSET "11*8"
  96. #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
  97. #define DSTW_OFFSET "11*8+4*4*256*2" //do not change, its hardcoded in the asm
  98. #define ESP_OFFSET "11*8+4*4*256*2+4"
  99. #define VROUNDER_OFFSET "11*8+4*4*256*2+8"
  100. uint64_t redDither __attribute__((aligned(8)));
  101. uint64_t greenDither __attribute__((aligned(8)));
  102. uint64_t blueDither __attribute__((aligned(8)));
  103. uint64_t yCoeff __attribute__((aligned(8)));
  104. uint64_t vrCoeff __attribute__((aligned(8)));
  105. uint64_t ubCoeff __attribute__((aligned(8)));
  106. uint64_t vgCoeff __attribute__((aligned(8)));
  107. uint64_t ugCoeff __attribute__((aligned(8)));
  108. uint64_t yOffset __attribute__((aligned(8)));
  109. uint64_t uOffset __attribute__((aligned(8)));
  110. uint64_t vOffset __attribute__((aligned(8)));
  111. int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
  112. int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
  113. int dstW;
  114. int esp;
  115. uint64_t vRounder __attribute__((aligned(8)));
  116. } SwsContext;
  117. //FIXME check init (where 0)
  118. SwsFunc yuv2rgb_get_func_ptr (SwsContext *c);
  119. int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
  120. #endif