... | ... |
@@ -321,21 +321,10 @@ static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region) |
321 | 321 |
|
322 | 322 |
} |
323 | 323 |
|
324 |
-static void delete_state(DVBSubContext *ctx) |
|
324 |
+static void delete_cluts(DVBSubContext *ctx) |
|
325 | 325 |
{ |
326 |
- DVBSubRegion *region; |
|
327 | 326 |
DVBSubCLUT *clut; |
328 | 327 |
|
329 |
- while (ctx->region_list) { |
|
330 |
- region = ctx->region_list; |
|
331 |
- |
|
332 |
- ctx->region_list = region->next; |
|
333 |
- |
|
334 |
- delete_region_display_list(ctx, region); |
|
335 |
- av_free(region->pbuf); |
|
336 |
- av_free(region); |
|
337 |
- } |
|
338 |
- |
|
339 | 328 |
while (ctx->clut_list) { |
340 | 329 |
clut = ctx->clut_list; |
341 | 330 |
|
... | ... |
@@ -343,12 +332,35 @@ static void delete_state(DVBSubContext *ctx) |
343 | 343 |
|
344 | 344 |
av_free(clut); |
345 | 345 |
} |
346 |
+} |
|
346 | 347 |
|
347 |
- av_freep(&ctx->display_definition); |
|
348 |
+static void delete_objects(DVBSubContext *ctx) |
|
349 |
+{ |
|
350 |
+ DVBSubObject *object; |
|
348 | 351 |
|
349 |
- /* Should already be null */ |
|
350 |
- if (ctx->object_list) |
|
351 |
- av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n"); |
|
352 |
+ while (ctx->object_list) { |
|
353 |
+ object = ctx->object_list; |
|
354 |
+ |
|
355 |
+ ctx->object_list = object->next; |
|
356 |
+ |
|
357 |
+ av_free(object); |
|
358 |
+ } |
|
359 |
+} |
|
360 |
+ |
|
361 |
+static void delete_regions(DVBSubContext *ctx) |
|
362 |
+{ |
|
363 |
+ DVBSubRegion *region; |
|
364 |
+ |
|
365 |
+ while (ctx->region_list) { |
|
366 |
+ region = ctx->region_list; |
|
367 |
+ |
|
368 |
+ ctx->region_list = region->next; |
|
369 |
+ |
|
370 |
+ delete_region_display_list(ctx, region); |
|
371 |
+ |
|
372 |
+ av_free(region->pbuf); |
|
373 |
+ av_free(region); |
|
374 |
+ } |
|
352 | 375 |
} |
353 | 376 |
|
354 | 377 |
static av_cold int dvbsub_init_decoder(AVCodecContext *avctx) |
... | ... |
@@ -433,7 +445,13 @@ static av_cold int dvbsub_close_decoder(AVCodecContext *avctx) |
433 | 433 |
DVBSubContext *ctx = avctx->priv_data; |
434 | 434 |
DVBSubRegionDisplay *display; |
435 | 435 |
|
436 |
- delete_state(ctx); |
|
436 |
+ delete_regions(ctx); |
|
437 |
+ |
|
438 |
+ delete_objects(ctx); |
|
439 |
+ |
|
440 |
+ delete_cluts(ctx); |
|
441 |
+ |
|
442 |
+ av_freep(&ctx->display_definition); |
|
437 | 443 |
|
438 | 444 |
while (ctx->display_list) { |
439 | 445 |
display = ctx->display_list; |
... | ... |
@@ -1125,7 +1143,9 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, |
1125 | 1125 |
av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state); |
1126 | 1126 |
|
1127 | 1127 |
if (page_state == 2) { |
1128 |
- delete_state(ctx); |
|
1128 |
+ delete_regions(ctx); |
|
1129 |
+ delete_objects(ctx); |
|
1130 |
+ delete_cluts(ctx); |
|
1129 | 1131 |
} |
1130 | 1132 |
|
1131 | 1133 |
tmp_display_list = ctx->display_list; |