summaryrefslogtreecommitdiffstats
path: root/spudec.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-14 13:57:30 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-14 13:57:30 +0000
commit56e0f7fe9e735af2df4c016990cbd803f6a9ef0c (patch)
tree11a0ae449ef138398246488ded4d978ce995adc4 /spudec.c
parent68219deebfa8172a82c813fe3c00536cd23310e9 (diff)
downloadmpv-56e0f7fe9e735af2df4c016990cbd803f6a9ef0c.tar.bz2
mpv-56e0f7fe9e735af2df4c016990cbd803f6a9ef0c.tar.xz
Avoid using sscanf for basic parsing, it is horribly slow.
Now uses strncmp as a first step, which is 40 times faster. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30576 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'spudec.c')
-rw-r--r--spudec.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/spudec.c b/spudec.c
index a20d97d865..51a70ec708 100644
--- a/spudec.c
+++ b/spudec.c
@@ -1161,9 +1161,13 @@ static void spudec_parse_extradata(spudec_handle_t *this,
buffer[extradata_len] = 0;
do {
- sscanf(ptr, "size: %dx%d", &this->orig_frame_width, &this->orig_frame_height);
- if (sscanf(ptr, "palette: %x, %x, %x, %x, %x, %x, %x, %x,"
- " %x, %x, %x, %x, %x, %x, %x, %x",
+ if (*ptr == '#')
+ continue;
+ if (!strncmp(ptr, "size: ", 6))
+ sscanf(ptr + 6, "%dx%d", &this->orig_frame_width, &this->orig_frame_height);
+ if (!strncmp(ptr, "palette: ", 9) &&
+ sscanf(ptr + 9, "%x, %x, %x, %x, %x, %x, %x, %x, "
+ "%x, %x, %x, %x, %x, %x, %x, %x",
&pal[ 0], &pal[ 1], &pal[ 2], &pal[ 3],
&pal[ 4], &pal[ 5], &pal[ 6], &pal[ 7],
&pal[ 8], &pal[ 9], &pal[10], &pal[11],
@@ -1174,7 +1178,8 @@ static void spudec_parse_extradata(spudec_handle_t *this,
}
if (!strncasecmp(ptr, "forced subs: on", 15))
this->forced_subs_only = 1;
- if (sscanf(ptr, "custom colors: ON, tridx: %x, colors: %x, %x, %x, %x",
+ if (!strncmp(ptr, "custom colors: ON, tridx: ", 26) &&
+ sscanf(ptr + 26, "%x, colors: %x, %x, %x, %x",
&tridx, cuspal+0, cuspal+1, cuspal+2, cuspal+3) == 5) {
for (i=0; i<4; i++) {
cuspal[i] = vobsub_rgb_to_yuv(cuspal[i]);