video: add IMGFMT_Y16/PIX_FMT_GRAY16

This pixel format is sometimes used with yuv4mpeg.

vo_direct3d used its own IMGFMT_Y16 internally for some reason.

vo_opengl, vo_opengl_old, and vo_direct3d should be able to display
this pixel format natively.
This commit is contained in:
wm4 2012-11-14 11:19:04 +01:00
parent a86ec72986
commit e5f7976000
5 changed files with 26 additions and 5 deletions

View File

@ -62,6 +62,8 @@ static const struct {
{IMGFMT_NV21, PIX_FMT_NV21},
{IMGFMT_Y800, PIX_FMT_GRAY8},
{IMGFMT_Y8, PIX_FMT_GRAY8},
{IMGFMT_Y16LE, PIX_FMT_GRAY16LE},
{IMGFMT_Y16BE, PIX_FMT_GRAY16BE},
{IMGFMT_YVU9, PIX_FMT_YUV410P},
{IMGFMT_IF09, PIX_FMT_YUV410P},
{IMGFMT_YV12, PIX_FMT_YUV420P},

View File

@ -103,6 +103,12 @@ int mp_get_chroma_shift(int format, int *x_shift, int *y_shift,
xs = 31;
ys = 31;
break;
case IMGFMT_Y16BE:
case IMGFMT_Y16LE:
bits = 16;
xs = 31;
ys = 31;
break;
default:
err = 1;
break;
@ -164,6 +170,9 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = {
{"hm12", IMGFMT_HM12},
{"y800", IMGFMT_Y800},
{"y8", IMGFMT_Y8},
{"y16ne", IMGFMT_Y16},
{"y16le", IMGFMT_Y16LE},
{"y16be", IMGFMT_Y16BE},
{"nv12", IMGFMT_NV12},
{"nv21", IMGFMT_NV21},
{"bgr24", IMGFMT_BGR24},

View File

@ -102,7 +102,17 @@
#define IMGFMT_BGR_DEPTH(fmt) ((fmt)&0x3F)
// AV_PIX_FMT_BGR0
#define IMGFMT_BGR0 0x1DC70000
#define IMGFMT_BGR0 0x1DC70000
// AV_PIX_FMT_GRAY16LE
#define IMGFMT_Y16LE 0x1DC70001
// AV_PIX_FMT_GRAY16BE
#define IMGFMT_Y16BE 0x1DC70002
#if BYTE_ORDER == BIG_ENDIAN
#define IMGFMT_Y16 IMGFMT_Y16BE
#else
#define IMGFMT_Y16 IMGFMT_Y16LE
#endif
/* Planar YUV Formats */
@ -170,8 +180,8 @@
#endif
// These macros are misnamed - they actually match 9, 10 or 16 bits
#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt - 0x51000034) & 0xfc0000ff) == 0)
#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000fc) == 0)
#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt - 0x51000034) & 0xfc0000ff) == 0 || fmt == IMGFMT_Y16LE)
#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000fc) == 0 || fmt == IMGFMT_Y16BE)
#define IMGFMT_IS_YUVP16(fmt) (IMGFMT_IS_YUVP16_LE(fmt) || IMGFMT_IS_YUVP16_BE(fmt))
/* Packed YUV Formats */

View File

@ -193,6 +193,8 @@ void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
return;
case IMGFMT_Y800:
case IMGFMT_Y8:
case IMGFMT_Y16LE:
case IMGFMT_Y16BE:
/* they're planar ones, but for easier handling use them as packed */
mpi->flags&=~MP_IMGFLAG_PLANAR;
mpi->num_planes=1;

View File

@ -49,8 +49,6 @@
// TODO: beg someone to add this (there is already IMGFMT_Y8)
// equals MAKEFOURCC('Y', '1', '6', ' ')
#define IMGFMT_Y16 0x20363159
#define IMGFMT_A8Y8 MAKEFOURCC('A', '8', 'Y', '8')
#define IMGFMT_IS_Y(x) ((x) == IMGFMT_Y8 || (x) == IMGFMT_Y16 || (x) == IMGFMT_A8Y8)