[FFmpeg-devel] [PATCH] avcodec_free_context instead of close+av_free

Lectem lectem at gmail.com
Sat Jul 11 19:24:02 CEST 2015


If I understood the source and documentation correctly, avcodec_free_context should now be used to free a context instead of avcodec_close + av_free.
---
 doc/examples/decoding_encoding.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
index f6643f6..e257501 100644
--- a/doc/examples/decoding_encoding.c
+++ b/doc/examples/decoding_encoding.c
@@ -232,8 +232,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);
 }
 
 /*
@@ -279,7 +278,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
     }
     outfile = fopen(outfilename, "wb");
     if (!outfile) {
-        av_free(c);
+        avcodec_free_context(c);
         exit(1);
     }
 
@@ -336,8 +335,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);
 }
 
@@ -479,8 +477,7 @@ static void video_encode_example(const char *filename, int codec_id)
     fwrite(endcode, 1, sizeof(endcode), f);
     fclose(f);
 
-    avcodec_close(c);
-    av_free(c);
+    avcodec_free_context(c);
     av_freep(&frame->data[0]);
     av_frame_free(&frame);
     printf("\n");
@@ -622,8 +619,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(&frame);
     printf("\n");
 }
-- 
1.9.5.msysgit.0



More information about the ffmpeg-devel mailing list