hwdec_drmprime: support rpi4_8 and rpi4_10 formats

HEVC hardware decode with drm wasn't working on the RPi 4. Mpv would
report the image format (rpi4_8 for 8-bit and rpi4_10 for 10-bit) wasn't
supported. The change to hwdec_drmprime.c identifies these two formats
as NV12 because it functions exactly the same. The change to
dmabuf_interop_gl.c adds support for P030 which rpi4_10 uses. These
changes were tested on a Pi 4 with this fork of ffmpeg:
https://github.com/jc-kynesim/rpi-ffmpeg.

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
This commit is contained in:
EmperorPenguin18 2023-01-19 19:25:15 -05:00 committed by Philip Langdale
parent c50f536bd1
commit c7a8e71578
2 changed files with 14 additions and 1 deletions

View File

@ -185,6 +185,9 @@ static bool vaapi_gl_map(struct ra_hwdec_mapper *mapper,
format[2] = DRM_FORMAT_R8; format[2] = DRM_FORMAT_R8;
break; break;
case DRM_FORMAT_P010: case DRM_FORMAT_P010:
#ifdef DRM_FORMAT_P030 /* Format added in a newer libdrm version than minimum */
case DRM_FORMAT_P030:
#endif
format[0] = DRM_FORMAT_R16; format[0] = DRM_FORMAT_R16;
format[1] = DRM_FORMAT_GR1616; format[1] = DRM_FORMAT_GR1616;
break; break;

View File

@ -167,6 +167,16 @@ static int mapper_init(struct ra_hwdec_mapper *mapper)
struct dmabuf_interop_priv *p = mapper->priv; struct dmabuf_interop_priv *p = mapper->priv;
mapper->dst_params = mapper->src_params; mapper->dst_params = mapper->src_params;
/*
* rpi4_8 and rpi4_10 function identically to NV12. These two pixel
* formats however are not defined in upstream ffmpeg so a string
* comparison is used to identify them instead of a mpv IMGFMT.
*/
const char* fmt_name = mp_imgfmt_to_name(mapper->src_params.hw_subfmt);
if (strcmp(fmt_name, "rpi4_8") == 0 || strcmp(fmt_name, "rpi4_10") == 0)
mapper->dst_params.imgfmt = IMGFMT_NV12;
else
mapper->dst_params.imgfmt = mapper->src_params.hw_subfmt; mapper->dst_params.imgfmt = mapper->src_params.hw_subfmt;
mapper->dst_params.hw_subfmt = 0; mapper->dst_params.hw_subfmt = 0;