mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
sws: Update rgb24toyv12_c() to user supplied rgb2yuv tables
As the function arguments change, we also change the function name to ensure that anyone using this (non public) function doesnt end with hard to debug crashes. The new name also has a proper prefix. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
8e27c6ebbb
commit
a37fd7f957
@ -73,10 +73,11 @@ void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst,
|
|||||||
uint8_t *udst, uint8_t *vdst,
|
uint8_t *udst, uint8_t *vdst,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int lumStride, int chromStride, int srcStride);
|
int lumStride, int chromStride, int srcStride);
|
||||||
void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst,
|
void (*ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst,
|
||||||
uint8_t *udst, uint8_t *vdst,
|
uint8_t *udst, uint8_t *vdst,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int lumStride, int chromStride, int srcStride);
|
int lumStride, int chromStride, int srcStride,
|
||||||
|
int32_t *rgb2yuv);
|
||||||
void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
|
void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
|
||||||
int srcStride, int dstStride);
|
int srcStride, int dstStride);
|
||||||
void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst,
|
void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst,
|
||||||
|
@ -76,9 +76,9 @@ void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, int src_size);
|
|||||||
void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size);
|
void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size);
|
||||||
void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size);
|
void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size);
|
||||||
|
|
||||||
void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
||||||
uint8_t *vdst, int width, int height, int lumStride,
|
uint8_t *vdst, int width, int height, int lumStride,
|
||||||
int chromStride, int srcStride);
|
int chromStride, int srcStride, int32_t *rgb2yuv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height should be a multiple of 2 and width should be a multiple of 16.
|
* Height should be a multiple of 2 and width should be a multiple of 16.
|
||||||
@ -124,9 +124,10 @@ extern void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uin
|
|||||||
* Chrominance data is only taken from every second line, others are ignored.
|
* Chrominance data is only taken from every second line, others are ignored.
|
||||||
* FIXME: Write high quality version.
|
* FIXME: Write high quality version.
|
||||||
*/
|
*/
|
||||||
extern void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
extern void (*ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int lumStride, int chromStride, int srcStride);
|
int lumStride, int chromStride, int srcStride,
|
||||||
|
int32_t *rgb2yuv);
|
||||||
extern void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
|
extern void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
|
||||||
int srcStride, int dstStride);
|
int srcStride, int dstStride);
|
||||||
|
|
||||||
|
@ -612,10 +612,13 @@ static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst,
|
|||||||
* others are ignored in the C version.
|
* others are ignored in the C version.
|
||||||
* FIXME: Write HQ version.
|
* FIXME: Write HQ version.
|
||||||
*/
|
*/
|
||||||
void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
||||||
uint8_t *vdst, int width, int height, int lumStride,
|
uint8_t *vdst, int width, int height, int lumStride,
|
||||||
int chromStride, int srcStride)
|
int chromStride, int srcStride, int32_t *rgb2yuv)
|
||||||
{
|
{
|
||||||
|
int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
|
||||||
|
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 y;
|
int y;
|
||||||
const int chromWidth = width >> 1;
|
const int chromWidth = width >> 1;
|
||||||
|
|
||||||
@ -626,9 +629,9 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
|||||||
unsigned int g = src[6 * i + 1];
|
unsigned int g = src[6 * i + 1];
|
||||||
unsigned int r = src[6 * i + 2];
|
unsigned int r = src[6 * i + 2];
|
||||||
|
|
||||||
unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
|
unsigned int Y = ((ry * r + gy * g + by * b) >> RGB2YUV_SHIFT) + 16;
|
||||||
unsigned int V = ((RV * r + GV * g + BV * b) >> RGB2YUV_SHIFT) + 128;
|
unsigned int V = ((rv * r + gv * g + bv * b) >> RGB2YUV_SHIFT) + 128;
|
||||||
unsigned int U = ((RU * r + GU * g + BU * b) >> RGB2YUV_SHIFT) + 128;
|
unsigned int U = ((ru * r + gu * g + bu * b) >> RGB2YUV_SHIFT) + 128;
|
||||||
|
|
||||||
udst[i] = U;
|
udst[i] = U;
|
||||||
vdst[i] = V;
|
vdst[i] = V;
|
||||||
@ -638,7 +641,7 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
|||||||
g = src[6 * i + 4];
|
g = src[6 * i + 4];
|
||||||
r = src[6 * i + 5];
|
r = src[6 * i + 5];
|
||||||
|
|
||||||
Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
|
Y = ((ry * r + gy * g + by * b) >> RGB2YUV_SHIFT) + 16;
|
||||||
ydst[2 * i + 1] = Y;
|
ydst[2 * i + 1] = Y;
|
||||||
}
|
}
|
||||||
ydst += lumStride;
|
ydst += lumStride;
|
||||||
@ -652,7 +655,7 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
|||||||
unsigned int g = src[6 * i + 1];
|
unsigned int g = src[6 * i + 1];
|
||||||
unsigned int r = src[6 * i + 2];
|
unsigned int r = src[6 * i + 2];
|
||||||
|
|
||||||
unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
|
unsigned int Y = ((ry * r + gy * g + by * b) >> RGB2YUV_SHIFT) + 16;
|
||||||
|
|
||||||
ydst[2 * i] = Y;
|
ydst[2 * i] = Y;
|
||||||
|
|
||||||
@ -660,7 +663,7 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
|||||||
g = src[6 * i + 4];
|
g = src[6 * i + 4];
|
||||||
r = src[6 * i + 5];
|
r = src[6 * i + 5];
|
||||||
|
|
||||||
Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
|
Y = ((ry * r + gy * g + by * b) >> RGB2YUV_SHIFT) + 16;
|
||||||
ydst[2 * i + 1] = Y;
|
ydst[2 * i + 1] = Y;
|
||||||
}
|
}
|
||||||
udst += chromStride;
|
udst += chromStride;
|
||||||
@ -915,7 +918,7 @@ static inline void rgb2rgb_init_c(void)
|
|||||||
yuv422ptouyvy = yuv422ptouyvy_c;
|
yuv422ptouyvy = yuv422ptouyvy_c;
|
||||||
yuy2toyv12 = yuy2toyv12_c;
|
yuy2toyv12 = yuy2toyv12_c;
|
||||||
planar2x = planar2x_c;
|
planar2x = planar2x_c;
|
||||||
rgb24toyv12 = rgb24toyv12_c;
|
ff_rgb24toyv12 = ff_rgb24toyv12_c;
|
||||||
interleaveBytes = interleaveBytes_c;
|
interleaveBytes = interleaveBytes_c;
|
||||||
vu9_to_vu12 = vu9_to_vu12_c;
|
vu9_to_vu12 = vu9_to_vu12_c;
|
||||||
yvu9_to_yuy2 = yvu9_to_yuy2_c;
|
yvu9_to_yuy2 = yvu9_to_yuy2_c;
|
||||||
|
@ -746,13 +746,14 @@ static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
|
|||||||
int srcStride[], int srcSliceY, int srcSliceH,
|
int srcStride[], int srcSliceY, int srcSliceH,
|
||||||
uint8_t *dst[], int dstStride[])
|
uint8_t *dst[], int dstStride[])
|
||||||
{
|
{
|
||||||
rgb24toyv12(
|
ff_rgb24toyv12(
|
||||||
src[0],
|
src[0],
|
||||||
dst[0] + srcSliceY * dstStride[0],
|
dst[0] + srcSliceY * dstStride[0],
|
||||||
dst[1] + (srcSliceY >> 1) * dstStride[1],
|
dst[1] + (srcSliceY >> 1) * dstStride[1],
|
||||||
dst[2] + (srcSliceY >> 1) * dstStride[2],
|
dst[2] + (srcSliceY >> 1) * dstStride[2],
|
||||||
c->srcW, srcSliceH,
|
c->srcW, srcSliceH,
|
||||||
dstStride[0], dstStride[1], srcStride[0]);
|
dstStride[0], dstStride[1], srcStride[0],
|
||||||
|
c->input_rgb2yuv_table);
|
||||||
if (dst[3])
|
if (dst[3])
|
||||||
fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
|
fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
|
||||||
return srcSliceH;
|
return srcSliceH;
|
||||||
|
@ -1612,7 +1612,8 @@ static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t
|
|||||||
*/
|
*/
|
||||||
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int lumStride, int chromStride, int srcStride)
|
int lumStride, int chromStride, int srcStride,
|
||||||
|
int32_t *rgb2yuv)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
const x86_reg chromWidth= width>>1;
|
const x86_reg chromWidth= width>>1;
|
||||||
@ -1850,7 +1851,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
|
|||||||
SFENCE" \n\t"
|
SFENCE" \n\t"
|
||||||
:::"memory");
|
:::"memory");
|
||||||
|
|
||||||
rgb24toyv12_c(src, ydst, udst, vdst, width, height-y, lumStride, chromStride, srcStride);
|
ff_rgb24toyv12_c(src, ydst, udst, vdst, width, height-y, lumStride, chromStride, srcStride, rgb2yuv);
|
||||||
}
|
}
|
||||||
#endif /* !COMPILE_TEMPLATE_SSE2 */
|
#endif /* !COMPILE_TEMPLATE_SSE2 */
|
||||||
|
|
||||||
@ -2486,7 +2487,7 @@ static inline void RENAME(rgb2rgb_init)(void)
|
|||||||
#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
|
#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
|
||||||
planar2x = RENAME(planar2x);
|
planar2x = RENAME(planar2x);
|
||||||
#endif /* COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW */
|
#endif /* COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW */
|
||||||
rgb24toyv12 = RENAME(rgb24toyv12);
|
ff_rgb24toyv12 = RENAME(rgb24toyv12);
|
||||||
|
|
||||||
yuyvtoyuv420 = RENAME(yuyvtoyuv420);
|
yuyvtoyuv420 = RENAME(yuyvtoyuv420);
|
||||||
uyvytoyuv420 = RENAME(uyvytoyuv420);
|
uyvytoyuv420 = RENAME(uyvytoyuv420);
|
||||||
|
Loading…
Reference in New Issue
Block a user