avconv.c:3494: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `new_video_stream`.

avconv.c:3464:10: Unknown value from: strcmp
3462.     av_strlcpy(oc->filename, filename, sizeof(oc->filename));
3463. 
3464.     if (!strcmp(file_oformat->name, "ffm") &&
               ^
3465.         av_strstart(filename, "http:", NULL)) {
3466.         /* special case for files sent to avserver: we get the stream

avconv.c:3494:13: Call
3492.                 }
3493.             }
3494.             NEW_STREAM(video, idx);
                  ^
3495.         }
3496. 

avconv.c:3116:1: Parameter `oc->nb_streams`
  3114. }
  3115. 
  3116. static OutputStream *new_video_stream(AVFormatContext *oc)
        ^
  3117. {
  3118.     AVStream *st;

avconv.c:3122:11: Call
  3120.     AVCodecContext *video_enc;
  3121. 
  3122.     ost = new_output_stream(oc, AVMEDIA_TYPE_VIDEO);
                  ^
  3123.     st  = ost->st;
  3124.     if (!st->stream_copy) {

avconv.c:3078:1: <LHS trace>
3076. }
3077. 
3078. static OutputStream *new_output_stream(AVFormatContext *oc, enum AVMediaType type)
      ^
3079. {
3080.     OutputStream *ost;

avconv.c:3078:1: Global `nb_streamid_map`
    3076. }
    3077. 
    3078. static OutputStream *new_output_stream(AVFormatContext *oc, enum AVMediaType type)
          ^
    3079. {
    3080.     OutputStream *ost;

avconv.c:3081:20: Call
    3079. {
    3080.     OutputStream *ost;
    3081.     AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
                             ^
    3082.     int idx      = oc->nb_streams - 1;
    3083. 

libavformat/utils.c:2657:1: Parameter `s->nb_streams`
      2655. }
      2656. 
      2657. AVStream *av_new_stream(AVFormatContext *s, int id)
            ^
      2658. {
      2659.     AVStream *st;

avconv.c:3082:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `new_video_stream` 
    3080.     OutputStream *ost;
    3081.     AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
    3082.     int idx      = oc->nb_streams - 1;
              ^
    3083. 
    3084.     if (!st) {

static OutputStream *new_output_stream(AVFormatContext *oc, enum AVMediaType type)
{
    OutputStream *ost;
    AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
    int idx      = oc->nb_streams - 1;
    if (!st) {
        av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n");
        exit_program(1);
    }
    output_streams_for_file[nb_output_files] =
        grow_array(output_streams_for_file[nb_output_files],
                   sizeof(*output_streams_for_file[nb_output_files]),
                   &nb_output_streams_for_file[nb_output_files],
                   oc->nb_streams);
    ost = output_streams_for_file[nb_output_files][idx] =
        av_mallocz(sizeof(OutputStream));
    if (!ost) {
        fprintf(stderr, "Could not alloc output stream\n");
        exit_program(1);
    }
    ost->file_index = nb_output_files;
    ost->index = idx;
    ost->st    = st;
    st->codec->codec_type = type;
    ost->enc = choose_codec(oc, st, type, codec_names);
    if (ost->enc) {
        ost->opts  = filter_codec_opts(codec_opts, ost->enc->id, oc, st);
    }
    avcodec_get_context_defaults3(st->codec, ost->enc);
    st->codec->codec_type = type;
    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
    return ost;
}
['static void opt_output_file(const char *filename)\n{\n    AVFormatContext *oc;\n    int i, err;\n    AVOutputFormat *file_oformat;\n    OutputStream *ost;\n    InputStream  *ist;\n    if (!strcmp(filename, "-"))\n        filename = "pipe:";\n    oc = avformat_alloc_context();\n    if (!oc) {\n        print_error(filename, AVERROR(ENOMEM));\n        exit_program(1);\n    }\n    if (last_asked_format) {\n        file_oformat = av_guess_format(last_asked_format, NULL, NULL);\n        if (!file_oformat) {\n            fprintf(stderr, "Requested output format \'%s\' is not a suitable output format\\n", last_asked_format);\n            exit_program(1);\n        }\n        last_asked_format = NULL;\n    } else {\n        file_oformat = av_guess_format(NULL, filename, NULL);\n        if (!file_oformat) {\n            fprintf(stderr, "Unable to find a suitable output format for \'%s\'\\n",\n                    filename);\n            exit_program(1);\n        }\n    }\n    oc->oformat = file_oformat;\n    av_strlcpy(oc->filename, filename, sizeof(oc->filename));\n    if (!strcmp(file_oformat->name, "ffm") &&\n        av_strstart(filename, "http:", NULL)) {\n        int err = read_avserver_streams(oc, filename);\n        if (err < 0) {\n            print_error(filename, err);\n            exit_program(1);\n        }\n    } else if (!nb_stream_maps) {\n#define NEW_STREAM(type, index)\\\n        if (index >= 0) {\\\n            ost = new_ ## type ## _stream(oc);\\\n            ost->source_index = index;\\\n            ost->sync_ist     = &input_streams[index];\\\n            input_streams[index].discard = 0;\\\n        }\n        if (!video_disable && oc->oformat->video_codec != CODEC_ID_NONE) {\n            int area = 0, idx = -1;\n            for (i = 0; i < nb_input_streams; i++) {\n                ist = &input_streams[i];\n                if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&\n                    ist->st->codec->width * ist->st->codec->height > area) {\n                    area = ist->st->codec->width * ist->st->codec->height;\n                    idx = i;\n                }\n            }\n            NEW_STREAM(video, idx);\n        }\n        if (!audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) {\n            int channels = 0, idx = -1;\n            for (i = 0; i < nb_input_streams; i++) {\n                ist = &input_streams[i];\n                if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&\n                    ist->st->codec->channels > channels) {\n                    channels = ist->st->codec->channels;\n                    idx = i;\n                }\n            }\n            NEW_STREAM(audio, idx);\n        }\n        if (!subtitle_disable && oc->oformat->subtitle_codec != CODEC_ID_NONE) {\n            for (i = 0; i < nb_input_streams; i++)\n                if (input_streams[i].st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {\n                    NEW_STREAM(subtitle, i);\n                    break;\n                }\n        }\n    } else {\n        for (i = 0; i < nb_stream_maps; i++) {\n            StreamMap *map = &stream_maps[i];\n            if (map->disabled)\n                continue;\n            ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index];\n            switch (ist->st->codec->codec_type) {\n            case AVMEDIA_TYPE_VIDEO:    ost = new_video_stream(oc);    break;\n            case AVMEDIA_TYPE_AUDIO:    ost = new_audio_stream(oc);    break;\n            case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(oc); break;\n            case AVMEDIA_TYPE_DATA:     ost = new_data_stream(oc);     break;\n            default:\n                av_log(NULL, AV_LOG_ERROR, "Cannot map stream #%d.%d - unsupported type.\\n",\n                       map->file_index, map->stream_index);\n                exit_program(1);\n            }\n            ost->source_index = input_files[map->file_index].ist_index + map->stream_index;\n            ost->sync_ist = &input_streams[input_files[map->sync_file_index].ist_index +\n                                           map->sync_stream_index];\n            ist->discard = 0;\n        }\n    }\n    av_dict_copy(&oc->metadata, metadata, 0);\n    av_dict_free(&metadata);\n    av_dict_copy(&output_opts[nb_output_files], format_opts, 0);\n    output_files[nb_output_files++] = oc;\n    if (oc->oformat->flags & AVFMT_NEEDNUMBER) {\n        if (!av_filename_number_test(oc->filename)) {\n            print_error(oc->filename, AVERROR(EINVAL));\n            exit_program(1);\n        }\n    }\n    if (!(oc->oformat->flags & AVFMT_NOFILE)) {\n        if (!file_overwrite &&\n            (strchr(filename, \':\') == NULL ||\n             filename[1] == \':\' ||\n             av_strstart(filename, "file:", NULL))) {\n            if (avio_check(filename, 0) == 0) {\n                if (!using_stdin) {\n                    fprintf(stderr,"File \'%s\' already exists. Overwrite ? [y/N] ", filename);\n                    fflush(stderr);\n                    if (!read_yesno()) {\n                        fprintf(stderr, "Not overwriting - exiting\\n");\n                        exit_program(1);\n                    }\n                }\n                else {\n                    fprintf(stderr,"File \'%s\' already exists. Exiting.\\n", filename);\n                    exit_program(1);\n                }\n            }\n        }\n        if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {\n            print_error(filename, err);\n            exit_program(1);\n        }\n    }\n    oc->preload= (int)(mux_preload*AV_TIME_BASE);\n    oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);\n    oc->flags |= AVFMT_FLAG_NONBLOCK;\n    if (chapters_input_file >= nb_input_files) {\n        if (chapters_input_file == INT_MAX) {\n            chapters_input_file = -1;\n            for (i = 0; i < nb_input_files; i++)\n                if (input_files[i].ctx->nb_chapters) {\n                    chapters_input_file = i;\n                    break;\n                }\n        } else {\n            av_log(NULL, AV_LOG_ERROR, "Invalid input file index %d in chapter mapping.\\n",\n                   chapters_input_file);\n            exit_program(1);\n        }\n    }\n    if (chapters_input_file >= 0)\n        copy_chapters(chapters_input_file, nb_output_files - 1);\n    for (i = 0; i < nb_meta_data_maps; i++) {\n        AVFormatContext *files[2];\n        AVDictionary    **meta[2];\n        int j;\n#define METADATA_CHECK_INDEX(index, nb_elems, desc)\\\n        if ((index) < 0 || (index) >= (nb_elems)) {\\\n            av_log(NULL, AV_LOG_ERROR, "Invalid %s index %d while processing metadata maps\\n",\\\n                     (desc), (index));\\\n            exit_program(1);\\\n        }\n        int in_file_index = meta_data_maps[i][1].file;\n        if (in_file_index < 0)\n            continue;\n        METADATA_CHECK_INDEX(in_file_index, nb_input_files, "input file")\n        files[0] = oc;\n        files[1] = input_files[in_file_index].ctx;\n        for (j = 0; j < 2; j++) {\n            MetadataMap *map = &meta_data_maps[i][j];\n            switch (map->type) {\n            case \'g\':\n                meta[j] = &files[j]->metadata;\n                break;\n            case \'s\':\n                METADATA_CHECK_INDEX(map->index, files[j]->nb_streams, "stream")\n                meta[j] = &files[j]->streams[map->index]->metadata;\n                break;\n            case \'c\':\n                METADATA_CHECK_INDEX(map->index, files[j]->nb_chapters, "chapter")\n                meta[j] = &files[j]->chapters[map->index]->metadata;\n                break;\n            case \'p\':\n                METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program")\n                meta[j] = &files[j]->programs[map->index]->metadata;\n                break;\n            }\n        }\n        av_dict_copy(meta[0], *meta[1], AV_DICT_DONT_OVERWRITE);\n    }\n    if (metadata_global_autocopy)\n        av_dict_copy(&oc->metadata, input_files[0].ctx->metadata,\n                     AV_DICT_DONT_OVERWRITE);\n    if (metadata_streams_autocopy)\n        for (i = 0; i < oc->nb_streams; i++) {\n            InputStream *ist = &input_streams[output_streams_for_file[nb_output_files-1][i]->source_index];\n            av_dict_copy(&oc->streams[i]->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);\n        }\n    frame_rate    = (AVRational){0, 0};\n    frame_width   = 0;\n    frame_height  = 0;\n    audio_sample_rate = 0;\n    audio_channels    = 0;\n    audio_sample_fmt  = AV_SAMPLE_FMT_NONE;\n    chapters_input_file = INT_MAX;\n    av_freep(&meta_data_maps);\n    nb_meta_data_maps = 0;\n    metadata_global_autocopy   = 1;\n    metadata_streams_autocopy  = 1;\n    metadata_chapters_autocopy = 1;\n    av_freep(&stream_maps);\n    nb_stream_maps = 0;\n    av_dict_free(&codec_names);\n    av_freep(&forced_key_frames);\n    uninit_opts();\n    init_opts();\n}', 'static OutputStream *new_video_stream(AVFormatContext *oc)\n{\n    AVStream *st;\n    OutputStream *ost;\n    AVCodecContext *video_enc;\n    ost = new_output_stream(oc, AVMEDIA_TYPE_VIDEO);\n    st  = ost->st;\n    if (!st->stream_copy) {\n        ost->frame_aspect_ratio = frame_aspect_ratio;\n        frame_aspect_ratio = 0;\n#if CONFIG_AVFILTER\n        ost->avfilter= vfilters;\n        vfilters = NULL;\n#endif\n    }\n    ost->bitstream_filters = video_bitstream_filters;\n    video_bitstream_filters= NULL;\n    st->codec->thread_count= thread_count;\n    video_enc = st->codec;\n    if(video_codec_tag)\n        video_enc->codec_tag= video_codec_tag;\n    if(oc->oformat->flags & AVFMT_GLOBALHEADER) {\n        video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;\n    }\n    if (st->stream_copy) {\n        video_enc->sample_aspect_ratio =\n        st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);\n    } else {\n        const char *p;\n        int i;\n        if (frame_rate.num)\n            ost->frame_rate = frame_rate;\n        video_enc->width = frame_width;\n        video_enc->height = frame_height;\n        video_enc->pix_fmt = frame_pix_fmt;\n        st->sample_aspect_ratio = video_enc->sample_aspect_ratio;\n        if (intra_only)\n            video_enc->gop_size = 0;\n        if (video_qscale || same_quant) {\n            video_enc->flags |= CODEC_FLAG_QSCALE;\n            video_enc->global_quality = FF_QP2LAMBDA * video_qscale;\n        }\n        if(intra_matrix)\n            video_enc->intra_matrix = intra_matrix;\n        if(inter_matrix)\n            video_enc->inter_matrix = inter_matrix;\n        p= video_rc_override_string;\n        for(i=0; p; i++){\n            int start, end, q;\n            int e=sscanf(p, "%d,%d,%d", &start, &end, &q);\n            if(e!=3){\n                fprintf(stderr, "error parsing rc_override\\n");\n                exit_program(1);\n            }\n            video_enc->rc_override=\n                av_realloc(video_enc->rc_override,\n                           sizeof(RcOverride)*(i+1));\n            video_enc->rc_override[i].start_frame= start;\n            video_enc->rc_override[i].end_frame  = end;\n            if(q>0){\n                video_enc->rc_override[i].qscale= q;\n                video_enc->rc_override[i].quality_factor= 1.0;\n            }\n            else{\n                video_enc->rc_override[i].qscale= 0;\n                video_enc->rc_override[i].quality_factor= -q/100.0;\n            }\n            p= strchr(p, \'/\');\n            if(p) p++;\n        }\n        video_enc->rc_override_count=i;\n        if (!video_enc->rc_initial_buffer_occupancy)\n            video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4;\n        video_enc->me_threshold= me_threshold;\n        video_enc->intra_dc_precision= intra_dc_precision - 8;\n        if (do_psnr)\n            video_enc->flags|= CODEC_FLAG_PSNR;\n        if (do_pass) {\n            if (do_pass == 1) {\n                video_enc->flags |= CODEC_FLAG_PASS1;\n            } else {\n                video_enc->flags |= CODEC_FLAG_PASS2;\n            }\n        }\n        if (forced_key_frames)\n            parse_forced_key_frames(forced_key_frames, ost, video_enc);\n    }\n    if (video_language) {\n        av_dict_set(&st->metadata, "language", video_language, 0);\n        av_freep(&video_language);\n    }\n    video_disable = 0;\n    av_freep(&forced_key_frames);\n    frame_pix_fmt = PIX_FMT_NONE;\n    return ost;\n}', 'static OutputStream *new_output_stream(AVFormatContext *oc, enum AVMediaType type)\n{\n    OutputStream *ost;\n    AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);\n    int idx      = oc->nb_streams - 1;\n    if (!st) {\n        av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\\n");\n        exit_program(1);\n    }\n    output_streams_for_file[nb_output_files] =\n        grow_array(output_streams_for_file[nb_output_files],\n                   sizeof(*output_streams_for_file[nb_output_files]),\n                   &nb_output_streams_for_file[nb_output_files],\n                   oc->nb_streams);\n    ost = output_streams_for_file[nb_output_files][idx] =\n        av_mallocz(sizeof(OutputStream));\n    if (!ost) {\n        fprintf(stderr, "Could not alloc output stream\\n");\n        exit_program(1);\n    }\n    ost->file_index = nb_output_files;\n    ost->index = idx;\n    ost->st    = st;\n    st->codec->codec_type = type;\n    ost->enc = choose_codec(oc, st, type, codec_names);\n    if (ost->enc) {\n        ost->opts  = filter_codec_opts(codec_opts, ost->enc->id, oc, st);\n    }\n    avcodec_get_context_defaults3(st->codec, ost->enc);\n    st->codec->codec_type = type;\n    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);\n    return ost;\n}', 'AVStream *av_new_stream(AVFormatContext *s, int id)\n{\n    AVStream *st;\n    int i;\n    AVStream **streams;\n    if (s->nb_streams >= INT_MAX/sizeof(*streams))\n        return NULL;\n    streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));\n    if (!streams)\n        return NULL;\n    s->streams = streams;\n    st = av_mallocz(sizeof(AVStream));\n    if (!st)\n        return NULL;\n    if (!(st->info = av_mallocz(sizeof(*st->info)))) {\n        av_free(st);\n        return NULL;\n    }\n    st->codec = avcodec_alloc_context3(NULL);\n    if (s->iformat) {\n        st->codec->bit_rate = 0;\n    }\n    st->index = s->nb_streams;\n    st->id = id;\n    st->start_time = AV_NOPTS_VALUE;\n    st->duration = AV_NOPTS_VALUE;\n    st->cur_dts = 0;\n    st->first_dts = AV_NOPTS_VALUE;\n    st->probe_packets = MAX_PROBE_PACKETS;\n    av_set_pts_info(st, 33, 1, 90000);\n    st->last_IP_pts = AV_NOPTS_VALUE;\n    for(i=0; i<MAX_REORDER_DELAY+1; i++)\n        st->pts_buffer[i]= AV_NOPTS_VALUE;\n    st->reference_dts = AV_NOPTS_VALUE;\n    st->sample_aspect_ratio = (AVRational){0,1};\n    s->streams[s->nb_streams++] = st;\n    return st;\n}']