2012-02-01 15:38:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*
|
|
|
|
* This file is part of Libav.
|
|
|
|
*
|
|
|
|
* Libav is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Libav is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with Libav; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "libavutil/avutil.h"
|
|
|
|
#include "libavutil/bswap.h"
|
|
|
|
#include "libavutil/cpu.h"
|
|
|
|
#include "libavutil/intreadwrite.h"
|
|
|
|
#include "libavutil/mathematics.h"
|
|
|
|
#include "libavutil/pixdesc.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "rgb2rgb.h"
|
|
|
|
#include "swscale.h"
|
|
|
|
#include "swscale_internal.h"
|
|
|
|
|
|
|
|
#define RGB2YUV_SHIFT 15
|
2012-04-15 19:33:30 +00:00
|
|
|
#define BY ((int)(0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define BV (-(int)(0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define BU ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define GY ((int)(0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define GV (-(int)(0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define GU (-(int)(0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define RY ((int)(0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define RV ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
|
|
|
#define RU (-(int)(0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
|
2012-02-01 15:38:55 +00:00
|
|
|
|
|
|
|
#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
|
|
|
|
|
2012-10-06 10:10:34 +00:00
|
|
|
#define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? b_r : r_b)
|
|
|
|
#define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? r_b : b_r)
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
|
|
|
|
const uint16_t *src, int width,
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat origin)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 19:33:30 +00:00
|
|
|
unsigned int r_b = input_pixel(&src[i * 3 + 0]);
|
|
|
|
unsigned int g = input_pixel(&src[i * 3 + 1]);
|
|
|
|
unsigned int b_r = input_pixel(&src[i * 3 + 2]);
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dst[i] = (RY * r + GY * g + BY * b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU,
|
|
|
|
uint16_t *dstV,
|
|
|
|
const uint16_t *src1,
|
|
|
|
const uint16_t *src2,
|
|
|
|
int width,
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat origin)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
assert(src1 == src2);
|
2012-02-01 15:38:55 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 19:33:30 +00:00
|
|
|
int r_b = input_pixel(&src1[i * 3 + 0]);
|
|
|
|
int g = input_pixel(&src1[i * 3 + 1]);
|
|
|
|
int b_r = input_pixel(&src1[i * 3 + 2]);
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU,
|
|
|
|
uint16_t *dstV,
|
|
|
|
const uint16_t *src1,
|
|
|
|
const uint16_t *src2,
|
|
|
|
int width,
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat origin)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
assert(src1 == src2);
|
2012-02-01 15:38:55 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 19:33:30 +00:00
|
|
|
int r_b = (input_pixel(&src1[6 * i + 0]) +
|
|
|
|
input_pixel(&src1[6 * i + 3]) + 1) >> 1;
|
|
|
|
int g = (input_pixel(&src1[6 * i + 1]) +
|
|
|
|
input_pixel(&src1[6 * i + 4]) + 1) >> 1;
|
|
|
|
int b_r = (input_pixel(&src1[6 * i + 2]) +
|
|
|
|
input_pixel(&src1[6 * i + 5]) + 1) >> 1;
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef r
|
|
|
|
#undef b
|
|
|
|
#undef input_pixel
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
#define rgb48funcs(pattern, BE_LE, origin) \
|
|
|
|
static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
|
|
|
|
const uint8_t *_src, \
|
|
|
|
int width, \
|
|
|
|
uint32_t *unused) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t *)_src; \
|
|
|
|
uint16_t *dst = (uint16_t *)_dst; \
|
|
|
|
rgb48ToY_c_template(dst, src, width, origin); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
|
|
|
|
uint8_t *_dstV, \
|
|
|
|
const uint8_t *_src1, \
|
|
|
|
const uint8_t *_src2, \
|
|
|
|
int width, \
|
|
|
|
uint32_t *unused) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src1 = (const uint16_t *)_src1, \
|
|
|
|
*src2 = (const uint16_t *)_src2; \
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU, \
|
|
|
|
*dstV = (uint16_t *)_dstV; \
|
|
|
|
rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
|
|
|
|
uint8_t *_dstV, \
|
|
|
|
const uint8_t *_src1, \
|
|
|
|
const uint8_t *_src2, \
|
|
|
|
int width, \
|
|
|
|
uint32_t *unused) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src1 = (const uint16_t *)_src1, \
|
|
|
|
*src2 = (const uint16_t *)_src2; \
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU, \
|
|
|
|
*dstV = (uint16_t *)_dstV; \
|
|
|
|
rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
2012-10-06 10:10:34 +00:00
|
|
|
rgb48funcs(rgb, LE, AV_PIX_FMT_RGB48LE)
|
|
|
|
rgb48funcs(rgb, BE, AV_PIX_FMT_RGB48BE)
|
|
|
|
rgb48funcs(bgr, LE, AV_PIX_FMT_BGR48LE)
|
|
|
|
rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-10-06 10:10:34 +00:00
|
|
|
#define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
|
|
|
|
origin == AV_PIX_FMT_BGRA || \
|
|
|
|
origin == AV_PIX_FMT_ARGB || \
|
|
|
|
origin == AV_PIX_FMT_ABGR) \
|
2012-04-15 19:33:30 +00:00
|
|
|
? AV_RN32A(&src[(i) * 4]) \
|
|
|
|
: (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
|
|
|
|
: AV_RL16(&src[(i) * 2])))
|
|
|
|
|
|
|
|
static av_always_inline void rgb16_32ToY_c_template(uint8_t *dst,
|
|
|
|
const uint8_t *src,
|
|
|
|
int width,
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat origin,
|
2012-04-15 19:33:30 +00:00
|
|
|
int shr, int shg,
|
|
|
|
int shb, int shp,
|
|
|
|
int maskr, int maskg,
|
|
|
|
int maskb, int rsh,
|
|
|
|
int gsh, int bsh, int S)
|
|
|
|
{
|
|
|
|
const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh;
|
2012-02-01 15:38:55 +00:00
|
|
|
const unsigned rnd = 33u << (S - 1);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int px = input_pixel(i) >> shp;
|
2012-04-15 19:33:30 +00:00
|
|
|
int b = (px & maskb) >> shb;
|
|
|
|
int g = (px & maskg) >> shg;
|
|
|
|
int r = (px & maskr) >> shr;
|
2012-02-01 15:38:55 +00:00
|
|
|
|
|
|
|
dst[i] = (ry * r + gy * g + by * b + rnd) >> S;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static av_always_inline void rgb16_32ToUV_c_template(uint8_t *dstU,
|
|
|
|
uint8_t *dstV,
|
|
|
|
const uint8_t *src,
|
|
|
|
int width,
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat origin,
|
2012-04-15 19:33:30 +00:00
|
|
|
int shr, int shg,
|
|
|
|
int shb, int shp,
|
|
|
|
int maskr, int maskg,
|
|
|
|
int maskb, int rsh,
|
|
|
|
int gsh, int bsh, int S)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
2012-04-15 19:33:30 +00:00
|
|
|
const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
|
|
|
|
rv = RV << rsh, gv = GV << gsh, bv = BV << bsh;
|
2012-02-01 15:38:55 +00:00
|
|
|
const unsigned rnd = 257u << (S - 1);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int px = input_pixel(i) >> shp;
|
2012-04-15 19:33:30 +00:00
|
|
|
int b = (px & maskb) >> shb;
|
|
|
|
int g = (px & maskg) >> shg;
|
|
|
|
int r = (px & maskr) >> shr;
|
2012-02-01 15:38:55 +00:00
|
|
|
|
|
|
|
dstU[i] = (ru * r + gu * g + bu * b + rnd) >> S;
|
|
|
|
dstV[i] = (rv * r + gv * g + bv * b + rnd) >> S;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static av_always_inline void rgb16_32ToUV_half_c_template(uint8_t *dstU,
|
|
|
|
uint8_t *dstV,
|
|
|
|
const uint8_t *src,
|
|
|
|
int width,
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat origin,
|
2012-04-15 19:33:30 +00:00
|
|
|
int shr, int shg,
|
|
|
|
int shb, int shp,
|
|
|
|
int maskr, int maskg,
|
|
|
|
int maskb, int rsh,
|
|
|
|
int gsh, int bsh, int S)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
2012-04-15 19:33:30 +00:00
|
|
|
const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
|
|
|
|
rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
|
|
|
|
maskgx = ~(maskr | maskb);
|
2012-02-01 15:38:55 +00:00
|
|
|
const unsigned rnd = 257u << S;
|
|
|
|
int i;
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
maskr |= maskr << 1;
|
|
|
|
maskb |= maskb << 1;
|
|
|
|
maskg |= maskg << 1;
|
2012-02-01 15:38:55 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int px0 = input_pixel(2 * i + 0) >> shp;
|
|
|
|
int px1 = input_pixel(2 * i + 1) >> shp;
|
|
|
|
int b, r, g = (px0 & maskgx) + (px1 & maskgx);
|
|
|
|
int rb = px0 + px1 - g;
|
|
|
|
|
|
|
|
b = (rb & maskb) >> shb;
|
2012-04-15 19:33:30 +00:00
|
|
|
if (shp ||
|
2012-10-06 10:10:34 +00:00
|
|
|
origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
|
|
|
|
origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
|
2012-02-01 15:38:55 +00:00
|
|
|
g >>= shg;
|
|
|
|
} else {
|
2012-04-15 19:33:30 +00:00
|
|
|
g = (g & maskg) >> shg;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
r = (rb & maskr) >> shr;
|
|
|
|
|
|
|
|
dstU[i] = (ru * r + gu * g + bu * b + rnd) >> (S + 1);
|
|
|
|
dstV[i] = (rv * r + gv * g + bv * b + rnd) >> (S + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef input_pixel
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
#define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
|
|
|
|
maskg, maskb, rsh, gsh, bsh, S) \
|
|
|
|
static void name ## ToY_c(uint8_t *dst, const uint8_t *src, \
|
|
|
|
int width, uint32_t *unused) \
|
|
|
|
{ \
|
|
|
|
rgb16_32ToY_c_template(dst, src, width, fmt, shr, shg, shb, shp, \
|
|
|
|
maskr, maskg, maskb, rsh, gsh, bsh, S); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
|
|
|
|
const uint8_t *src, const uint8_t *dummy, \
|
|
|
|
int width, uint32_t *unused) \
|
|
|
|
{ \
|
|
|
|
rgb16_32ToUV_c_template(dstU, dstV, src, width, fmt, \
|
|
|
|
shr, shg, shb, shp, \
|
|
|
|
maskr, maskg, maskb, rsh, gsh, bsh, S); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
|
|
|
|
const uint8_t *src, \
|
|
|
|
const uint8_t *dummy, \
|
|
|
|
int width, uint32_t *unused) \
|
|
|
|
{ \
|
|
|
|
rgb16_32ToUV_half_c_template(dstU, dstV, src, width, fmt, \
|
|
|
|
shr, shg, shb, shp, \
|
|
|
|
maskr, maskg, maskb, \
|
|
|
|
rsh, gsh, bsh, S); \
|
|
|
|
}
|
|
|
|
|
2012-10-06 10:10:34 +00:00
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
|
|
|
|
rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
|
2012-04-15 19:33:30 +00:00
|
|
|
|
|
|
|
static void abgrToA_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[4 * i];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static void rgbaToA_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[4 * i + 3];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void palToY_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int d = src[i];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dst[i] = pal[d] & 0xFF;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void palToUV_c(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src1, const uint8_t *src2,
|
|
|
|
int width, uint32_t *pal)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
assert(src1 == src2);
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int p = pal[src1[i]];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dstU[i] = p >> 8;
|
|
|
|
dstV[i] = p >> 16;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void monowhite2Y_c(uint8_t *dst, const uint8_t *src,
|
|
|
|
int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i, j;
|
2012-04-04 17:50:29 +00:00
|
|
|
width = (width + 7) >> 3;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 19:33:30 +00:00
|
|
|
int d = ~src[i];
|
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
dst[8 * i + j] = ((d >> (7 - j)) & 1) * 255;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void monoblack2Y_c(uint8_t *dst, const uint8_t *src,
|
|
|
|
int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i, j;
|
2012-04-04 17:50:29 +00:00
|
|
|
width = (width + 7) >> 3;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 19:33:30 +00:00
|
|
|
int d = src[i];
|
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
dst[8 * i + j] = ((d >> (7 - j)) & 1) * 255;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[2 * i];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src1[4 * i + 1];
|
|
|
|
dstV[i] = src1[4 * i + 3];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
assert(src1 == src2);
|
|
|
|
}
|
|
|
|
|
2014-04-07 15:19:53 +00:00
|
|
|
static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstV[i] = src1[4 * i + 1];
|
|
|
|
dstU[i] = src1[4 * i + 3];
|
|
|
|
}
|
|
|
|
assert(src1 == src2);
|
|
|
|
}
|
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, int width,
|
|
|
|
uint32_t *unused)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
const uint16_t *src = (const uint16_t *)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
for (i = 0; i < width; i++)
|
2012-02-01 15:38:55 +00:00
|
|
|
dst[i] = av_bswap16(src[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src1,
|
|
|
|
const uint8_t *_src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
const uint16_t *src1 = (const uint16_t *)_src1,
|
|
|
|
*src2 = (const uint16_t *)_src2;
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-02-01 15:38:55 +00:00
|
|
|
dstU[i] = av_bswap16(src1[i]);
|
|
|
|
dstV[i] = av_bswap16(src2[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-20 05:05:35 +00:00
|
|
|
static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
|
|
|
|
}
|
|
|
|
|
2012-02-01 15:38:55 +00:00
|
|
|
/* This is almost identical to the previous, end exists only because
|
2012-04-15 19:33:30 +00:00
|
|
|
* yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
|
2012-02-01 15:38:55 +00:00
|
|
|
static void uyvyToY_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[2 * i + 1];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src1[4 * i + 0];
|
|
|
|
dstV[i] = src1[4 * i + 2];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
assert(src1 == src2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
|
|
|
|
const uint8_t *src, int width)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 19:33:30 +00:00
|
|
|
dst1[i] = src[2 * i + 0];
|
|
|
|
dst2[i] = src[2 * i + 1];
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src1, const uint8_t *src2,
|
|
|
|
int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
nvXXtoUV_c(dstU, dstV, src1, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src1, const uint8_t *src2,
|
|
|
|
int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
nvXXtoUV_c(dstV, dstU, src1, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
|
|
|
|
|
|
|
|
static void bgr24ToY_c(uint8_t *dst, const uint8_t *src,
|
|
|
|
int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int b = src[i * 3 + 0];
|
|
|
|
int g = src[i * 3 + 1];
|
|
|
|
int r = src[i * 3 + 2];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bgr24ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int b = src1[3 * i + 0];
|
|
|
|
int g = src1[3 * i + 1];
|
|
|
|
int r = src1[3 * i + 2];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
assert(src1 == src2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bgr24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int b = src1[6 * i + 0] + src1[6 * i + 3];
|
|
|
|
int g = src1[6 * i + 1] + src1[6 * i + 4];
|
|
|
|
int r = src1[6 * i + 2] + src1[6 * i + 5];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
assert(src1 == src2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rgb24ToY_c(uint8_t *dst, const uint8_t *src, int width,
|
|
|
|
uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = src[i * 3 + 0];
|
|
|
|
int g = src[i * 3 + 1];
|
|
|
|
int b = src[i * 3 + 2];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-04-15 19:33:30 +00:00
|
|
|
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rgb24ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
assert(src1 == src2);
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = src1[3 * i + 0];
|
|
|
|
int g = src1[3 * i + 1];
|
|
|
|
int b = src1[3 * i + 2];
|
|
|
|
|
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rgb24ToUV_half_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1,
|
|
|
|
const uint8_t *src2, int width, uint32_t *unused)
|
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
assert(src1 == src2);
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = src1[6 * i + 0] + src1[6 * i + 3];
|
|
|
|
int g = src1[6 * i + 1] + src1[6 * i + 4];
|
|
|
|
int b = src1[6 * i + 2] + src1[6 * i + 5];
|
|
|
|
|
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb_to_y(uint8_t *dst, const uint8_t *src[4], int width)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int g = src[0][i];
|
|
|
|
int b = src[1][i];
|
|
|
|
int r = src[2][i];
|
|
|
|
|
|
|
|
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
static void planar_rgb_to_uv(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4], int width)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-05-12 14:21:32 +00:00
|
|
|
int g = src[0][i];
|
|
|
|
int b = src[1][i];
|
|
|
|
int r = src[2][i];
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
#define rdpx(src) \
|
|
|
|
is_be ? AV_RB16(src) : AV_RL16(src)
|
|
|
|
static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
|
|
|
|
int width, int bpc, int is_be)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
const uint16_t **src = (const uint16_t **)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
2012-02-01 15:38:55 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-05-12 14:21:32 +00:00
|
|
|
int g = rdpx(src[0] + i);
|
|
|
|
int b = rdpx(src[1] + i);
|
|
|
|
int r = rdpx(src[2] + i);
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
static void planar_rgb9le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
2012-05-12 14:21:32 +00:00
|
|
|
planar_rgb16_to_y(dst, src, w, 9, 0);
|
|
|
|
}
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
static void planar_rgb9be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_y(dst, src, w, 9, 1);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
static void planar_rgb10le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
2012-05-12 14:21:32 +00:00
|
|
|
planar_rgb16_to_y(dst, src, w, 10, 0);
|
|
|
|
}
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_y(dst, src, w, 10, 1);
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_y(dst, src, w, 16, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb16be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_y(dst, src, w, 16, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
|
|
|
|
const uint8_t *_src[4], int width,
|
|
|
|
int bpc, int is_be)
|
2012-02-01 15:38:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 19:33:30 +00:00
|
|
|
const uint16_t **src = (const uint16_t **)_src;
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
uint16_t *dstV = (uint16_t *)_dstV;
|
2012-02-01 15:38:55 +00:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-05-12 14:21:32 +00:00
|
|
|
int g = rdpx(src[0] + i);
|
|
|
|
int b = rdpx(src[1] + i);
|
|
|
|
int r = rdpx(src[2] + i);
|
2012-02-01 15:38:55 +00:00
|
|
|
|
2012-05-12 14:21:32 +00:00
|
|
|
dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT;
|
|
|
|
dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-12 14:21:32 +00:00
|
|
|
#undef rdpx
|
|
|
|
|
|
|
|
static void planar_rgb9le_to_uv(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, 9, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb9be_to_uv(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, 9, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb10le_to_uv(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, 10, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, 16, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void planar_rgb16be_to_uv(uint8_t *dstU, uint8_t *dstV,
|
|
|
|
const uint8_t *src[4], int w)
|
|
|
|
{
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, 16, 1);
|
|
|
|
}
|
2012-02-01 15:38:55 +00:00
|
|
|
|
|
|
|
av_cold void ff_sws_init_input_funcs(SwsContext *c)
|
|
|
|
{
|
2012-10-06 10:10:34 +00:00
|
|
|
enum AVPixelFormat srcFormat = c->srcFormat;
|
2012-02-01 15:38:55 +00:00
|
|
|
|
|
|
|
c->chrToYV12 = NULL;
|
2012-04-15 19:33:30 +00:00
|
|
|
switch (srcFormat) {
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_YUYV422:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = yuy2ToUV_c;
|
|
|
|
break;
|
2014-04-07 15:19:53 +00:00
|
|
|
case AV_PIX_FMT_YVYU422:
|
|
|
|
c->chrToYV12 = yvy2ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_UYVY422:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = uyvyToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_NV12:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = nv12ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_NV21:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = nv21ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB8:
|
|
|
|
case AV_PIX_FMT_BGR8:
|
|
|
|
case AV_PIX_FMT_PAL8:
|
|
|
|
case AV_PIX_FMT_BGR4_BYTE:
|
|
|
|
case AV_PIX_FMT_RGB4_BYTE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = palToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP9LE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readChrPlanar = planar_rgb9le_to_uv;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP10LE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readChrPlanar = planar_rgb10le_to_uv;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP16LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->readChrPlanar = planar_rgb16le_to_uv;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP9BE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readChrPlanar = planar_rgb9be_to_uv;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP10BE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readChrPlanar = planar_rgb10be_to_uv;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP16BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->readChrPlanar = planar_rgb16be_to_uv;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->readChrPlanar = planar_rgb_to_uv;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
#if HAVE_BIGENDIAN
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_YUV444P9LE:
|
|
|
|
case AV_PIX_FMT_YUV422P9LE:
|
|
|
|
case AV_PIX_FMT_YUV420P9LE:
|
|
|
|
case AV_PIX_FMT_YUV422P10LE:
|
|
|
|
case AV_PIX_FMT_YUV444P10LE:
|
|
|
|
case AV_PIX_FMT_YUV420P10LE:
|
|
|
|
case AV_PIX_FMT_YUV420P16LE:
|
|
|
|
case AV_PIX_FMT_YUV422P16LE:
|
|
|
|
case AV_PIX_FMT_YUV444P16LE:
|
2012-10-31 10:26:32 +00:00
|
|
|
case AV_PIX_FMT_YUVA444P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA420P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA420P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA420P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bswap16UV_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
#else
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_YUV444P9BE:
|
|
|
|
case AV_PIX_FMT_YUV422P9BE:
|
|
|
|
case AV_PIX_FMT_YUV420P9BE:
|
|
|
|
case AV_PIX_FMT_YUV444P10BE:
|
|
|
|
case AV_PIX_FMT_YUV422P10BE:
|
|
|
|
case AV_PIX_FMT_YUV420P10BE:
|
|
|
|
case AV_PIX_FMT_YUV420P16BE:
|
|
|
|
case AV_PIX_FMT_YUV422P16BE:
|
|
|
|
case AV_PIX_FMT_YUV444P16BE:
|
2012-10-31 10:26:32 +00:00
|
|
|
case AV_PIX_FMT_YUVA444P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA420P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA420P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA420P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bswap16UV_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (c->chrSrcHSubSample) {
|
2012-04-15 19:33:30 +00:00
|
|
|
switch (srcFormat) {
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB48BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb48BEToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB48LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb48LEToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR48BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr48BEToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR48LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr48LEToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB32:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr32ToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB32_1:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr321ToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR24:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr24ToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR565LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr16leToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR565BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr16beToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR555LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr15leToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR555BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr15beToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR444LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr12leToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR444BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr12beToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR32:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb32ToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR32_1:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb321ToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB24:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb24ToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB565LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb16leToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB565BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb16beToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB555LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb15leToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB555BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb15beToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB444LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb12leToUV_half_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB444BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb12beToUV_half_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-04-15 19:33:30 +00:00
|
|
|
switch (srcFormat) {
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB48BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb48BEToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB48LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb48LEToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR48BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr48BEToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR48LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr48LEToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB32:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr32ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB32_1:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr321ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR24:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr24ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR565LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr16leToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR565BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr16beToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR555LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr15leToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR555BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr15beToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR444LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr12leToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR444BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = bgr12beToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR32:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb32ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR32_1:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb321ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB24:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb24ToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB565LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb16leToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB565BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb16beToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB555LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb15leToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB555BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb15beToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB444LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb12leToUV_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB444BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->chrToYV12 = rgb12beToUV_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c->lumToYV12 = NULL;
|
|
|
|
c->alpToYV12 = NULL;
|
|
|
|
switch (srcFormat) {
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP9LE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readLumPlanar = planar_rgb9le_to_y;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP10LE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readLumPlanar = planar_rgb10le_to_y;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP16LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->readLumPlanar = planar_rgb16le_to_y;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP9BE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readLumPlanar = planar_rgb9be_to_y;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP10BE:
|
2012-05-12 14:21:32 +00:00
|
|
|
c->readLumPlanar = planar_rgb10be_to_y;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP16BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->readLumPlanar = planar_rgb16be_to_y;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_GBRP:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->readLumPlanar = planar_rgb_to_y;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
#if HAVE_BIGENDIAN
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_YUV444P9LE:
|
|
|
|
case AV_PIX_FMT_YUV422P9LE:
|
|
|
|
case AV_PIX_FMT_YUV420P9LE:
|
|
|
|
case AV_PIX_FMT_YUV444P10LE:
|
|
|
|
case AV_PIX_FMT_YUV422P10LE:
|
|
|
|
case AV_PIX_FMT_YUV420P10LE:
|
|
|
|
case AV_PIX_FMT_YUV420P16LE:
|
|
|
|
case AV_PIX_FMT_YUV422P16LE:
|
|
|
|
case AV_PIX_FMT_YUV444P16LE:
|
|
|
|
case AV_PIX_FMT_GRAY16LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bswap16Y_c;
|
|
|
|
break;
|
2012-10-31 10:26:32 +00:00
|
|
|
case AV_PIX_FMT_YUVA444P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA420P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA420P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA420P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16LE:
|
|
|
|
c->lumToYV12 = bswap16Y_c;
|
|
|
|
c->alpToYV12 = bswap16Y_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
#else
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_YUV444P9BE:
|
|
|
|
case AV_PIX_FMT_YUV422P9BE:
|
|
|
|
case AV_PIX_FMT_YUV420P9BE:
|
|
|
|
case AV_PIX_FMT_YUV444P10BE:
|
|
|
|
case AV_PIX_FMT_YUV422P10BE:
|
|
|
|
case AV_PIX_FMT_YUV420P10BE:
|
|
|
|
case AV_PIX_FMT_YUV420P16BE:
|
|
|
|
case AV_PIX_FMT_YUV422P16BE:
|
|
|
|
case AV_PIX_FMT_YUV444P16BE:
|
|
|
|
case AV_PIX_FMT_GRAY16BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bswap16Y_c;
|
|
|
|
break;
|
2012-10-31 10:26:32 +00:00
|
|
|
case AV_PIX_FMT_YUVA444P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA420P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA420P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA420P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16BE:
|
|
|
|
c->lumToYV12 = bswap16Y_c;
|
|
|
|
c->alpToYV12 = bswap16Y_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
#endif
|
2014-07-20 05:05:35 +00:00
|
|
|
case AV_PIX_FMT_YA16LE:
|
|
|
|
c->lumToYV12 = read_ya16le_gray_c;
|
|
|
|
c->alpToYV12 = read_ya16le_alpha_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_YA16BE:
|
|
|
|
c->lumToYV12 = read_ya16be_gray_c;
|
|
|
|
c->alpToYV12 = read_ya16be_alpha_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_YUYV422:
|
2014-04-07 15:19:53 +00:00
|
|
|
case AV_PIX_FMT_YVYU422:
|
2014-07-29 13:02:09 +00:00
|
|
|
case AV_PIX_FMT_YA8:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = yuy2ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_UYVY422:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = uyvyToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR24:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr24ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR565LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr16leToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR565BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr16beToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR555LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr15leToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR555BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr15beToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR444LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr12leToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR444BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr12beToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB24:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb24ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB565LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb16leToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB565BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb16beToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB555LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb15leToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB555BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb15beToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB444LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb12leToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB444BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb12beToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB8:
|
|
|
|
case AV_PIX_FMT_BGR8:
|
|
|
|
case AV_PIX_FMT_PAL8:
|
|
|
|
case AV_PIX_FMT_BGR4_BYTE:
|
|
|
|
case AV_PIX_FMT_RGB4_BYTE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = palToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_MONOBLACK:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = monoblack2Y_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_MONOWHITE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = monowhite2Y_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB32:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr32ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB32_1:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr321ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR32:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb32ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR32_1:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb321ToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB48BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb48BEToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_RGB48LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = rgb48LEToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR48BE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr48BEToY_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGR48LE:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->lumToYV12 = bgr48LEToY_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
if (c->alpPixBuf) {
|
|
|
|
switch (srcFormat) {
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_BGRA:
|
|
|
|
case AV_PIX_FMT_RGBA:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->alpToYV12 = rgbaToA_c;
|
|
|
|
break;
|
2012-10-06 10:10:34 +00:00
|
|
|
case AV_PIX_FMT_ABGR:
|
|
|
|
case AV_PIX_FMT_ARGB:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->alpToYV12 = abgrToA_c;
|
|
|
|
break;
|
2014-07-29 13:02:09 +00:00
|
|
|
case AV_PIX_FMT_YA8:
|
2012-04-15 19:33:30 +00:00
|
|
|
c->alpToYV12 = uyvyToY_c;
|
|
|
|
break;
|
2012-02-01 15:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|