[libbluray-devel] Added decoding of presentation composition segments

hpi1 git at videolan.org
Fri May 6 14:38:43 CEST 2011


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri May  6 14:44:27 2011 +0300| [bbcc1b90307f10e4807b15fb8a72a866820ccf3b] | committer: hpi1

Added decoding of presentation composition segments

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=bbcc1b90307f10e4807b15fb8a72a866820ccf3b
---

 src/libbluray/decoders/graphics_processor.c |   30 ++++++++++++++--------
 src/libbluray/decoders/graphics_processor.h |    2 +-
 src/libbluray/decoders/pg.h                 |   13 +++++++++
 src/libbluray/decoders/pg_decode.c          |   37 +++++++++++++++++++++++++++
 src/libbluray/decoders/pg_decode.h          |    3 ++
 5 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/src/libbluray/decoders/graphics_processor.c b/src/libbluray/decoders/graphics_processor.c
index 12eeffe..358555f 100644
--- a/src/libbluray/decoders/graphics_processor.c
+++ b/src/libbluray/decoders/graphics_processor.c
@@ -234,8 +234,8 @@ static int _decode_pds(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
         for (ii = 0; ii < s->num_palette; ii++) {
             if (s->palette[ii].id == id) {
                 int rr;
-                if ( (s->ics && s->ics->composition_descriptor.state == 0)/* ||
-                     (s->pcs && s->pcs->composition_descriptor.state == 2)*/) {
+                if ( (s->ics && s->ics->composition_descriptor.state == 0) ||
+                     (s->pcs && s->pcs->composition_descriptor.state == 0)) {
                     /* 8.8.3.1.1 */
                     rr = pg_decode_palette_update(bb, &s->palette[ii]);
                 } else {
@@ -266,7 +266,8 @@ static int _decode_pds(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
 
 static void _check_epoch_start(PG_DISPLAY_SET *s)
 {
-    if (s->ics->composition_descriptor.state == 2) {
+    if ((s->pcs && s->pcs->composition_descriptor.state == 2) ||
+        (s->ics && s->ics->composition_descriptor.state == 2)) {
         /* epoch start, drop all cached data */
 
         unsigned ii;
@@ -287,12 +288,20 @@ static void _check_epoch_start(PG_DISPLAY_SET *s)
 
 static int _decode_pcs(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
 {
-    (void)s;
-    (void)bb;
-    (void)p;
+    pg_free_composition(&s->pcs);
+    s->pcs = calloc(1, sizeof(*s->pcs));
 
-    BD_DEBUG(DBG_DECODE | DBG_CRIT, "unhandled segment type (PGS_PG_COMPOSITION)\n");
-    return 0;
+    if (!pg_decode_composition(bb, s->pcs)) {
+        pg_free_composition(&s->pcs);
+        return 0;
+    }
+
+    s->pcs->pts  = p->pts;
+    s->valid_pts = p->pts;
+
+    _check_epoch_start(s);
+
+    return 1;
 }
 
 static int _decode_ics(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
@@ -305,9 +314,8 @@ static int _decode_ics(PG_DISPLAY_SET *s, BITBUFFER *bb, PES_BUFFER *p)
         return 0;
     }
 
-    s->ics->pts = p->pts;
-
-    s->valid_pts   = s->ics->pts;
+    s->ics->pts  = p->pts;
+    s->valid_pts = p->pts;
 
     _check_epoch_start(s);
 
diff --git a/src/libbluray/decoders/graphics_processor.h b/src/libbluray/decoders/graphics_processor.h
index 37f6287..19b8cf3 100644
--- a/src/libbluray/decoders/graphics_processor.h
+++ b/src/libbluray/decoders/graphics_processor.h
@@ -48,7 +48,7 @@ typedef struct {
 
     /* only one of the following segments can be present */
     BD_IG_INTERACTIVE   *ics;
-    /*BD_PG_PRESENTATON_COMPOSITION_SEGMENT  *pcs;*/
+    BD_PG_COMPOSITION   *pcs;
 
 } PG_DISPLAY_SET;
 
diff --git a/src/libbluray/decoders/pg.h b/src/libbluray/decoders/pg.h
index c6b54b3..1567a17 100644
--- a/src/libbluray/decoders/pg.h
+++ b/src/libbluray/decoders/pg.h
@@ -85,5 +85,18 @@ typedef struct {
 
 } BD_PG_OBJECT;
 
+typedef struct {
+    int64_t       pts;
+
+    BD_PG_VIDEO_DESCRIPTOR        video_descriptor;
+    BD_PG_COMPOSITION_DESCRIPTOR  composition_descriptor;
+
+    uint8_t       palette_update_flag;
+    uint8_t       palette_id_ref;
+
+    unsigned                  num_composition_objects;
+    BD_PG_COMPOSITION_OBJECT *composition_object;
+
+} BD_PG_COMPOSITION;
 
 #endif // _BD_PG_H_
diff --git a/src/libbluray/decoders/pg_decode.c b/src/libbluray/decoders/pg_decode.c
index 3fac4b2..6708bac 100644
--- a/src/libbluray/decoders/pg_decode.c
+++ b/src/libbluray/decoders/pg_decode.c
@@ -196,6 +196,28 @@ int pg_decode_object(BITBUFFER *bb, BD_PG_OBJECT *p)
     return _decode_rle(bb, p);
 }
 
+int pg_decode_composition(BITBUFFER *bb, BD_PG_COMPOSITION *p)
+{
+    unsigned ii;
+
+    pg_decode_video_descriptor(bb, &p->video_descriptor);
+    pg_decode_composition_descriptor(bb, &p->composition_descriptor);
+
+    p->palette_update_flag = bb_read(bb, 1);
+    bb_skip(bb, 7);
+
+    p->palette_id_ref      = bb_read(bb, 8);
+
+    p->num_composition_objects = bb_read(bb, 8);
+    p->composition_object      = calloc(p->num_composition_objects, sizeof(BD_PG_COMPOSITION_OBJECT));
+
+    for (ii = 0; ii < p->num_composition_objects; ii++) {
+        pg_decode_composition_object(bb, &p->composition_object[ii]);
+    }
+
+    return 1;
+}
+
 /*
  * cleanup
  */
@@ -207,6 +229,13 @@ void pg_clean_object(BD_PG_OBJECT *p)
     }
 }
 
+void pg_clean_composition(BD_PG_COMPOSITION *p)
+{
+    if (p) {
+        X_FREE(p->composition_object);
+    }
+}
+
 void pg_free_window(BD_PG_WINDOW **p)
 {
     if (p && *p) {
@@ -228,3 +257,11 @@ void pg_free_object(BD_PG_OBJECT **p)
         X_FREE(*p);
     }
 }
+
+void pg_free_composition(BD_PG_COMPOSITION **p)
+{
+    if (p && *p) {
+        pg_clean_composition(*p);
+        X_FREE(*p);
+    }
+}
diff --git a/src/libbluray/decoders/pg_decode.h b/src/libbluray/decoders/pg_decode.h
index 169efe7..d8af2b5 100644
--- a/src/libbluray/decoders/pg_decode.h
+++ b/src/libbluray/decoders/pg_decode.h
@@ -42,15 +42,18 @@ BD_PRIVATE void pg_decode_composition_object(BITBUFFER *bb, BD_PG_COMPOSITION_OB
 BD_PRIVATE int pg_decode_palette_update(BITBUFFER *bb, BD_PG_PALETTE *p);
 BD_PRIVATE int pg_decode_palette(BITBUFFER *bb, BD_PG_PALETTE *p);
 BD_PRIVATE int pg_decode_object(BITBUFFER *bb, BD_PG_OBJECT *p);
+BD_PRIVATE int pg_decode_composition(BITBUFFER *bb, BD_PG_COMPOSITION *p);
 
 /*
  * cleanup
  */
 
 BD_PRIVATE void pg_clean_object(BD_PG_OBJECT *p);
+BD_PRIVATE void pg_clean_composition(BD_PG_COMPOSITION *p);
 
 BD_PRIVATE void pg_free_window(BD_PG_WINDOW **p);
 BD_PRIVATE void pg_free_palette(BD_PG_PALETTE **p);
 BD_PRIVATE void pg_free_object(BD_PG_OBJECT **p);
+BD_PRIVATE void pg_free_composition(BD_PG_COMPOSITION **p);
 
 #endif // _PG_DECODE_H_



More information about the libbluray-devel mailing list