[libbluray-devel] graphics_processor: ignore orphan segments
hpi1
git at videolan.org
Sun Aug 17 19:00:29 CEST 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Aug 17 19:58:34 2014 +0300| [9e2bb8c234c329e21894dbf66f9e71f8f2f28538] | committer: hpi1
graphics_processor: ignore orphan segments
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=9e2bb8c234c329e21894dbf66f9e71f8f2f28538
---
src/libbluray/decoders/graphics_processor.c | 39 +++++++++++++++++++++++++--
src/libbluray/decoders/graphics_processor.h | 2 ++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/libbluray/decoders/graphics_processor.c b/src/libbluray/decoders/graphics_processor.c
index 293767b..479ccaa 100644
--- a/src/libbluray/decoders/graphics_processor.c
+++ b/src/libbluray/decoders/graphics_processor.c
@@ -201,6 +201,11 @@ static int _decode_wds(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
(void)p;
+ if (!s->decoding) {
+ BD_DEBUG(DBG_DECODE, "skipping orphan window definition segment\n");
+ return 0;
+ }
+
s->num_window = 0;
if (pg_decode_windows(bb, &w)) {
@@ -217,6 +222,11 @@ static int _decode_wds(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
static int _decode_ods(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
{
+ if (!s->decoding) {
+ BD_DEBUG(DBG_DECODE, "skipping orphan object definition segment\n");
+ return 0;
+ }
+
/* search for object to be updated */
if (s->object) {
@@ -259,6 +269,11 @@ static int _decode_ods(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
static int _decode_pds(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
{
+ if (!s->decoding) {
+ BD_DEBUG(DBG_DECODE, "skipping orphan palette definition segment\n");
+ return 0;
+ }
+
/* search for palette to be updated */
if (s->palette) {
@@ -328,6 +343,11 @@ static void _check_epoch_start(PG_DISPLAY_SET *s)
static int _decode_pcs(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
{
+ if (s->complete) {
+ BD_DEBUG(DBG_DECODE | DBG_CRIT, "ERROR: updating complete (non-consumed) PG composition\n");
+ s->complete = 0;
+ }
+
pg_free_composition(&s->pcs);
s->pcs = calloc(1, sizeof(*s->pcs));
if (!s->pcs) {
@@ -345,11 +365,18 @@ static int _decode_pcs(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
_check_epoch_start(s);
+ s->decoding = 1;
+
return 1;
}
static int _decode_ics(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
{
+ if (s->complete) {
+ BD_DEBUG(DBG_DECODE | DBG_CRIT, "ERROR: updating complete (non-consumed) IG composition\n");
+ s->complete = 0;
+ }
+
ig_free_interactive(&s->ics);
s->ics = calloc(1, sizeof(*s->ics));
if (!s->ics) {
@@ -367,6 +394,8 @@ static int _decode_ics(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
_check_epoch_start(s);
+ s->decoding = 1;
+
return 1;
}
@@ -374,6 +403,8 @@ static int _decode_dialog_style(PG_DISPLAY_SET *s, BITBUFFER *bb)
{
_free_dialogs(s);
+ s->complete = 0;
+
s->style = calloc(1, sizeof(*s->style));
if (!s->style) {
BD_DEBUG(DBG_DECODE | DBG_CRIT, "out of memory\n");
@@ -458,7 +489,13 @@ static int _decode_segment(PG_DISPLAY_SET *s, PES_BUFFER *p)
return _decode_ics(s, &bb, p);
case PGS_END_OF_DISPLAY:
+ if (!s->decoding) {
+ /* avoid duplicate initialization / presenataton */
+ BD_DEBUG(DBG_DECODE, "skipping orphan end of display segment\n");
+ return 0;
+ }
s->complete = 1;
+ s->decoding = 0;
return 1;
case TGS_DIALOG_STYLE:
@@ -524,8 +561,6 @@ static int graphics_processor_decode_pes(PG_DISPLAY_SET **s, PES_BUFFER **p, int
GP_TRACE("Decoding segment, dts %010"PRId64" pts %010"PRId64" len %d\n",
(*p)->dts, (*p)->pts, (*p)->len);
- (*s)->complete = 0;
-
_decode_segment(*s, *p);
pes_buffer_remove(p, *p);
diff --git a/src/libbluray/decoders/graphics_processor.h b/src/libbluray/decoders/graphics_processor.h
index de61b81..f1d7690 100644
--- a/src/libbluray/decoders/graphics_processor.h
+++ b/src/libbluray/decoders/graphics_processor.h
@@ -56,6 +56,8 @@ typedef struct {
BD_PG_COMPOSITION *pcs;
BD_TEXTST_DIALOG_STYLE *style;
+ uint8_t decoding; /* internal flag: PCS/ICS decoded, but no end of presentation seen yet */
+
} PG_DISPLAY_SET;
BD_PRIVATE void pg_display_set_free(PG_DISPLAY_SET **s);
More information about the libbluray-devel
mailing list