Commit bbcc1b90 authored by hpi1's avatar hpi1

Added decoding of presentation composition segments

parent 0bee3610
......@@ -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);
......
......@@ -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;
......
......@@ -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_
......@@ -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);
}
}
......@@ -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_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment