You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
sws/output: factor yuv2rgb_write_full() out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -1217,45 +1217,13 @@ YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0)
|
|||||||
YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
|
YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
|
||||||
YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
|
YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
|
||||||
|
|
||||||
static av_always_inline void
|
static av_always_inline void yuv2rgb_write_full(SwsContext *c,
|
||||||
yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
|
uint8_t *dest, int i, int Y, int A, int U, int V,
|
||||||
const int16_t **lumSrc, int lumFilterSize,
|
int y, enum AVPixelFormat target, int hasAlpha, int err[4])
|
||||||
const int16_t *chrFilter, const int16_t **chrUSrc,
|
|
||||||
const int16_t **chrVSrc, int chrFilterSize,
|
|
||||||
const int16_t **alpSrc, uint8_t *dest,
|
|
||||||
int dstW, int y, enum AVPixelFormat target, int hasAlpha)
|
|
||||||
{
|
{
|
||||||
int i;
|
int R, G, B;
|
||||||
int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
|
|
||||||
int err[4] = {0};
|
|
||||||
int isrgb8 = target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8;
|
int isrgb8 = target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8;
|
||||||
|
|
||||||
for (i = 0; i < dstW; i++) {
|
|
||||||
int j;
|
|
||||||
int Y = 1<<9;
|
|
||||||
int U = (1<<9)-(128 << 19);
|
|
||||||
int V = (1<<9)-(128 << 19);
|
|
||||||
int R, G, B, A;
|
|
||||||
|
|
||||||
for (j = 0; j < lumFilterSize; j++) {
|
|
||||||
Y += lumSrc[j][i] * lumFilter[j];
|
|
||||||
}
|
|
||||||
for (j = 0; j < chrFilterSize; j++) {
|
|
||||||
U += chrUSrc[j][i] * chrFilter[j];
|
|
||||||
V += chrVSrc[j][i] * chrFilter[j];
|
|
||||||
}
|
|
||||||
Y >>= 10;
|
|
||||||
U >>= 10;
|
|
||||||
V >>= 10;
|
|
||||||
if (hasAlpha) {
|
|
||||||
A = 1 << 18;
|
|
||||||
for (j = 0; j < lumFilterSize; j++) {
|
|
||||||
A += alpSrc[j][i] * lumFilter[j];
|
|
||||||
}
|
|
||||||
A >>= 19;
|
|
||||||
if (A & 0x100)
|
|
||||||
A = av_clip_uint8(A);
|
|
||||||
}
|
|
||||||
Y -= c->yuv2rgb_y_offset;
|
Y -= c->yuv2rgb_y_offset;
|
||||||
Y *= c->yuv2rgb_y_coeff;
|
Y *= c->yuv2rgb_y_coeff;
|
||||||
Y += 1 << 21;
|
Y += 1 << 21;
|
||||||
@@ -1337,9 +1305,53 @@ yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
|
|||||||
dest[0] = b + 4*g + 32*r;
|
dest[0] = b + 4*g + 32*r;
|
||||||
} else
|
} else
|
||||||
av_assert2(0);
|
av_assert2(0);
|
||||||
step = 1;
|
|
||||||
break;}
|
break;}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static av_always_inline void
|
||||||
|
yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
|
||||||
|
const int16_t **lumSrc, int lumFilterSize,
|
||||||
|
const int16_t *chrFilter, const int16_t **chrUSrc,
|
||||||
|
const int16_t **chrVSrc, int chrFilterSize,
|
||||||
|
const int16_t **alpSrc, uint8_t *dest,
|
||||||
|
int dstW, int y, enum AVPixelFormat target, int hasAlpha)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
|
||||||
|
int err[4] = {0};
|
||||||
|
|
||||||
|
if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
|
||||||
|
|| target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8)
|
||||||
|
step = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < dstW; i++) {
|
||||||
|
int j;
|
||||||
|
int Y = 1<<9;
|
||||||
|
int U = (1<<9)-(128 << 19);
|
||||||
|
int V = (1<<9)-(128 << 19);
|
||||||
|
int A;
|
||||||
|
|
||||||
|
for (j = 0; j < lumFilterSize; j++) {
|
||||||
|
Y += lumSrc[j][i] * lumFilter[j];
|
||||||
|
}
|
||||||
|
for (j = 0; j < chrFilterSize; j++) {
|
||||||
|
U += chrUSrc[j][i] * chrFilter[j];
|
||||||
|
V += chrVSrc[j][i] * chrFilter[j];
|
||||||
|
}
|
||||||
|
Y >>= 10;
|
||||||
|
U >>= 10;
|
||||||
|
V >>= 10;
|
||||||
|
if (hasAlpha) {
|
||||||
|
A = 1 << 18;
|
||||||
|
for (j = 0; j < lumFilterSize; j++) {
|
||||||
|
A += alpSrc[j][i] * lumFilter[j];
|
||||||
|
}
|
||||||
|
A >>= 19;
|
||||||
|
if (A & 0x100)
|
||||||
|
A = av_clip_uint8(A);
|
||||||
|
}
|
||||||
|
yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
|
||||||
dest += step;
|
dest += step;
|
||||||
}
|
}
|
||||||
c->dither_error[0][i] = err[0];
|
c->dither_error[0][i] = err[0];
|
||||||
|
Reference in New Issue
Block a user