#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/ppc/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "rgb2rgb.h"
#define RET 0xC3 // near return opcode for x86
typedef struct FormatEntry {
- int is_supported_in, is_supported_out;
+ uint8_t is_supported_in :1;
+ uint8_t is_supported_out :1;
+ uint8_t is_supported_endianness :1;
} FormatEntry;
static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
[AV_PIX_FMT_YUV444P9LE] = { 1, 1 },
[AV_PIX_FMT_YUV444P10BE] = { 1, 1 },
[AV_PIX_FMT_YUV444P10LE] = { 1, 1 },
- [AV_PIX_FMT_GBRP] = { 1, 0 },
- [AV_PIX_FMT_GBRP9LE] = { 1, 0 },
- [AV_PIX_FMT_GBRP9BE] = { 1, 0 },
- [AV_PIX_FMT_GBRP10LE] = { 1, 0 },
- [AV_PIX_FMT_GBRP10BE] = { 1, 0 },
+ [AV_PIX_FMT_GBRP] = { 1, 1 },
+ [AV_PIX_FMT_GBRP9LE] = { 1, 1 },
+ [AV_PIX_FMT_GBRP9BE] = { 1, 1 },
+ [AV_PIX_FMT_GBRP10LE] = { 1, 1 },
+ [AV_PIX_FMT_GBRP10BE] = { 1, 1 },
[AV_PIX_FMT_GBRP16LE] = { 1, 0 },
[AV_PIX_FMT_GBRP16BE] = { 1, 0 },
+ [AV_PIX_FMT_XYZ12BE] = { 0, 0, 1 },
+ [AV_PIX_FMT_XYZ12LE] = { 0, 0, 1 },
};
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
format_entries[pix_fmt].is_supported_out : 0;
}
-extern const int32_t ff_yuv2rgb_coeffs[8][4];
+int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
+{
+ return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
+ format_entries[pix_fmt].is_supported_endianness : 0;
+}
const char *sws_format_name(enum AVPixelFormat format)
{
dist - 1.0);
}
-static int initFilter(int16_t **outFilter, int32_t **filterPos,
- int *outFilterSize, int xInc, int srcW, int dstW,
- int filterAlign, int one, int flags, int cpu_flags,
- SwsVector *srcFilter, SwsVector *dstFilter,
- double param[2], int is_horizontal)
+static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
+ int *outFilterSize, int xInc, int srcW,
+ int dstW, int filterAlign, int one,
+ int flags, int cpu_flags,
+ SwsVector *srcFilter, SwsVector *dstFilter,
+ double param[2], int is_horizontal)
{
int i;
int filterSize;
minFilterSize = min;
}
- if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
+ if (PPC_ALTIVEC(cpu_flags)) {
// we can handle the special case 4, so we don't want to go the full 8
if (minFilterSize < 5)
filterAlign = 4;
}
#if HAVE_MMXEXT_INLINE
-static int init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode,
- int16_t *filter, int32_t *filterPos,
- int numSplits)
+static av_cold int init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode,
+ int16_t *filter, int32_t *filterPos,
+ int numSplits)
{
uint8_t *fragmentA;
x86_reg imm8OfPShufW1A;
contrast, saturation);
// FIXME factorize
- if (HAVE_ALTIVEC && av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)
- ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness,
- contrast, saturation);
+ if (ARCH_PPC)
+ ff_yuv2rgb_init_tables_ppc(c, inv_table, brightness,
+ contrast, saturation);
return 0;
}
{
SwsContext *c = av_mallocz(sizeof(SwsContext));
- c->av_class = &sws_context_class;
- av_opt_set_defaults(c);
+ if (c) {
+ c->av_class = &sws_context_class;
+ av_opt_set_defaults(c);
+ }
return c;
}
unscaled = (srcW == dstW && srcH == dstH);
+ if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) &&
+ av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) {
if (!sws_isSupportedInput(srcFormat)) {
av_log(c, AV_LOG_ERROR, "%s is not supported as input pixel format\n",
sws_format_name(srcFormat));
sws_format_name(dstFormat));
return AVERROR(EINVAL);
}
+ }
i = flags & (SWS_POINT |
SWS_AREA |
getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
+ if (isPlanarRGB(dstFormat)) {
+ if (!(flags & SWS_FULL_CHR_H_INT)) {
+ av_log(c, AV_LOG_DEBUG,
+ "%s output is not supported with half chroma resolution, switching to full\n",
+ av_get_pix_fmt_name(dstFormat));
+ flags |= SWS_FULL_CHR_H_INT;
+ c->flags = flags;
+ }
+ }
+
/* reuse chroma for 2 pixels RGB/BGR unless user wants full
* chroma interpolation */
if (flags & SWS_FULL_CHR_H_INT &&
isAnyRGB(dstFormat) &&
+ !isPlanarRGB(dstFormat) &&
dstFormat != AV_PIX_FMT_RGBA &&
dstFormat != AV_PIX_FMT_ARGB &&
dstFormat != AV_PIX_FMT_BGRA &&
srcFormat != AV_PIX_FMT_RGB8 && srcFormat != AV_PIX_FMT_BGR8 &&
srcFormat != AV_PIX_FMT_RGB4 && srcFormat != AV_PIX_FMT_BGR4 &&
srcFormat != AV_PIX_FMT_RGB4_BYTE && srcFormat != AV_PIX_FMT_BGR4_BYTE &&
+ srcFormat != AV_PIX_FMT_GBRP9BE && srcFormat != AV_PIX_FMT_GBRP9LE &&
+ srcFormat != AV_PIX_FMT_GBRP10BE && srcFormat != AV_PIX_FMT_GBRP10LE &&
+ srcFormat != AV_PIX_FMT_GBRP16BE && srcFormat != AV_PIX_FMT_GBRP16LE &&
((dstW >> c->chrDstHSubSample) <= (srcW >> 1) ||
(flags & SWS_FAST_BILINEAR)))
c->chrSrcHSubSample = 1;
(c->srcRange == c->dstRange || isAnyRGB(dstFormat))) {
ff_get_unscaled_swscale(c);
- if (c->swScale) {
+ if (c->swscale) {
if (flags & SWS_PRINT_INFO)
av_log(c, AV_LOG_INFO,
"using unscaled %s -> %s special converter\n",
} else
#endif /* HAVE_MMXEXT_INLINE */
{
- const int filterAlign =
- (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? 4 :
- (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) ? 8 :
- 1;
+ const int filterAlign = X86_MMX(cpu_flags) ? 4 :
+ PPC_ALTIVEC(cpu_flags) ? 8 : 1;
if (initFilter(&c->hLumFilter, &c->hLumFilterPos,
&c->hLumFilterSize, c->lumXInc,
/* precalculate vertical scaler filter coefficients */
{
- const int filterAlign =
- (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? 2 :
- (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) ? 8 :
- 1;
+ const int filterAlign = X86_MMX(cpu_flags) ? 2 :
+ PPC_ALTIVEC(cpu_flags) ? 8 : 1;
if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize,
c->lumYInc, srcH, dstH, filterAlign, (1 << 12),
av_log(c, AV_LOG_INFO, "using 3DNOW\n");
else if (INLINE_MMX(cpu_flags))
av_log(c, AV_LOG_INFO, "using MMX\n");
- else if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC)
+ else if (PPC_ALTIVEC(cpu_flags))
av_log(c, AV_LOG_INFO, "using AltiVec\n");
else
av_log(c, AV_LOG_INFO, "using C\n");
c->chrXInc, c->chrYInc);
}
- c->swScale = ff_getSwsFunc(c);
+ c->swscale = ff_getSwsFunc(c);
return 0;
fail: // FIXME replace things by appropriate error codes
return -1;