fix i422ToI420 calculation, add mock FastBoxSampling

This commit is contained in:
Abdarrakhman Akhmetgali
2023-04-15 17:56:41 +06:00
committed by Eric Daniels
parent 0dc4f43c94
commit bf290b026c
3 changed files with 27 additions and 2 deletions

View File

@@ -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++
}

View File

@@ -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

View 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) {
}