On 04/08, Will Kelleher wrote: > > The leak is...continuous. We only noticed it during long running decode > operations because the amount is small, but it definitely adds up. > Hi all,
I finally got some time to revisit this. In the simple case where we are not decoding the HEVC bitstream, the parser never frees the caption data. This patch adds a function similar to what the H.264 decoder is using to free SEI data. This gets called near the top of each parse_nal_units run to clear any SEI data from the previous picture. This is almost a copy-paste from the H.264 solution. I would love to get this in, because anyone using an HEVC input with bitstream caption data is going to see this leak. Thanks, will
>From d2aa2530b7d808c3710db7b627b96f4159bef460 Mon Sep 17 00:00:00 2001 From: Will Kelleher <wkelle...@gogoair.com> Date: Thu, 7 Apr 2016 08:58:31 -0500 Subject: [PATCH] hevc: Fix memory leak related to a53_caption data Signed-off-by: Will Kelleher <wkelle...@gogoair.com> --- libavcodec/hevc.c | 2 ++ libavcodec/hevc.h | 9 +++++++++ libavcodec/hevc_parser.c | 2 ++ libavcodec/hevc_sei.c | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index d1aa0b0..b478065 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -3155,6 +3155,8 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) s->context_initialized = 1; s->eos = 0; + ff_hevc_reset_sei(s); + return 0; fail: diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h index f44fa49..be91010 100644 --- a/libavcodec/hevc.h +++ b/libavcodec/hevc.h @@ -1054,6 +1054,15 @@ void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size); int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id, uint8_t *buf, int buf_size); +/** + * Reset SEI values that are stored on the Context. + * e.g. Caption data that was extracted during NAL + * parsing. + * + * @param s HEVCContext. + */ +void ff_hevc_reset_sei(HEVCContext *s); + extern const uint8_t ff_hevc_qpel_extra_before[4]; extern const uint8_t ff_hevc_qpel_extra_after[4]; extern const uint8_t ff_hevc_qpel_extra[4]; diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index 1227358..b5633f1 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -211,6 +211,8 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, h->avctx = avctx; + ff_hevc_reset_sei(h); + if (!buf_size) return 0; diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 40685fe..59c5941 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -373,3 +373,10 @@ int ff_hevc_decode_nal_sei(HEVCContext *s) } while (more_rbsp_data(&s->HEVClc->gb)); return 1; } + +void ff_hevc_reset_sei(HEVCContext *s) +{ + s->a53_caption_size = 0; + av_freep(&s->a53_caption); +} + -- 2.8.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel