mirror of
https://github.com/pion/mediadevices.git
synced 2025-09-26 20:41:46 +08:00
fix i422ToI420 calculation, add mock FastBoxSampling
This commit is contained in:

committed by
Eric Daniels

parent
0dc4f43c94
commit
bf290b026c
@@ -57,8 +57,8 @@ func i422ToI420(img image.YCbCr, dst []uint8) image.YCbCr {
|
||||
for j := 0; j < img.CStride; j++ {
|
||||
cb := uint16(img.Cb[addrSrc]) + uint16(img.Cb[addrSrc+img.CStride])
|
||||
cr := uint16(img.Cr[addrSrc]) + uint16(img.Cr[addrSrc+img.CStride])
|
||||
cbDst[addrDst] = uint8(cb / 4)
|
||||
crDst[addrDst] = uint8(cr / 4)
|
||||
cbDst[addrDst] = uint8(cb / 2)
|
||||
crDst[addrDst] = uint8(cr / 2)
|
||||
addrSrc++
|
||||
addrDst++
|
||||
}
|
||||
|
@@ -526,6 +526,9 @@ func TestScale(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestScaleFastBoxSampling(t *testing.T) {
|
||||
if !hasCGOConvert {
|
||||
t.Skip("Skip: nocgo implementation is not supported for FastBoxSampling")
|
||||
}
|
||||
cases := map[string]struct {
|
||||
src image.Image
|
||||
width, height int
|
||||
|
22
pkg/io/video/scaler_nocgo.go
Normal file
22
pkg/io/video/scaler_nocgo.go
Normal file
@@ -0,0 +1,22 @@
|
||||
//go:build !cgo
|
||||
// +build !cgo
|
||||
|
||||
package video
|
||||
|
||||
import (
|
||||
"golang.org/x/image/draw"
|
||||
"image"
|
||||
)
|
||||
|
||||
// ScalerFastBoxSampling mock scaler for nocgo implementation to pass tests for CGO_ENABLED=0
|
||||
var (
|
||||
ScalerFastBoxSampling = Scaler(&FastBoxSampling{})
|
||||
)
|
||||
|
||||
// FastBoxSampling mock implementation for nocgo implementation
|
||||
// TODO implement nocgo FastBoxSampling scaling algorithm
|
||||
type FastBoxSampling struct {
|
||||
}
|
||||
|
||||
func (f *FastBoxSampling) Scale(_ draw.Image, _ image.Rectangle, _ image.Image, _ image.Rectangle, _ draw.Op, _ *draw.Options) {
|
||||
}
|
Reference in New Issue
Block a user