Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SWSCALE_SWSCALE_INTERNAL_H
00022 #define SWSCALE_SWSCALE_INTERNAL_H
00023
00024 #include "config.h"
00025
00026 #if HAVE_ALTIVEC_H
00027 #include <altivec.h>
00028 #endif
00029
00030 #include "libavutil/avutil.h"
00031
00032 #define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long
00033
00034 #define MAX_FILTER_SIZE 256
00035
00036 #if ARCH_X86
00037 #define VOFW 5120
00038 #else
00039 #define VOFW 2048 // faster on PPC and not tested on others
00040 #endif
00041
00042 #define VOF (VOFW*2)
00043
00044 #ifdef WORDS_BIGENDIAN
00045 #define ALT32_CORR (-1)
00046 #else
00047 #define ALT32_CORR 1
00048 #endif
00049
00050 #if ARCH_X86_64
00051 # define APCK_PTR2 8
00052 # define APCK_COEF 16
00053 # define APCK_SIZE 24
00054 #else
00055 # define APCK_PTR2 4
00056 # define APCK_COEF 8
00057 # define APCK_SIZE 16
00058 #endif
00059
00060 struct SwsContext;
00061
00062 typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
00063 int srcSliceH, uint8_t* dst[], int dstStride[]);
00064
00065
00066 typedef struct SwsContext{
00070 const AVClass *av_class;
00071
00076 SwsFunc swScale;
00077 int srcW, srcH, dstH;
00078 int chrSrcW, chrSrcH, chrDstW, chrDstH;
00079 int lumXInc, chrXInc;
00080 int lumYInc, chrYInc;
00081 enum PixelFormat dstFormat, srcFormat;
00082 int origDstFormat, origSrcFormat;
00083 int chrSrcHSubSample, chrSrcVSubSample;
00084 int chrIntHSubSample, chrIntVSubSample;
00085 int chrDstHSubSample, chrDstVSubSample;
00086 int vChrDrop;
00087 int sliceDir;
00088 double param[2];
00089
00090 uint32_t pal_yuv[256];
00091 uint32_t pal_rgb[256];
00092
00093 int16_t **lumPixBuf;
00094 int16_t **chrPixBuf;
00095 int16_t *hLumFilter;
00096 int16_t *hLumFilterPos;
00097 int16_t *hChrFilter;
00098 int16_t *hChrFilterPos;
00099 int16_t *vLumFilter;
00100 int16_t *vLumFilterPos;
00101 int16_t *vChrFilter;
00102 int16_t *vChrFilterPos;
00103
00104 uint8_t formatConvBuffer[VOF];
00105
00106 int hLumFilterSize;
00107 int hChrFilterSize;
00108 int vLumFilterSize;
00109 int vChrFilterSize;
00110 int vLumBufSize;
00111 int vChrBufSize;
00112
00113 uint8_t *funnyYCode;
00114 uint8_t *funnyUVCode;
00115 int32_t *lumMmx2FilterPos;
00116 int32_t *chrMmx2FilterPos;
00117 int16_t *lumMmx2Filter;
00118 int16_t *chrMmx2Filter;
00119
00120 int canMMX2BeUsed;
00121
00122 int lastInLumBuf;
00123 int lastInChrBuf;
00124 int lumBufIndex;
00125 int chrBufIndex;
00126 int dstY;
00127 int flags;
00128 void * yuvTable;
00129 uint8_t * table_rV[256];
00130 uint8_t * table_gU[256];
00131 int table_gV[256];
00132 uint8_t * table_bU[256];
00133
00134
00135 int contrast, brightness, saturation;
00136 int srcColorspaceTable[4];
00137 int dstColorspaceTable[4];
00138 int srcRange, dstRange;
00139 int yuv2rgb_y_offset;
00140 int yuv2rgb_y_coeff;
00141 int yuv2rgb_v2r_coeff;
00142 int yuv2rgb_v2g_coeff;
00143 int yuv2rgb_u2g_coeff;
00144 int yuv2rgb_u2b_coeff;
00145
00146 #define RED_DITHER "0*8"
00147 #define GREEN_DITHER "1*8"
00148 #define BLUE_DITHER "2*8"
00149 #define Y_COEFF "3*8"
00150 #define VR_COEFF "4*8"
00151 #define UB_COEFF "5*8"
00152 #define VG_COEFF "6*8"
00153 #define UG_COEFF "7*8"
00154 #define Y_OFFSET "8*8"
00155 #define U_OFFSET "9*8"
00156 #define V_OFFSET "10*8"
00157 #define LUM_MMX_FILTER_OFFSET "11*8"
00158 #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
00159 #define DSTW_OFFSET "11*8+4*4*256*2" //do not change, it is hardcoded in the ASM
00160 #define ESP_OFFSET "11*8+4*4*256*2+8"
00161 #define VROUNDER_OFFSET "11*8+4*4*256*2+16"
00162 #define U_TEMP "11*8+4*4*256*2+24"
00163 #define V_TEMP "11*8+4*4*256*2+32"
00164
00165 uint64_t redDither __attribute__((aligned(8)));
00166 uint64_t greenDither __attribute__((aligned(8)));
00167 uint64_t blueDither __attribute__((aligned(8)));
00168
00169 uint64_t yCoeff __attribute__((aligned(8)));
00170 uint64_t vrCoeff __attribute__((aligned(8)));
00171 uint64_t ubCoeff __attribute__((aligned(8)));
00172 uint64_t vgCoeff __attribute__((aligned(8)));
00173 uint64_t ugCoeff __attribute__((aligned(8)));
00174 uint64_t yOffset __attribute__((aligned(8)));
00175 uint64_t uOffset __attribute__((aligned(8)));
00176 uint64_t vOffset __attribute__((aligned(8)));
00177 int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
00178 int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
00179 int dstW;
00180 uint64_t esp __attribute__((aligned(8)));
00181 uint64_t vRounder __attribute__((aligned(8)));
00182 uint64_t u_temp __attribute__((aligned(8)));
00183 uint64_t v_temp __attribute__((aligned(8)));
00184
00185 #if HAVE_ALTIVEC
00186
00187 vector signed short CY;
00188 vector signed short CRV;
00189 vector signed short CBU;
00190 vector signed short CGU;
00191 vector signed short CGV;
00192 vector signed short OY;
00193 vector unsigned short CSHIFT;
00194 vector signed short *vYCoeffsBank, *vCCoeffsBank;
00195
00196 #endif
00197
00198
00199 #if ARCH_BFIN
00200 uint32_t oy __attribute__((aligned(4)));
00201 uint32_t oc __attribute__((aligned(4)));
00202 uint32_t zero __attribute__((aligned(4)));
00203 uint32_t cy __attribute__((aligned(4)));
00204 uint32_t crv __attribute__((aligned(4)));
00205 uint32_t rmask __attribute__((aligned(4)));
00206 uint32_t cbu __attribute__((aligned(4)));
00207 uint32_t bmask __attribute__((aligned(4)));
00208 uint32_t cgu __attribute__((aligned(4)));
00209 uint32_t cgv __attribute__((aligned(4)));
00210 uint32_t gmask __attribute__((aligned(4)));
00211 #endif
00212
00213 #if HAVE_VIS
00214 uint64_t sparc_coeffs[10] __attribute__((aligned(8)));
00215 #endif
00216
00217 } SwsContext;
00218
00219
00220 SwsFunc sws_yuv2rgb_get_func_ptr (SwsContext *c);
00221 int sws_yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
00222
00223 void sws_yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation);
00224 SwsFunc sws_yuv2rgb_init_altivec (SwsContext *c);
00225 void altivec_yuv2packedX (SwsContext *c,
00226 int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
00227 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
00228 uint8_t *dest, int dstW, int dstY);
00229
00230 const char *sws_format_name(int format);
00231
00232
00233 #define isPlanarYUV(x) ( \
00234 (x)==PIX_FMT_YUV410P \
00235 || (x)==PIX_FMT_YUV420P \
00236 || (x)==PIX_FMT_YUV411P \
00237 || (x)==PIX_FMT_YUV422P \
00238 || (x)==PIX_FMT_YUV444P \
00239 || (x)==PIX_FMT_YUV440P \
00240 || (x)==PIX_FMT_NV12 \
00241 || (x)==PIX_FMT_NV21 \
00242 )
00243 #define isYUV(x) ( \
00244 (x)==PIX_FMT_UYVY422 \
00245 || (x)==PIX_FMT_YUYV422 \
00246 || isPlanarYUV(x) \
00247 )
00248 #define isGray(x) ( \
00249 (x)==PIX_FMT_GRAY8 \
00250 || (x)==PIX_FMT_GRAY16BE \
00251 || (x)==PIX_FMT_GRAY16LE \
00252 )
00253 #define isGray16(x) ( \
00254 (x)==PIX_FMT_GRAY16BE \
00255 || (x)==PIX_FMT_GRAY16LE \
00256 )
00257 #define isRGB(x) ( \
00258 (x)==PIX_FMT_RGB32 \
00259 || (x)==PIX_FMT_RGB32_1 \
00260 || (x)==PIX_FMT_RGB24 \
00261 || (x)==PIX_FMT_RGB565 \
00262 || (x)==PIX_FMT_RGB555 \
00263 || (x)==PIX_FMT_RGB8 \
00264 || (x)==PIX_FMT_RGB4 \
00265 || (x)==PIX_FMT_RGB4_BYTE \
00266 || (x)==PIX_FMT_MONOBLACK \
00267 || (x)==PIX_FMT_MONOWHITE \
00268 )
00269 #define isBGR(x) ( \
00270 (x)==PIX_FMT_BGR32 \
00271 || (x)==PIX_FMT_BGR32_1 \
00272 || (x)==PIX_FMT_BGR24 \
00273 || (x)==PIX_FMT_BGR565 \
00274 || (x)==PIX_FMT_BGR555 \
00275 || (x)==PIX_FMT_BGR8 \
00276 || (x)==PIX_FMT_BGR4 \
00277 || (x)==PIX_FMT_BGR4_BYTE \
00278 || (x)==PIX_FMT_MONOBLACK \
00279 || (x)==PIX_FMT_MONOWHITE \
00280 )
00281 #define isALPHA(x) ( \
00282 (x)==PIX_FMT_BGR32 \
00283 || (x)==PIX_FMT_BGR32_1 \
00284 || (x)==PIX_FMT_RGB32 \
00285 || (x)==PIX_FMT_RGB32_1 \
00286 || (x)==PIX_FMT_YUVA420P \
00287 )
00288
00289 static inline int fmt_depth(int fmt)
00290 {
00291 switch(fmt) {
00292 case PIX_FMT_BGRA:
00293 case PIX_FMT_ABGR:
00294 case PIX_FMT_RGBA:
00295 case PIX_FMT_ARGB:
00296 return 32;
00297 case PIX_FMT_BGR24:
00298 case PIX_FMT_RGB24:
00299 return 24;
00300 case PIX_FMT_BGR565:
00301 case PIX_FMT_RGB565:
00302 case PIX_FMT_GRAY16BE:
00303 case PIX_FMT_GRAY16LE:
00304 return 16;
00305 case PIX_FMT_BGR555:
00306 case PIX_FMT_RGB555:
00307 return 15;
00308 case PIX_FMT_BGR8:
00309 case PIX_FMT_RGB8:
00310 return 8;
00311 case PIX_FMT_BGR4:
00312 case PIX_FMT_RGB4:
00313 case PIX_FMT_BGR4_BYTE:
00314 case PIX_FMT_RGB4_BYTE:
00315 return 4;
00316 case PIX_FMT_MONOBLACK:
00317 case PIX_FMT_MONOWHITE:
00318 return 1;
00319 default:
00320 return 0;
00321 }
00322 }
00323
00324 extern const uint64_t ff_dither4[2];
00325 extern const uint64_t ff_dither8[2];
00326
00327 extern const AVClass sws_context_class;
00328
00329 #endif