fftools/ffmpeg_mux_init: simplify inner loop in map_auto_{video,audio}
Skip unusable streams early and do not compute any scores for them.
This commit is contained in:
		
							parent
							
								
									4c40581614
								
							
						
					
					
						commit
						86e2ffedfe
					
				@ -869,15 +869,18 @@ static void map_auto_video(Muxer *mux, const OptionsContext *o)
 | 
				
			|||||||
        for (int i = 0; i < ifile->nb_streams; i++) {
 | 
					        for (int i = 0; i < ifile->nb_streams; i++) {
 | 
				
			||||||
            int score;
 | 
					            int score;
 | 
				
			||||||
            ist = input_streams[ifile->ist_index + i];
 | 
					            ist = input_streams[ifile->ist_index + i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (ist->user_set_discard == AVDISCARD_ALL ||
 | 
				
			||||||
 | 
					                ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            score = ist->st->codecpar->width * ist->st->codecpar->height
 | 
					            score = ist->st->codecpar->width * ist->st->codecpar->height
 | 
				
			||||||
                       + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
 | 
					                       + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
 | 
				
			||||||
                       + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
 | 
					                       + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
 | 
				
			||||||
            if (ist->user_set_discard == AVDISCARD_ALL)
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
 | 
					            if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
 | 
				
			||||||
                score = 1;
 | 
					                score = 1;
 | 
				
			||||||
            if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
 | 
					
 | 
				
			||||||
                score > file_best_score) {
 | 
					            if (score > file_best_score) {
 | 
				
			||||||
                if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
 | 
					                if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                file_best_score = score;
 | 
					                file_best_score = score;
 | 
				
			||||||
@ -913,13 +916,15 @@ static void map_auto_audio(Muxer *mux, const OptionsContext *o)
 | 
				
			|||||||
        for (int i = 0; i < ifile->nb_streams; i++) {
 | 
					        for (int i = 0; i < ifile->nb_streams; i++) {
 | 
				
			||||||
            int score;
 | 
					            int score;
 | 
				
			||||||
            ist = input_streams[ifile->ist_index + i];
 | 
					            ist = input_streams[ifile->ist_index + i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (ist->user_set_discard == AVDISCARD_ALL ||
 | 
				
			||||||
 | 
					                ist->st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            score = ist->st->codecpar->ch_layout.nb_channels
 | 
					            score = ist->st->codecpar->ch_layout.nb_channels
 | 
				
			||||||
                    + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
 | 
					                    + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
 | 
				
			||||||
                    + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
 | 
					                    + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
 | 
				
			||||||
            if (ist->user_set_discard == AVDISCARD_ALL)
 | 
					            if (score > file_best_score) {
 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
 | 
					 | 
				
			||||||
                score > file_best_score) {
 | 
					 | 
				
			||||||
                file_best_score = score;
 | 
					                file_best_score = score;
 | 
				
			||||||
                file_best_idx = ifile->ist_index + i;
 | 
					                file_best_idx = ifile->ist_index + i;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user