Fixed hardware device context buffer unref

This commit is contained in:
Quentin Renard
2024-01-31 14:52:23 +01:00
parent a13f0e58d5
commit d4abd8ded6
2 changed files with 6 additions and 6 deletions

View File

@@ -53,6 +53,9 @@ func newCodecContextFromC(c *C.struct_AVCodecContext) *CodecContext {
}
func (cc *CodecContext) Free() {
if cc.c.hw_device_ctx != nil {
C.av_buffer_unref(&cc.c.hw_device_ctx)
}
C.avcodec_free_context(&cc.c)
}
@@ -290,6 +293,9 @@ func (cc *CodecContext) SendFrame(f *Frame) error {
}
func (cc *CodecContext) SetHardwareDeviceContext(hdc *HardwareDeviceContext) {
if cc.c.hw_device_ctx != nil {
C.av_buffer_unref(&cc.c.hw_device_ctx)
}
cc.c.hw_device_ctx = C.av_buffer_ref(hdc.c)
}