avconv.c:4320: error: Integer Overflow L1
  (0 - 1):unsigned32 by call to `init_output_filter`.

avconv.c:4339:17: Assignment
4337.                                                map->sync_stream_index];
4338.                 ist->discard = 0;
4339.                 ist->st->discard = AVDISCARD_NONE;
                      ^
4340.             }
4341.         }

avconv.c:4316:21: Call
4314. loop_end:
4315.                 if (!ofilter) {
4316.                     av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
                          ^
4317.                            "in any defined filter graph.\n", map->linklabel);
4318.                     exit_program(1);

libavutil/log.c:140:1: Parameter `*avcl`
  138.     av_log_default_callback;
  139. 
  140. void av_log(void* avcl, int level, const char *fmt, ...)
       ^
  141. {
  142.     AVClass* avc = avcl ? *(AVClass **) avcl : NULL;

avconv.c:4320:17: Call
4318.                     exit_program(1);
4319.                 }
4320.                 init_output_filter(ofilter, o, oc);
                      ^
4321.             } else {
4322.                 ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];

avconv.c:4161:1: Parameter `oc->nb_streams`
  4159. }
  4160. 
  4161. static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
        ^
  4162.                                AVFormatContext *oc)
  4163. {

avconv.c:4171:25: Call
  4169.     }
  4170. 
  4171.     ost               = new_video_stream(o, oc);
                                ^
  4172.     ost->source_index = -1;
  4173.     ost->filter       = ofilter;

avconv.c:3920:1: Parameter `oc->nb_streams`
    3918. }
    3919. 
    3920. static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
          ^
    3921. {
    3922.     AVStream *st;

avconv.c:3926:11: Call
    3924.     AVCodecContext *video_enc;
    3925. 
    3926.     ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO);
                    ^
    3927.     st  = ost->st;
    3928.     video_enc = st->codec;

avconv.c:3797:1: <LHS trace>
3795. }
3796. 
3797. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
      ^
