[FFmpeg-cvslog] dvbsubdec: Split delete_state()
JULIAN GARDNER
git at videolan.org
Wed May 4 23:36:20 CEST 2011
ffmpeg | branch: master | JULIAN GARDNER <joolzg at btinternet.com> | Wed May 4 20:44:14 2011 +0200| [e822c237b3f78bb6f0f6ba5219a2a6cab3b27ce4] | committer: Michael Niedermayer
dvbsubdec: Split delete_state()
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e822c237b3f78bb6f0f6ba5219a2a6cab3b27ce4
---
libavcodec/dvbsubdec.c | 56 ++++++++++++++++++++++++++++++++---------------
1 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 288e6f5..cd2b53d 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -321,21 +321,10 @@ static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region)
}
-static void delete_state(DVBSubContext *ctx)
+static void delete_cluts(DVBSubContext *ctx)
{
- DVBSubRegion *region;
DVBSubCLUT *clut;
- while (ctx->region_list) {
- region = ctx->region_list;
-
- ctx->region_list = region->next;
-
- delete_region_display_list(ctx, region);
- av_free(region->pbuf);
- av_free(region);
- }
-
while (ctx->clut_list) {
clut = ctx->clut_list;
@@ -343,12 +332,35 @@ static void delete_state(DVBSubContext *ctx)
av_free(clut);
}
+}
- av_freep(&ctx->display_definition);
+static void delete_objects(DVBSubContext *ctx)
+{
+ DVBSubObject *object;
- /* Should already be null */
- if (ctx->object_list)
- av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n");
+ while (ctx->object_list) {
+ object = ctx->object_list;
+
+ ctx->object_list = object->next;
+
+ av_free(object);
+ }
+}
+
+static void delete_regions(DVBSubContext *ctx)
+{
+ DVBSubRegion *region;
+
+ while (ctx->region_list) {
+ region = ctx->region_list;
+
+ ctx->region_list = region->next;
+
+ delete_region_display_list(ctx, region);
+
+ av_free(region->pbuf);
+ av_free(region);
+ }
}
static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
@@ -433,7 +445,13 @@ static av_cold int dvbsub_close_decoder(AVCodecContext *avctx)
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegionDisplay *display;
- delete_state(ctx);
+ delete_regions(ctx);
+
+ delete_objects(ctx);
+
+ delete_cluts(ctx);
+
+ av_freep(&ctx->display_definition);
while (ctx->display_list) {
display = ctx->display_list;
@@ -1125,7 +1143,9 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if (page_state == 2) {
- delete_state(ctx);
+ delete_regions(ctx);
+ delete_objects(ctx);
+ delete_cluts(ctx);
}
tmp_display_list = ctx->display_list;
More information about the ffmpeg-cvslog
mailing list