mirror of
https://github.com/kerberos-io/agent.git
synced 2026-10-23 18:18:24 +00:00
Update codec context and frame deallocation methods
Replaced avcodec_close with avcodec_free_context for proper resource management.
This commit is contained in:
@@ -1527,13 +1527,13 @@ func newDecoder(codecName string) (*Decoder, error) {
|
||||
|
||||
res := C.avcodec_open2(codecCtx, codec, nil)
|
||||
if res < 0 {
|
||||
C.avcodec_close(codecCtx)
|
||||
C.avcodec_free_context(&codecCtx)
|
||||
return nil, fmt.Errorf("avcodec_open2() failed")
|
||||
}
|
||||
|
||||
srcFrame := C.av_frame_alloc()
|
||||
if srcFrame == nil {
|
||||
C.avcodec_close(codecCtx)
|
||||
C.avcodec_free_context(&codecCtx)
|
||||
return nil, fmt.Errorf("av_frame_alloc() failed")
|
||||
}
|
||||
|
||||
@@ -1549,7 +1549,7 @@ func (d *Decoder) Close() {
|
||||
C.av_frame_free(&d.srcFrame)
|
||||
}
|
||||
C.av_frame_free(&d.srcFrame)
|
||||
C.avcodec_close(d.codecCtx)
|
||||
C.avcodec_free_context(&d.codecCtx)
|
||||
}
|
||||
|
||||
func (d *Decoder) decode(nalu []byte) (image.YCbCr, error) {
|
||||
|
||||
Reference in New Issue
Block a user