Commit e87c6b88 authored by titou10's avatar titou10

Added managment of IG streams, secondary audio stream, secondary video+...

Added managment of IG streams, secondary audio stream, secondary video+ streams and PIP/IG streams in libbdnav/mpls_parse
parent c4ac4104
......@@ -31,6 +31,8 @@ VALUE_MAP codec_map[] = {
{0x84, "AC-3 Plus"},
{0x85, "DTS-HD"},
{0x86, "DTS-HD Master"},
{0xa1, "AC-3 Plus for secondary audio"},
{0xa2, "DTS-HD for secondary audio"},
{0xea, "VC-1"},
{0x1b, "H.264"},
{0x90, "Presentation Graphics"},
......@@ -147,6 +149,8 @@ _show_stream(MPLS_STREAM *ss, int level)
case 0x84:
case 0x85:
case 0x86:
case 0xa1:
case 0xa2:
indent_printf(level, "Format %02x: %s", ss->format,
_lookup_str(audio_format_map, ss->format));
indent_printf(level, "Rate %02x:", ss->rate,
......@@ -173,7 +177,7 @@ _show_stream(MPLS_STREAM *ss, int level)
static void
_show_details(MPLS_PL *pl, int level)
{
int ii, jj;
int ii, jj, kk;
for (ii = 0; ii < pl->list_count; ii++) {
MPLS_PI *pi;
......@@ -200,10 +204,31 @@ _show_details(MPLS_PL *pl, int level)
indent_printf(level+1, "Audio Stream %d:", jj);
_show_stream(&pi->stn.audio[jj], level + 2);
}
for (jj = 0; jj < pi->stn.num_pg; jj++) {
indent_printf(level+1, "Presentation Graphics Stream %d:", jj);
for (jj = 0; jj < (pi->stn.num_pg + pi->stn.num_pip_pg); jj++) {
if (jj < pi->stn.num_pg) {
indent_printf(level+1, "Presentation Graphics Stream %d:", jj);
} else {
indent_printf(level+1, "PIP Presentation Graphics Stream %d:", jj);
}
_show_stream(&pi->stn.pg[jj], level + 2);
}
for (jj = 0; jj < pi->stn.num_secondary_video; jj++) {
indent_printf(level+1, "Secondary Video Stream %d:", jj);
_show_stream(&pi->stn.secondary_video[jj], level + 2);
for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_secondary_audio_ref; kk++) {
indent_printf(level+2, "Secondary Audio Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_secondary_audio_ref[kk]);
}
for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_pip_pg_ref; kk++) {
indent_printf(level+2, "PIP Presentation Graphic Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_pip_pg_ref[kk]);
}
}
for (jj = 0; jj < pi->stn.num_secondary_audio; jj++) {
indent_printf(level+1, "Secondary Audio Stream %d:", jj);
_show_stream(&pi->stn.secondary_audio[jj], level + 2);
for (kk = 0; kk < pi->stn.secondary_audio[jj].sa_num_primary_audio_ref; kk++) {
indent_printf(level+2, "Primary Audio Ref %d: %d", kk,pi->stn.secondary_audio[jj].sa_primary_audio_ref[kk]);
}
}
printf("\n");
}
}
......
......@@ -191,6 +191,8 @@ _parse_stream(BITSTREAM *bits, MPLS_STREAM *s)
case 0x84:
case 0x85:
case 0x86:
case 0xa1:
case 0xa2:
s->format = bs_read(bits, 4);
s->rate = bs_read(bits, 4);
bs_read_bytes(bits, s->lang, 3);
......@@ -221,8 +223,8 @@ _parse_stn(BITSTREAM *bits, MPLS_STN *stn)
{
int len;
int pos;
MPLS_STREAM *ss;
int ii;
MPLS_STREAM *ss;
int ii,jj;
if (!bs_is_align(bits, 0x07)) {
fprintf(stderr, "_parse_stream: Stream alignment error\n");
......@@ -245,45 +247,127 @@ _parse_stn(BITSTREAM *bits, MPLS_STN *stn)
// 5 reserve bytes
bs_skip(bits, 5 * 8);
// Primary Video Streams
ss = NULL;
if (stn->num_video) {
ss = calloc(stn->num_video, sizeof(MPLS_STREAM));
}
for (ii = 0; ii < stn->num_video; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing video entry\n");
return 0;
for (ii = 0; ii < stn->num_video; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing video entry\n");
return 0;
}
}
}
stn->video = ss;
// Primary Audio Streams
ss = NULL;
if (stn->num_audio)
if (stn->num_audio) {
ss = calloc(stn->num_audio, sizeof(MPLS_STREAM));
for (ii = 0; ii < stn->num_audio; ii++) {
for (ii = 0; ii < stn->num_audio; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing audio entry\n");
return 0;
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing audio entry\n");
return 0;
}
}
}
stn->audio = ss;
// Presentation Graphic Streams
ss = NULL;
if (stn->num_pg) {
ss = calloc(stn->num_pg, sizeof(MPLS_STREAM));
}
for (ii = 0; ii < stn->num_pg; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing pg entry\n");
return 0;
if (stn->num_pg || stn->num_pip_pg) {
ss = calloc(stn->num_pg + stn->num_pip_pg, sizeof(MPLS_STREAM));
for (ii = 0; ii < (stn->num_pg + stn->num_pip_pg); ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing pg/pip-pg entry\n");
return 0;
}
}
}
stn->pg = ss;
// Interactive Graphic Streams
ss = NULL;
if (stn->num_ig) {
ss = calloc(stn->num_ig, sizeof(MPLS_STREAM));
for (ii = 0; ii < stn->num_ig; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing ig entry\n");
return 0;
}
}
}
stn->ig = ss;
// Secondary Audio Streams
ss = NULL;
if (stn->num_secondary_audio) {
ss = calloc(1, sizeof(MPLS_STREAM));
for (ii = 0; ii < stn->num_secondary_audio; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing secondary audio entry\n");
return 0;
}
// Read Secondary Audio Extra Attributes
ss->sa_num_primary_audio_ref = bs_read(bits, 8);
bs_skip(bits, 8);
if (ss->sa_num_primary_audio_ref) {
ss->sa_primary_audio_ref = calloc(ss->sa_num_primary_audio_ref, sizeof(uint8_t));
for (jj = 0; jj < ss->sa_num_primary_audio_ref; jj++) {
ss->sa_primary_audio_ref[jj] = bs_read(bits, 8);
}
if (ss->sa_num_primary_audio_ref % 2) {
bs_skip(bits, 8);
}
}
}
}
stn->secondary_audio = ss;
// Secondary Video Streams
ss = NULL;
if (stn->num_secondary_video) {
ss = calloc(stn->num_secondary_video, sizeof(MPLS_STREAM));
for (ii = 0; ii < stn->num_secondary_video; ii++) {
if (!_parse_stream(bits, &ss[ii])) {
X_FREE(ss);
fprintf(stderr, "error parsing secondary video entry\n");
return 0;
}
// Read Secondary Video Extra Attributes
ss->sv_num_secondary_audio_ref = bs_read(bits, 8);
bs_skip(bits, 8);
if (ss->sv_num_secondary_audio_ref) {
ss->sv_secondary_audio_ref = calloc(ss->sv_num_secondary_audio_ref, sizeof(uint8_t));
for (jj = 0; jj < ss->sv_num_secondary_audio_ref; jj++) {
ss->sv_secondary_audio_ref[jj] = bs_read(bits, 8);
}
if (ss->sv_num_secondary_audio_ref % 2) {
bs_skip(bits, 8);
}
}
ss->sv_num_pip_pg_ref = bs_read(bits, 8);
bs_skip(bits, 8);
if (ss->sv_num_pip_pg_ref) {
ss->sv_pip_pg_ref = calloc(ss->sv_num_pip_pg_ref, sizeof(uint8_t));
for (jj = 0; jj < ss->sv_num_pip_pg_ref; jj++) {
ss->sv_pip_pg_ref[jj] = bs_read(bits, 8);
}
if (ss->sv_num_pip_pg_ref % 2) {
bs_skip(bits, 8);
}
}
}
}
stn->secondary_video = ss;
bs_seek_byte(bits, pos + len);
return 1;
}
......
......@@ -54,6 +54,14 @@ typedef struct
uint8_t rate;
uint8_t char_code;
uint8_t lang[4];
// Secondary audio specific fields
uint8_t sa_num_primary_audio_ref;
uint8_t *sa_primary_audio_ref;
// Secondary video specific fields
uint8_t sv_num_secondary_audio_ref;
uint8_t sv_num_pip_pg_ref;
uint8_t *sv_secondary_audio_ref;
uint8_t *sv_pip_pg_ref;
} MPLS_STREAM;
typedef struct
......@@ -68,6 +76,9 @@ typedef struct
MPLS_STREAM *video;
MPLS_STREAM *audio;
MPLS_STREAM *pg;
MPLS_STREAM *ig;
MPLS_STREAM *secondary_audio;
MPLS_STREAM *secondary_video;
} MPLS_STN;
typedef struct
......
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