*
* You should have received a copy of the GNU General Public License
* along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* the C code (not assembly, mmx, ...) of this file can be used
* under the LGPL license too
YVU9 -> YV12
untested special converters
- YV12/I420 -> BGR15/BGR24/BGR32 (its the yuv2rgb stuff, so it should be ok)
+ YV12/I420 -> BGR15/BGR24/BGR32 (it is the yuv2rgb stuff, so it should be ok)
YV12/I420 -> YV12/I420
YUY2/BGR15/BGR24/BGR32/RGB24/RGB32 -> same format
BGR24 -> BGR32 & RGB24 -> RGB32
#include "x86_cpu.h"
#include "bswap.h"
#include "rgb2rgb.h"
-#ifdef USE_FASTMEMCPY
-#include "libvo/fastmemcpy.h"
-#endif
+#include "libavcodec/opt.h"
#undef MOVNTQ
#undef PAVGB
#define PI 3.14159265358979323846
#endif
-#define isSupportedIn(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422 \
- || (x)==PIX_FMT_RGB32 || (x)==PIX_FMT_BGR24 || (x)==PIX_FMT_BGR565 || (x)==PIX_FMT_BGR555 \
- || (x)==PIX_FMT_BGR32 || (x)==PIX_FMT_RGB24 || (x)==PIX_FMT_RGB565 || (x)==PIX_FMT_RGB555 \
- || (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P \
- || (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE \
- || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P \
- || (x)==PIX_FMT_PAL8 || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_RGB8 \
- || (x)==PIX_FMT_BGR4_BYTE || (x)==PIX_FMT_RGB4_BYTE)
-#define isSupportedOut(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422 \
- || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P \
- || isRGB(x) || isBGR(x) \
- || (x)==PIX_FMT_NV12 || (x)==PIX_FMT_NV21 \
- || (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE \
- || (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P)
-#define isPacked(x) ((x)==PIX_FMT_PAL8 || (x)==PIX_FMT_YUYV422 || \
- (x)==PIX_FMT_UYVY422 || isRGB(x) || isBGR(x))
+#define isSupportedIn(x) ( \
+ (x)==PIX_FMT_YUV420P \
+ || (x)==PIX_FMT_YUYV422 \
+ || (x)==PIX_FMT_UYVY422 \
+ || (x)==PIX_FMT_RGB32 \
+ || (x)==PIX_FMT_BGR24 \
+ || (x)==PIX_FMT_BGR565 \
+ || (x)==PIX_FMT_BGR555 \
+ || (x)==PIX_FMT_BGR32 \
+ || (x)==PIX_FMT_RGB24 \
+ || (x)==PIX_FMT_RGB565 \
+ || (x)==PIX_FMT_RGB555 \
+ || (x)==PIX_FMT_GRAY8 \
+ || (x)==PIX_FMT_YUV410P \
+ || (x)==PIX_FMT_GRAY16BE \
+ || (x)==PIX_FMT_GRAY16LE \
+ || (x)==PIX_FMT_YUV444P \
+ || (x)==PIX_FMT_YUV422P \
+ || (x)==PIX_FMT_YUV411P \
+ || (x)==PIX_FMT_PAL8 \
+ || (x)==PIX_FMT_BGR8 \
+ || (x)==PIX_FMT_RGB8 \
+ || (x)==PIX_FMT_BGR4_BYTE \
+ || (x)==PIX_FMT_RGB4_BYTE \
+ )
+#define isSupportedOut(x) ( \
+ (x)==PIX_FMT_YUV420P \
+ || (x)==PIX_FMT_YUYV422 \
+ || (x)==PIX_FMT_UYVY422 \
+ || (x)==PIX_FMT_YUV444P \
+ || (x)==PIX_FMT_YUV422P \
+ || (x)==PIX_FMT_YUV411P \
+ || isRGB(x) \
+ || isBGR(x) \
+ || (x)==PIX_FMT_NV12 \
+ || (x)==PIX_FMT_NV21 \
+ || (x)==PIX_FMT_GRAY16BE \
+ || (x)==PIX_FMT_GRAY16LE \
+ || (x)==PIX_FMT_GRAY8 \
+ || (x)==PIX_FMT_YUV410P \
+ )
+#define isPacked(x) ( \
+ (x)==PIX_FMT_PAL8 \
+ || (x)==PIX_FMT_YUYV422 \
+ || (x)==PIX_FMT_UYVY422 \
+ || isRGB(x) \
+ || isBGR(x) \
+ )
#define RGB2YUV_SHIFT 16
#define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
return "swscaler";
}
-static AVClass sws_context_class = { "SWScaler", sws_context_to_name, NULL };
+#define OFFSET(x) offsetof(SwsContext, x)
+#define DEFAULT 0
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+
+static const AVOption options[] = {
+ { "sws_flags", "scaler/cpu flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "fast_bilinear", "fast bilinear", 0, FF_OPT_TYPE_CONST, SWS_FAST_BILINEAR, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "bilinear", "bilinear", 0, FF_OPT_TYPE_CONST, SWS_BILINEAR, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "bicubic", "bicubic", 0, FF_OPT_TYPE_CONST, SWS_BICUBIC, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "experimental", "experimental", 0, FF_OPT_TYPE_CONST, SWS_X, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "neighbor", "nearest neighbor", 0, FF_OPT_TYPE_CONST, SWS_POINT, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "area", "averaging area", 0, FF_OPT_TYPE_CONST, SWS_AREA, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "bicublin", "luma bicubic, chroma bilinear", 0, FF_OPT_TYPE_CONST, SWS_BICUBLIN, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "gauss", "gaussian", 0, FF_OPT_TYPE_CONST, SWS_GAUSS, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "sinc", "sinc", 0, FF_OPT_TYPE_CONST, SWS_SINC, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "lanczos", "lanczos", 0, FF_OPT_TYPE_CONST, SWS_LANCZOS, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "spline", "natural bicubic spline", 0, FF_OPT_TYPE_CONST, SWS_SPLINE, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "print_info", "print info", 0, FF_OPT_TYPE_CONST, SWS_PRINT_INFO, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "accurate_rnd", "accurate rounding", 0, FF_OPT_TYPE_CONST, SWS_ACCURATE_RND, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "mmx", "MMX SIMD acceleration", 0, FF_OPT_TYPE_CONST, SWS_CPU_CAPS_MMX, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "mmx2", "MMX2 SIMD acceleration", 0, FF_OPT_TYPE_CONST, SWS_CPU_CAPS_MMX2, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "3dnow", "3DNOW SIMD acceleration", 0, FF_OPT_TYPE_CONST, SWS_CPU_CAPS_3DNOW, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "altivec", "AltiVec SIMD acceleration", 0, FF_OPT_TYPE_CONST, SWS_CPU_CAPS_ALTIVEC, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "bfin", "Blackfin SIMD acceleration", 0, FF_OPT_TYPE_CONST, SWS_CPU_CAPS_BFIN, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "full_chroma_int", "full chroma interpolation", 0 , FF_OPT_TYPE_CONST, SWS_FULL_CHR_H_INT, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { "full_chroma_inp", "full chroma input", 0 , FF_OPT_TYPE_CONST, SWS_FULL_CHR_H_INP, INT_MIN, INT_MAX, VE, "sws_flags" },
+ { NULL }
+};
+
+#undef VE
+#undef DEFAULT
+
+static AVClass sws_context_class = { "SWScaler", sws_context_to_name, options };
char *sws_format_name(enum PixelFormat format)
{
int Y2 = 1<<18;\
int U = 1<<18;\
int V = 1<<18;\
- type attribute_unused *r, *b, *g;\
+ type av_unused *r, *b, *g;\
const int i2= 2*i;\
\
for (j=0; j<lumFilterSize; j++)\
double *filter2=NULL;
#if defined(ARCH_X86)
if (flags & SWS_CPU_CAPS_MMX)
- asm volatile("emms\n\t"::: "memory"); //FIXME this shouldnt be required but it IS (even for non mmx versions)
+ asm volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions)
#endif
// Note the +1 is for the MMXscaler which reads over the end
av_free(filter); filter=NULL;
/* try to reduce the filter-size (step1 find size and shift left) */
- // Assume its near normalized (*0.5 or *2.0 is ok but * 0.001 is not)
+ // Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not).
minFilterSize= 0;
for (i=dstW-1; i>=0; i--)
{
if (cutOff > SWS_MAX_REDUCE_CUTOFF) break;
- /* preserve Monotonicity because the core can't handle the filter otherwise */
+ /* preserve monotonicity because the core can't handle the filter otherwise */
if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break;
// Move filter coeffs left
if(conv)
{
- if (dstStride[0]*srcBpp == srcStride[0]*dstBpp)
- conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
- else
- {
- int i;
- uint8_t *srcPtr= src[0];
- uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
-
- for (i=0; i<srcSliceH; i++)
+ if (dstStride[0]*srcBpp == srcStride[0]*dstBpp)
+ conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]);
+ else
{
- conv(srcPtr, dstPtr, c->srcW*srcBpp);
- srcPtr+= srcStride[0];
- dstPtr+= dstStride[0];
+ int i;
+ uint8_t *srcPtr= src[0];
+ uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
+
+ for (i=0; i<srcSliceH; i++)
+ {
+ conv(srcPtr, dstPtr, c->srcW*srcBpp);
+ srcPtr+= srcStride[0];
+ dstPtr+= dstStride[0];
+ }
}
}
- }
return srcSliceH;
}
/**
* @param inv_table the yuv2rgb coeffs, normally Inverse_Table_6_9[x]
- * @param fullRange if 1 then the luma range is 0..255 if 0 its 16..235
+ * @param fullRange if 1 then the luma range is 0..255 if 0 it is 16..235
* @return -1 if not supported
*/
int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation){
#endif
#if !defined(RUNTIME_CPUDETECT) || !defined (CONFIG_GPL) //ensure that the flags match the compiled variant if cpudetect is off
- flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC);
+ flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
#ifdef HAVE_MMX2
flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
#elif defined (HAVE_3DNOW)
flags |= SWS_CPU_CAPS_MMX;
#elif defined (HAVE_ALTIVEC)
flags |= SWS_CPU_CAPS_ALTIVEC;
+#elif defined (ARCH_BFIN)
+ flags |= SWS_CPU_CAPS_BFIN;
#endif
#endif /* RUNTIME_CPUDETECT */
if (clip_table[512] != 255) globalInit();
c->swScale= gray16swap;
}
+#ifdef ARCH_BFIN
+ if (flags & SWS_CPU_CAPS_BFIN)
+ ff_bfin_get_unscaled_swscale (c);
+#endif
+
if (c->swScale){
if (flags&SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO, "SwScaler: using unscaled %s -> %s special converter\n",
// match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst
// but only for the FAST_BILINEAR mode otherwise do correct scaling
// n-2 is the last chrominance sample available
- // this is not perfect, but noone shuld notice the difference, the more correct variant
+ // this is not perfect, but no one should notice the difference, the more correct variant
// would be like the vertical one, but that would require some special code for the
// first and last pixel
if (flags&SWS_FAST_BILINEAR)