3798. {
3799.     OutputStream *ost;

avconv.c:3797:1: Parameter `o->nb_streamid_map`
      3795. }
      3796. 
      3797. static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
            ^
      3798. {
      3799.     OutputStream *ost;

avconv.c:3814:18: Binary operation: (0 - 1):unsigned32 by call to `init_output_filter` 
      3812. 
      3813.     if (oc->nb_streams - 1 < o->nb_streamid_map)
      3814.         st->id = o->streamid_map[oc->nb_streams - 1];
                             ^
      3815. 
      3816.     output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams,

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);
    if (!(ost = av_mallocz(sizeof(*ost))))
        exit_program(1);
    output_streams[nb_output_streams - 1] = ost;
    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);
    ost->pix_fmts[0] = ost->pix_fmts[1] = PIX_FMT_NONE;
    return ost;
}
['static void opt_output_file(void *optctx, const char *filename)\n{\n    OptionsContext *o = optctx;\n    AVFormatContext *oc;\n    int i, j, err;\n    AVOutputFormat *file_oformat;\n    OutputStream *ost;\n    InputStream  *ist;\n    if (configure_complex_filters() < 0) {\n        av_log(NULL, AV_LOG_FATAL, "Error configuring filters.\\n");\n        exit_program(1);\n    }\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    oc->interrupt_callback = int_cb;\n    av_strlcpy(oc->filename, filename, sizeof(oc->filename));\n    for (i = 0; i < nb_filtergraphs; i++) {\n        FilterGraph *fg = filtergraphs[i];\n        for (j = 0; j < fg->nb_outputs; j++) {\n            OutputFilter *ofilter = fg->outputs[j];\n            if (!ofilter->out_tmp || ofilter->out_tmp->name)\n                continue;\n            switch (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type) {\n            case AVMEDIA_TYPE_VIDEO:    o->video_disable    = 1; break;\n            case AVMEDIA_TYPE_AUDIO:    o->audio_disable    = 1; break;\n            case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;\n            }\n            init_output_filter(ofilter, o, oc);\n        }\n    }\n    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            input_streams[index]->st->discard = AVDISCARD_NONE;\\\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            if (map->linklabel) {\n                FilterGraph *fg;\n                OutputFilter *ofilter = NULL;\n                int j, k;\n                for (j = 0; j < nb_filtergraphs; j++) {\n                    fg = filtergraphs[j];\n                    for (k = 0; k < fg->nb_outputs; k++) {\n                        AVFilterInOut *out = fg->outputs[k]->out_tmp;\n                        if (out && !strcmp(out->name, map->linklabel)) {\n                            ofilter = fg->outputs[k];\n                            goto loop_end;\n                        }\n                    }\n                }\nloop_end:\n                if (!ofilter) {\n                    av_log(NULL, AV_LOG_FATAL, "Output with label \'%s\' does not exist "\n                           "in any defined filter graph.\\n", map->linklabel);\n                    exit_program(1);\n                }\n                init_output_filter(ofilter, o, oc);\n            } else {\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                ist->st->discard = AVDISCARD_NONE;\n            }\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_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 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    if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0]))))\n        exit_program(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    if (o->recording_time != INT64_MAX)\n        oc->duration = 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_open2(&oc->pb, filename, AVIO_FLAG_WRITE,\n                              &oc->interrupt_callback,\n                              &output_files[nb_output_files - 1]->opts)) < 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    for (i = 0; i < o->nb_metadata_map; i++) {\n        char *p;\n        int in_file_index = strtol(o->metadata_map[i].u.str, &p, 0);\n        if (in_file_index < 0)\n            continue;\n        if (in_file_index >= nb_input_files) {\n            av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\\n", in_file_index);\n            exit_program(1);\n        }\n        copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, input_files[in_file_index]->ctx, o);\n    }\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    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        const char *stream_spec;\n        int index = 0, j, ret;\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, &stream_spec);\n        if (type == \'s\') {\n            for (j = 0; j < oc->nb_streams; j++) {\n                if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) {\n                    av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0);\n                } else if (ret < 0)\n                    exit_program(1);\n            }\n            printf("ret %d, stream_spec %s\\n", ret, stream_spec);\n        }\n        else {\n            switch (type) {\n            case \'g\':\n                m = &oc->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    }\n    reset_options(o);\n}', 'void av_log(void* avcl, int level, const char *fmt, ...)\n{\n    AVClass* avc = avcl ? *(AVClass **) avcl : NULL;\n    va_list vl;\n    va_start(vl, fmt);\n    if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&\n        avc->log_level_offset_offset && level >= AV_LOG_FATAL)\n        level += *(int *) (((uint8_t *) avcl) + avc->log_level_offset_offset);\n    av_vlog(avcl, level, fmt, vl);\n    va_end(vl);\n}', 'static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,\n                               AVFormatContext *oc)\n{\n    OutputStream *ost;\n    if (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type != AVMEDIA_TYPE_VIDEO) {\n        av_log(NULL, AV_LOG_FATAL, "Only video filters are supported currently.\\n");\n        exit_program(1);\n    }\n    ost               = new_video_stream(o, oc);\n    ost->source_index = -1;\n    ost->filter       = ofilter;\n    ofilter->ost      = ost;\n    if (configure_output_filter(ofilter->graph, ofilter, ofilter->out_tmp) < 0) {\n        av_log(NULL, AV_LOG_FATAL, "Error configuring filter.\\n");\n        exit_program(1);\n    }\n    avfilter_inout_free(&ofilter->out_tmp);\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(filters, str, filters, oc, st);\n        if (filters)\n            ost->avfilter = av_strdup(filters);\n    } else {\n        MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc ,st);\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    if (!(ost = av_mallocz(sizeof(*ost))))\n        exit_program(1);\n    output_streams[nb_output_streams - 1] = ost;\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    ost->pix_fmts[0] = ost->pix_fmts[1] = PIX_FMT_NONE;\n    return ost;\n}']