img_format: add RGB30 format

FFmpeg does not support this from what I can see. This makes supporting
it a bit awkward.

Later commits use this format.
This commit is contained in:
wm4 2019-10-20 19:37:59 +02:00
parent 62bd8da490
commit 8f5979c5d8
2 changed files with 24 additions and 1 deletions

View File

@ -36,6 +36,7 @@ struct mp_imgfmt_entry {
static const struct mp_imgfmt_entry mp_imgfmt_list[] = {
// not in ffmpeg
{"vdpau_output", IMGFMT_VDPAU_OUTPUT},
{"rgb30", IMGFMT_RGB30},
// FFmpeg names have an annoying "_vld" suffix
{"videotoolbox", IMGFMT_VIDEOTOOLBOX},
{"vaapi", IMGFMT_VAAPI},
@ -107,6 +108,19 @@ static struct mp_imgfmt_desc mp_only_imgfmt_desc(int mpfmt)
.flags = MP_IMGFLAG_BE | MP_IMGFLAG_LE | MP_IMGFLAG_RGB |
MP_IMGFLAG_HWACCEL,
};
case IMGFMT_RGB30:
return (struct mp_imgfmt_desc) {
.id = mpfmt,
.avformat = AV_PIX_FMT_NONE,
.flags = MP_IMGFLAG_BYTE_ALIGNED | MP_IMGFLAG_NE | MP_IMGFLAG_RGB,
.num_planes = 1,
.align_x = 1,
.align_y = 1,
.bytes = {4},
.bpp = {32},
.plane_bits = 30,
.component_bits = 10,
};
}
return (struct mp_imgfmt_desc) {0};
}
@ -309,6 +323,9 @@ static bool validate_regular_imgfmt(const struct mp_regular_imgfmt *fmt)
enum mp_csp mp_imgfmt_get_forced_csp(int imgfmt)
{
if (imgfmt == IMGFMT_RGB30)
return MP_CSP_RGB;
enum AVPixelFormat pixfmt = imgfmt2pixfmt(imgfmt);
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(pixfmt);
@ -327,10 +344,13 @@ enum mp_csp mp_imgfmt_get_forced_csp(int imgfmt)
enum mp_component_type mp_imgfmt_get_component_type(int imgfmt)
{
if (imgfmt == IMGFMT_RGB30)
return MP_COMPONENT_TYPE_UINT;
const AVPixFmtDescriptor *pixdesc =
av_pix_fmt_desc_get(imgfmt2pixfmt(imgfmt));
if (!pixdesc)
if (!pixdesc || (pixdesc->flags & AV_PIX_FMT_FLAG_HWACCEL))
return MP_COMPONENT_TYPE_UNKNOWN;
#if LIBAVUTIL_VERSION_MICRO >= 100

View File

@ -192,6 +192,9 @@ enum mp_imgfmt {
// Accessed with bit-shifts after endian-swapping the uint16_t pixel
IMGFMT_RGB565, // 5r 6g 5b (MSB to LSB)
// Accessed with bit-shifts, uint32_t units.
IMGFMT_RGB30, // 2pad 10r 10g 10b (MSG to LSB)
// Hardware accelerated formats. Plane data points to special data
// structures, instead of pixel data.
IMGFMT_VDPAU, // VdpVideoSurface