Do not store temporary pictures as vmaf_read_pictures unrefs them

This commit is contained in:
DataHoarder 2022-11-12 11:04:17 +01:00
parent 322e4466d1
commit 7662721dca
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

View file

@ -19,9 +19,8 @@ func Version() string {
}
type VMAF struct {
context *C.VmafContext
model *C.VmafModel
pictures []*C.VmafPicture
context *C.VmafContext
model *C.VmafModel
}
type ModelFlags uint64
@ -229,19 +228,15 @@ func (v *VMAF) ReadPictures(reference, distorted frame.Frame, index uint) error
ref := v.frameToPicture(reference)
dist := v.frameToPicture(distorted)
defer v.deallocatePicture(ref)
defer v.deallocatePicture(dist)
if ref == nil || dist == nil {
v.deallocatePicture(ref)
v.deallocatePicture(dist)
return errors.New("could not allocate pictures")
}
if ret := C.vmaf_read_pictures(v.context, ref, dist, C.uint(index)); ret != 0 {
v.deallocatePicture(ref)
v.deallocatePicture(dist)
return fmt.Errorf("vmaf_read_pictures error %d", ret)
} else {
//save memory
v.pictures = append(v.pictures, ref)
v.pictures = append(v.pictures, dist)
return nil
}
}