summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-09 20:05:02 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-09 20:05:02 +0200
commited5e08b5078e0fc1d06c6e869ee10c57896f61ad (patch)
tree2336c95fcf94b8cbaa7a988d6421176a47569687
parentd9879fae94a82bb6b43af44102613dcf7db01f30 (diff)
downloadxine-lib-ed5e08b5078e0fc1d06c6e869ee10c57896f61ad.tar.gz
xine-lib-ed5e08b5078e0fc1d06c6e869ee10c57896f61ad.tar.bz2
Avoid 1KB buffer for decoding anxdata headers.
Instead of using a 1KB buffer to copy over the Content-Type header value to compare it, get a (pointer, length) pair and use that for comparison. This should also allow the compiler to inline the decode_anxdata_header() function. --HG-- extra : transplant_source : W%EE%5CN%BD%B8%8C%FA%CD%15p%CD%A5%CBQ%1E%893%97S
-rw-r--r--src/demuxers/demux_ogg.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index a58304744..16e6c40d9 100644
--- a/src/demuxers/demux_ogg.c
+++ b/src/demuxers/demux_ogg.c
@@ -1267,8 +1267,8 @@ static void decode_annodex_header (demux_ogg_t *this, const int stream_num, ogg_
static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
int64_t granule_rate_n, granule_rate_d;
uint32_t secondary_headers;
- char content_type[1024];
- int content_type_length;
+ const char *content_type = "";
+ size_t content_type_length = 0;
lprintf("AnxData stream detected\n");
@@ -1280,11 +1280,16 @@ static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_
lprintf("granule_rate %" PRId64 "/%" PRId64 ", %d secondary headers\n",
granule_rate_n, granule_rate_d, secondary_headers);
- /* read "Content-Tyoe" MIME header */
- sscanf(&op->packet[28], "Content-Type: %1023s\r\n", content_type);
- content_type_length = strlen(content_type);
+ /* read "Content-Type" MIME header */
+ const char *startline = &op->packet[28];
+ const char *endline;
+ if ( strcmp(&op->packet[28], "Content-Type: ") == 0 &&
+ (endline = strstr(startline, "\r\n")) ) {
+ content_type = startline + sizeof("Content-Type: ");
+ content_type_length = startline - endline;
+ }
- lprintf("Content-Type: %s (length:%d)\n", content_type, content_type_length);
+ lprintf("Content-Type: %s (length:%td)\n", content_type, content_type_length);
/* how many header packets in the AnxData stream? */
this->si[stream_num]->headers = secondary_headers + 1;