Update about packed and planar YUV formats

This commit is contained in:
Alex X
2025-01-10 15:01:01 +03:00
parent 7dc9beb171
commit 83907132b5
4 changed files with 19 additions and 5 deletions
+2 -2
View File
@@ -196,7 +196,7 @@ func (d *Device) StreamOff() (err error) {
return ioctl(d.fd, VIDIOC_REQBUFS, unsafe.Pointer(&rb))
}
func (d *Device) Capture(cositedYUV bool) ([]byte, error) {
func (d *Device) Capture(planarYUV bool) ([]byte, error) {
dec := v4l2_buffer{
typ: V4L2_BUF_TYPE_VIDEO_CAPTURE,
memory: V4L2_MEMORY_MMAP,
@@ -206,7 +206,7 @@ func (d *Device) Capture(cositedYUV bool) ([]byte, error) {
}
buf := make([]byte, dec.bytesused)
if cositedYUV {
if planarYUV {
YUYV2YUV(buf, d.bufs[dec.index][:dec.bytesused])
} else {
copy(buf, d.bufs[dec.index][:dec.bytesused])
+1 -1
View File
@@ -16,7 +16,7 @@ var Formats = []Format{
{V4L2_PIX_FMT_MJPEG, "Motion-JPEG", "mjpeg"},
}
// YUYV2YUV convert [Y0 Cb Y1 Cr] to cosited [Y0Y1... Cb... Cr...]
// YUYV2YUV convert packed YUV to planar YUV
func YUYV2YUV(dst, src []byte) {
n := len(src)
i0 := 0