From 43d3f84993bef136c47210b7f9e4417a7e5c8b20 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Fri, 8 Mar 2024 18:43:23 +0300 Subject: [PATCH] Add support of the 0RGB1555 pixel format --- pkg/encoder/encoder.go | 2 ++ pkg/encoder/yuv/libyuv/libyuv.go | 2 ++ pkg/encoder/yuv/yuv.go | 3 ++- pkg/worker/caged/libretro/nanoarch/nanoarch.go | 2 -- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/encoder/encoder.go b/pkg/encoder/encoder.go index a323290b..550f75d1 100644 --- a/pkg/encoder/encoder.go +++ b/pkg/encoder/encoder.go @@ -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: diff --git a/pkg/encoder/yuv/libyuv/libyuv.go b/pkg/encoder/yuv/libyuv/libyuv.go index e7a19739..07c0b8c1 100644 --- a/pkg/encoder/yuv/libyuv/libyuv.go +++ b/pkg/encoder/yuv/libyuv/libyuv.go @@ -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 diff --git a/pkg/encoder/yuv/yuv.go b/pkg/encoder/yuv/yuv.go index 82f59ea7..25d591d1 100644 --- a/pkg/encoder/yuv/yuv.go +++ b/pkg/encoder/yuv/yuv.go @@ -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 } diff --git a/pkg/worker/caged/libretro/nanoarch/nanoarch.go b/pkg/worker/caged/libretro/nanoarch/nanoarch.go index 0ae21175..95cd24a6 100644 --- a/pkg/worker/caged/libretro/nanoarch/nanoarch.go +++ b/pkg/worker/caged/libretro/nanoarch/nanoarch.go @@ -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 {