Do not store temporary pictures as vmaf_read_pictures unrefs them
This commit is contained in:
parent
322e4466d1
commit
7662721dca
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue