From b25d931a82c7b95b2f47e6759c9d9be7705d664b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 2 Apr 2011 16:09:47 +0200 Subject: [PATCH] Fix stream mapping regression Signed-off-by: Michael Niedermayer --- ffmpeg.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 2a7431cf54..5d89fc064d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1948,7 +1948,7 @@ static int transcode(AVFormatContext **output_files, int nb_input_files, AVStreamMap *stream_maps, int nb_stream_maps) { - int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0; + int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0, step; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; AVOutputStream *ost, **ost_table = NULL; @@ -1959,6 +1959,8 @@ static int transcode(AVFormatContext **output_files, int want_sdp = 1; uint8_t no_packet[MAX_FILES]={0}; int no_packet_count=0; + int nb_frame_threshold[AVMEDIA_TYPE_NB]={0}; + int nb_streams[AVMEDIA_TYPE_NB]={0}; file_table= av_mallocz(nb_input_files * sizeof(AVInputFile)); if (!file_table) @@ -2043,6 +2045,43 @@ static int transcode(AVFormatContext **output_files, ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams); if (!ost_table) goto fail; + + for(k=0;knb_streams;i++,n++) { + nb_streams[os->streams[i]->codec->codec_type]++; + } + } + for(step=1<<30; step; step>>=1){ + int found_streams[AVMEDIA_TYPE_NB]={0}; + for(j=0; jfile_index ]; + skip=1; + for(pi=0; pinb_programs; pi++){ + AVProgram *p= f->programs[pi]; + if(p->id == opt_programid) + for(si=0; sinb_stream_indexes; si++){ + if(f->streams[ p->stream_index[si] ] == ist->st) + skip=0; + } + } + } + if (ist->discard && ist->st->discard != AVDISCARD_ALL && !skip + && nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames){ + found_streams[ist->st->codec->codec_type]++; + } + } + for(j=0; jdiscard && ist->st->discard != AVDISCARD_ALL && !skip && - ist->st->codec->codec_type == ost->st->codec->codec_type) { - if(best_nb_frames < ist->st->codec_info_nb_frames){ - best_nb_frames= ist->st->codec_info_nb_frames; + ist->st->codec->codec_type == ost->st->codec->codec_type && + nb_frame_threshold[ist->st->codec->codec_type] <= ist->st->codec_info_nb_frames) { ost->source_index = j; found = 1; - } + break; } }