mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 13:40:21 +00:00
vdec/jpegxs: allow decoding 10-bit Y444 to UYVY
This should be the last compat needed (in respect to the encoder producing 4:2:0 only in 8-bit - lavc encoder is not considered but it will likely work just with encoded UYVY, anyways).
This commit is contained in:
@@ -424,6 +424,40 @@ yuv422p_to_uyvy(const struct from_planar_data d)
|
||||
yuv422p_to_uyvy_yuyv(d, false);
|
||||
}
|
||||
|
||||
static void yuv422pXXle_to_uyvy_int(const struct from_planar_data d, int in_depth)
|
||||
{
|
||||
for(unsigned y = 0; y < d.height; ++y) {
|
||||
const uint16_t *src_y = (const void *)(d.in_data[0] + d.in_linesize[0] * y);
|
||||
const uint16_t *src_cb = (const void *)(d.in_data[1] + d.in_linesize[1] * y);
|
||||
const uint16_t *src_cr = (const void *)(d.in_data[2] + d.in_linesize[2] * y);
|
||||
uint8_t *dst =
|
||||
(uint8_t *) (void *) (d.out_data + y * d.out_pitch);
|
||||
|
||||
for(unsigned x = 0; x < d.width / 2; ++x) {
|
||||
*dst++ = *src_cb++ >> (in_depth - 8);
|
||||
*dst++ = *src_y++ >> (in_depth - 8);
|
||||
*dst++ = *src_cr++ >> (in_depth - 8);
|
||||
*dst++ = *src_y++ >> (in_depth - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void yuv422p10le_to_uyvy(const struct from_planar_data d)
|
||||
{
|
||||
yuv422pXXle_to_uyvy_int(d, DEPTH10);
|
||||
}
|
||||
|
||||
void
|
||||
yuv422pXX_to_uyvy(const struct from_planar_data d)
|
||||
{
|
||||
if (d.in_depth == DEPTH8) {
|
||||
yuv422p_to_uyvy_yuyv(d, false);
|
||||
} else {
|
||||
yuv422pXXle_to_uyvy_int(d, d.in_depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
yuv422p_to_yuyv(const struct from_planar_data d)
|
||||
{
|
||||
|
||||
@@ -85,6 +85,8 @@ decode_planar_func_t gbrap_to_rgb;
|
||||
decode_planar_func_t rgbpXX_to_rgb;
|
||||
decode_planar_func_t yuv420_to_i420;
|
||||
decode_planar_func_t yuv422p_to_uyvy;
|
||||
decode_planar_func_t yuv422p10le_to_uyvy;
|
||||
decode_planar_func_t yuv422pXX_to_uyvy;
|
||||
decode_planar_func_t yuv422p_to_yuyv;
|
||||
decode_planar_func_t gbrp10le_to_rgb;
|
||||
decode_planar_func_t gbrp10le_to_rgba;
|
||||
|
||||
@@ -1173,28 +1173,6 @@ static void yuv420p10le_to_uyvy(struct av_conv_data d)
|
||||
}
|
||||
}
|
||||
|
||||
static void yuv422p10le_to_uyvy(struct av_conv_data d)
|
||||
{
|
||||
const int width = d.in_frame->width;
|
||||
const int height = d.in_frame->height;
|
||||
const AVFrame *in_frame = d.in_frame;
|
||||
|
||||
for(int y = 0; y < height; ++y) {
|
||||
uint16_t *src_y = (uint16_t *)(void *)(in_frame->data[0] + in_frame->linesize[0] * y);
|
||||
uint16_t *src_cb = (uint16_t *)(void *)(in_frame->data[1] + in_frame->linesize[1] * y);
|
||||
uint16_t *src_cr = (uint16_t *)(void *)(in_frame->data[2] + in_frame->linesize[2] * y);
|
||||
uint8_t *dst =
|
||||
(uint8_t *) (void *) (d.dst_buffer + y * d.pitch);
|
||||
|
||||
for(int x = 0; x < width / 2; ++x) {
|
||||
*dst++ = *src_cb++ >> 2;
|
||||
*dst++ = *src_y++ >> 2;
|
||||
*dst++ = *src_cr++ >> 2;
|
||||
*dst++ = *src_y++ >> 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined __GNUC__
|
||||
static inline void yuv444p1Xle_to_uyvy(struct av_conv_data d, int in_depth)
|
||||
__attribute__((always_inline));
|
||||
@@ -2073,7 +2051,7 @@ static const struct av_to_uv_conversion av_to_uv_conversions[] = {
|
||||
{ AV_PIX_FMT_YUV420P10LE, RGBA, yuv420p10le_to_rgb32, nullptr },
|
||||
{ AV_PIX_FMT_YUV420P10LE, R10k, yuv420p10le_to_rgb30, nullptr },
|
||||
{ AV_PIX_FMT_YUV422P10LE, v210, from_planar_conversion, yuv422p10le_to_v210 },
|
||||
{ AV_PIX_FMT_YUV422P10LE, UYVY, yuv422p10le_to_uyvy, nullptr },
|
||||
{ AV_PIX_FMT_YUV422P10LE, UYVY, from_planar_conversion, yuv422p10le_to_uyvy },
|
||||
{ AV_PIX_FMT_YUV422P10LE, RGB, yuv422p10le_to_rgb24, nullptr },
|
||||
{ AV_PIX_FMT_YUV422P10LE, RGBA, yuv422p10le_to_rgb32, nullptr },
|
||||
{ AV_PIX_FMT_YUV422P10LE, R10k, yuv422p10le_to_rgb30, nullptr },
|
||||
|
||||
@@ -81,7 +81,7 @@ struct jpegxs_to_uv_conversion {
|
||||
};
|
||||
|
||||
static const struct jpegxs_to_uv_conversion jpegxs_to_uv_conversions[] = {
|
||||
{ COLOUR_FORMAT_PLANAR_YUV422, UYVY, yuv422p_to_uyvy },
|
||||
{ COLOUR_FORMAT_PLANAR_YUV422, UYVY, yuv422pXX_to_uyvy },
|
||||
{ COLOUR_FORMAT_PLANAR_YUV422, YUYV, yuv422p_to_yuyv },
|
||||
{ COLOUR_FORMAT_PLANAR_YUV420, I420, yuv420_to_i420 },
|
||||
{ COLOUR_FORMAT_PLANAR_YUV420, UYVY, yuv420p_to_uyvy },
|
||||
|
||||
Reference in New Issue
Block a user