Skip to content

Commit

Permalink
Add support of the 0RGB1555 pixel format
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Mar 8, 2024
1 parent 72e8468 commit 43d3f84
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/encoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions pkg/encoder/yuv/libyuv/libyuv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/encoder/yuv/yuv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/worker/caged/libretro/nanoarch/nanoarch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 43d3f84

Please sign in to comment.