Skip to content

Commit e4d896e

Browse files
committed
from_lavc_vid_conv: add conv YCbCr 444->VUYA
When supported by the display, this eliminates the conversion eg. to Y416 for video display because UYVY or v210 are 4:2:2. But the conversion went over UYVY anyways (there was no conv from Y444 keeping subsampling), eg: `$ uv -t testcard:c=vuya -d gl` was originally: ``` ./src/libavcodec/from_lavc_vid_conv.c: selected conversion from yuv444p to Y416 with UYVY intermediate. ``` now VUYA is selected
1 parent d41ad41 commit e4d896e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/libavcodec/from_lavc_vid_conv.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <stdalign.h> // for alignof
5555
#endif
5656
#include <stdbool.h>
57+
#include <stddef.h> // for NULL, ptrdiff_t, size_t
5758
#include <stdint.h>
5859

5960
#include "color.h"
@@ -1040,6 +1041,31 @@ yuv422p_to_v210(struct av_conv_data d)
10401041
}
10411042
}
10421043

1044+
static void
1045+
yuv444p_to_vuya(struct av_conv_data d)
1046+
{
1047+
const int width = d.in_frame->width;
1048+
const int height = d.in_frame->height;
1049+
const AVFrame *in_frame = d.in_frame;
1050+
for (ptrdiff_t y = 0; y < height; ++y) {
1051+
unsigned char *src_y = (unsigned char *) in_frame->data[0] +
1052+
(in_frame->linesize[0] * y);
1053+
unsigned char *src_cb = (unsigned char *) in_frame->data[1] +
1054+
(in_frame->linesize[1] * y);
1055+
unsigned char *src_cr = (unsigned char *) in_frame->data[2] +
1056+
(in_frame->linesize[2] * y);
1057+
unsigned char *dst =
1058+
(unsigned char *) d.dst_buffer + (d.pitch * y);
1059+
OPTIMIZED_FOR (int x = 0; x < width; ++x) {
1060+
enum { ALPHA = 0xFF };
1061+
*dst++ = *src_cr++;
1062+
*dst++ = *src_cb++;
1063+
*dst++ = *src_y++;
1064+
*dst++ = ALPHA;
1065+
}
1066+
}
1067+
}
1068+
10431069
static void
10441070
yuv444p_to_uyvy(struct av_conv_data d)
10451071
{
@@ -2540,6 +2566,7 @@ static const struct av_to_uv_conversion av_to_uv_conversions[] = {
25402566
{AV_PIX_FMT_YUV422P, RGBA, yuv422p_to_rgb32},
25412567
{AV_PIX_FMT_YUV444P, v210, yuv444p_to_v210},
25422568
{AV_PIX_FMT_YUV444P, UYVY, yuv444p_to_uyvy},
2569+
{AV_PIX_FMT_YUV444P, VUYA, yuv444p_to_vuya},
25432570
{AV_PIX_FMT_YUV444P, RGB, yuv444p_to_rgb24},
25442571
{AV_PIX_FMT_YUV444P, RGBA, yuv444p_to_rgb32},
25452572
// 8-bit YUV - this should be supposedly full range JPEG but lavd decoder doesn't honor
@@ -2554,6 +2581,7 @@ static const struct av_to_uv_conversion av_to_uv_conversions[] = {
25542581
{AV_PIX_FMT_YUVJ422P, RGB, yuv422p_to_rgb24},
25552582
{AV_PIX_FMT_YUVJ422P, RGBA, yuv422p_to_rgb32},
25562583
{AV_PIX_FMT_YUVJ444P, v210, yuv444p_to_v210},
2584+
{AV_PIX_FMT_YUVJ444P, VUYA, yuv444p_to_vuya},
25572585
{AV_PIX_FMT_YUVJ444P, UYVY, yuv444p_to_uyvy},
25582586
{AV_PIX_FMT_YUVJ444P, RGB, yuv444p_to_rgb24},
25592587
{AV_PIX_FMT_YUVJ444P, RGBA, yuv444p_to_rgb32},

src/video_decompress/libavcodec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ static int libavcodec_decompress_get_priority(codec_t compression, struct pixfmt
12241224
case VIDEO_CODEC_NONE:
12251225
return VDEC_PRIO_PROBE_LO; // for probe
12261226
case UYVY:
1227+
case VUYA:
12271228
case RG48:
12281229
case RGB:
12291230
case RGBA:

0 commit comments

Comments
 (0)