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