Skip to content

Commit

Permalink
Use avcodec_free_context() instead of avcodec_close()
Browse files Browse the repository at this point in the history
This is stated in ffmpeg api documentation:
`Do not use this function. Use avcodec_free_context() to destroy a codec context (either open or closed). Opening and closing a codec context multiple times is not supported anymore – use multiple codec contexts instead.`

av_freep -calls are also performed inside avcodec_free_context() so remove them
  • Loading branch information
pesintta committed Mar 18, 2018
1 parent a6aac5f commit 01bad31
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ void CodecVideoClose(VideoDecoder * video_decoder)

if (video_decoder->VideoCtx) {
pthread_mutex_lock(&CodecLockMutex);
avcodec_close(video_decoder->VideoCtx);
av_freep(&video_decoder->VideoCtx);
avcodec_free_context(&video_decoder->VideoCtx);
pthread_mutex_unlock(&CodecLockMutex);
}
}
Expand Down Expand Up @@ -454,8 +453,7 @@ void CodecAudioClose(AudioDecoder * audio_decoder)
}
if (audio_decoder->AudioCtx) {
pthread_mutex_lock(&CodecLockMutex);
avcodec_close(audio_decoder->AudioCtx);
av_freep(&audio_decoder->AudioCtx);
avcodec_free_context(&audio_decoder->AudioCtx);
pthread_mutex_unlock(&CodecLockMutex);
}
}
Expand Down

0 comments on commit 01bad31

Please sign in to comment.