summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authormosu <mosu@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-06-08 21:30:32 +0000
committermosu <mosu@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-06-08 21:30:32 +0000
commit8e68ace3ab3ce423723ce5b94ee01390fb0894a9 (patch)
treeadbde30d263cf0f8e6c7b190f948c77408cef8ba /libmpdemux
parent004f28c0390eff8acf83840c96083b59a171d0fb (diff)
downloadmpv-8e68ace3ab3ce423723ce5b94ee01390fb0894a9.tar.bz2
mpv-8e68ace3ab3ce423723ce5b94ee01390fb0894a9.tar.xz
Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12548 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_mkv.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c
index 13ab9cbeab..5bf3570ea0 100644
--- a/libmpdemux/demux_mkv.c
+++ b/libmpdemux/demux_mkv.c
@@ -89,6 +89,9 @@ typedef struct mkv_track
/* generic content encoding support */
mkv_content_encoding_t *encodings;
int num_encodings;
+
+ /* For VobSubs */
+ mkv_sh_sub_t sh_sub;
} mkv_track_t;
typedef struct mkv_index
@@ -304,6 +307,89 @@ aac_get_sample_rate_index (uint32_t sample_rate)
static int
+demux_mkv_parse_idx (mkv_track_t *t)
+{
+ int things_found, last;
+ char *buf, *pos, *start;
+
+ if ((t->private_data == NULL) || (t->private_size == 0))
+ return 0;
+
+ things_found = 0;
+ buf = (char *)malloc(t->private_size + 1);
+ if (buf == NULL)
+ return 0;
+ memcpy(buf, t->private_data, t->private_size);
+ buf[t->private_size] = 0;
+
+ pos = buf;
+ start = buf;
+ last = 0;
+ do
+ {
+ if ((*pos == 0) || (*pos == '\r') || (*pos == '\n'))
+ {
+ if (*pos == 0)
+ last = 1;
+ *pos = 0;
+
+ if (!strncmp(start, "size: ", 6) &&
+ ((things_found & 1) == 0) &&
+ (sscanf(&start[6], "%dx%d", &t->sh_sub.width, &t->sh_sub.height)
+ == 2))
+ {
+ things_found |= 1;
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub size: %ux%u\n",
+ t->sh_sub.width, t->sh_sub.height);
+ }
+ else if (!strncmp(start, "palette: ", 9) &&
+ ((things_found & 2) == 0) &&
+ (sscanf(&start[9], "%06x,%06x,%06x,%06x,%06x,%06x,%06x,"
+ "%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x",
+ &t->sh_sub.palette[0], &t->sh_sub.palette[1],
+ &t->sh_sub.palette[2], &t->sh_sub.palette[3],
+ &t->sh_sub.palette[4], &t->sh_sub.palette[5],
+ &t->sh_sub.palette[6], &t->sh_sub.palette[7],
+ &t->sh_sub.palette[8], &t->sh_sub.palette[9],
+ &t->sh_sub.palette[10], &t->sh_sub.palette[11],
+ &t->sh_sub.palette[12], &t->sh_sub.palette[13],
+ &t->sh_sub.palette[14], &t->sh_sub.palette[15]) ==
+ 16))
+ {
+ things_found |= 2;
+ mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub palette: %06x,%06x,"
+ "%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,"
+ "%06x,%06x,%06x\n", t->sh_sub.palette[0],
+ t->sh_sub.palette[1], t->sh_sub.palette[2],
+ t->sh_sub.palette[3], t->sh_sub.palette[4],
+ t->sh_sub.palette[5], t->sh_sub.palette[6],
+ t->sh_sub.palette[7], t->sh_sub.palette[8],
+ t->sh_sub.palette[9], t->sh_sub.palette[10],
+ t->sh_sub.palette[11], t->sh_sub.palette[12],
+ t->sh_sub.palette[13], t->sh_sub.palette[14],
+ t->sh_sub.palette[15]);
+ }
+ if (last)
+ break;
+ do
+ {
+ pos++;
+ }
+ while ((*pos == '\r') || (*pos == '\n'));
+ start = pos;
+ }
+ else
+ pos++;
+ }
+ while (!last && (*start != 0) && (things_found != 3));
+
+ free(buf);
+
+ return (things_found == 3);
+}
+
+
+static int
demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
uint32_t *size, uint32_t type)
{
@@ -1808,6 +1894,12 @@ demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track)
free (track->private_data);
track->private_data = buffer;
}
+ if (demux_mkv_parse_idx (track))
+ {
+ demuxer->sub->sh = malloc(sizeof(mkv_sh_sub_t));
+ if (demuxer->sub->sh != NULL)
+ memcpy(demuxer->sub->sh, &track->sh_sub, sizeof(mkv_sh_sub_t));
+ }
}
}
else