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