Add support of the 0RGB1555 pixel format

This commit is contained in:
Sergey Stepanov 2024-03-08 18:43:23 +03:00
parent 72e846894e
commit 43d3f84993
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
4 changed files with 6 additions and 3 deletions

View file

@ -97,6 +97,8 @@ func (v *Video) SetPixFormat(f uint32) {
}
switch f {
case 0:
v.pf = yuv.PixFmt(yuv.FourccRgb0)
case 1:
v.pf = yuv.PixFmt(yuv.FourccArgb)
case 2:

View file

@ -35,6 +35,7 @@ enum FourCC {
FOURCC_I420 = FOURCC('I', '4', '2', '0'),
FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'),
FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE.
FOURCC_ANY = -1,
};
@ -102,6 +103,7 @@ import "fmt"
const FourccRgbp uint32 = C.FOURCC_RGBP
const FourccArgb uint32 = C.FOURCC_ARGB
const FourccAbgr uint32 = C.FOURCC_ABGR
const FourccRgb0 uint32 = C.FOURCC_RGBO
func Y420(src []byte, dst []byte, _, h, stride int, dw, dh int, rot uint, pix uint32, cx, cy int) {
cw := (dw + 1) / 2

View file

@ -25,6 +25,7 @@ type PixFmt uint32
const FourccRgbp = libyuv.FourccRgbp
const FourccArgb = libyuv.FourccArgb
const FourccAbgr = libyuv.FourccAbgr
const FourccRgb0 = libyuv.FourccRgb0
func NewYuvConv(w, h int, scale float64) Conv {
if scale < 1 {
@ -47,7 +48,7 @@ func (c *Conv) Process(frame RawFrame, rot uint, pf PixFmt) []byte {
}
stride := frame.Stride >> 2
if pf == PixFmt(libyuv.FourccRgbp) {
if pf == PixFmt(libyuv.FourccRgbp) || pf == PixFmt(libyuv.FourccRgb0) {
stride = frame.Stride >> 1
}

View file

@ -378,8 +378,6 @@ func videoSetPixelFormat(format uint32) (C.bool, error) {
if err := graphics.SetPixelFormat(graphics.UnsignedShort5551); err != nil {
return false, fmt.Errorf("unknown pixel format %v", Nan0.Video.PixFmt)
}
// format is not implemented
return false, fmt.Errorf("unsupported pixel type %v converter", format)
case C.RETRO_PIXEL_FORMAT_XRGB8888:
Nan0.Video.PixFmt = RGBA8888Rev
if err := graphics.SetPixelFormat(graphics.UnsignedInt8888Rev); err != nil {