[FFmpeg-cvslog] r18406 - in trunk/libavcodec: h264.c h264.h h264_parser.c
reimar
subversion
Fri Apr 10 09:01:56 CEST 2009
Author: reimar
Date: Fri Apr 10 09:01:55 2009
New Revision: 18406
Log:
Add a ff_h264_free_context function and call it from the H.264 parser.
This ensures that the parser will no longer leak memory for all SPS/PPS it encounters.
Modified:
trunk/libavcodec/h264.c
trunk/libavcodec/h264.h
trunk/libavcodec/h264_parser.c
Modified: trunk/libavcodec/h264.c
==============================================================================
--- trunk/libavcodec/h264.c Fri Apr 10 02:09:07 2009 (r18405)
+++ trunk/libavcodec/h264.c Fri Apr 10 09:01:55 2009 (r18406)
@@ -8083,10 +8083,8 @@ int main(void){
#endif /* TEST */
-static av_cold int decode_end(AVCodecContext *avctx)
+av_cold ff_h264_free_context(H264Context *h)
{
- H264Context *h = avctx->priv_data;
- MpegEncContext *s = &h->s;
int i;
av_freep(&h->rbsp_buffer[0]);
@@ -8098,6 +8096,14 @@ static av_cold int decode_end(AVCodecCon
for(i = 0; i < MAX_PPS_COUNT; i++)
av_freep(h->pps_buffers + i);
+}
+
+static av_cold int decode_end(AVCodecContext *avctx)
+{
+ H264Context *h = avctx->priv_data;
+ MpegEncContext *s = &h->s;
+
+ ff_h264_free_context(h);
MPV_common_end(s);
Modified: trunk/libavcodec/h264.h
==============================================================================
--- trunk/libavcodec/h264.h Fri Apr 10 02:09:07 2009 (r18405)
+++ trunk/libavcodec/h264.h Fri Apr 10 09:01:55 2009 (r18406)
@@ -569,4 +569,9 @@ const uint8_t *ff_h264_decode_nal(H264Co
*/
int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src);
+/**
+ * frees any data that may have been allocated in the H264 context like SPS, PPS etc.
+ */
+av_cold ff_h264_free_context(H264Context *h);
+
#endif /* AVCODEC_H264_H */
Modified: trunk/libavcodec/h264_parser.c
==============================================================================
--- trunk/libavcodec/h264_parser.c Fri Apr 10 02:09:07 2009 (r18405)
+++ trunk/libavcodec/h264_parser.c Fri Apr 10 09:01:55 2009 (r18406)
@@ -306,6 +306,7 @@ static void close(AVCodecParserContext *
ParseContext *pc = &h->s.parse_context;
av_free(pc->buffer);
+ ff_h264_free_context(h);
}
More information about the ffmpeg-cvslog
mailing list