[Libav-user] Hi, question regarding closing a codec context

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Hi, question regarding closing a codec context

Dafna Hirschfeld
 I use the ffmpeg api to decode video.
After allocating and opening a AvCodecContext with avcodec_open2, then when decoding finishes, is it valid to call just       avcodec_flush_buffers and avcodec_free_context without calling avcodec_close ?

thanks
Dafna

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|

Re: Hi, question regarding closing a codec context

Jaka Bac
On 23 August 2017 at 12:21, Dafna Hirschfeld <[hidden email]> wrote:
 I use the ffmpeg api to decode video.
After allocating and opening a AvCodecContext with avcodec_open2, then when decoding finishes, is it valid to call just       avcodec_flush_buffers and avcodec_free_context without calling avcodec_close ?

thanks
Dafna
 

Hi Dafna,

avcodec_free_context actually does this:

void avcodec_free_context(AVCodecContext **pavctx)
{
       AVCodecContext *avctx = *pavctx;
   
       if (!avctx)
           return;
   
       avcodec_close(avctx);
   
       av_freep(&avctx->extradata);
       av_freep(&avctx->subtitle_header);
       av_freep(&avctx->intra_matrix);
       av_freep(&avctx->inter_matrix);
       av_freep(&avctx->rc_override);
   
       av_freep(pavctx);
}

From what I know avcodec_close should not be used anymore in the latest ffmpeg versions.

Jaka

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user