mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 18:45:25 +00:00
gl_video: add support for NV12
There's really no reason for this, but it feels nice being able to support a weird pixel format.
This commit is contained in:
parent
1df2edda3a
commit
120d6bf57c
@ -690,7 +690,12 @@ static void compile_shaders(struct gl_video *p)
|
||||
bool convert_input_to_linear = !p->is_linear_rgb &&
|
||||
(p->opts.srgb || p->use_lut_3d);
|
||||
|
||||
shader_def_opt(&header_conv, "USE_PLANAR", p->plane_count > 1);
|
||||
if (p->image_format == IMGFMT_NV12) {
|
||||
shader_def(&header_conv, "USE_CONV", "CONV_NV12");
|
||||
} else if (p->plane_count > 1) {
|
||||
shader_def(&header_conv, "USE_CONV", "CONV_PLANAR");
|
||||
}
|
||||
|
||||
shader_def_opt(&header_conv, "USE_GBRP", p->image_format == IMGFMT_GBRP);
|
||||
shader_def_opt(&header_conv, "USE_YGRAY", p->is_yuv && p->plane_count == 1);
|
||||
shader_def_opt(&header_conv, "USE_COLORMATRIX", p->is_yuv);
|
||||
@ -1603,6 +1608,13 @@ static bool init_format(int fmt, struct gl_video *init)
|
||||
}
|
||||
}
|
||||
|
||||
// YUV/half-packed
|
||||
if (!supported && fmt == IMGFMT_NV12) {
|
||||
supported = true;
|
||||
plane_format[0] = IMGFMT_Y8;
|
||||
plane_format[1] = IMGFMT_YA8;
|
||||
}
|
||||
|
||||
// RGB/planar
|
||||
if (!supported && fmt == IMGFMT_GBRP) {
|
||||
supported = true;
|
||||
|
@ -131,6 +131,9 @@ uniform vec2 dither_size;
|
||||
in vec2 texcoord;
|
||||
DECLARE_FRAGPARMS
|
||||
|
||||
#define CONV_NV12 1
|
||||
#define CONV_PLANAR 2
|
||||
|
||||
vec4 sample_bilinear(sampler2D tex, vec2 texsize, vec2 texcoord) {
|
||||
return texture(tex, texcoord);
|
||||
}
|
||||
@ -316,10 +319,13 @@ vec4 sample_sharpen5(sampler2D tex, vec2 texsize, vec2 texcoord) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifdef USE_PLANAR
|
||||
#if USE_CONV == CONV_PLANAR
|
||||
vec3 color = vec3(SAMPLE_L(textures[0], textures_size[0], texcoord).r,
|
||||
SAMPLE_C(textures[1], textures_size[1], texcoord).r,
|
||||
SAMPLE_C(textures[2], textures_size[2], texcoord).r);
|
||||
#elif USE_CONV == CONV_NV12
|
||||
vec3 color = vec3(SAMPLE_L(textures[0], textures_size[0], texcoord).r,
|
||||
SAMPLE_C(textures[1], textures_size[1], texcoord).rg);
|
||||
#else
|
||||
vec3 color = SAMPLE_L(textures[0], textures_size[0], texcoord).rgb;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user