Add decoder support for pixel format BGRA & ARGB#315
Add decoder support for pixel format BGRA & ARGB#315
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #315 +/- ##
==========================================
- Coverage 44.51% 44.22% -0.29%
==========================================
Files 80 81 +1
Lines 5556 5592 +36
==========================================
Hits 2473 2473
- Misses 2913 2949 +36
Partials 170 170 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| *(*uint32)(unsafe.Pointer(&frame[i])) = func(v uint32) uint32 { | ||
| return (v & 0xFF00FF00) | (v&0xFF)<<16 | (v&0xFF0000)>>16 | ||
| }(*(*uint32)(unsafe.Pointer(&frame[i]))) | ||
| //frame[i], frame[i+2] = frame[i+2], frame[i] |
There was a problem hiding this comment.
It seems like a conversion from ARGB to GRAB. (frame[i] is A and frame[i+2] is G in the original ARGB data)
Maybe the implementations of decodeARGB and decodeBGRA are swapped?
There was a problem hiding this comment.
I think it only matters to the name of the pixel format.
according to libyuv formats:
kCMPixelFormat_32ARGB = 32, FOURCC_BGRA
kCMPixelFormat_32BGRA = 'BGRA', FOURCC_ARGBand I use the FOURCC_* naming to to name frame.FormatBGRA and frame.FormatARGB which results a similar mapping in avfoundation pkg.
There was a problem hiding this comment.
Sorry, I misread endian. (It should be little endian on x86 and ARM)
This func seems converting 0xXXYYZZWW (input) to 0xXXWWZZYY (output).
As the output byte order for image.RGBA is RGBA order (XX=A, WW=B, ZZ=G, YY=R on little endian uint32), input byte order shoud be BGRA.
I guess
https://github.com/pion/mediadevices/pull/315/files#diff-99707109ce57457c8ab1161707d059373858d14ae66e06aed05c50501e29eaa6R148-R153
https://github.com/pion/mediadevices/pull/315/files#diff-99707109ce57457c8ab1161707d059373858d14ae66e06aed05c50501e29eaa6R179-R184
are reversed and name of decodeARGB and decodeBGRA should be swapped?
(I don't have any Macintosh computers, so I couldn't test it on the real environment.)
| r := image.Rect(0, 0, width, height) | ||
| for i := 0; i < size; i += 4 { | ||
| *(*uint32)(unsafe.Pointer(&frame[i])) = bits.RotateLeft32(*(*uint32)(unsafe.Pointer(&frame[i])), -8) | ||
| //frame[i], frame[i+1], frame[i+2], frame[i+3] = frame[i+1], frame[i+2], frame[i+3], frame[i] |
| "fmt" | ||
| "testing" | ||
| ) | ||
|
|
There was a problem hiding this comment.
It would be nice to have a simple test like:
mediadevices/pkg/frame/yuv_test.go
Lines 10 to 41 in dafd208
|
HI @zyxar, do you still want to get this in? |
Description
This PR adds decoder support for pixel format
BGRA&ARGB, and enables them in pkgavfoundation.