Add YUV colorspace and color range attributes to EGLImage

This commit is contained in:
Cameron Gutman
2021-11-19 01:15:33 -06:00
parent 1193943228
commit 4de3aa96b6
2 changed files with 46 additions and 0 deletions

View File

@@ -517,6 +517,41 @@ ssize_t DrmRenderer::exportEGLImages(AVFrame *frame, EGLDisplay dpy,
}
}
// Add colorspace data if present
switch (frame->colorspace) {
case AVCOL_SPC_BT2020_CL:
case AVCOL_SPC_BT2020_NCL:
attribs[attribIndex++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
attribs[attribIndex++] = EGL_ITU_REC2020_EXT;
break;
case AVCOL_SPC_SMPTE170M:
case AVCOL_SPC_BT470BG:
case AVCOL_SPC_FCC:
attribs[attribIndex++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
attribs[attribIndex++] = EGL_ITU_REC601_EXT;
break;
case AVCOL_SPC_BT709:
attribs[attribIndex++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
attribs[attribIndex++] = EGL_ITU_REC709_EXT;
break;
default:
break;
}
// Add color range data if present
switch (frame->color_range) {
case AVCOL_RANGE_JPEG:
attribs[attribIndex++] = EGL_SAMPLE_RANGE_HINT_EXT;
attribs[attribIndex++] = EGL_YUV_FULL_RANGE_EXT;
break;
case AVCOL_RANGE_MPEG:
attribs[attribIndex++] = EGL_SAMPLE_RANGE_HINT_EXT;
attribs[attribIndex++] = EGL_YUV_NARROW_RANGE_EXT;
break;
default:
break;
}
// Terminate the attribute list
attribs[attribIndex++] = EGL_NONE;
SDL_assert(attribIndex <= MAX_ATTRIB_COUNT);