Ticket #4840: patch.diff

File patch.diff, 3.1 KB (added by Alex Agranovsky, 11 years ago)

Proposed patch

  • libavcodec/mjpegdec.c

    diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
    index 818f8c9..9f41bd1 100644
    a b eoi_parser:  
    20932093            if (s->interlaced) {
    20942094                s->bottom_field ^= 1;
    20952095                /* if not bottom field, do not output image yet */
     2096#if 0               
    20962097                if (s->bottom_field == !s->interlace_polarity)
    20972098                    break;
     2099#endif                   
    20982100            }
    20992101            if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)
    21002102                return ret;
  • libavformat/format.c

    diff --git a/libavformat/format.c b/libavformat/format.c
    index 7df06b7..f4836d7 100644
    a b int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,  
    261261
    262262    if (pb->av_class) {
    263263        uint8_t *mime_type_opt = NULL;
     264        char* semi;
    264265        av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type_opt);
    265266        pd.mime_type = (const char *)mime_type_opt;
     267        semi = strchr(pd.mime_type, ';');
     268        if (semi) {
     269            *semi='\0';
     270        }
    266271    }
    267272#if 0
    268273    if (!*fmt && pb->av_class && av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type) >= 0 && mime_type) {
  • libavformat/mpjpegdec.c

    diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
    index b8281fc..f963c95 100644
    a b static int get_line(AVIOContext *pb, char *line, int line_size)  
    4040    return 0;
    4141}
    4242
     43
     44static void trim_right(char* p)
     45{
     46    while (*p!='\0' && !av_isspace(*p))
     47        p++;
     48    *p = '\0';   
     49}
     50
    4351static int split_tag_value(char **tag, char **value, char *line)
    4452{
     53    *tag = NULL;
     54    *value = NULL;
     55
    4556    char *p = line;
     57    int  foundData = 0;
    4658
    47     while (*p != '\0' && *p != ':')
     59    while (*p != '\0' && *p != ':') {
     60        if (!av_isspace(*p)) {
     61            foundData = 1;
     62        }
    4863        p++;
    49     if (*p != ':')
    50         return AVERROR_INVALIDDATA;
     64    }
     65    if (*p != ':') {
     66        if (*p!='\0' || foundData)
     67            return AVERROR_INVALIDDATA;
     68        return 0;
     69    }
    5170
    5271    *p   = '\0';
    5372    *tag = line;
     73    trim_right(*tag);
    5474
    5575    p++;
    5676
    static int split_tag_value(char **tag, char **value, char *line)  
    5979
    6080    *value = p;
    6181
     82    trim_right(*value);
     83
    6284    return 0;
    6385}
    6486
    static int check_content_type(char *line)  
    6789    char *tag, *value;
    6890    int ret = split_tag_value(&tag, &value, line);
    6991
    70     if (ret < 0)
     92    if (ret < 0 || tag == NULL || value == NULL)
    7193        return ret;
    7294
    7395    if (av_strcasecmp(tag, "Content-type") ||
    static int parse_multipart_header(AVFormatContext *s)  
    165187
    166188        ret = get_line(s->pb, line, sizeof(line));
    167189        if (ret < 0)
    168             return ret;
     190            break;
    169191
    170192        if (line[0] == '\0')
    171193            break;
    static int parse_multipart_header(AVFormatContext *s)  
    173195        ret = split_tag_value(&tag, &value, line);
    174196        if (ret < 0)
    175197            return ret;
     198        if (value==NULL || tag==NULL)
     199            break;
    176200
    177201        if (!av_strcasecmp(tag, "Content-type")) {
    178202            if (av_strcasecmp(value, "image/jpeg")) {