summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xine/BluRay/decode_spuhdmv.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/xine/BluRay/decode_spuhdmv.c b/xine/BluRay/decode_spuhdmv.c
index 9011a9f2..3465aa6d 100644
--- a/xine/BluRay/decode_spuhdmv.c
+++ b/xine/BluRay/decode_spuhdmv.c
@@ -84,11 +84,9 @@ struct subtitle_object_s {
uint num_rle;
size_t data_size;
-#if 0
uint8_t *raw_data; /* partial RLE data in HDMV format */
size_t raw_data_len;
size_t raw_data_size;
-#endif
subtitle_object_t *next;
@@ -156,7 +154,7 @@ struct presentation_segment_s {
* list handling
*/
-#define LIST_REPLACE(list, obj) \
+#define LIST_REPLACE(list, obj, FREE_FUNC) \
do { \
uint id = obj->id; \
\
@@ -170,16 +168,32 @@ struct presentation_segment_s {
if (obj->next) { \
void *tmp = (void*)obj->next; \
obj->next = obj->next->next; \
- free(tmp); \
+ FREE_FUNC(tmp); \
} \
} while (0);
-#define LIST_DESTROY(list) \
+#define LIST_DESTROY(list, FREE_FUNC) \
while (list) { \
void *tmp = (void*)list; \
list = list->next; \
- free (tmp); \
+ FREE_FUNC(tmp); \
+ }
+
+static void free_subtitle_object(void *ptr)
+{
+ if (ptr) {
+ free(((subtitle_object_t*)ptr)->rle);
+ free(ptr);
+ }
+}
+static void free_presentation_segment(void *ptr)
+{
+ if (ptr) {
+ presentation_segment_t *seg = (presentation_segment_t*)ptr;
+ LIST_DESTROY(seg->comp_objs, free);
+ free(ptr);
}
+}
/*
@@ -596,7 +610,7 @@ static int decode_palette(spuhdmv_decoder_t *this)
if (!clut)
return 1;
- LIST_REPLACE (this->cluts, clut);
+ LIST_REPLACE (this->cluts, clut, free);
return 0;
}
@@ -608,7 +622,7 @@ static int decode_object(spuhdmv_decoder_t *this)
if (!obj)
return 1;
- LIST_REPLACE (this->objects, obj);
+ LIST_REPLACE (this->objects, obj, free_subtitle_object);
return 0;
}
@@ -620,7 +634,7 @@ static int decode_window_definition(spuhdmv_decoder_t *this)
if (!wnd)
return 1;
- LIST_REPLACE (this->windows, wnd);
+ LIST_REPLACE (this->windows, wnd, free);
return 0;
}
@@ -715,8 +729,6 @@ static int show_overlay(spuhdmv_decoder_t *this, composition_object_t *cobj, uin
ovl_manager->add_event (ovl_manager, (void *)&event);
- obj->rle = NULL;
-
return 0;
}
@@ -790,12 +802,19 @@ static int decode_presentation_segment(spuhdmv_decoder_t *this)
hide_overlays (this, this->pts);
} else {
show_overlays (this, &p);
- LIST_DESTROY (p.comp_objs);
+ LIST_DESTROY (p.comp_objs, free);
}
return buf->error;
}
+static void free_objs(spuhdmv_decoder_t *this)
+{
+ LIST_DESTROY (this->cluts , free);
+ LIST_DESTROY (this->objects, free_subtitle_object);
+ LIST_DESTROY (this->windows, free);
+}
+
static void decode_segment(spuhdmv_decoder_t *this)
{
TRACE("*** new segment, pts %010ld: 0x%02x (%8d bytes)",
@@ -887,9 +906,7 @@ static void spudec_reset (spu_decoder_t * this_gen)
if (this->buf)
segbuf_reset(this->buf);
- LIST_DESTROY (this->cluts);
- LIST_DESTROY (this->objects);
- LIST_DESTROY (this->windows);
+ free_objs(this);
close_osd(this);
}
@@ -908,9 +925,7 @@ static void spudec_dispose (spu_decoder_t *this_gen)
close_osd (this);
segbuf_dispose (this->buf);
- LIST_DESTROY (this->cluts);
- LIST_DESTROY (this->objects);
- LIST_DESTROY (this->windows);
+ free_objs(this);
free (this);
}