diff --git a/ffmpeg.c b/ffmpeg.c index d89a5bd981..4e207a5c21 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -293,9 +293,6 @@ typedef struct OutputStream { AVDictionary *opts; } OutputStream; -static OutputStream **output_streams_for_file[MAX_FILES] = { NULL }; -static int nb_output_streams_for_file[MAX_FILES] = { 0 }; - typedef struct InputStream { int file_index; AVStream *st; @@ -332,6 +329,7 @@ static struct termios oldtty; typedef struct OutputFile { AVFormatContext *ctx; AVDictionary *opts; + int ost_index; /* index of the first stream in output_streams */ } OutputFile; static InputStream *input_streams = NULL; @@ -339,6 +337,8 @@ static int nb_input_streams = 0; static InputFile *input_files = NULL; static int nb_input_files = 0; +static OutputStream *output_streams = NULL; +static int nb_output_streams = 0; static OutputFile *output_files = NULL; static int nb_output_files = 0; @@ -525,7 +525,6 @@ static int exit_program(int ret) if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb) avio_close(s->pb); avformat_free_context(s); - av_free(output_streams_for_file[i]); av_dict_free(&output_files[i].opts); } for(i=0;ist->codec; if (!ost->st->stream_copy && enc->coded_frame) q = enc->coded_frame->quality/(float)FF_QP2LAMBDA; @@ -1454,7 +1454,7 @@ static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_ /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(InputStream *ist, int ist_index, - OutputStream **ost_table, int nb_ostreams, + OutputStream *ost_table, int nb_ostreams, const AVPacket *pkt) { AVFormatContext *os; @@ -1605,7 +1605,7 @@ static int output_packet(InputStream *ist, int ist_index, if(ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) if (start_time == 0 || ist->pts >= start_time) { for(i=0;iinput_video_filter && ost->source_index == ist_index) { if (!picture.sample_aspect_ratio.num) picture.sample_aspect_ratio = ist->st->sample_aspect_ratio; @@ -1644,7 +1644,7 @@ static int output_packet(InputStream *ist, int ist_index, for(i=0;isource_index == ist_index) { AVCodecContext *enc= ost->st->codec; os = output_files[ost->file_index].ctx; @@ -1895,11 +1895,10 @@ static int transcode(OutputFile *output_files, InputFile *input_files, int nb_input_files) { - int ret = 0, i, j, k, n, nb_ostreams = 0; - + int ret = 0, i, j; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; - OutputStream *ost, **ost_table = NULL; + OutputStream *ost; InputStream *ist; char error[1024]; int key; @@ -1912,7 +1911,6 @@ static int transcode(OutputFile *output_files, input_streams[i].start = av_gettime(); /* output stream init */ - nb_ostreams = 0; for(i=0;inb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { @@ -1921,22 +1919,11 @@ static int transcode(OutputFile *output_files, ret = AVERROR(EINVAL); goto fail; } - nb_ostreams += os->nb_streams; - } - - ost_table = av_mallocz(sizeof(OutputStream *) * nb_ostreams); - if (!ost_table) - goto fail; - n = 0; - for(k=0;knb_streams; i++, n++) - ost_table[n] = output_streams_for_file[k][i]; } /* for each output stream, we compute the right encoding parameters */ - for(i=0;ifile_index].ctx; ist = &input_streams[ost->source_index]; @@ -2159,8 +2146,8 @@ static int transcode(OutputFile *output_files, } /* open each encoder */ - for(i=0;iencoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; @@ -2252,8 +2239,8 @@ static int transcode(OutputFile *output_files, /* dump the stream mapping */ if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); - for(i=0;i #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, @@ -2326,9 +2313,9 @@ static int transcode(OutputFile *output_files, double ts; fprintf(stderr, "\nEnter command: