static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx)
{
    int idx = oc->nb_streams - 1;
    OutputStream *ost;
    output_streams_for_file[file_idx] =
        grow_array(output_streams_for_file[file_idx],
                   sizeof(*output_streams_for_file[file_idx]),
                   &nb_output_streams_for_file[file_idx],
                   oc->nb_streams);
    ost = output_streams_for_file[file_idx][idx] =
        av_mallocz(sizeof(OutputStream));
    if (!ost) {
        fprintf(stderr, "Could not alloc output stream\n");
        ffmpeg_exit(1);
    }
    ost->file_index = file_idx;
    ost->index = idx;
    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
    return ost;
}
['static int opt_new_stream(const char *opt, const char *arg)\n{\n    AVFormatContext *oc;\n    int file_idx = nb_output_files - 1;\n    if (nb_output_files <= 0) {\n        fprintf(stderr, "At least one output file must be specified\\n");\n        ffmpeg_exit(1);\n    }\n    oc = output_files[file_idx];\n    if      (!strcmp(opt, "newvideo"   )) new_video_stream   (oc, file_idx);\n    else if (!strcmp(opt, "newaudio"   )) new_audio_stream   (oc, file_idx);\n    else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc, file_idx);\n    else if (!strcmp(opt, "newdata"    )) new_data_stream    (oc, file_idx);\n    else av_assert0(0);\n    return 0;\n}', 'static void new_video_stream(AVFormatContext *oc, int file_idx)\n{\n    AVStream *st;\n    OutputStream *ost;\n    AVCodecContext *video_enc;\n    enum CodecID codec_id = CODEC_ID_NONE;\n    AVCodec *codec= NULL;\n    st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);\n    if (!st) {\n        fprintf(stderr, "Could not alloc stream\\n");\n        ffmpeg_exit(1);\n    }\n    ost = new_output_stream(oc, file_idx);\n    if(!video_stream_copy){\n        if (video_codec_name) {\n            codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1,\n                                         avcodec_opts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance);\n            codec = avcodec_find_encoder_by_name(video_codec_name);\n            ost->enc = codec;\n        } else {\n            codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_VIDEO);\n            codec = avcodec_find_encoder(codec_id);\n        }\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    avcodec_get_context_defaults3(st->codec, codec);\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        avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;\n    }\n    if (video_stream_copy) {\n        st->stream_copy = 1;\n        video_enc->codec_type = AVMEDIA_TYPE_VIDEO;\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->codec_id = codec_id;\n        set_context_opts(video_enc, avcodec_opts[AVMEDIA_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec);\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_quality) {\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                ffmpeg_exit(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(&video_codec_name);\n    av_freep(&forced_key_frames);\n    video_stream_copy = 0;\n    frame_pix_fmt = PIX_FMT_NONE;\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_context();\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}', 'static OutputStream *new_output_stream(AVFormatContext *oc, int file_idx)\n{\n    int idx = oc->nb_streams - 1;\n    OutputStream *ost;\n    output_streams_for_file[file_idx] =\n        grow_array(output_streams_for_file[file_idx],\n                   sizeof(*output_streams_for_file[file_idx]),\n                   &nb_output_streams_for_file[file_idx],\n                   oc->nb_streams);\n    ost = output_streams_for_file[file_idx][idx] =\n        av_mallocz(sizeof(OutputStream));\n    if (!ost) {\n        fprintf(stderr, "Could not alloc output stream\\n");\n        ffmpeg_exit(1);\n    }\n    ost->file_index = file_idx;\n    ost->index = idx;\n    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);\n    return ost;\n}']