1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-13 18:36:09 +00:00

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
This commit is contained in:
mosu 2004-06-08 21:30:32 +00:00
parent 004f28c039
commit 8e68ace3ab

View File

@ -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
@ -303,6 +306,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