watery01 / libyuv

Automatically exported from code.google.com/p/libyuv
0 stars 0 forks source link

Support for non-standard OS X fourccs #229

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As reported by the camtwist guys, we should support at least 
kCMPixelFormat_32ARGB. The full CMPixelFormatType is below, for reference. I'll 
send out a CL shortly that shows the change.

CMPixelFormatType
Four-character codes identifying pixel formats.

enum {
  kCMPixelFormat_32ARGB          = 32,
  kCMPixelFormat_32BGRA          = 'BGRA',
  kCMPixelFormat_24RGB           = 24,
  kCMPixelFormat_16BE555         = 16,
  kCMPixelFormat_16BE565         = 'B565',
  kCMPixelFormat_16LE555         = 'L555',
  kCMPixelFormat_16LE565         = 'L565',
  kCMPixelFormat_16LE5551        = '5551',
  kCMPixelFormat_422YpCbCr8      = '2vuy',
  kCMPixelFormat_422YpCbCr8_yuvs = 'yuvs',
  kCMPixelFormat_444YpCbCr8      = 'v308',
  kCMPixelFormat_4444YpCbCrA8    = 'v408',
  kCMPixelFormat_422YpCbCr16     = 'v216',
  kCMPixelFormat_422YpCbCr10     = 'v210',
  kCMPixelFormat_444YpCbCr10     = 'v410',
  kCMPixelFormat_8IndexedGray_WhiteIsZero = 0x00000028,
};
typedef FourCharCode CMPixelFormatType;

Original issue reported on code.google.com by fbarch...@chromium.org on 17 May 2013 at 12:32

GoogleCodeExporter commented 9 years ago
kCMPixelFormat_32ARGB
kCMPixelFormat_24RGB
kCMPixelFormat_16BE555
kCMPixelFormat_16BE565
are big endian formats, left over from PowerPC, but still used.
kCMPixelFormat_32ARGB is equivalent to libyuv BGRA
kCMPixelFormat_24RGB is equivalent to libyuv RAW
kCMPixelFormat_16BE555 is similar to libyuv RGBO, but big endian.
kCMPixelFormat_16BE565 is similar to libyuv RGBP, but big endian.

Original comment by fbarch...@chromium.org on 19 May 2013 at 6:27

GoogleCodeExporter commented 9 years ago
Fixed in r698
  kCMPixelFormat_32ARGB          = 32,  -> FOURCC_CM32
  kCMPixelFormat_24RGB           = 24,  -> FOURCC_CM24

This is how the others map across if anyone needs them:
enum {
  kCMPixelFormat_32ARGB          = 32,      FOURCC_BGRA
  kCMPixelFormat_32BGRA          = 'BGRA',  FOURCC_ARGB
  kCMPixelFormat_24RGB           = 24,      FOURCC_RAW
  kCMPixelFormat_16BE555         = 16,      Not supported.
  kCMPixelFormat_16BE565         = 'B565',  Not supported.
  kCMPixelFormat_16LE555         = 'L555',  FOURCC_RGBO
  kCMPixelFormat_16LE565         = 'L565',  FOURCC_RGBP
  kCMPixelFormat_16LE5551        = '5551',  Not supported
  kCMPixelFormat_422YpCbCr8      = '2vuy',  FOURCC_UYVY
  kCMPixelFormat_422YpCbCr8_yuvs = 'yuvs',  FOURCC_YUY2
  kCMPixelFormat_444YpCbCr8      = 'v308',  FOURCC_I444 ?
  kCMPixelFormat_4444YpCbCrA8    = 'v408',  Not supported.
  kCMPixelFormat_422YpCbCr16     = 'v216',  Not supported.
  kCMPixelFormat_422YpCbCr10     = 'v210',  FOURCC_V210 previously.  Removed now.
  kCMPixelFormat_444YpCbCr10     = 'v410',  Not supported.
  kCMPixelFormat_8IndexedGray_WhiteIsZero = 0x00000028,  Not supported.
};

Original comment by fbarch...@chromium.org on 19 May 2013 at 6:56

GoogleCodeExporter commented 9 years ago
Unfortunately, not fixed :-/ kCMPixelFormat_32BGRA is supposed to be 
FOURCC_ARGB, but since it is 'BGRA', it is read as BGRA.

We should be careful, though, since you could end up with:
format = GetCanonicalFormat(kCMPixelFormat_32ARGB) -> format is 'BGRA'
format = GetCanonicalFormat(format) -> format is now 'ARGB'!

...which is sorta scary :(

Original comment by noah...@chromium.org on 30 Dec 2013 at 7:48

GoogleCodeExporter commented 9 years ago
So FOURCC_BGRA means FOURCC_ARGB on OSX... and likely iOS.
It would be risky to map CM32 to FOURCC_BGRA and also have a mapping for 
FOURCC_BGRA to FOURCC_ARGB.

Original comment by fbarch...@google.com on 31 Dec 2013 at 1:36

GoogleCodeExporter commented 9 years ago
The ARGB formats are working now and documented.  Will leave it at that.. case 
by case for advanced formats like 16 bit channels.

Original comment by fbarch...@google.com on 25 Oct 2014 at 12:21