2012-02-01 18:38:55 +03:00
|
|
|
/*
|
2012-02-08 04:59:09 +03:00
|
|
|
* Copyright (C) 2001-2012 Michael Niedermayer <michaelni@gmx.at>
|
2012-02-01 18:38:55 +03:00
|
|
|
*
|
2012-02-08 04:59:09 +03:00
|
|
|
* This file is part of FFmpeg.
|
2012-02-01 18:38:55 +03:00
|
|
|
*
|
2012-02-08 04:59:09 +03:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-02-01 18:38:55 +03:00
|
|
|
* 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.
|
|
|
|
*
|
2012-02-08 04:59:09 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-02-01 18:38:55 +03:00
|
|
|
* 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
|
2012-02-08 04:59:09 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-02-01 18:38:55 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "libavutil/bswap.h"
|
|
|
|
#include "libavutil/intreadwrite.h"
|
2012-07-18 17:18:32 +03:00
|
|
|
#include "libavutil/avassert.h"
|
2012-02-01 18:38:55 +03:00
|
|
|
#include "config.h"
|
|
|
|
#include "swscale_internal.h"
|
|
|
|
|
2022-09-08 03:45:12 +02:00
|
|
|
#define input_pixel(pos) (is_be ? AV_RB16(pos) : AV_RL16(pos))
|
|
|
|
|
|
|
|
#define IS_BE_LE 0
|
|
|
|
#define IS_BE_BE 1
|
|
|
|
#define IS_BE_ 0
|
|
|
|
/* ENDIAN_IDENTIFIER needs to be "BE", "LE" or "". The latter is intended
|
|
|
|
* for single-byte cases where the concept of endianness does not apply. */
|
|
|
|
#define IS_BE(ENDIAN_IDENTIFIER) IS_BE_ ## ENDIAN_IDENTIFIER
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2014-04-02 20:27:16 +03:00
|
|
|
#define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? b_r : r_b)
|
|
|
|
#define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? r_b : b_r)
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-03-04 02:43:18 +03:00
|
|
|
static av_always_inline void
|
|
|
|
rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
|
2022-09-08 03:45:12 +02:00
|
|
|
enum AVPixelFormat origin, int32_t *rgb2yuv, int is_be)
|
2012-03-04 02:43:18 +03:00
|
|
|
{
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2012-03-04 02:43:18 +03:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
unsigned int r_b = input_pixel(&src[i*4+0]);
|
|
|
|
unsigned int g = input_pixel(&src[i*4+1]);
|
|
|
|
unsigned int b_r = input_pixel(&src[i*4+2]);
|
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
|
2012-03-04 02:43:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void
|
|
|
|
rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
|
|
|
|
const uint16_t *src1, const uint16_t *src2,
|
2022-09-08 03:45:12 +02:00
|
|
|
int width, enum AVPixelFormat origin, int32_t *rgb2yuv, int is_be)
|
2012-03-04 02:43:18 +03:00
|
|
|
{
|
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1==src2);
|
2012-03-04 02:43:18 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2022-11-15 21:30:23 +02:00
|
|
|
unsigned int r_b = input_pixel(&src1[i*4+0]);
|
|
|
|
unsigned int g = input_pixel(&src1[i*4+1]);
|
|
|
|
unsigned int b_r = input_pixel(&src1[i*4+2]);
|
2012-03-04 02:43:18 +03:00
|
|
|
|
2013-04-14 20:55:06 +03: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-03-04 02:43:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void
|
|
|
|
rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
|
|
|
|
const uint16_t *src1, const uint16_t *src2,
|
2022-09-08 03:45:12 +02:00
|
|
|
int width, enum AVPixelFormat origin, int32_t *rgb2yuv, int is_be)
|
2012-03-04 02:43:18 +03:00
|
|
|
{
|
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1==src2);
|
2012-03-04 02:43:18 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2022-11-16 00:10:02 +02:00
|
|
|
unsigned r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 4]) + 1) >> 1;
|
|
|
|
unsigned g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 5]) + 1) >> 1;
|
|
|
|
unsigned b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 6]) + 1) >> 1;
|
2012-03-04 02:43:18 +03:00
|
|
|
|
2013-04-14 20:55:06 +03: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-03-04 02:43:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-08 03:45:12 +02:00
|
|
|
#define RGB64FUNCS_EXT(pattern, BE_LE, origin, is_be) \
|
2012-03-04 02:43:18 +03:00
|
|
|
static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *rgb2yuv, void *opq) \
|
2012-03-04 02:43:18 +03:00
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t *) _src; \
|
|
|
|
uint16_t *dst = (uint16_t *) _dst; \
|
2022-09-08 03:45:12 +02:00
|
|
|
rgb64ToY_c_template(dst, src, width, origin, rgb2yuv, is_be); \
|
2012-03-04 02:43:18 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
|
|
|
|
const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *rgb2yuv, void *opq) \
|
2012-03-04 02:43:18 +03:00
|
|
|
{ \
|
|
|
|
const uint16_t *src1 = (const uint16_t *) _src1, \
|
|
|
|
*src2 = (const uint16_t *) _src2; \
|
|
|
|
uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
|
2022-09-08 03:45:12 +02:00
|
|
|
rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \
|
2012-03-04 02:43:18 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
|
|
|
|
const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *rgb2yuv, void *opq) \
|
2012-03-04 02:43:18 +03:00
|
|
|
{ \
|
|
|
|
const uint16_t *src1 = (const uint16_t *) _src1, \
|
|
|
|
*src2 = (const uint16_t *) _src2; \
|
|
|
|
uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
|
2022-09-08 03:45:12 +02:00
|
|
|
rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \
|
2012-03-04 02:43:18 +03:00
|
|
|
}
|
2022-09-08 03:45:12 +02:00
|
|
|
#define RGB64FUNCS(pattern, endianness, base_fmt) \
|
|
|
|
RGB64FUNCS_EXT(pattern, endianness, base_fmt ## endianness, IS_BE(endianness))
|
2012-03-04 02:43:18 +03:00
|
|
|
|
2022-09-08 03:45:12 +02:00
|
|
|
RGB64FUNCS(rgb, LE, AV_PIX_FMT_RGBA64)
|
|
|
|
RGB64FUNCS(rgb, BE, AV_PIX_FMT_RGBA64)
|
|
|
|
RGB64FUNCS(bgr, LE, AV_PIX_FMT_BGRA64)
|
|
|
|
RGB64FUNCS(bgr, BE, AV_PIX_FMT_BGRA64)
|
2012-03-04 02:43:18 +03:00
|
|
|
|
2012-04-15 22:33:30 +03:00
|
|
|
static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
|
|
|
|
const uint16_t *src, int width,
|
2013-04-14 20:55:06 +03:00
|
|
|
enum AVPixelFormat origin,
|
2022-09-08 03:45:12 +02:00
|
|
|
int32_t *rgb2yuv, int is_be)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 22:33:30 +03: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 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 22:33:30 +03: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,
|
2013-04-14 20:55:06 +03:00
|
|
|
enum AVPixelFormat origin,
|
2022-09-08 03:45:12 +02:00
|
|
|
int32_t *rgb2yuv, int is_be)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-02-01 18:38:55 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2022-11-16 00:10:02 +02:00
|
|
|
unsigned r_b = input_pixel(&src1[i * 3 + 0]);
|
|
|
|
unsigned g = input_pixel(&src1[i * 3 + 1]);
|
|
|
|
unsigned b_r = input_pixel(&src1[i * 3 + 2]);
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03: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 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 22:33:30 +03: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,
|
2013-04-14 20:55:06 +03:00
|
|
|
enum AVPixelFormat origin,
|
2022-09-08 03:45:12 +02:00
|
|
|
int32_t *rgb2yuv, int is_be)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-02-01 18:38:55 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2022-11-16 00:10:02 +02:00
|
|
|
unsigned r_b = (input_pixel(&src1[6 * i + 0]) +
|
|
|
|
input_pixel(&src1[6 * i + 3]) + 1) >> 1;
|
|
|
|
unsigned g = (input_pixel(&src1[6 * i + 1]) +
|
|
|
|
input_pixel(&src1[6 * i + 4]) + 1) >> 1;
|
|
|
|
unsigned b_r = (input_pixel(&src1[6 * i + 2]) +
|
|
|
|
input_pixel(&src1[6 * i + 5]) + 1) >> 1;
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03: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 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef r
|
|
|
|
#undef b
|
|
|
|
#undef input_pixel
|
|
|
|
|
2022-09-08 03:45:12 +02:00
|
|
|
#define RGB48FUNCS_EXT(pattern, BE_LE, origin, is_be) \
|
2012-04-15 22:33:30 +03:00
|
|
|
static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
|
|
|
|
const uint8_t *_src, \
|
2012-04-24 01:19:55 +03:00
|
|
|
const uint8_t *unused0, const uint8_t *unused1,\
|
2012-04-15 22:33:30 +03:00
|
|
|
int width, \
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2012-04-15 22:33:30 +03:00
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t *)_src; \
|
|
|
|
uint16_t *dst = (uint16_t *)_dst; \
|
2022-09-08 03:45:12 +02:00
|
|
|
rgb48ToY_c_template(dst, src, width, origin, rgb2yuv, is_be); \
|
2012-04-15 22:33:30 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
|
|
|
|
uint8_t *_dstV, \
|
2012-04-24 01:19:55 +03:00
|
|
|
const uint8_t *unused0, \
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint8_t *_src1, \
|
|
|
|
const uint8_t *_src2, \
|
|
|
|
int width, \
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2012-04-15 22:33:30 +03:00
|
|
|
{ \
|
|
|
|
const uint16_t *src1 = (const uint16_t *)_src1, \
|
|
|
|
*src2 = (const uint16_t *)_src2; \
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU, \
|
|
|
|
*dstV = (uint16_t *)_dstV; \
|
2022-09-08 03:45:12 +02:00
|
|
|
rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \
|
2012-04-15 22:33:30 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
|
|
|
|
uint8_t *_dstV, \
|
2012-04-24 01:19:55 +03:00
|
|
|
const uint8_t *unused0, \
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint8_t *_src1, \
|
|
|
|
const uint8_t *_src2, \
|
|
|
|
int width, \
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2012-04-15 22:33:30 +03:00
|
|
|
{ \
|
|
|
|
const uint16_t *src1 = (const uint16_t *)_src1, \
|
|
|
|
*src2 = (const uint16_t *)_src2; \
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU, \
|
|
|
|
*dstV = (uint16_t *)_dstV; \
|
2022-09-08 03:45:12 +02:00
|
|
|
rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
2022-09-08 03:45:12 +02:00
|
|
|
#define RGB48FUNCS(pattern, endianness, base_fmt) \
|
|
|
|
RGB48FUNCS_EXT(pattern, endianness, base_fmt ## endianness, IS_BE(endianness))
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2022-09-08 03:45:12 +02:00
|
|
|
RGB48FUNCS(rgb, LE, AV_PIX_FMT_RGB48)
|
|
|
|
RGB48FUNCS(rgb, BE, AV_PIX_FMT_RGB48)
|
|
|
|
RGB48FUNCS(bgr, LE, AV_PIX_FMT_BGR48)
|
|
|
|
RGB48FUNCS(bgr, BE, AV_PIX_FMT_BGR48)
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-10-06 13:10:34 +03:00
|
|
|
#define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
|
|
|
|
origin == AV_PIX_FMT_BGRA || \
|
|
|
|
origin == AV_PIX_FMT_ARGB || \
|
2020-07-20 03:34:07 +02:00
|
|
|
origin == AV_PIX_FMT_ABGR) \
|
|
|
|
? AV_RN32A(&src[(i) * 4]) \
|
2021-09-25 01:09:15 +02:00
|
|
|
: ((origin == AV_PIX_FMT_X2RGB10LE || \
|
|
|
|
origin == AV_PIX_FMT_X2BGR10LE) \
|
2020-07-20 03:34:07 +02:00
|
|
|
? AV_RL32(&src[(i) * 4]) \
|
2022-09-08 03:45:12 +02:00
|
|
|
: (is_be ? AV_RB16(&src[(i) * 2]) \
|
2020-07-20 03:34:07 +02:00
|
|
|
: AV_RL16(&src[(i) * 2]))))
|
2012-04-15 22:33:30 +03:00
|
|
|
|
2012-04-24 01:19:55 +03:00
|
|
|
static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint8_t *src,
|
|
|
|
int width,
|
2012-10-06 13:10:34 +03:00
|
|
|
enum AVPixelFormat origin,
|
2012-04-15 22:33:30 +03:00
|
|
|
int shr, int shg,
|
|
|
|
int shb, int shp,
|
|
|
|
int maskr, int maskg,
|
|
|
|
int maskb, int rsh,
|
2013-04-14 20:55:06 +03:00
|
|
|
int gsh, int bsh, int S,
|
2022-09-08 03:45:12 +02:00
|
|
|
int32_t *rgb2yuv, int is_be)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2013-04-14 20:55:06 +03:00
|
|
|
const int ry = rgb2yuv[RY_IDX]<<rsh, gy = rgb2yuv[GY_IDX]<<gsh, by = rgb2yuv[BY_IDX]<<bsh;
|
2012-02-08 04:59:09 +03:00
|
|
|
const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int px = input_pixel(i) >> shp;
|
2012-04-15 22:33:30 +03:00
|
|
|
int b = (px & maskb) >> shb;
|
|
|
|
int g = (px & maskg) >> shg;
|
|
|
|
int r = (px & maskr) >> shr;
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-02-08 04:59:09 +03:00
|
|
|
dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 01:19:55 +03:00
|
|
|
static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
|
|
|
|
int16_t *dstV,
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint8_t *src,
|
|
|
|
int width,
|
2012-10-06 13:10:34 +03:00
|
|
|
enum AVPixelFormat origin,
|
2012-04-15 22:33:30 +03:00
|
|
|
int shr, int shg,
|
|
|
|
int shb, int shp,
|
|
|
|
int maskr, int maskg,
|
|
|
|
int maskb, int rsh,
|
2013-04-14 20:55:06 +03:00
|
|
|
int gsh, int bsh, int S,
|
2022-09-08 03:45:12 +02:00
|
|
|
int32_t *rgb2yuv, int is_be)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2020-01-21 23:52:19 +02:00
|
|
|
const int ru = rgb2yuv[RU_IDX] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
|
|
|
|
rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << bsh);
|
2012-02-08 04:59:09 +03:00
|
|
|
const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int px = input_pixel(i) >> shp;
|
2012-04-15 22:33:30 +03:00
|
|
|
int b = (px & maskb) >> shb;
|
|
|
|
int g = (px & maskg) >> shg;
|
|
|
|
int r = (px & maskr) >> shr;
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-02-08 04:59:09 +03:00
|
|
|
dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
|
|
|
|
dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 01:19:55 +03:00
|
|
|
static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
|
|
|
|
int16_t *dstV,
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint8_t *src,
|
|
|
|
int width,
|
2012-10-06 13:10:34 +03:00
|
|
|
enum AVPixelFormat origin,
|
2012-04-15 22:33:30 +03:00
|
|
|
int shr, int shg,
|
|
|
|
int shb, int shp,
|
|
|
|
int maskr, int maskg,
|
|
|
|
int maskb, int rsh,
|
2013-04-14 20:55:06 +03:00
|
|
|
int gsh, int bsh, int S,
|
2022-09-08 03:45:12 +02:00
|
|
|
int32_t *rgb2yuv, int is_be)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2020-01-21 23:52:19 +02:00
|
|
|
const int ru = rgb2yuv[RU_IDX] * (1 << rsh), gu = rgb2yuv[GU_IDX] * (1 << gsh), bu = rgb2yuv[BU_IDX] * (1 << bsh),
|
|
|
|
rv = rgb2yuv[RV_IDX] * (1 << rsh), gv = rgb2yuv[GV_IDX] * (1 << gsh), bv = rgb2yuv[BV_IDX] * (1 << bsh),
|
2012-04-15 22:33:30 +03:00
|
|
|
maskgx = ~(maskr | maskb);
|
2012-02-08 04:59:09 +03:00
|
|
|
const unsigned rnd = (256U<<(S)) + (1<<(S-6));
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
|
2012-04-15 22:33:30 +03:00
|
|
|
maskr |= maskr << 1;
|
|
|
|
maskb |= maskb << 1;
|
|
|
|
maskg |= maskg << 1;
|
2012-02-01 18:38:55 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2014-06-16 23:46:46 +03:00
|
|
|
unsigned px0 = input_pixel(2 * i + 0) >> shp;
|
|
|
|
unsigned px1 = input_pixel(2 * i + 1) >> shp;
|
2012-02-01 18:38:55 +03:00
|
|
|
int b, r, g = (px0 & maskgx) + (px1 & maskgx);
|
|
|
|
int rb = px0 + px1 - g;
|
|
|
|
|
|
|
|
b = (rb & maskb) >> shb;
|
2012-04-15 22:33:30 +03:00
|
|
|
if (shp ||
|
2012-10-06 13:10:34 +03:00
|
|
|
origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
|
|
|
|
origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
|
2012-02-01 18:38:55 +03:00
|
|
|
g >>= shg;
|
|
|
|
} else {
|
2012-04-15 22:33:30 +03:00
|
|
|
g = (g & maskg) >> shg;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
r = (rb & maskr) >> shr;
|
|
|
|
|
2012-02-08 04:59:09 +03:00
|
|
|
dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
|
|
|
|
dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef input_pixel
|
|
|
|
|
2022-09-08 03:45:12 +02:00
|
|
|
#define RGB16_32FUNCS_EXT(fmt, name, shr, shg, shb, shp, maskr, \
|
|
|
|
maskg, maskb, rsh, gsh, bsh, S, is_be) \
|
2012-04-24 01:19:55 +03:00
|
|
|
static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *tab, void *opq) \
|
2012-04-15 22:33:30 +03:00
|
|
|
{ \
|
2012-04-24 01:19:55 +03:00
|
|
|
rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
|
2022-09-08 03:45:12 +02:00
|
|
|
maskr, maskg, maskb, rsh, gsh, bsh, S, tab, is_be); \
|
2012-04-15 22:33:30 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
|
2012-04-24 01:19:55 +03:00
|
|
|
const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *tab, void *opq) \
|
2012-04-15 22:33:30 +03:00
|
|
|
{ \
|
2012-04-24 01:19:55 +03:00
|
|
|
rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
|
2012-04-15 22:33:30 +03:00
|
|
|
shr, shg, shb, shp, \
|
2022-09-08 03:45:12 +02:00
|
|
|
maskr, maskg, maskb, rsh, gsh, bsh, S, tab, is_be); \
|
2012-04-15 22:33:30 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
|
2012-04-24 01:19:55 +03:00
|
|
|
const uint8_t *unused0, const uint8_t *src, \
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint8_t *dummy, \
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *tab, void *opq) \
|
2012-04-15 22:33:30 +03:00
|
|
|
{ \
|
2012-04-24 01:19:55 +03:00
|
|
|
rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
|
2012-04-15 22:33:30 +03:00
|
|
|
shr, shg, shb, shp, \
|
|
|
|
maskr, maskg, maskb, \
|
2022-09-08 03:45:12 +02:00
|
|
|
rsh, gsh, bsh, S, tab, is_be); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RGB16_32FUNCS(base_fmt, endianness, name, shr, shg, shb, shp, maskr, \
|
|
|
|
maskg, maskb, rsh, gsh, bsh, S) \
|
|
|
|
RGB16_32FUNCS_EXT(base_fmt ## endianness, name, shr, shg, shb, shp, maskr, \
|
|
|
|
maskg, maskb, rsh, gsh, bsh, S, IS_BE(endianness))
|
|
|
|
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR32, , bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR32_1, , bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB32, , rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB32_1, , rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR565, LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR555, LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR444, LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB565, LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB555, LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB444, LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR565, BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR555, BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_BGR444, BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB565, BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB555, BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_RGB444, BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_X2RGB10, LE, rgb30le, 16, 6, 0, 0, 0x3FF00000, 0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6)
|
|
|
|
RGB16_32FUNCS(AV_PIX_FMT_X2BGR10, LE, bgr30le, 0, 6, 16, 0, 0x3FF, 0xFFC00, 0x3FF00000, 4, 0, 0, RGB2YUV_SHIFT + 6)
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
|
2012-02-08 04:59:09 +03:00
|
|
|
const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
uint16_t *dstV = (uint16_t *)_dstV;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
|
|
|
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2012-04-24 01:19:55 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-02-08 04:59:09 +03:00
|
|
|
unsigned int g = gsrc[2*i] + gsrc[2*i+1];
|
|
|
|
unsigned int b = bsrc[2*i] + bsrc[2*i+1];
|
|
|
|
unsigned int r = rsrc[2*i] + rsrc[2*i+1];
|
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
|
2012-02-08 04:59:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-21 21:23:45 +02:00
|
|
|
static void rgba64leToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *unused2, int width, uint32_t *unused, void *opq)
|
2012-03-04 02:43:18 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
|
|
|
const uint16_t *src = (const uint16_t *)_src;
|
2012-03-04 02:43:18 +03:00
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++)
|
2015-01-21 21:23:45 +02:00
|
|
|
dst[i] = AV_RL16(src + 4 * i + 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rgba64beToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *unused2, int width, uint32_t *unused, void *opq)
|
2015-01-21 21:23:45 +02:00
|
|
|
{
|
|
|
|
int16_t *dst = (int16_t *)_dst;
|
|
|
|
const uint16_t *src = (const uint16_t *)_src;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = AV_RB16(src + 4 * i + 3);
|
2012-03-04 02:43:18 +03:00
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
|
|
|
|
const uint8_t *unused2, int width, uint32_t *unused, void *opq)
|
2012-02-08 04:59:09 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2012-02-08 04:59:09 +03:00
|
|
|
int i;
|
|
|
|
for (i=0; i<width; i++) {
|
2020-02-15 11:07:51 +02:00
|
|
|
dst[i]= src[4*i]<<6 | src[4*i]>>2;
|
2012-02-08 04:59:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
|
|
|
|
const uint8_t *unused2, int width, uint32_t *unused, void *opq)
|
2012-02-08 04:59:09 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2012-02-08 04:59:09 +03:00
|
|
|
int i;
|
|
|
|
for (i=0; i<width; i++) {
|
2020-02-15 11:07:51 +02:00
|
|
|
dst[i]= src[4*i+3]<<6 | src[4*i+3]>>2;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
|
|
|
|
const uint8_t *unused2, int width, uint32_t *pal, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
for (i=0; i<width; i++) {
|
2012-02-08 04:59:09 +03:00
|
|
|
int d= src[i];
|
|
|
|
|
2020-02-15 11:07:51 +02:00
|
|
|
dst[i]= (pal[d] >> 24)<<6 | pal[d]>>26;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
|
|
|
|
const uint8_t *unused2, int width, uint32_t *pal, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int d = src[i];
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-04-24 01:19:55 +03:00
|
|
|
dst[i] = (pal[d] & 0xFF)<<6;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
|
|
|
|
int width, uint32_t *pal, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
int16_t *dstV = (int16_t *)_dstV;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int p = pal[src1[i]];
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2012-04-24 01:19:55 +03:00
|
|
|
dstU[i] = (uint8_t)(p>> 8)<<6;
|
|
|
|
dstV[i] = (uint8_t)(p>>16)<<6;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
|
|
|
|
const uint8_t *unused2, int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i, j;
|
2012-04-04 20:50:29 +03:00
|
|
|
width = (width + 7) >> 3;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 22:33:30 +03:00
|
|
|
int d = ~src[i];
|
|
|
|
for (j = 0; j < 8; j++)
|
2012-04-24 01:19:55 +03:00
|
|
|
dst[8*i+j]= ((d>>(7-j))&1) * 16383;
|
2012-02-08 04:59:09 +03:00
|
|
|
}
|
|
|
|
if(width&7){
|
|
|
|
int d= ~src[i];
|
2012-04-24 01:19:55 +03:00
|
|
|
for (j = 0; j < (width&7); j++)
|
|
|
|
dst[8*i+j]= ((d>>(7-j))&1) * 16383;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1,
|
|
|
|
const uint8_t *unused2, int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i, j;
|
2012-04-04 20:50:29 +03:00
|
|
|
width = (width + 7) >> 3;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-04-15 22:33:30 +03:00
|
|
|
int d = src[i];
|
|
|
|
for (j = 0; j < 8; j++)
|
2012-04-24 01:19:55 +03:00
|
|
|
dst[8*i+j]= ((d>>(7-j))&1) * 16383;
|
2012-02-08 04:59:09 +03:00
|
|
|
}
|
|
|
|
if(width&7){
|
2012-04-24 01:19:55 +03:00
|
|
|
int d = src[i];
|
|
|
|
for (j = 0; j < (width&7); j++)
|
|
|
|
dst[8*i+j] = ((d>>(7-j))&1) * 16383;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
|
|
|
uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[2 * i];
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
|
2012-02-08 04:59:09 +03:00
|
|
|
static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src1[4 * i + 1];
|
|
|
|
dstV[i] = src1[4 * i + 3];
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
|
2014-04-09 04:20:52 +03:00
|
|
|
static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *unused, void *opq)
|
2014-04-07 18:19:53 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstV[i] = src1[4 * i + 1];
|
|
|
|
dstU[i] = src1[4 * i + 3];
|
|
|
|
}
|
2014-04-09 06:14:34 +03:00
|
|
|
av_assert1(src1 == src2);
|
2014-04-07 18:19:53 +03:00
|
|
|
}
|
|
|
|
|
2022-09-05 01:42:32 +02:00
|
|
|
#define y21xle_wrapper(bits, shift) \
|
|
|
|
static void y2 ## bits ## le_UV_c(uint8_t *dstU, uint8_t *dstV, \
|
|
|
|
const uint8_t *unused0, \
|
|
|
|
const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, int width, \
|
|
|
|
uint32_t *unused2, void *opq) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < width; i++) { \
|
|
|
|
AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> shift); \
|
|
|
|
AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> shift); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void y2 ## bits ## le_Y_c(uint8_t *dst, const uint8_t *src, \
|
|
|
|
const uint8_t *unused0, \
|
|
|
|
const uint8_t *unused1, int width, \
|
|
|
|
uint32_t *unused2, void *opq) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < width; i++) \
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> shift); \
|
2020-01-15 08:59:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-08 01:43:01 +02:00
|
|
|
y21xle_wrapper(10, 6)
|
|
|
|
y21xle_wrapper(12, 4)
|
2024-10-22 02:41:22 +02:00
|
|
|
y21xle_wrapper(16, 0)
|
2020-01-15 08:59:34 +02:00
|
|
|
|
2014-04-09 04:20:52 +03:00
|
|
|
static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint16_t *src = (const uint16_t *)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
for (i = 0; i < width; i++)
|
2012-02-01 18:38:55 +03:00
|
|
|
dst[i] = av_bswap16(src[i]);
|
|
|
|
}
|
|
|
|
|
2012-02-08 04:59:09 +03:00
|
|
|
static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *_src2, int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03: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 18:38:55 +03:00
|
|
|
dstU[i] = av_bswap16(src1[i]);
|
|
|
|
dstV[i] = av_bswap16(src2[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-04 23:26:13 +03:00
|
|
|
static void read_ya16le_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused, void *opq)
|
2014-07-20 08:05:35 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 4));
|
|
|
|
}
|
|
|
|
|
2014-08-04 23:26:13 +03:00
|
|
|
static void read_ya16le_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused, void *opq)
|
2014-07-20 08:05:35 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 4 + 2));
|
|
|
|
}
|
|
|
|
|
2014-08-04 23:26:13 +03:00
|
|
|
static void read_ya16be_gray_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused, void *opq)
|
2014-07-20 08:05:35 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 4));
|
|
|
|
}
|
|
|
|
|
2014-08-04 23:26:13 +03:00
|
|
|
static void read_ya16be_alpha_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused, void *opq)
|
2014-07-20 08:05:35 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 4 + 2));
|
|
|
|
}
|
|
|
|
|
2015-07-03 14:15:47 +02:00
|
|
|
static void read_ayuv64le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused2, void *opq)
|
2015-07-03 14:15:47 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2));
|
|
|
|
}
|
|
|
|
|
2024-10-15 19:38:22 +02:00
|
|
|
static void read_ayuv64be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 8 + 2));
|
|
|
|
}
|
2015-07-03 14:15:47 +02:00
|
|
|
|
2024-10-23 18:10:53 +02:00
|
|
|
static av_always_inline void ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, int width,
|
|
|
|
int u_offset, int v_offset)
|
2015-07-03 14:15:47 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2024-10-23 18:10:53 +02:00
|
|
|
AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + u_offset));
|
|
|
|
AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + v_offset));
|
2015-07-03 14:15:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-23 18:10:53 +02:00
|
|
|
static av_always_inline void ayuv64be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, int width,
|
|
|
|
int u_offset, int v_offset)
|
2024-10-15 19:38:22 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2024-10-23 18:10:53 +02:00
|
|
|
AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + u_offset));
|
|
|
|
AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + v_offset));
|
2024-10-15 19:38:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-23 18:10:53 +02:00
|
|
|
#define ayuv64_UV_funcs(pixfmt, U, V) \
|
|
|
|
static void read_ ## pixfmt ## le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq) \
|
|
|
|
{ \
|
|
|
|
ayuv64le_UV_c(dstU, dstV, src, width, U, V); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void read_ ## pixfmt ## be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq) \
|
|
|
|
{ \
|
|
|
|
ayuv64be_UV_c(dstU, dstV, src, width, U, V); \
|
|
|
|
}
|
|
|
|
|
|
|
|
ayuv64_UV_funcs(ayuv64, 4, 6)
|
|
|
|
ayuv64_UV_funcs(xv48, 0, 4)
|
|
|
|
|
2015-07-03 14:15:47 +02:00
|
|
|
static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused2, void *opq)
|
2015-07-03 14:15:47 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 8));
|
|
|
|
}
|
|
|
|
|
2024-10-15 19:38:22 +02:00
|
|
|
static void read_ayuv64be_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 8));
|
|
|
|
}
|
|
|
|
|
2022-08-20 01:53:37 +02:00
|
|
|
static void read_vuyx_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
2022-08-04 05:10:30 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src[i * 4 + 1];
|
|
|
|
dstV[i] = src[i * 4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-20 01:53:37 +02:00
|
|
|
static void read_vuyx_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused2, void *opq)
|
2022-08-04 05:10:30 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[i * 4 + 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_vuya_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused2, void *opq)
|
2022-08-04 05:10:30 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[i * 4 + 3];
|
|
|
|
}
|
|
|
|
|
2024-10-06 19:45:07 +02:00
|
|
|
static void read_ayuv_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src[i * 4 + 2];
|
|
|
|
dstV[i] = src[i * 4 + 3];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_ayuv_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[i * 4 + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void read_ayuv_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[i * 4];
|
|
|
|
}
|
|
|
|
|
2024-10-07 00:43:24 +02:00
|
|
|
static void read_uyva_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src[i * 4];
|
|
|
|
dstV[i] = src[i * 4 + 2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-07 05:06:41 +02:00
|
|
|
static void vyuToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[i * 3 + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vyuToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src[i * 3 + 2];
|
|
|
|
dstV[i] = src[i * 3];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-07 18:36:19 +02:00
|
|
|
static void read_v30xle_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, (AV_RL32(src + i * 4) >> 12) & 0x3FFu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void read_v30xle_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
unsigned int uv = AV_RL32(src + i * 4);
|
|
|
|
AV_WN16(dstU + i * 2, (uv >> 2) & 0x3FFu);
|
|
|
|
AV_WN16(dstV + i * 2, (uv >> 22) & 0x3FFu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 01:32:06 +02:00
|
|
|
static void read_xv30le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, (AV_RL32(src + i * 4) >> 10) & 0x3FFu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void read_xv30le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
AV_WN16(dstU + i * 2, AV_RL32(src + i * 4) & 0x3FFu);
|
|
|
|
AV_WN16(dstV + i * 2, (AV_RL32(src + i * 4) >> 20) & 0x3FFu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 00:58:47 +02:00
|
|
|
static void read_xv36le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2) >> 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void read_xv36le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 0) >> 4);
|
|
|
|
AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 4) >> 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-15 19:29:43 +02:00
|
|
|
static void read_xv36be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width,
|
|
|
|
uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 8 + 2) >> 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void read_xv36be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 0) >> 4);
|
|
|
|
AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 4) >> 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-01 18:38:55 +03:00
|
|
|
/* This is almost identical to the previous, end exists only because
|
2012-04-15 22:33:30 +03:00
|
|
|
* yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
|
2012-02-08 04:59:09 +03:00
|
|
|
static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[2 * i + 1];
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
|
2012-02-08 04:59:09 +03:00
|
|
|
static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dstU[i] = src1[4 * i + 0];
|
|
|
|
dstV[i] = src1[4 * i + 2];
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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 22:33:30 +03:00
|
|
|
dst1[i] = src[2 * i + 0];
|
|
|
|
dst2[i] = src[2 * i + 1];
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
|
2012-02-08 04:59:09 +03:00
|
|
|
const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
nvXXtoUV_c(dstU, dstV, src1, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
|
2012-02-08 04:59:09 +03:00
|
|
|
const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *unused, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
nvXXtoUV_c(dstV, dstU, src1, width);
|
|
|
|
}
|
|
|
|
|
2022-09-05 00:43:23 +02:00
|
|
|
#define p01x_uv_wrapper(bits, shift) \
|
|
|
|
static void p0 ## bits ## LEToUV_c(uint8_t *dstU, uint8_t *dstV, \
|
|
|
|
const uint8_t *unused0, \
|
|
|
|
const uint8_t *src1, \
|
|
|
|
const uint8_t *src2, int width, \
|
|
|
|
uint32_t *unused, void *opq) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < width; i++) { \
|
|
|
|
AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> shift); \
|
|
|
|
AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> shift); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void p0 ## bits ## BEToUV_c(uint8_t *dstU, uint8_t *dstV, \
|
|
|
|
const uint8_t *unused0, \
|
|
|
|
const uint8_t *src1, \
|
|
|
|
const uint8_t *src2, int width, \
|
|
|
|
uint32_t *unused, void *opq) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < width; i++) { \
|
|
|
|
AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> shift); \
|
|
|
|
AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> shift); \
|
|
|
|
} \
|
2015-12-08 12:53:54 +02:00
|
|
|
}
|
|
|
|
|
2022-09-05 00:43:23 +02:00
|
|
|
#define p01x_wrapper(bits, shift) \
|
|
|
|
static void p0 ## bits ## LEToY_c(uint8_t *dst, const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, \
|
|
|
|
const uint8_t *unused2, int width, \
|
|
|
|
uint32_t *unused, void *opq) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < width; i++) { \
|
|
|
|
AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> shift); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void p0 ## bits ## BEToY_c(uint8_t *dst, const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, \
|
|
|
|
const uint8_t *unused2, int width, \
|
|
|
|
uint32_t *unused, void *opq) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < width; i++) { \
|
|
|
|
AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> shift); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
p01x_uv_wrapper(bits, shift)
|
|
|
|
|
2022-09-08 01:43:01 +02:00
|
|
|
p01x_wrapper(10, 6)
|
|
|
|
p01x_wrapper(12, 4)
|
|
|
|
p01x_uv_wrapper(16, 0)
|
2016-11-21 00:32:49 +02:00
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2012-04-15 22:33:30 +03: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 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dstU = (int16_t *)_dstU;
|
|
|
|
int16_t *dstV = (int16_t *)_dstV;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2012-04-15 22:33:30 +03: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 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dstU = (int16_t *)_dstU;
|
|
|
|
int16_t *dstV = (int16_t *)_dstV;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-04-15 22:33:30 +03: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 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
|
2022-08-10 15:12:24 +02:00
|
|
|
uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dst = (int16_t *)_dst;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2012-04-15 22:33:30 +03: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 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dst[i] = ((ry*r + gy*g + by*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dstU = (int16_t *)_dstU;
|
|
|
|
int16_t *dstV = (int16_t *)_dstV;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-04-15 22:33:30 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = src1[3 * i + 0];
|
|
|
|
int g = src1[3 * i + 1];
|
|
|
|
int b = src1[3 * i + 2];
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-19 04:07:38 +03:00
|
|
|
static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src2, int width, uint32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
int16_t *dstU = (int16_t *)_dstU;
|
|
|
|
int16_t *dstV = (int16_t *)_dstV;
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-07-18 17:18:32 +03:00
|
|
|
av_assert1(src1 == src2);
|
2012-04-15 22:33:30 +03:00
|
|
|
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];
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int g = src[0][i];
|
|
|
|
int b = src[1][i];
|
|
|
|
int r = src[2][i];
|
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void planar_rgb_to_a(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *unused, void *opq)
|
2013-05-06 18:13:53 +03:00
|
|
|
{
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
dst[i] = src[3][i] << 6;
|
|
|
|
}
|
|
|
|
|
2022-08-10 15:12:24 +02:00
|
|
|
static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width, int32_t *rgb2yuv, void *opq)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-07-19 04:07:38 +03:00
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
uint16_t *dstV = (uint16_t *)_dstV;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2012-02-01 18:38:55 +03:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
2012-05-12 17:21:32 +03:00
|
|
|
int g = src[0][i];
|
|
|
|
int b = src[1][i];
|
|
|
|
int r = src[2][i];
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2013-04-14 20:55:06 +03:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 17:21:32 +03:00
|
|
|
#define rdpx(src) \
|
2021-11-03 19:55:14 +02:00
|
|
|
(is_be ? AV_RB16(src) : AV_RL16(src))
|
2012-05-12 17:21:32 +03:00
|
|
|
static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
|
2013-04-14 20:55:06 +03:00
|
|
|
int width, int bpc, int is_be, int32_t *rgb2yuv)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint16_t **src = (const uint16_t **)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2013-07-19 05:19:23 +03:00
|
|
|
int shift = bpc < 16 ? bpc : 14;
|
2012-02-01 18:38:55 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-05-12 17:21:32 +03:00
|
|
|
int g = rdpx(src[0] + i);
|
|
|
|
int b = rdpx(src[1] + i);
|
|
|
|
int r = rdpx(src[2] + i);
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2020-10-04 01:31:58 +02:00
|
|
|
dst[i] = (ry*r + gy*g + by*b + (16 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-24 00:14:03 +02:00
|
|
|
static av_always_inline void planar_rgb16_to_a(uint8_t *_dst, const uint8_t *_src[4],
|
|
|
|
int width, int bpc, int is_be, int32_t *rgb2yuv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const uint16_t **src = (const uint16_t **)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
int shift = bpc < 16 ? bpc : 14;
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
dst[i] = rdpx(src[3] + i) << (14 - shift);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-12 17:21:32 +03:00
|
|
|
static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
|
|
|
|
const uint8_t *_src[4], int width,
|
2013-04-14 20:55:06 +03:00
|
|
|
int bpc, int is_be, int32_t *rgb2yuv)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-15 22:33:30 +03:00
|
|
|
const uint16_t **src = (const uint16_t **)_src;
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
uint16_t *dstV = (uint16_t *)_dstV;
|
2013-04-14 20:55:06 +03:00
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2013-07-19 05:19:23 +03:00
|
|
|
int shift = bpc < 16 ? bpc : 14;
|
2012-02-01 18:38:55 +03:00
|
|
|
for (i = 0; i < width; i++) {
|
2012-05-12 17:21:32 +03:00
|
|
|
int g = rdpx(src[0] + i);
|
|
|
|
int b = rdpx(src[1] + i);
|
|
|
|
int r = rdpx(src[2] + i);
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2020-10-04 01:31:58 +02:00
|
|
|
dstU[i] = (ru*r + gu*g + bu*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
|
|
|
|
dstV[i] = (rv*r + gv*g + bv*b + (128 << (RGB2YUV_SHIFT + bpc - 8)) + (1 << (RGB2YUV_SHIFT + shift - 15))) >> (RGB2YUV_SHIFT + shift - 14);
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
2012-05-12 17:21:32 +03:00
|
|
|
#undef rdpx
|
|
|
|
|
2020-05-04 01:10:03 +02:00
|
|
|
#define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src)))
|
|
|
|
|
|
|
|
static av_always_inline void planar_rgbf32_to_a(uint8_t *_dst, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const float **src = (const float **)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
swscale/input: clip rgbf32 values before lrintf
if the float pixel * 65535.0f > 2147483647.0f
lrintf may overfow and return negative values, depending on implementation.
nan and +/-inf values may also be implementation defined
clip the value first so lrintf always works.
values < 0.0f, -inf, nan = 0.0f
values > 65535.0f, +inf = 65535.0f
old timings
195960 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
186120 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
188645 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
183625 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
181157 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
177533 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
175689 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
232960 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
221380 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
216640 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
213505 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
211558 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
210596 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
210202 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
161680 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
153540 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
148255 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
140600 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
132935 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128531 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
140933 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
190980 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
176080 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
167980 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
164685 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
162751 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
162404 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
167849 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
new timings
183320 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
175700 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
179570 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
172932 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
168707 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
165224 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
163423 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
184940 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
185150 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
185790 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
185472 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
185277 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
185813 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
185332 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
145400 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
145100 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
143490 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
136687 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
131271 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128698 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
127170 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
156020 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
146990 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
142020 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
141052 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
138973 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
138027 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
143939 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-15 08:22:21 +02:00
|
|
|
dst[i] = lrintf(av_clipf(65535.0f * rdpx(src[3] + i), 0.0f, 65535.0f));
|
2020-05-04 01:10:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void planar_rgbf32_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const float **src = (const float **)_src;
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
uint16_t *dstV = (uint16_t *)_dstV;
|
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
2020-09-29 05:44:34 +02:00
|
|
|
|
2020-05-04 01:10:03 +02:00
|
|
|
for (i = 0; i < width; i++) {
|
swscale/input: clip rgbf32 values before lrintf
if the float pixel * 65535.0f > 2147483647.0f
lrintf may overfow and return negative values, depending on implementation.
nan and +/-inf values may also be implementation defined
clip the value first so lrintf always works.
values < 0.0f, -inf, nan = 0.0f
values > 65535.0f, +inf = 65535.0f
old timings
195960 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
186120 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
188645 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
183625 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
181157 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
177533 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
175689 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
232960 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
221380 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
216640 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
213505 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
211558 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
210596 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
210202 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
161680 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
153540 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
148255 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
140600 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
132935 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128531 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
140933 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
190980 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
176080 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
167980 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
164685 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
162751 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
162404 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
167849 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
new timings
183320 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
175700 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
179570 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
172932 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
168707 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
165224 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
163423 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
184940 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
185150 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
185790 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
185472 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
185277 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
185813 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
185332 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
145400 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
145100 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
143490 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
136687 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
131271 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128698 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
127170 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
156020 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
146990 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
142020 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
141052 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
138973 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
138027 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
143939 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-15 08:22:21 +02:00
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(src[0] + i), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(src[1] + i), 0.0f, 65535.0f));
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(src[2] + i), 0.0f, 65535.0f));
|
2020-05-04 01:10:03 +02:00
|
|
|
|
2020-09-29 05:44:34 +02: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;
|
2020-05-04 01:10:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void planar_rgbf32_to_y(uint8_t *_dst, const uint8_t *_src[4], int width, int is_be, int32_t *rgb2yuv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const float **src = (const float **)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
|
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
2020-09-29 05:44:34 +02:00
|
|
|
|
2020-05-04 01:10:03 +02:00
|
|
|
for (i = 0; i < width; i++) {
|
swscale/input: clip rgbf32 values before lrintf
if the float pixel * 65535.0f > 2147483647.0f
lrintf may overfow and return negative values, depending on implementation.
nan and +/-inf values may also be implementation defined
clip the value first so lrintf always works.
values < 0.0f, -inf, nan = 0.0f
values > 65535.0f, +inf = 65535.0f
old timings
195960 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
186120 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
188645 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
183625 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
181157 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
177533 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
175689 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
232960 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
221380 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
216640 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
213505 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
211558 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
210596 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
210202 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
161680 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
153540 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
148255 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
140600 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
132935 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128531 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
140933 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
190980 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
176080 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
167980 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
164685 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
162751 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
162404 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
167849 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
new timings
183320 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
175700 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
179570 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
172932 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
168707 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
165224 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
163423 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
184940 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
185150 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
185790 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
185472 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
185277 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
185813 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
185332 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
145400 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
145100 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
143490 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
136687 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
131271 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128698 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
127170 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
156020 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
146990 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
142020 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
141052 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
138973 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
138027 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
143939 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-15 08:22:21 +02:00
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(src[0] + i), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(src[1] + i), 0.0f, 65535.0f));
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(src[2] + i), 0.0f, 65535.0f));
|
2020-05-04 01:10:03 +02:00
|
|
|
|
2020-09-29 05:44:34 +02:00
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
2020-05-04 01:10:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-14 10:33:10 +02:00
|
|
|
static av_always_inline void rgbf32_to_uv_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused1,
|
|
|
|
const uint8_t *_src, const uint8_t *unused2,
|
|
|
|
int width, int is_be, int32_t *rgb2yuv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const float *src = (const float *)_src;
|
|
|
|
uint16_t *dstU = (uint16_t *)_dstU;
|
|
|
|
uint16_t *dstV = (uint16_t *)_dstV;
|
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(&src[3*i]), 0.0f, 65535.0f));
|
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 1]), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 2]), 0.0f, 65535.0f));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void rgbf32_to_y_c(uint8_t *_dst, const uint8_t *_src,
|
|
|
|
const uint8_t *unused1, const uint8_t *unused2,
|
|
|
|
int width, int is_be, int32_t *rgb2yuv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const float *src = (const float *)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
|
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
|
|
|
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(&src[3*i]), 0.0f, 65535.0f));
|
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 1]), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(&src[3*i + 2]), 0.0f, 65535.0f));
|
|
|
|
|
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 17:06:50 +02:00
|
|
|
static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
|
swscale/input: unify grayf32 funcs with rgbf32 funcs
This is ment to be a cosmetic change
old timings:
42780 UNITS in grayf32le, 1 runs, 0 skips
56720 UNITS in grayf32le, 2 runs, 0 skips
67265 UNITS in grayf32le, 4 runs, 0 skips
58082 UNITS in grayf32le, 8 runs, 0 skips
63512 UNITS in grayf32le, 16 runs, 0 skips
52720 UNITS in grayf32le, 32 runs, 0 skips
46491 UNITS in grayf32le, 64 runs, 0 skips
68500 UNITS in grayf32be, 1 runs, 0 skips
66930 UNITS in grayf32be, 2 runs, 0 skips
62305 UNITS in grayf32be, 4 runs, 0 skips
55510 UNITS in grayf32be, 8 runs, 0 skips
50216 UNITS in grayf32be, 16 runs, 0 skips
44480 UNITS in grayf32be, 32 runs, 0 skips
42394 UNITS in grayf32be, 64 runs, 0 skips
new timings:
46660 UNITS in grayf32le, 1 runs, 0 skips
51830 UNITS in grayf32le, 2 runs, 0 skips
53390 UNITS in grayf32le, 4 runs, 0 skips
50910 UNITS in grayf32le, 8 runs, 0 skips
44968 UNITS in grayf32le, 16 runs, 0 skips
40349 UNITS in grayf32le, 32 runs, 0 skips
38330 UNITS in grayf32le, 64 runs, 0 skips
39980 UNITS in grayf32be, 1 runs, 0 skips
49630 UNITS in grayf32be, 2 runs, 0 skips
53540 UNITS in grayf32be, 4 runs, 0 skips
59767 UNITS in grayf32be, 8 runs, 0 skips
51206 UNITS in grayf32be, 16 runs, 0 skips
44743 UNITS in grayf32be, 32 runs, 0 skips
41468 UNITS in grayf32be, 64 runs, 0 skips
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 04:56:52 +02:00
|
|
|
const uint8_t *unused2, int width, int is_be, uint32_t *unused)
|
2018-08-03 17:06:50 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const float *src = (const float *)_src;
|
|
|
|
uint16_t *dst = (uint16_t *)_dst;
|
|
|
|
|
|
|
|
for (i = 0; i < width; ++i){
|
swscale/input: clip rgbf32 values before lrintf
if the float pixel * 65535.0f > 2147483647.0f
lrintf may overfow and return negative values, depending on implementation.
nan and +/-inf values may also be implementation defined
clip the value first so lrintf always works.
values < 0.0f, -inf, nan = 0.0f
values > 65535.0f, +inf = 65535.0f
old timings
195960 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
186120 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
188645 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
183625 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
181157 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
177533 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
175689 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
232960 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
221380 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
216640 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
213505 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
211558 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
210596 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
210202 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
161680 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
153540 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
148255 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
140600 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
132935 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128531 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
140933 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
190980 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
176080 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
167980 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
164685 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
162751 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
162404 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
167849 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
new timings
183320 decicycles in planar_rgbf32le_to_uv, 1 runs, 0 skips
175700 decicycles in planar_rgbf32le_to_uv, 2 runs, 0 skips
179570 decicycles in planar_rgbf32le_to_uv, 4 runs, 0 skips
172932 decicycles in planar_rgbf32le_to_uv, 8 runs, 0 skips
168707 decicycles in planar_rgbf32le_to_uv, 16 runs, 0 skips
165224 decicycles in planar_rgbf32le_to_uv, 32 runs, 0 skips
163423 decicycles in planar_rgbf32le_to_uv, 64 runs, 0 skips
184940 decicycles in planar_rgbf32be_to_uv, 1 runs, 0 skips
185150 decicycles in planar_rgbf32be_to_uv, 2 runs, 0 skips
185790 decicycles in planar_rgbf32be_to_uv, 4 runs, 0 skips
185472 decicycles in planar_rgbf32be_to_uv, 8 runs, 0 skips
185277 decicycles in planar_rgbf32be_to_uv, 16 runs, 0 skips
185813 decicycles in planar_rgbf32be_to_uv, 32 runs, 0 skips
185332 decicycles in planar_rgbf32be_to_uv, 64 runs, 0 skips
145400 decicycles in planar_rgbf32le_to_y, 1 runs, 0 skips
145100 decicycles in planar_rgbf32le_to_y, 2 runs, 0 skips
143490 decicycles in planar_rgbf32le_to_y, 4 runs, 0 skips
136687 decicycles in planar_rgbf32le_to_y, 8 runs, 0 skips
131271 decicycles in planar_rgbf32le_to_y, 16 runs, 0 skips
128698 decicycles in planar_rgbf32le_to_y, 32 runs, 0 skips
127170 decicycles in planar_rgbf32le_to_y, 64 runs, 0 skips
156020 decicycles in planar_rgbf32be_to_y, 1 runs, 0 skips
146990 decicycles in planar_rgbf32be_to_y, 2 runs, 0 skips
142020 decicycles in planar_rgbf32be_to_y, 4 runs, 0 skips
141052 decicycles in planar_rgbf32be_to_y, 8 runs, 0 skips
138973 decicycles in planar_rgbf32be_to_y, 16 runs, 0 skips
138027 decicycles in planar_rgbf32be_to_y, 32 runs, 0 skips
143939 decicycles in planar_rgbf32be_to_y, 64 runs, 0 skips
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-15 08:22:21 +02:00
|
|
|
dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i), 0.0f, 65535.0f));
|
2018-08-03 17:06:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
swscale/input: unify grayf32 funcs with rgbf32 funcs
This is ment to be a cosmetic change
old timings:
42780 UNITS in grayf32le, 1 runs, 0 skips
56720 UNITS in grayf32le, 2 runs, 0 skips
67265 UNITS in grayf32le, 4 runs, 0 skips
58082 UNITS in grayf32le, 8 runs, 0 skips
63512 UNITS in grayf32le, 16 runs, 0 skips
52720 UNITS in grayf32le, 32 runs, 0 skips
46491 UNITS in grayf32le, 64 runs, 0 skips
68500 UNITS in grayf32be, 1 runs, 0 skips
66930 UNITS in grayf32be, 2 runs, 0 skips
62305 UNITS in grayf32be, 4 runs, 0 skips
55510 UNITS in grayf32be, 8 runs, 0 skips
50216 UNITS in grayf32be, 16 runs, 0 skips
44480 UNITS in grayf32be, 32 runs, 0 skips
42394 UNITS in grayf32be, 64 runs, 0 skips
new timings:
46660 UNITS in grayf32le, 1 runs, 0 skips
51830 UNITS in grayf32le, 2 runs, 0 skips
53390 UNITS in grayf32le, 4 runs, 0 skips
50910 UNITS in grayf32le, 8 runs, 0 skips
44968 UNITS in grayf32le, 16 runs, 0 skips
40349 UNITS in grayf32le, 32 runs, 0 skips
38330 UNITS in grayf32le, 64 runs, 0 skips
39980 UNITS in grayf32be, 1 runs, 0 skips
49630 UNITS in grayf32be, 2 runs, 0 skips
53540 UNITS in grayf32be, 4 runs, 0 skips
59767 UNITS in grayf32be, 8 runs, 0 skips
51206 UNITS in grayf32be, 16 runs, 0 skips
44743 UNITS in grayf32be, 32 runs, 0 skips
41468 UNITS in grayf32be, 64 runs, 0 skips
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 04:56:52 +02:00
|
|
|
#undef rdpx
|
2018-08-03 17:06:50 +02:00
|
|
|
|
2013-04-21 23:31:36 +03:00
|
|
|
#define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
|
|
|
|
static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
|
2022-08-10 15:12:24 +02:00
|
|
|
int w, int32_t *rgb2yuv, void *opq) \
|
2013-04-21 23:31:36 +03:00
|
|
|
{ \
|
|
|
|
planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
|
|
|
|
} \
|
|
|
|
static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src[4], int w, int32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2013-04-21 23:31:36 +03:00
|
|
|
{ \
|
|
|
|
planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
|
|
|
|
} \
|
|
|
|
|
2017-03-07 10:28:00 +02:00
|
|
|
#define rgb9plus_planar_transparency_funcs(nbits) \
|
|
|
|
static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
|
2022-08-10 15:12:24 +02:00
|
|
|
int w, int32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2017-03-07 10:28:00 +02:00
|
|
|
{ \
|
|
|
|
planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv); \
|
|
|
|
} \
|
|
|
|
static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
|
2022-08-10 15:12:24 +02:00
|
|
|
int w, int32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2017-03-07 10:28:00 +02:00
|
|
|
{ \
|
|
|
|
planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv); \
|
|
|
|
}
|
|
|
|
|
2013-04-21 23:31:36 +03:00
|
|
|
#define rgb9plus_planar_funcs(nbits) \
|
|
|
|
rgb9plus_planar_funcs_endian(nbits, le, 0) \
|
|
|
|
rgb9plus_planar_funcs_endian(nbits, be, 1)
|
|
|
|
|
|
|
|
rgb9plus_planar_funcs(9)
|
|
|
|
rgb9plus_planar_funcs(10)
|
|
|
|
rgb9plus_planar_funcs(12)
|
|
|
|
rgb9plus_planar_funcs(14)
|
|
|
|
rgb9plus_planar_funcs(16)
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2017-03-07 10:28:00 +02:00
|
|
|
rgb9plus_planar_transparency_funcs(10)
|
|
|
|
rgb9plus_planar_transparency_funcs(12)
|
2023-09-27 16:13:16 +02:00
|
|
|
rgb9plus_planar_transparency_funcs(14)
|
2017-03-07 10:28:00 +02:00
|
|
|
rgb9plus_planar_transparency_funcs(16)
|
|
|
|
|
2024-10-14 10:33:10 +02:00
|
|
|
#define rgbf32_funcs_endian(endian_name, endian) \
|
2020-05-04 01:10:03 +02:00
|
|
|
static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
|
2022-08-10 15:12:24 +02:00
|
|
|
int w, int32_t *rgb2yuv, void *opq) \
|
2020-05-04 01:10:03 +02:00
|
|
|
{ \
|
|
|
|
planar_rgbf32_to_y(dst, src, w, endian, rgb2yuv); \
|
|
|
|
} \
|
|
|
|
static void planar_rgbf32##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
|
2022-08-10 15:12:24 +02:00
|
|
|
const uint8_t *src[4], int w, int32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
2020-05-04 01:10:03 +02:00
|
|
|
{ \
|
|
|
|
planar_rgbf32_to_uv(dstU, dstV, src, w, endian, rgb2yuv); \
|
|
|
|
} \
|
|
|
|
static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4], \
|
2022-08-10 15:12:24 +02:00
|
|
|
int w, int32_t *rgb2yuv, void *opq) \
|
2020-05-04 01:10:03 +02:00
|
|
|
{ \
|
|
|
|
planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
|
swscale/input: unify grayf32 funcs with rgbf32 funcs
This is ment to be a cosmetic change
old timings:
42780 UNITS in grayf32le, 1 runs, 0 skips
56720 UNITS in grayf32le, 2 runs, 0 skips
67265 UNITS in grayf32le, 4 runs, 0 skips
58082 UNITS in grayf32le, 8 runs, 0 skips
63512 UNITS in grayf32le, 16 runs, 0 skips
52720 UNITS in grayf32le, 32 runs, 0 skips
46491 UNITS in grayf32le, 64 runs, 0 skips
68500 UNITS in grayf32be, 1 runs, 0 skips
66930 UNITS in grayf32be, 2 runs, 0 skips
62305 UNITS in grayf32be, 4 runs, 0 skips
55510 UNITS in grayf32be, 8 runs, 0 skips
50216 UNITS in grayf32be, 16 runs, 0 skips
44480 UNITS in grayf32be, 32 runs, 0 skips
42394 UNITS in grayf32be, 64 runs, 0 skips
new timings:
46660 UNITS in grayf32le, 1 runs, 0 skips
51830 UNITS in grayf32le, 2 runs, 0 skips
53390 UNITS in grayf32le, 4 runs, 0 skips
50910 UNITS in grayf32le, 8 runs, 0 skips
44968 UNITS in grayf32le, 16 runs, 0 skips
40349 UNITS in grayf32le, 32 runs, 0 skips
38330 UNITS in grayf32le, 64 runs, 0 skips
39980 UNITS in grayf32be, 1 runs, 0 skips
49630 UNITS in grayf32be, 2 runs, 0 skips
53540 UNITS in grayf32be, 4 runs, 0 skips
59767 UNITS in grayf32be, 8 runs, 0 skips
51206 UNITS in grayf32be, 16 runs, 0 skips
44743 UNITS in grayf32be, 32 runs, 0 skips
41468 UNITS in grayf32be, 64 runs, 0 skips
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 04:56:52 +02:00
|
|
|
} \
|
2024-10-14 10:33:10 +02:00
|
|
|
static void rgbf32##endian_name##_to_y_c(uint8_t *dst, const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, const uint8_t *unused2, \
|
|
|
|
int w, uint32_t *rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
rgbf32_to_y_c(dst, src, unused1, unused2, w, endian, rgb2yuv); \
|
|
|
|
} \
|
|
|
|
static void rgbf32##endian_name##_to_uv_c(uint8_t *dstU, uint8_t *dstV, \
|
|
|
|
const uint8_t *unused1, \
|
|
|
|
const uint8_t *src, const uint8_t *unused2, \
|
|
|
|
int w, uint32_t *rgb2yuv, \
|
|
|
|
void *opq) \
|
|
|
|
{ \
|
|
|
|
rgbf32_to_uv_c(dstU, dstV, unused1, src, unused2, w, endian, rgb2yuv); \
|
|
|
|
} \
|
swscale/input: unify grayf32 funcs with rgbf32 funcs
This is ment to be a cosmetic change
old timings:
42780 UNITS in grayf32le, 1 runs, 0 skips
56720 UNITS in grayf32le, 2 runs, 0 skips
67265 UNITS in grayf32le, 4 runs, 0 skips
58082 UNITS in grayf32le, 8 runs, 0 skips
63512 UNITS in grayf32le, 16 runs, 0 skips
52720 UNITS in grayf32le, 32 runs, 0 skips
46491 UNITS in grayf32le, 64 runs, 0 skips
68500 UNITS in grayf32be, 1 runs, 0 skips
66930 UNITS in grayf32be, 2 runs, 0 skips
62305 UNITS in grayf32be, 4 runs, 0 skips
55510 UNITS in grayf32be, 8 runs, 0 skips
50216 UNITS in grayf32be, 16 runs, 0 skips
44480 UNITS in grayf32be, 32 runs, 0 skips
42394 UNITS in grayf32be, 64 runs, 0 skips
new timings:
46660 UNITS in grayf32le, 1 runs, 0 skips
51830 UNITS in grayf32le, 2 runs, 0 skips
53390 UNITS in grayf32le, 4 runs, 0 skips
50910 UNITS in grayf32le, 8 runs, 0 skips
44968 UNITS in grayf32le, 16 runs, 0 skips
40349 UNITS in grayf32le, 32 runs, 0 skips
38330 UNITS in grayf32le, 64 runs, 0 skips
39980 UNITS in grayf32be, 1 runs, 0 skips
49630 UNITS in grayf32be, 2 runs, 0 skips
53540 UNITS in grayf32be, 4 runs, 0 skips
59767 UNITS in grayf32be, 8 runs, 0 skips
51206 UNITS in grayf32be, 16 runs, 0 skips
44743 UNITS in grayf32be, 32 runs, 0 skips
41468 UNITS in grayf32be, 64 runs, 0 skips
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 04:56:52 +02:00
|
|
|
static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \
|
|
|
|
const uint8_t *unused1, const uint8_t *unused2, \
|
2022-08-10 15:12:24 +02:00
|
|
|
int width, uint32_t *unused, void *opq) \
|
swscale/input: unify grayf32 funcs with rgbf32 funcs
This is ment to be a cosmetic change
old timings:
42780 UNITS in grayf32le, 1 runs, 0 skips
56720 UNITS in grayf32le, 2 runs, 0 skips
67265 UNITS in grayf32le, 4 runs, 0 skips
58082 UNITS in grayf32le, 8 runs, 0 skips
63512 UNITS in grayf32le, 16 runs, 0 skips
52720 UNITS in grayf32le, 32 runs, 0 skips
46491 UNITS in grayf32le, 64 runs, 0 skips
68500 UNITS in grayf32be, 1 runs, 0 skips
66930 UNITS in grayf32be, 2 runs, 0 skips
62305 UNITS in grayf32be, 4 runs, 0 skips
55510 UNITS in grayf32be, 8 runs, 0 skips
50216 UNITS in grayf32be, 16 runs, 0 skips
44480 UNITS in grayf32be, 32 runs, 0 skips
42394 UNITS in grayf32be, 64 runs, 0 skips
new timings:
46660 UNITS in grayf32le, 1 runs, 0 skips
51830 UNITS in grayf32le, 2 runs, 0 skips
53390 UNITS in grayf32le, 4 runs, 0 skips
50910 UNITS in grayf32le, 8 runs, 0 skips
44968 UNITS in grayf32le, 16 runs, 0 skips
40349 UNITS in grayf32le, 32 runs, 0 skips
38330 UNITS in grayf32le, 64 runs, 0 skips
39980 UNITS in grayf32be, 1 runs, 0 skips
49630 UNITS in grayf32be, 2 runs, 0 skips
53540 UNITS in grayf32be, 4 runs, 0 skips
59767 UNITS in grayf32be, 8 runs, 0 skips
51206 UNITS in grayf32be, 16 runs, 0 skips
44743 UNITS in grayf32be, 32 runs, 0 skips
41468 UNITS in grayf32be, 64 runs, 0 skips
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 04:56:52 +02:00
|
|
|
{ \
|
|
|
|
grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \
|
2020-05-04 01:10:03 +02:00
|
|
|
}
|
|
|
|
|
2024-10-14 10:33:10 +02:00
|
|
|
rgbf32_funcs_endian(le, 0)
|
|
|
|
rgbf32_funcs_endian(be, 1)
|
2020-05-04 01:10:03 +02:00
|
|
|
|
2022-08-08 14:02:31 +02:00
|
|
|
#define rdpx(src) av_int2float(half2float(is_be ? AV_RB16(&src) : AV_RL16(&src), h2f_tbl))
|
|
|
|
|
|
|
|
static av_always_inline void rgbaf16ToUV_half_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
|
|
|
|
const uint16_t *src, int width,
|
|
|
|
int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = (lrintf(av_clipf(65535.0f * rdpx(src[i*8+0]), 0.0f, 65535.0f)) +
|
|
|
|
lrintf(av_clipf(65535.0f * rdpx(src[i*8+4]), 0.0f, 65535.0f))) >> 1;
|
|
|
|
int g = (lrintf(av_clipf(65535.0f * rdpx(src[i*8+1]), 0.0f, 65535.0f)) +
|
|
|
|
lrintf(av_clipf(65535.0f * rdpx(src[i*8+5]), 0.0f, 65535.0f))) >> 1;
|
|
|
|
int b = (lrintf(av_clipf(65535.0f * rdpx(src[i*8+2]), 0.0f, 65535.0f)) +
|
|
|
|
lrintf(av_clipf(65535.0f * rdpx(src[i*8+6]), 0.0f, 65535.0f))) >> 1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void rgbaf16ToUV_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
|
|
|
|
const uint16_t *src, int width,
|
|
|
|
int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(src[i*4+0]), 0.0f, 65535.0f));
|
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(src[i*4+1]), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(src[i*4+2]), 0.0f, 65535.0f));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void rgbaf16ToY_endian(uint16_t *dst, const uint16_t *src, int is_be,
|
|
|
|
int width, int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(src[i*4+0]), 0.0f, 65535.0f));
|
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(src[i*4+1]), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(src[i*4+2]), 0.0f, 65535.0f));
|
|
|
|
|
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void rgbaf16ToA_endian(uint16_t *dst, const uint16_t *src, int is_be,
|
|
|
|
int width, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i<width; i++) {
|
|
|
|
dst[i] = lrintf(av_clipf(65535.0f * rdpx(src[i*4+3]), 0.0f, 65535.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-14 10:33:12 +02:00
|
|
|
static av_always_inline void rgbf16ToUV_half_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
|
|
|
|
const uint16_t *src, int width,
|
|
|
|
int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = (lrintf(av_clipf(65535.0f * rdpx(src[i*6+0]), 0.0f, 65535.0f)) +
|
|
|
|
lrintf(av_clipf(65535.0f * rdpx(src[i*6+3]), 0.0f, 65535.0f))) >> 1;
|
|
|
|
int g = (lrintf(av_clipf(65535.0f * rdpx(src[i*6+1]), 0.0f, 65535.0f)) +
|
|
|
|
lrintf(av_clipf(65535.0f * rdpx(src[i*6+4]), 0.0f, 65535.0f))) >> 1;
|
|
|
|
int b = (lrintf(av_clipf(65535.0f * rdpx(src[i*6+2]), 0.0f, 65535.0f)) +
|
|
|
|
lrintf(av_clipf(65535.0f * rdpx(src[i*6+5]), 0.0f, 65535.0f))) >> 1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void rgbf16ToUV_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
|
|
|
|
const uint16_t *src, int width,
|
|
|
|
int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
|
|
|
|
int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(src[i*3+0]), 0.0f, 65535.0f));
|
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(src[i*3+1]), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(src[i*3+2]), 0.0f, 65535.0f));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static av_always_inline void rgbf16ToY_endian(uint16_t *dst, const uint16_t *src, int is_be,
|
|
|
|
int width, int32_t *rgb2yuv, Half2FloatTables *h2f_tbl)
|
|
|
|
{
|
|
|
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < width; i++) {
|
|
|
|
int r = lrintf(av_clipf(65535.0f * rdpx(src[i*3+0]), 0.0f, 65535.0f));
|
|
|
|
int g = lrintf(av_clipf(65535.0f * rdpx(src[i*3+1]), 0.0f, 65535.0f));
|
|
|
|
int b = lrintf(av_clipf(65535.0f * rdpx(src[i*3+2]), 0.0f, 65535.0f));
|
|
|
|
|
|
|
|
dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-08 14:02:31 +02:00
|
|
|
#undef rdpx
|
|
|
|
|
|
|
|
#define rgbaf16_funcs_endian(endian_name, endian) \
|
|
|
|
static void rgbaf16##endian_name##ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \
|
|
|
|
const uint8_t *src1, const uint8_t *src2, \
|
|
|
|
int width, uint32_t *_rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)src1; \
|
|
|
|
uint16_t *dstU = (uint16_t*)_dstU; \
|
|
|
|
uint16_t *dstV = (uint16_t*)_dstV; \
|
|
|
|
int32_t *rgb2yuv = (int32_t*)_rgb2yuv; \
|
|
|
|
av_assert1(src1==src2); \
|
|
|
|
rgbaf16ToUV_half_endian(dstU, dstV, endian, src, width, rgb2yuv, opq); \
|
|
|
|
} \
|
|
|
|
static void rgbaf16##endian_name##ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \
|
|
|
|
const uint8_t *src1, const uint8_t *src2, \
|
|
|
|
int width, uint32_t *_rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)src1; \
|
|
|
|
uint16_t *dstU = (uint16_t*)_dstU; \
|
|
|
|
uint16_t *dstV = (uint16_t*)_dstV; \
|
|
|
|
int32_t *rgb2yuv = (int32_t*)_rgb2yuv; \
|
|
|
|
av_assert1(src1==src2); \
|
|
|
|
rgbaf16ToUV_endian(dstU, dstV, endian, src, width, rgb2yuv, opq); \
|
|
|
|
} \
|
|
|
|
static void rgbaf16##endian_name##ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, \
|
|
|
|
const uint8_t *unused1, int width, uint32_t *_rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)_src; \
|
|
|
|
uint16_t *dst = (uint16_t*)_dst; \
|
|
|
|
int32_t *rgb2yuv = (int32_t*)_rgb2yuv; \
|
|
|
|
rgbaf16ToY_endian(dst, src, endian, width, rgb2yuv, opq); \
|
|
|
|
} \
|
|
|
|
static void rgbaf16##endian_name##ToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, \
|
|
|
|
const uint8_t *unused1, int width, uint32_t *unused2, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)_src; \
|
|
|
|
uint16_t *dst = (uint16_t*)_dst; \
|
|
|
|
rgbaf16ToA_endian(dst, src, endian, width, opq); \
|
2024-10-14 10:33:12 +02:00
|
|
|
} \
|
|
|
|
static void rgbf16##endian_name##ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \
|
|
|
|
const uint8_t *src1, const uint8_t *src2, \
|
|
|
|
int width, uint32_t *_rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)src1; \
|
|
|
|
uint16_t *dstU = (uint16_t*)_dstU; \
|
|
|
|
uint16_t *dstV = (uint16_t*)_dstV; \
|
|
|
|
int32_t *rgb2yuv = (int32_t*)_rgb2yuv; \
|
|
|
|
av_assert1(src1==src2); \
|
|
|
|
rgbf16ToUV_half_endian(dstU, dstV, endian, src, width, rgb2yuv, opq); \
|
|
|
|
} \
|
|
|
|
static void rgbf16##endian_name##ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused, \
|
|
|
|
const uint8_t *src1, const uint8_t *src2, \
|
|
|
|
int width, uint32_t *_rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)src1; \
|
|
|
|
uint16_t *dstU = (uint16_t*)_dstU; \
|
|
|
|
uint16_t *dstV = (uint16_t*)_dstV; \
|
|
|
|
int32_t *rgb2yuv = (int32_t*)_rgb2yuv; \
|
|
|
|
av_assert1(src1==src2); \
|
|
|
|
rgbf16ToUV_endian(dstU, dstV, endian, src, width, rgb2yuv, opq); \
|
|
|
|
} \
|
|
|
|
static void rgbf16##endian_name##ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, \
|
|
|
|
const uint8_t *unused1, int width, uint32_t *_rgb2yuv, void *opq) \
|
|
|
|
{ \
|
|
|
|
const uint16_t *src = (const uint16_t*)_src; \
|
|
|
|
uint16_t *dst = (uint16_t*)_dst; \
|
|
|
|
int32_t *rgb2yuv = (int32_t*)_rgb2yuv; \
|
|
|
|
rgbf16ToY_endian(dst, src, endian, width, rgb2yuv, opq); \
|
|
|
|
} \
|
2022-08-08 14:02:31 +02:00
|
|
|
|
|
|
|
rgbaf16_funcs_endian(le, 0)
|
|
|
|
rgbaf16_funcs_endian(be, 1)
|
|
|
|
|
swscale: rename SwsContext to SwsInternal
And preserve the public SwsContext as separate name. The motivation here
is that I want to turn SwsContext into a public struct, while keeping the
internal implementation hidden. Additionally, I also want to be able to
use multiple internal implementations, e.g. for GPU devices.
This commit does not include any functional changes. For the most part, it is
a simple rename. The only complications arise from the public facing API
functions, which preserve their current type (and hence require an additional
unwrapping step internally), and the checkasm test framework, which directly
accesses SwsInternal.
For consistency, the affected functions that need to maintain a distionction
have generally been changed to refer to the SwsContext as *sws, and the
SwsInternal as *c.
In an upcoming commit, I will provide a backing definition for the public
SwsContext, and update `sws_internal()` to dereference the internal struct
instead of merely casting it.
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2024-10-09 19:44:33 +02:00
|
|
|
av_cold void ff_sws_init_input_funcs(SwsInternal *c,
|
2024-10-01 12:32:29 +02:00
|
|
|
planar1_YV12_fn *lumToYV12,
|
|
|
|
planar1_YV12_fn *alpToYV12,
|
|
|
|
planar2_YV12_fn *chrToYV12,
|
|
|
|
planarX_YV12_fn *readLumPlanar,
|
|
|
|
planarX_YV12_fn *readAlpPlanar,
|
|
|
|
planarX2_YV12_fn *readChrPlanar)
|
2012-02-01 18:38:55 +03:00
|
|
|
{
|
2012-10-06 13:10:34 +03:00
|
|
|
enum AVPixelFormat srcFormat = c->srcFormat;
|
2012-02-01 18:38:55 +03:00
|
|
|
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = NULL;
|
2012-04-15 22:33:30 +03:00
|
|
|
switch (srcFormat) {
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUYV422:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = yuy2ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2014-04-07 18:19:53 +03:00
|
|
|
case AV_PIX_FMT_YVYU422:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = yvy2ToUV_c;
|
2014-04-07 18:19:53 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_UYVY422:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = uyvyToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2024-10-07 05:06:41 +02:00
|
|
|
case AV_PIX_FMT_VYU444:
|
|
|
|
*chrToYV12 = vyuToUV_c;
|
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_NV12:
|
2022-06-01 22:33:37 +02:00
|
|
|
case AV_PIX_FMT_NV16:
|
2019-05-10 06:02:09 +02:00
|
|
|
case AV_PIX_FMT_NV24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = nv12ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_NV21:
|
2019-05-10 06:02:09 +02:00
|
|
|
case AV_PIX_FMT_NV42:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = nv21ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03: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:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = palToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP9LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb9le_to_uv;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-06-10 13:01:26 +02:00
|
|
|
case AV_PIX_FMT_GBRAP10LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb10le_to_uv;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-02-08 23:40:10 +02:00
|
|
|
case AV_PIX_FMT_GBRAP12LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP12LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb12le_to_uv;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2023-09-27 16:13:16 +02:00
|
|
|
case AV_PIX_FMT_GBRAP14LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP14LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb14le_to_uv;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP16LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb16le_to_uv;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2020-05-04 01:10:03 +02:00
|
|
|
case AV_PIX_FMT_GBRAPF32LE:
|
|
|
|
case AV_PIX_FMT_GBRPF32LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgbf32le_to_uv;
|
2020-05-04 01:10:03 +02:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP9BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb9be_to_uv;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-06-10 13:01:26 +02:00
|
|
|
case AV_PIX_FMT_GBRAP10BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP10BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb10be_to_uv;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-02-08 23:40:10 +02:00
|
|
|
case AV_PIX_FMT_GBRAP12BE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP12BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb12be_to_uv;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2023-09-27 16:13:16 +02:00
|
|
|
case AV_PIX_FMT_GBRAP14BE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP14BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb14be_to_uv;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP16BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb16be_to_uv;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2020-05-04 01:10:03 +02:00
|
|
|
case AV_PIX_FMT_GBRAPF32BE:
|
|
|
|
case AV_PIX_FMT_GBRPF32BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgbf32be_to_uv;
|
2020-05-04 01:10:03 +02:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readChrPlanar = planar_rgb_to_uv;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
#if HAVE_BIGENDIAN
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P9LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P9LE:
|
|
|
|
case AV_PIX_FMT_YUV444P9LE:
|
|
|
|
case AV_PIX_FMT_YUV420P10LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV422P10LE:
|
2015-05-05 15:38:15 +02:00
|
|
|
case AV_PIX_FMT_YUV440P10LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV444P10LE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV420P12LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV422P12LE:
|
2015-05-05 15:38:15 +02:00
|
|
|
case AV_PIX_FMT_YUV440P12LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV444P12LE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV420P14LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV422P14LE:
|
|
|
|
case AV_PIX_FMT_YUV444P14LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P16LE:
|
|
|
|
case AV_PIX_FMT_YUV422P16LE:
|
|
|
|
case AV_PIX_FMT_YUV444P16LE:
|
2012-10-30 19:41:17 +03:00
|
|
|
|
|
|
|
case AV_PIX_FMT_YUVA420P9LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P9LE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P10LE:
|
2012-10-31 13:26:32 +03:00
|
|
|
case AV_PIX_FMT_YUVA422P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10LE:
|
2018-11-24 17:22:52 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P12LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P12LE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bswap16UV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
#else
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P9BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P9BE:
|
|
|
|
case AV_PIX_FMT_YUV444P9BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P10BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P10BE:
|
2015-05-05 15:38:15 +02:00
|
|
|
case AV_PIX_FMT_YUV440P10BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV444P10BE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV420P12BE:
|
|
|
|
case AV_PIX_FMT_YUV422P12BE:
|
2015-05-05 15:38:15 +02:00
|
|
|
case AV_PIX_FMT_YUV440P12BE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV444P12BE:
|
|
|
|
case AV_PIX_FMT_YUV420P14BE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV422P14BE:
|
|
|
|
case AV_PIX_FMT_YUV444P14BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P16BE:
|
|
|
|
case AV_PIX_FMT_YUV422P16BE:
|
|
|
|
case AV_PIX_FMT_YUV444P16BE:
|
2012-10-30 19:41:17 +03:00
|
|
|
|
|
|
|
case AV_PIX_FMT_YUVA420P9BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P9BE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P10BE:
|
2012-10-31 13:26:32 +03:00
|
|
|
case AV_PIX_FMT_YUVA422P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10BE:
|
2018-11-24 17:22:52 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P12BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P12BE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bswap16UV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
#endif
|
2022-08-04 05:10:30 +02:00
|
|
|
case AV_PIX_FMT_VUYA:
|
2022-08-20 01:53:37 +02:00
|
|
|
case AV_PIX_FMT_VUYX:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = read_vuyx_UV_c;
|
2022-08-04 05:10:30 +02:00
|
|
|
break;
|
2022-09-05 01:32:06 +02:00
|
|
|
case AV_PIX_FMT_XV30LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = read_xv30le_UV_c;
|
2022-09-05 01:32:06 +02:00
|
|
|
break;
|
2024-10-07 18:36:19 +02:00
|
|
|
case AV_PIX_FMT_V30XLE:
|
|
|
|
*chrToYV12 = read_v30xle_UV_c;
|
|
|
|
break;
|
2024-10-06 19:45:07 +02:00
|
|
|
case AV_PIX_FMT_AYUV:
|
|
|
|
*chrToYV12 = read_ayuv_UV_c;
|
|
|
|
break;
|
2015-07-03 14:15:47 +02:00
|
|
|
case AV_PIX_FMT_AYUV64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = read_ayuv64le_UV_c;
|
2015-07-03 14:15:47 +02:00
|
|
|
break;
|
2024-10-15 19:38:22 +02:00
|
|
|
case AV_PIX_FMT_AYUV64BE:
|
|
|
|
*chrToYV12 = read_ayuv64be_UV_c;
|
|
|
|
break;
|
2024-10-07 00:43:24 +02:00
|
|
|
case AV_PIX_FMT_UYVA:
|
|
|
|
*chrToYV12 = read_uyva_UV_c;
|
|
|
|
break;
|
2022-09-04 00:58:47 +02:00
|
|
|
case AV_PIX_FMT_XV36LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = read_xv36le_UV_c;
|
2022-09-04 00:58:47 +02:00
|
|
|
break;
|
2024-10-15 19:29:43 +02:00
|
|
|
case AV_PIX_FMT_XV36BE:
|
|
|
|
*chrToYV12 = read_xv36be_UV_c;
|
|
|
|
break;
|
2024-10-23 18:10:53 +02:00
|
|
|
case AV_PIX_FMT_XV48LE:
|
|
|
|
*chrToYV12 = read_xv48le_UV_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_XV48BE:
|
|
|
|
*chrToYV12 = read_xv48be_UV_c;
|
|
|
|
break;
|
2015-12-08 12:53:54 +02:00
|
|
|
case AV_PIX_FMT_P010LE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P210LE:
|
|
|
|
case AV_PIX_FMT_P410LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = p010LEToUV_c;
|
2015-12-08 12:53:54 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_P010BE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P210BE:
|
|
|
|
case AV_PIX_FMT_P410BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = p010BEToUV_c;
|
2015-12-08 12:53:54 +02:00
|
|
|
break;
|
2022-09-05 00:43:23 +02:00
|
|
|
case AV_PIX_FMT_P012LE:
|
2023-02-25 10:36:58 +02:00
|
|
|
case AV_PIX_FMT_P212LE:
|
|
|
|
case AV_PIX_FMT_P412LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = p012LEToUV_c;
|
2022-09-05 00:43:23 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_P012BE:
|
2023-02-25 10:36:58 +02:00
|
|
|
case AV_PIX_FMT_P212BE:
|
|
|
|
case AV_PIX_FMT_P412BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = p012BEToUV_c;
|
2022-09-05 00:43:23 +02:00
|
|
|
break;
|
2016-11-21 00:32:49 +02:00
|
|
|
case AV_PIX_FMT_P016LE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P216LE:
|
|
|
|
case AV_PIX_FMT_P416LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = p016LEToUV_c;
|
2016-11-21 00:32:49 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_P016BE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P216BE:
|
|
|
|
case AV_PIX_FMT_P416BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = p016BEToUV_c;
|
2016-11-21 00:32:49 +02:00
|
|
|
break;
|
2020-01-15 08:59:34 +02:00
|
|
|
case AV_PIX_FMT_Y210LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = y210le_UV_c;
|
2020-01-15 08:59:34 +02:00
|
|
|
break;
|
2022-09-05 01:42:32 +02:00
|
|
|
case AV_PIX_FMT_Y212LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = y212le_UV_c;
|
2022-09-05 01:42:32 +02:00
|
|
|
break;
|
2024-10-22 02:41:22 +02:00
|
|
|
case AV_PIX_FMT_Y216LE:
|
|
|
|
*chrToYV12 = y216le_UV_c;
|
|
|
|
break;
|
2024-10-14 10:33:10 +02:00
|
|
|
case AV_PIX_FMT_RGBF32LE:
|
|
|
|
*chrToYV12 = rgbf32le_to_uv_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBF32BE:
|
|
|
|
*chrToYV12 = rgbf32be_to_uv_c;
|
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
if (c->chrSrcHSubSample) {
|
2012-04-15 22:33:30 +03:00
|
|
|
switch (srcFormat) {
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_RGBA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb64BEToUV_half_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_RGBA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb64LEToUV_half_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2014-04-02 20:27:16 +03:00
|
|
|
case AV_PIX_FMT_BGRA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr64BEToUV_half_c;
|
2014-04-02 20:27:16 +03:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_BGRA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr64LEToUV_half_c;
|
2014-04-02 20:27:16 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB48BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb48BEToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb48LEToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR48BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr48BEToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr48LEToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB32:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr32ToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB32_1:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr321ToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr24ToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR565LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr16leToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR565BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr16beToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR555LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr15leToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR555BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr15beToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP:
|
|
|
|
case AV_PIX_FMT_GBRP:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = gbr24pToUV_half_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR444LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr12leToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR444BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr12beToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR32:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb32ToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR32_1:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb321ToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb24ToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB565LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb16leToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB565BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb16beToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB555LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb15leToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB555BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb15beToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB444LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb12leToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB444BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb12beToUV_half_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2020-04-22 07:23:02 +02:00
|
|
|
case AV_PIX_FMT_X2RGB10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb30leToUV_half_c;
|
2020-04-22 07:23:02 +02:00
|
|
|
break;
|
2021-09-25 01:09:15 +02:00
|
|
|
case AV_PIX_FMT_X2BGR10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr30leToUV_half_c;
|
2021-09-25 01:09:15 +02:00
|
|
|
break;
|
2022-08-08 14:02:31 +02:00
|
|
|
case AV_PIX_FMT_RGBAF16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgbaf16beToUV_half_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBAF16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgbaf16leToUV_half_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
2024-10-14 10:33:12 +02:00
|
|
|
case AV_PIX_FMT_RGBF16BE:
|
|
|
|
*chrToYV12 = rgbf16beToUV_half_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBF16LE:
|
|
|
|
*chrToYV12 = rgbf16leToUV_half_c;
|
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
} else {
|
2012-04-15 22:33:30 +03:00
|
|
|
switch (srcFormat) {
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_RGBA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb64BEToUV_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_RGBA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb64LEToUV_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2014-04-02 20:27:16 +03:00
|
|
|
case AV_PIX_FMT_BGRA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr64BEToUV_c;
|
2014-04-02 20:27:16 +03:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_BGRA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr64LEToUV_c;
|
2014-04-02 20:27:16 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB48BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb48BEToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb48LEToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR48BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr48BEToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr48LEToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB32:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr32ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB32_1:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr321ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr24ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR565LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr16leToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR565BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr16beToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR555LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr15leToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR555BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr15beToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR444LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr12leToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR444BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr12beToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR32:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb32ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR32_1:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb321ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb24ToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB565LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb16leToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB565BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb16beToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB555LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb15leToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB555BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb15beToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB444LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb12leToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB444BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb12beToUV_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2020-04-22 07:23:02 +02:00
|
|
|
case AV_PIX_FMT_X2RGB10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgb30leToUV_c;
|
2020-04-22 07:23:02 +02:00
|
|
|
break;
|
2021-09-25 01:09:15 +02:00
|
|
|
case AV_PIX_FMT_X2BGR10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = bgr30leToUV_c;
|
2021-09-25 01:09:15 +02:00
|
|
|
break;
|
2022-08-08 14:02:31 +02:00
|
|
|
case AV_PIX_FMT_RGBAF16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgbaf16beToUV_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBAF16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*chrToYV12 = rgbaf16leToUV_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
2024-10-14 10:33:12 +02:00
|
|
|
case AV_PIX_FMT_RGBF16BE:
|
|
|
|
*chrToYV12 = rgbf16beToUV_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBF16LE:
|
|
|
|
*chrToYV12 = rgbf16leToUV_c;
|
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = NULL;
|
|
|
|
*alpToYV12 = NULL;
|
2012-02-01 18:38:55 +03:00
|
|
|
switch (srcFormat) {
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP9LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb9le_to_y;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-06-10 13:01:26 +02:00
|
|
|
case AV_PIX_FMT_GBRAP10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb10le_to_a;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb10le_to_y;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-02-08 23:40:10 +02:00
|
|
|
case AV_PIX_FMT_GBRAP12LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb12le_to_a;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP12LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb12le_to_y;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2023-09-27 16:13:16 +02:00
|
|
|
case AV_PIX_FMT_GBRAP14LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb14le_to_a;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP14LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb14le_to_y;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb16le_to_a;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb16le_to_y;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2020-05-04 01:10:03 +02:00
|
|
|
case AV_PIX_FMT_GBRAPF32LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgbf32le_to_a;
|
2020-05-04 01:10:03 +02:00
|
|
|
case AV_PIX_FMT_GBRPF32LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgbf32le_to_y;
|
2020-05-04 01:10:03 +02:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP9BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb9be_to_y;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-06-10 13:01:26 +02:00
|
|
|
case AV_PIX_FMT_GBRAP10BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb10be_to_a;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP10BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb10be_to_y;
|
2012-05-12 17:21:32 +03:00
|
|
|
break;
|
2016-02-08 23:40:10 +02:00
|
|
|
case AV_PIX_FMT_GBRAP12BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb12be_to_a;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP12BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb12be_to_y;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2023-09-27 16:13:16 +02:00
|
|
|
case AV_PIX_FMT_GBRAP14BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb14be_to_a;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_GBRP14BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb14be_to_y;
|
2012-07-03 05:10:11 +03:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb16be_to_a;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb16be_to_y;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2020-05-04 01:10:03 +02:00
|
|
|
case AV_PIX_FMT_GBRAPF32BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgbf32be_to_a;
|
2020-05-04 01:10:03 +02:00
|
|
|
case AV_PIX_FMT_GBRPF32BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgbf32be_to_y;
|
2020-05-04 01:10:03 +02:00
|
|
|
break;
|
2013-05-06 18:13:53 +03:00
|
|
|
case AV_PIX_FMT_GBRAP:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readAlpPlanar = planar_rgb_to_a;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GBRP:
|
2024-10-01 12:32:29 +02:00
|
|
|
*readLumPlanar = planar_rgb_to_y;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
#if HAVE_BIGENDIAN
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P9LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P9LE:
|
|
|
|
case AV_PIX_FMT_YUV444P9LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P10LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P10LE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV440P10LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV444P10LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV420P12LE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV422P12LE:
|
|
|
|
case AV_PIX_FMT_YUV440P12LE:
|
|
|
|
case AV_PIX_FMT_YUV444P12LE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV420P14LE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV422P14LE:
|
|
|
|
case AV_PIX_FMT_YUV444P14LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P16LE:
|
|
|
|
case AV_PIX_FMT_YUV422P16LE:
|
|
|
|
case AV_PIX_FMT_YUV444P16LE:
|
2012-10-30 19:41:17 +03:00
|
|
|
|
2017-08-05 14:28:45 +02:00
|
|
|
case AV_PIX_FMT_GRAY9LE:
|
2016-11-14 02:55:49 +02:00
|
|
|
case AV_PIX_FMT_GRAY10LE:
|
2016-11-03 17:10:03 +02:00
|
|
|
case AV_PIX_FMT_GRAY12LE:
|
2018-05-03 22:19:38 +02:00
|
|
|
case AV_PIX_FMT_GRAY14LE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GRAY16LE:
|
2016-11-21 00:32:49 +02:00
|
|
|
|
|
|
|
case AV_PIX_FMT_P016LE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P216LE:
|
|
|
|
case AV_PIX_FMT_P416LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bswap16Y_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P9LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P9LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P9LE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P10LE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P10LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10LE:
|
2018-11-24 17:22:52 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P12LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P12LE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16LE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bswap16Y_c;
|
|
|
|
*alpToYV12 = bswap16Y_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
#else
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P9BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P9BE:
|
|
|
|
case AV_PIX_FMT_YUV444P9BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P10BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV422P10BE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV440P10BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUV444P10BE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV420P12BE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV422P12BE:
|
|
|
|
case AV_PIX_FMT_YUV440P12BE:
|
|
|
|
case AV_PIX_FMT_YUV444P12BE:
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_YUV420P14BE:
|
2017-03-21 09:24:34 +02:00
|
|
|
case AV_PIX_FMT_YUV422P14BE:
|
|
|
|
case AV_PIX_FMT_YUV444P14BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV420P16BE:
|
|
|
|
case AV_PIX_FMT_YUV422P16BE:
|
|
|
|
case AV_PIX_FMT_YUV444P16BE:
|
2012-10-30 19:41:17 +03:00
|
|
|
|
2017-08-05 14:28:45 +02:00
|
|
|
case AV_PIX_FMT_GRAY9BE:
|
2016-11-14 02:55:49 +02:00
|
|
|
case AV_PIX_FMT_GRAY10BE:
|
2016-11-03 17:10:03 +02:00
|
|
|
case AV_PIX_FMT_GRAY12BE:
|
2018-05-03 22:19:38 +02:00
|
|
|
case AV_PIX_FMT_GRAY14BE:
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_GRAY16BE:
|
2016-11-21 00:32:49 +02:00
|
|
|
|
|
|
|
case AV_PIX_FMT_P016BE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P216BE:
|
|
|
|
case AV_PIX_FMT_P416BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bswap16Y_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P9BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P9BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P9BE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P10BE:
|
2016-09-25 23:09:57 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P10BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P10BE:
|
2018-11-24 17:22:52 +02:00
|
|
|
case AV_PIX_FMT_YUVA422P12BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P12BE:
|
2012-10-30 19:41:17 +03:00
|
|
|
case AV_PIX_FMT_YUVA420P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA422P16BE:
|
|
|
|
case AV_PIX_FMT_YUVA444P16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bswap16Y_c;
|
|
|
|
*alpToYV12 = bswap16Y_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
#endif
|
2014-07-20 08:05:35 +03:00
|
|
|
case AV_PIX_FMT_YA16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = read_ya16le_gray_c;
|
2014-07-20 08:05:35 +03:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_YA16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = read_ya16be_gray_c;
|
2014-07-20 08:05:35 +03:00
|
|
|
break;
|
2022-08-04 05:10:30 +02:00
|
|
|
case AV_PIX_FMT_VUYA:
|
2022-08-20 01:53:37 +02:00
|
|
|
case AV_PIX_FMT_VUYX:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = read_vuyx_Y_c;
|
2022-08-04 05:10:30 +02:00
|
|
|
break;
|
2022-09-05 01:32:06 +02:00
|
|
|
case AV_PIX_FMT_XV30LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = read_xv30le_Y_c;
|
2022-09-05 01:32:06 +02:00
|
|
|
break;
|
2024-10-07 18:36:19 +02:00
|
|
|
case AV_PIX_FMT_V30XLE:
|
|
|
|
*lumToYV12 = read_v30xle_Y_c;
|
|
|
|
break;
|
2024-10-06 19:45:07 +02:00
|
|
|
case AV_PIX_FMT_AYUV:
|
2024-10-07 00:43:24 +02:00
|
|
|
case AV_PIX_FMT_UYVA:
|
2024-10-06 19:45:07 +02:00
|
|
|
*lumToYV12 = read_ayuv_Y_c;
|
|
|
|
break;
|
2015-07-03 14:15:47 +02:00
|
|
|
case AV_PIX_FMT_AYUV64LE:
|
2024-10-23 18:10:53 +02:00
|
|
|
case AV_PIX_FMT_XV48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = read_ayuv64le_Y_c;
|
2015-07-03 14:15:47 +02:00
|
|
|
break;
|
2024-10-15 19:38:22 +02:00
|
|
|
case AV_PIX_FMT_AYUV64BE:
|
2024-10-23 18:10:53 +02:00
|
|
|
case AV_PIX_FMT_XV48BE:
|
2024-10-15 19:38:22 +02:00
|
|
|
*lumToYV12 = read_ayuv64be_Y_c;
|
|
|
|
break;
|
2022-09-04 00:58:47 +02:00
|
|
|
case AV_PIX_FMT_XV36LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = read_xv36le_Y_c;
|
2022-09-04 00:58:47 +02:00
|
|
|
break;
|
2024-10-15 19:29:43 +02:00
|
|
|
case AV_PIX_FMT_XV36BE:
|
|
|
|
*lumToYV12 = read_xv36be_Y_c;
|
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUYV422:
|
2014-04-07 18:19:53 +03:00
|
|
|
case AV_PIX_FMT_YVYU422:
|
2014-07-29 16:02:09 +03:00
|
|
|
case AV_PIX_FMT_YA8:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = yuy2ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_UYVY422:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = uyvyToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2024-10-07 05:06:41 +02:00
|
|
|
case AV_PIX_FMT_VYU444:
|
|
|
|
*lumToYV12 = vyuToY_c;
|
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr24ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR565LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr16leToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR565BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr16beToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR555LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr15leToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR555BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr15beToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR444LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr12leToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR444BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr12beToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB24:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb24ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB565LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb16leToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB565BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb16beToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB555LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb15leToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB555BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb15beToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB444LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb12leToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB444BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb12beToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03: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:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = palToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_MONOBLACK:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = monoblack2Y_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_MONOWHITE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = monowhite2Y_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB32:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr32ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB32_1:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr321ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR32:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb32ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR32_1:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb321ToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB48BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb48BEToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_RGB48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb48LEToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR48BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr48BEToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGR48LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr48LEToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_RGBA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb64BEToY_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_RGBA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb64LEToY_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2014-04-02 20:27:16 +03:00
|
|
|
case AV_PIX_FMT_BGRA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr64BEToY_c;
|
2014-04-02 20:27:16 +03:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_BGRA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr64LEToY_c;
|
2015-12-08 12:53:54 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_P010LE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P210LE:
|
|
|
|
case AV_PIX_FMT_P410LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = p010LEToY_c;
|
2015-12-08 12:53:54 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_P010BE:
|
2021-11-13 21:34:21 +02:00
|
|
|
case AV_PIX_FMT_P210BE:
|
|
|
|
case AV_PIX_FMT_P410BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = p010BEToY_c;
|
2015-12-08 12:53:54 +02:00
|
|
|
break;
|
2022-09-05 00:43:23 +02:00
|
|
|
case AV_PIX_FMT_P012LE:
|
2023-02-25 10:36:58 +02:00
|
|
|
case AV_PIX_FMT_P212LE:
|
|
|
|
case AV_PIX_FMT_P412LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = p012LEToY_c;
|
2022-09-05 00:43:23 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_P012BE:
|
2023-02-25 10:36:58 +02:00
|
|
|
case AV_PIX_FMT_P212BE:
|
|
|
|
case AV_PIX_FMT_P412BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = p012BEToY_c;
|
2022-09-05 00:43:23 +02:00
|
|
|
break;
|
2018-08-03 17:06:50 +02:00
|
|
|
case AV_PIX_FMT_GRAYF32LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = grayf32leToY16_c;
|
2018-08-03 17:06:50 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_GRAYF32BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = grayf32beToY16_c;
|
2018-08-03 17:06:50 +02:00
|
|
|
break;
|
2020-01-15 08:59:34 +02:00
|
|
|
case AV_PIX_FMT_Y210LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = y210le_Y_c;
|
2020-01-15 08:59:34 +02:00
|
|
|
break;
|
2022-09-05 01:42:32 +02:00
|
|
|
case AV_PIX_FMT_Y212LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = y212le_Y_c;
|
2022-09-05 01:42:32 +02:00
|
|
|
break;
|
2024-10-22 02:41:22 +02:00
|
|
|
case AV_PIX_FMT_Y216LE:
|
|
|
|
*lumToYV12 = y216le_Y_c;
|
|
|
|
break;
|
2020-04-22 07:23:02 +02:00
|
|
|
case AV_PIX_FMT_X2RGB10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgb30leToY_c;
|
2021-09-25 01:09:15 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_X2BGR10LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = bgr30leToY_c;
|
2020-04-22 07:23:02 +02:00
|
|
|
break;
|
2022-08-08 14:02:31 +02:00
|
|
|
case AV_PIX_FMT_RGBAF16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgbaf16beToY_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBAF16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*lumToYV12 = rgbaf16leToY_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
2024-10-14 10:33:12 +02:00
|
|
|
case AV_PIX_FMT_RGBF16BE:
|
|
|
|
*lumToYV12 = rgbf16beToY_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBF16LE:
|
|
|
|
*lumToYV12 = rgbf16leToY_c;
|
|
|
|
break;
|
2024-10-14 10:33:10 +02:00
|
|
|
case AV_PIX_FMT_RGBF32LE:
|
|
|
|
*lumToYV12 = rgbf32le_to_y_c;
|
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBF32BE:
|
|
|
|
*lumToYV12 = rgbf32be_to_y_c;
|
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
2016-03-28 18:25:18 +02:00
|
|
|
if (c->needAlpha) {
|
2012-10-31 05:03:32 +03:00
|
|
|
if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
|
2024-10-01 12:32:29 +02:00
|
|
|
if (HAVE_BIGENDIAN == !isBE(srcFormat) && !*readAlpPlanar)
|
|
|
|
*alpToYV12 = bswap16Y_c;
|
2012-10-31 05:03:32 +03:00
|
|
|
}
|
2012-02-01 18:38:55 +03:00
|
|
|
switch (srcFormat) {
|
2014-04-02 20:27:16 +03:00
|
|
|
case AV_PIX_FMT_BGRA64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
case AV_PIX_FMT_RGBA64LE: *alpToYV12 = rgba64leToA_c; break;
|
2014-04-02 20:27:16 +03:00
|
|
|
case AV_PIX_FMT_BGRA64BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
case AV_PIX_FMT_RGBA64BE: *alpToYV12 = rgba64beToA_c; break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_BGRA:
|
|
|
|
case AV_PIX_FMT_RGBA:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = rgbaToA_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_ABGR:
|
|
|
|
case AV_PIX_FMT_ARGB:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = abgrToA_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2022-08-08 14:02:31 +02:00
|
|
|
case AV_PIX_FMT_RGBAF16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = rgbaf16beToA_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_RGBAF16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = rgbaf16leToA_c;
|
2022-08-08 14:02:31 +02:00
|
|
|
break;
|
2014-07-29 16:02:09 +03:00
|
|
|
case AV_PIX_FMT_YA8:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = uyvyToY_c;
|
2012-04-15 22:33:30 +03:00
|
|
|
break;
|
2015-01-21 21:14:34 +02:00
|
|
|
case AV_PIX_FMT_YA16LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = read_ya16le_alpha_c;
|
2015-01-21 21:14:34 +02:00
|
|
|
break;
|
|
|
|
case AV_PIX_FMT_YA16BE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = read_ya16be_alpha_c;
|
2015-01-21 21:14:34 +02:00
|
|
|
break;
|
2022-08-04 05:10:30 +02:00
|
|
|
case AV_PIX_FMT_VUYA:
|
2024-10-07 00:43:24 +02:00
|
|
|
case AV_PIX_FMT_UYVA:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = read_vuya_A_c;
|
2022-08-04 05:10:30 +02:00
|
|
|
break;
|
2024-10-06 19:45:07 +02:00
|
|
|
case AV_PIX_FMT_AYUV:
|
|
|
|
*alpToYV12 = read_ayuv_A_c;
|
|
|
|
break;
|
2015-07-03 14:15:47 +02:00
|
|
|
case AV_PIX_FMT_AYUV64LE:
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = read_ayuv64le_A_c;
|
2015-07-03 14:15:47 +02:00
|
|
|
break;
|
2024-10-15 19:38:22 +02:00
|
|
|
case AV_PIX_FMT_AYUV64BE:
|
|
|
|
*alpToYV12 = read_ayuv64be_A_c;
|
|
|
|
break;
|
2012-10-08 21:54:00 +03:00
|
|
|
case AV_PIX_FMT_PAL8 :
|
2024-10-01 12:32:29 +02:00
|
|
|
*alpToYV12 = palToA_c;
|
2012-04-24 01:19:55 +03:00
|
|
|
break;
|
2012-02-01 18:38:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|