diff options
Diffstat (limited to 'video')
-rw-r--r-- | video/img_format.c | 29 | ||||
-rw-r--r-- | video/img_format.h | 16 | ||||
-rw-r--r-- | video/mp_image.c | 25 |
3 files changed, 59 insertions, 11 deletions
diff --git a/video/img_format.c b/video/img_format.c index 30f84222c7..90cce39126 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -47,6 +47,14 @@ struct mp_imgfmt_entry { .num_planes = 3, .forced_csp = MP_CSP_RGB, \ .planes = { {1, {2}}, {1, {3}}, {1, {1}} }, }, } +#define FLOAT_YUV(def, dname, xs, ys, a_planes) \ + [def - IMGFMT_CUST_BASE] = { \ + .name = dname, \ + .reg_desc = { .component_type = MP_COMPONENT_TYPE_FLOAT, \ + .component_size = 4, .num_planes = a_planes, \ + .planes = { {1, {1}}, {1, {2}}, {1, {3}}, {1, {4}} }, \ + .chroma_xs = xs, .chroma_ys = ys, }} + static const struct mp_imgfmt_entry mp_imgfmt_list[] = { // not in ffmpeg [IMGFMT_VDPAU_OUTPUT - IMGFMT_CUST_BASE] = { @@ -104,6 +112,27 @@ static const struct mp_imgfmt_entry mp_imgfmt_list[] = { .planes = { {1, {1}} }, }, }, + [IMGFMT_YAPF - IMGFMT_CUST_BASE] = { + .name = "grayaf32", // try to mimic ffmpeg naming convention + .reg_desc = { + .component_type = MP_COMPONENT_TYPE_FLOAT, + .component_size = 4, + .num_planes = 2, + .planes = { {1, {1}}, {1, {4}} }, + }, + }, + FLOAT_YUV(IMGFMT_444PF, "yuv444pf", 0, 0, 3), + FLOAT_YUV(IMGFMT_444APF, "yuva444pf", 0, 0, 4), + FLOAT_YUV(IMGFMT_420PF, "yuv420pf", 1, 1, 3), + FLOAT_YUV(IMGFMT_420APF, "yuva420pf", 1, 1, 4), + FLOAT_YUV(IMGFMT_422PF, "yuv422pf", 1, 0, 3), + FLOAT_YUV(IMGFMT_422APF, "yuva422pf", 1, 0, 4), + FLOAT_YUV(IMGFMT_440PF, "yuv440pf", 0, 1, 3), + FLOAT_YUV(IMGFMT_440APF, "yuva440pf", 0, 1, 4), + FLOAT_YUV(IMGFMT_410PF, "yuv410pf", 2, 2, 3), + FLOAT_YUV(IMGFMT_410APF, "yuva410pf", 2, 2, 4), + FLOAT_YUV(IMGFMT_411PF, "yuv411pf", 2, 0, 3), + FLOAT_YUV(IMGFMT_411APF, "yuva411pf", 2, 0, 4), FRINGE_GBRP(IMGFMT_GBRP1, "gbrp1", 1), FRINGE_GBRP(IMGFMT_GBRP2, "gbrp2", 2), FRINGE_GBRP(IMGFMT_GBRP3, "gbrp3", 3), diff --git a/video/img_format.h b/video/img_format.h index 489b0e88db..158fdb9df9 100644 --- a/video/img_format.h +++ b/video/img_format.h @@ -212,6 +212,22 @@ enum mp_imgfmt { IMGFMT_YAP8, IMGFMT_YAP16, + // Planar YUV/alpha formats. Sometimes useful for internal processing. There + // should be one for each subsampling factor, with and without alpha, gray. + IMGFMT_YAPF, // Note: non-alpha version exists in ffmpeg + IMGFMT_444PF, + IMGFMT_444APF, + IMGFMT_420PF, + IMGFMT_420APF, + IMGFMT_422PF, + IMGFMT_422APF, + IMGFMT_440PF, + IMGFMT_440APF, + IMGFMT_410PF, + IMGFMT_410APF, + IMGFMT_411PF, + IMGFMT_411APF, + // Accessed with bit-shifts, uint32_t units. IMGFMT_RGB30, // 2pad 10r 10g 10b (MSB to LSB) diff --git a/video/mp_image.c b/video/mp_image.c index cd0fe17713..cc581013da 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -563,24 +563,27 @@ void mp_image_clear(struct mp_image *img, int x0, int y0, int x1, int y1) struct mp_image area = *img; mp_image_crop(&area, x0, y0, x1, y1); + enum mp_component_type ctype = mp_imgfmt_get_component_type(img->imgfmt); uint32_t plane_clear[MP_MAX_PLANES] = {0}; - if (area.imgfmt == IMGFMT_UYVY) { - plane_clear[0] = av_le2ne16(0x0080); - } else if (area.fmt.flags & MP_IMGFLAG_YUV_NV) { - plane_clear[1] = 0x8080; - } else if (area.fmt.flags & MP_IMGFLAG_YUV_P) { - uint16_t chroma_clear = (1 << area.fmt.plane_bits) / 2; - if (!(area.fmt.flags & MP_IMGFLAG_NE)) - chroma_clear = av_bswap16(chroma_clear); - if (area.num_planes > 2) - plane_clear[1] = plane_clear[2] = chroma_clear; + if (ctype != MP_COMPONENT_TYPE_FLOAT) { + if (area.imgfmt == IMGFMT_UYVY) { + plane_clear[0] = av_le2ne16(0x0080); + } else if (area.fmt.flags & MP_IMGFLAG_YUV_NV) { + plane_clear[1] = 0x8080; + } else if (area.fmt.flags & MP_IMGFLAG_YUV_P) { + uint16_t chroma_clear = (1 << area.fmt.plane_bits) / 2; + if (!(area.fmt.flags & MP_IMGFLAG_NE)) + chroma_clear = av_bswap16(chroma_clear); + if (area.num_planes > 2) + plane_clear[1] = plane_clear[2] = chroma_clear; + } } for (int p = 0; p < area.num_planes; p++) { int bpp = area.fmt.bpp[p]; int bytes = (mp_image_plane_w(&area, p) * bpp + 7) / 8; - if (bpp <= 8) { + if (bpp <= 8 || bpp > 16) { memset_pic(area.planes[p], plane_clear[p], bytes, mp_image_plane_h(&area, p), area.stride[p]); } else { |