Mercurial > libavcodec.hg
changeset 9380:54e650136c87 libavcodec
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.
author | reimar |
---|---|
date | Fri, 10 Apr 2009 07:01:55 +0000 |
parents | d31c367da415 |
children | 7dfbd59b04e5 |
files | h264.c h264.h h264_parser.c |
diffstat | 3 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/h264.c Fri Apr 10 00:09:07 2009 +0000 +++ b/h264.c Fri Apr 10 07:01:55 2009 +0000 @@ -8083,10 +8083,8 @@ #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 @@ 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);
--- a/h264.h Fri Apr 10 00:09:07 2009 +0000 +++ b/h264.h Fri Apr 10 07:01:55 2009 +0000 @@ -569,4 +569,9 @@ */ 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 */