diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 818f8c9..9f41bd1 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2093,8 +2093,10 @@ eoi_parser:
             if (s->interlaced) {
                 s->bottom_field ^= 1;
                 /* if not bottom field, do not output image yet */
+#if 0                
                 if (s->bottom_field == !s->interlace_polarity)
                     break;
+#endif                    
             }
             if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)
                 return ret;
diff --git a/libavformat/format.c b/libavformat/format.c
index 7df06b7..f4836d7 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -261,8 +261,13 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
 
     if (pb->av_class) {
         uint8_t *mime_type_opt = NULL;
+        char* semi;
         av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type_opt);
         pd.mime_type = (const char *)mime_type_opt;
+        semi = strchr(pd.mime_type, ';');
+        if (semi) {
+            *semi='\0';
+        }
     }
 #if 0
     if (!*fmt && pb->av_class && av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type) >= 0 && mime_type) {
diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index b8281fc..f963c95 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -40,17 +40,37 @@ static int get_line(AVIOContext *pb, char *line, int line_size)
     return 0;
 }
 
+
+static void trim_right(char* p)
+{
+    while (*p!='\0' && !av_isspace(*p))
+        p++;
+    *p = '\0';    
+}
+
 static int split_tag_value(char **tag, char **value, char *line)
 {
+    *tag = NULL;
+    *value = NULL;
+
     char *p = line;
+    int  foundData = 0;
 
-    while (*p != '\0' && *p != ':')
+    while (*p != '\0' && *p != ':') {
+        if (!av_isspace(*p)) {
+            foundData = 1;
+        }
         p++;
-    if (*p != ':')
-        return AVERROR_INVALIDDATA;
+    }
+    if (*p != ':') {
+        if (*p!='\0' || foundData)
+            return AVERROR_INVALIDDATA;
+        return 0;
+    }
 
     *p   = '\0';
     *tag = line;
+    trim_right(*tag);
 
     p++;
 
@@ -59,6 +79,8 @@ static int split_tag_value(char **tag, char **value, char *line)
 
     *value = p;
 
+    trim_right(*value);
+
     return 0;
 }
 
@@ -67,7 +89,7 @@ static int check_content_type(char *line)
     char *tag, *value;
     int ret = split_tag_value(&tag, &value, line);
 
-    if (ret < 0)
+    if (ret < 0 || tag == NULL || value == NULL)
         return ret;
 
     if (av_strcasecmp(tag, "Content-type") ||
@@ -165,7 +187,7 @@ static int parse_multipart_header(AVFormatContext *s)
 
         ret = get_line(s->pb, line, sizeof(line));
         if (ret < 0)
-            return ret;
+            break;
 
         if (line[0] == '\0')
             break;
@@ -173,6 +195,8 @@ static int parse_multipart_header(AVFormatContext *s)
         ret = split_tag_value(&tag, &value, line);
         if (ret < 0)
             return ret;
+        if (value==NULL || tag==NULL)
+            break;
 
         if (!av_strcasecmp(tag, "Content-type")) {
             if (av_strcasecmp(value, "image/jpeg")) {
