[FFmpeg-cvslog] examples: Properly free AVCodecContext

Vittorio Giovara git at videolan.org
Tue Jan 31 18:35:52 EET 2017


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Jul 20 16:10:17 2016 +0200| [9833a406d3d743d238e4cbee08ffcaa12e067dd2] | committer: Vittorio Giovara

examples: Properly free AVCodecContext

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9833a406d3d743d238e4cbee08ffcaa12e067dd2
---

 doc/examples/avcodec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/doc/examples/avcodec.c b/doc/examples/avcodec.c
index f8d043f..8fee552 100644
--- a/doc/examples/avcodec.c
+++ b/doc/examples/avcodec.c
@@ -213,8 +213,7 @@ static void audio_encode_example(const char *filename)
 
     av_freep(&samples);
     av_frame_free(&frame);
-    avcodec_close(c);
-    av_free(c);
+    avcodec_free_context(&c);
 }
 
 /*
@@ -305,8 +304,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
     fclose(outfile);
     fclose(f);
 
-    avcodec_close(c);
-    av_free(c);
+    avcodec_free_context(&c);
     av_frame_free(&decoded_frame);
 }
 
@@ -428,8 +426,7 @@ static void video_encode_example(const char *filename)
     fwrite(endcode, 1, sizeof(endcode), f);
     fclose(f);
 
-    avcodec_close(c);
-    av_free(c);
+    avcodec_free_context(&c);
     av_freep(&picture->data[0]);
     av_frame_free(&picture);
     printf("\n");
@@ -565,8 +562,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
 
     fclose(f);
 
-    avcodec_close(c);
-    av_free(c);
+    avcodec_free_context(&c);
     av_frame_free(&picture);
     printf("\n");
 }



More information about the ffmpeg-cvslog mailing list