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

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

avconv.c:3568:13: Call
3566.                 }
3567.             }
3568.             NEW_STREAM(video, idx);
                  ^
3569.         }
3570. 

avconv.c:3226:1: Parameter `oc->nb_streams`
  3224. }
  3225. 
  3226. static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
        ^
  3227. {
  3228.     AVStream *st;

avconv.c:3232:11: Call
  3230.     AVCodecContext *video_enc;
  3231. 
  3232.     ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO);
                  ^
  3233.     st  = ost->st;
  3234.     video_enc = st->codec;

avconv.c:3109:1: <LHS trace>
3107. }
3108. 
3109. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
      ^
3110. {
3111.     OutputStream *ost;

avconv.c:3109:1: Parameter `oc->nb_streams`
    3107. }
    3108. 
    3109. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
          ^
    3110. {
    3111.     OutputStream *ost;

avconv.c:3112:20: Call
    3110. {
    3111.     OutputStream *ost;
    3112.     AVStream *st = avformat_new_stream(oc, NULL);
                             ^
    3113.     int idx      = oc->nb_streams - 1, ret = 0;
    3114.     char *bsf = NULL, *next, *codec_tag = NULL;

libavformat/utils.c:2703:1: Parameter `s->nb_streams`
      2701. #endif
      2702. 
      2703. AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
            ^
      2704. {
      2705.     AVStream *st;

avconv.c:3113:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `new_video_stream` 
    3111.     OutputStream *ost;
    3112.     AVStream *st = avformat_new_stream(oc, NULL);
    3113.     int idx      = oc->nb_streams - 1, ret = 0;
              ^
    3114.     char *bsf = NULL, *next, *codec_tag = NULL;
    3115.     AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;

static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
{
    OutputStream *ost;
    AVStream *st = avformat_new_stream(oc, NULL);
    int idx      = oc->nb_streams - 1, ret = 0;
    char *bsf = NULL, *next, *codec_tag = NULL;
    AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
    double qscale = -1;
    char *buf = NULL, *arg = NULL, *preset = NULL;
    AVIOContext *s = NULL;
    if (!st) {
        av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
        exit_program(1);
    }
    if (oc->nb_streams - 1 < o->nb_streamid_map)
        st->id = o->streamid_map[oc->nb_streams - 1];
    output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,
                                nb_output_streams + 1);
    ost = &output_streams[nb_output_streams - 1];
    ost->file_index = nb_output_files;
    ost->index = idx;
    ost->st    = st;
    st->codec->codec_type = type;
    choose_encoder(o, oc, ost);
    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;
    MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
    if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
        do  {
            buf = get_line(s);
            if (!buf[0] || buf[0] == '#') {
                av_free(buf);
                continue;
            }
            if (!(arg = strchr(buf, '='))) {
                av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
                exit_program(1);
            }
            *arg++ = 0;
            av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
            av_free(buf);
        } while (!s->eof_reached);
        avio_close(s);
    }
    if (ret) {
        av_log(NULL, AV_LOG_FATAL,
               "Preset %s specified for stream %d:%d, but could not be opened.\n",
               preset, ost->file_index, ost->index);
        exit_program(1);
    }
    ost->max_frames = INT64_MAX;
    MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
    MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
    while (bsf) {
        if (next = strchr(bsf, ','))
            *next++ = 0;
        if (!(bsfc = av_bitstream_filter_init(bsf))) {
            av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf);
            exit_program(1);
        }
        if (bsfc_prev)
            bsfc_prev->next = bsfc;
        else
            ost->bitstream_filters = bsfc;
        bsfc_prev = bsfc;
        bsf       = next;
    }
    MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
    if (codec_tag) {
        uint32_t tag = strtol(codec_tag, &next, 0);
        if (*next)
            tag = AV_RL32(codec_tag);
        st->codec->codec_tag = tag;
    }
    MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);
    if (qscale >= 0 || same_quant) {
        st->codec->flags |= CODEC_FLAG_QSCALE;
        st->codec->global_quality = FF_QP2LAMBDA * qscale;
    }
    if (oc->oformat->flags & AVFMT_GLOBALHEADER)
        st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
    av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags);
    return ost;
}
['static void opt_output_file(void *optctx, const char *filename)\n{\n    OptionsContext *o = optctx;\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 (o->format) {\n        file_oformat = av_guess_format(o->format, NULL, NULL);\n        if (!file_oformat) {\n            av_log(NULL, AV_LOG_FATAL, "Requested output format \'%s\' is not a suitable output format\\n", o->format);\n            exit_program(1);\n        }\n    } else {\n        file_oformat = av_guess_format(NULL, filename, NULL);\n        if (!file_oformat) {\n            av_log(NULL, AV_LOG_FATAL, "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(o, oc, filename);\n        if (err < 0) {\n            print_error(filename, err);\n            exit_program(1);\n        }\n    } else if (!o->nb_stream_maps) {\n#define NEW_STREAM(type, index)\\\n        if (index >= 0) {\\\n            ost = new_ ## type ## _stream(o, oc);\\\n            ost->source_index = index;\\\n            ost->sync_ist     = &input_streams[index];\\\n            input_streams[index].discard = 0;\\\n        }\n        if (!o->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 (!o->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 (!o->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 < o->nb_stream_maps; i++) {\n            StreamMap *map = &o->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(o, oc);    break;\n            case AVMEDIA_TYPE_AUDIO:    ost = new_audio_stream(o, oc);    break;\n            case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(o, oc); break;\n            case AVMEDIA_TYPE_DATA:     ost = new_data_stream(o, oc);     break;\n            case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc); break;\n            default:\n                av_log(NULL, AV_LOG_FATAL, "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    for (i = 0; i < o->nb_attachments; i++) {\n        AVIOContext *pb;\n        uint8_t *attachment;\n        const char *p;\n        int64_t len;\n        if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) {\n            av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\\n",\n                   o->attachments[i]);\n            exit_program(1);\n        }\n        if ((len = avio_size(pb)) <= 0) {\n            av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\\n",\n                   o->attachments[i]);\n            exit_program(1);\n        }\n        if (!(attachment = av_malloc(len))) {\n            av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\\n",\n                   o->attachments[i]);\n            exit_program(1);\n        }\n        avio_read(pb, attachment, len);\n        ost = new_attachment_stream(o, oc);\n        ost->stream_copy               = 0;\n        ost->source_index              = -1;\n        ost->attachment_filename       = o->attachments[i];\n        ost->st->codec->extradata      = attachment;\n        ost->st->codec->extradata_size = len;\n        p = strrchr(o->attachments[i], \'/\');\n        av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);\n        avio_close(pb);\n    }\n    output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1);\n    output_files[nb_output_files - 1].ctx       = oc;\n    output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams;\n    output_files[nb_output_files - 1].recording_time = o->recording_time;\n    output_files[nb_output_files - 1].start_time     = o->start_time;\n    output_files[nb_output_files - 1].limit_filesize = o->limit_filesize;\n    av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0);\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        assert_file_overwrite(filename);\n        if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {\n            print_error(filename, err);\n            exit_program(1);\n        }\n    }\n    if (o->mux_preload) {\n        uint8_t buf[64];\n        snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE));\n        av_dict_set(&output_files[nb_output_files - 1].opts, "preload", buf, 0);\n    }\n    oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);\n    oc->flags |= AVFMT_FLAG_NONBLOCK;\n    if (o->chapters_input_file >= nb_input_files) {\n        if (o->chapters_input_file == INT_MAX) {\n            o->chapters_input_file = -1;\n            for (i = 0; i < nb_input_files; i++)\n                if (input_files[i].ctx->nb_chapters) {\n                    o->chapters_input_file = i;\n                    break;\n                }\n        } else {\n            av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\\n",\n                   o->chapters_input_file);\n            exit_program(1);\n        }\n    }\n    if (o->chapters_input_file >= 0)\n        copy_chapters(&input_files[o->chapters_input_file], &output_files[nb_output_files - 1],\n                      !o->metadata_chapters_manual);\n    for (i = 0; i < o->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_FATAL, "Invalid %s index %d while processing metadata maps\\n",\\\n                     (desc), (index));\\\n            exit_program(1);\\\n        }\n        int in_file_index = o->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 = &o->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 (!o->metadata_global_manual && nb_input_files)\n        av_dict_copy(&oc->metadata, input_files[0].ctx->metadata,\n                     AV_DICT_DONT_OVERWRITE);\n    if (!o->metadata_streams_manual)\n        for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) {\n            InputStream *ist;\n            if (output_streams[i].source_index < 0)\n                continue;\n            ist = &input_streams[output_streams[i].source_index];\n            av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE);\n        }\n    for (i = 0; i < o->nb_metadata; i++) {\n        AVDictionary **m;\n        char type, *val;\n        int index = 0;\n        val = strchr(o->metadata[i].u.str, \'=\');\n        if (!val) {\n            av_log(NULL, AV_LOG_FATAL, "No \'=\' character in metadata string %s.\\n",\n                   o->metadata[i].u.str);\n            exit_program(1);\n        }\n        *val++ = 0;\n        parse_meta_type(o->metadata[i].specifier, &type, &index);\n        switch (type) {\n        case \'g\':\n            m = &oc->metadata;\n            break;\n        case \'s\':\n            if (index < 0 || index >= oc->nb_streams) {\n                av_log(NULL, AV_LOG_FATAL, "Invalid stream index %d in metadata specifier.\\n", index);\n                exit_program(1);\n            }\n            m = &oc->streams[index]->metadata;\n            break;\n        case \'c\':\n            if (index < 0 || index >= oc->nb_chapters) {\n                av_log(NULL, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\\n", index);\n                exit_program(1);\n            }\n            m = &oc->chapters[index]->metadata;\n            break;\n        default:\n            av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\\n", o->metadata[i].specifier);\n            exit_program(1);\n        }\n        av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0);\n    }\n    reset_options(o);\n}', 'static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)\n{\n    AVStream *st;\n    OutputStream *ost;\n    AVCodecContext *video_enc;\n    ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO);\n    st  = ost->st;\n    video_enc = st->codec;\n    if (!ost->stream_copy) {\n        const char *p = NULL;\n        char *forced_key_frames = NULL, *frame_rate = NULL, *frame_size = NULL;\n        char *frame_aspect_ratio = NULL, *frame_pix_fmt = NULL;\n        char *intra_matrix = NULL, *inter_matrix = NULL, *filters = NULL;\n        int i;\n        MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st);\n        if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {\n            av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\\n", frame_rate);\n            exit_program(1);\n        }\n        MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st);\n        if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, frame_size) < 0) {\n            av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\\n", frame_size);\n            exit_program(1);\n        }\n        MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);\n        if (frame_aspect_ratio)\n            ost->frame_aspect_ratio = parse_frame_aspect_ratio(frame_aspect_ratio);\n        MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);\n        if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == PIX_FMT_NONE) {\n            av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\\n", frame_pix_fmt);\n            exit_program(1);\n        }\n        st->sample_aspect_ratio = video_enc->sample_aspect_ratio;\n        MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st);\n        if (intra_matrix) {\n            if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) {\n                av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\\n");\n                exit_program(1);\n            }\n            parse_matrix_coeffs(video_enc->intra_matrix, intra_matrix);\n        }\n        MATCH_PER_STREAM_OPT(inter_matrices, str, inter_matrix, oc, st);\n        if (inter_matrix) {\n            if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) {\n                av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for inter matrix.\\n");\n                exit_program(1);\n            }\n            parse_matrix_coeffs(video_enc->inter_matrix, inter_matrix);\n        }\n        MATCH_PER_STREAM_OPT(rc_overrides, str, p, oc, st);\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                av_log(NULL, AV_LOG_FATAL, "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->intra_dc_precision= intra_dc_precision - 8;\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        MATCH_PER_STREAM_OPT(forced_key_frames, str, forced_key_frames, oc, st);\n        if (forced_key_frames)\n            parse_forced_key_frames(forced_key_frames, ost, video_enc);\n        MATCH_PER_STREAM_OPT(force_fps, i, ost->force_fps, oc, st);\n        ost->top_field_first = -1;\n        MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st);\n        MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc ,st);\n#if CONFIG_AVFILTER\n        MATCH_PER_STREAM_OPT(filters, str, filters, oc, st);\n        if (filters)\n            ost->avfilter = av_strdup(filters);\n#endif\n    }\n    return ost;\n}', 'static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)\n{\n    OutputStream *ost;\n    AVStream *st = avformat_new_stream(oc, NULL);\n    int idx      = oc->nb_streams - 1, ret = 0;\n    char *bsf = NULL, *next, *codec_tag = NULL;\n    AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;\n    double qscale = -1;\n    char *buf = NULL, *arg = NULL, *preset = NULL;\n    AVIOContext *s = NULL;\n    if (!st) {\n        av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\\n");\n        exit_program(1);\n    }\n    if (oc->nb_streams - 1 < o->nb_streamid_map)\n        st->id = o->streamid_map[oc->nb_streams - 1];\n    output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,\n                                nb_output_streams + 1);\n    ost = &output_streams[nb_output_streams - 1];\n    ost->file_index = nb_output_files;\n    ost->index = idx;\n    ost->st    = st;\n    st->codec->codec_type = type;\n    choose_encoder(o, oc, ost);\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    MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);\n    if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {\n        do  {\n            buf = get_line(s);\n            if (!buf[0] || buf[0] == \'#\') {\n                av_free(buf);\n                continue;\n            }\n            if (!(arg = strchr(buf, \'=\'))) {\n                av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\\n");\n                exit_program(1);\n            }\n            *arg++ = 0;\n            av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);\n            av_free(buf);\n        } while (!s->eof_reached);\n        avio_close(s);\n    }\n    if (ret) {\n        av_log(NULL, AV_LOG_FATAL,\n               "Preset %s specified for stream %d:%d, but could not be opened.\\n",\n               preset, ost->file_index, ost->index);\n        exit_program(1);\n    }\n    ost->max_frames = INT64_MAX;\n    MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);\n    MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);\n    while (bsf) {\n        if (next = strchr(bsf, \',\'))\n            *next++ = 0;\n        if (!(bsfc = av_bitstream_filter_init(bsf))) {\n            av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\\n", bsf);\n            exit_program(1);\n        }\n        if (bsfc_prev)\n            bsfc_prev->next = bsfc;\n        else\n            ost->bitstream_filters = bsfc;\n        bsfc_prev = bsfc;\n        bsf       = next;\n    }\n    MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);\n    if (codec_tag) {\n        uint32_t tag = strtol(codec_tag, &next, 0);\n        if (*next)\n            tag = AV_RL32(codec_tag);\n        st->codec->codec_tag = tag;\n    }\n    MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st);\n    if (qscale >= 0 || same_quant) {\n        st->codec->flags |= CODEC_FLAG_QSCALE;\n        st->codec->global_quality = FF_QP2LAMBDA * qscale;\n    }\n    if (oc->oformat->flags & AVFMT_GLOBALHEADER)\n        st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;\n    av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags);\n    return ost;\n}', 'AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)\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(c);\n    if (s->iformat) {\n        st->codec->bit_rate = 0;\n    }\n    st->index = s->nb_streams;\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}']