avformat/hlsenc: better checking var_stream_map content
When multiple variant streams are specified by var_stream_map option, implementation assumes that each elementary stream is assigned only once to any variant. But this is not checked. This patch makes this checking. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu> Reviewed-by: Steven Liu<lq@onvideo.cn>
This commit is contained in:
		
							parent
							
								
									01d8c72b95
								
							
						
					
					
						commit
						1beeb3b877
					
				| @ -1885,7 +1885,7 @@ static int parse_variant_stream_mapstring(AVFormatContext *s) | |||||||
| { | { | ||||||
|     HLSContext *hls = s->priv_data; |     HLSContext *hls = s->priv_data; | ||||||
|     VariantStream *vs; |     VariantStream *vs; | ||||||
|     int stream_index; |     int stream_index, i, j; | ||||||
|     enum AVMediaType codec_type; |     enum AVMediaType codec_type; | ||||||
|     int nb_varstreams, nb_streams; |     int nb_varstreams, nb_streams; | ||||||
|     char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval; |     char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval; | ||||||
| @ -1987,6 +1987,23 @@ static int parse_variant_stream_mapstring(AVFormatContext *s) | |||||||
|                                                            atoi(val)); |                                                            atoi(val)); | ||||||
| 
 | 
 | ||||||
|             if (stream_index >= 0 && nb_streams < vs->nb_streams) { |             if (stream_index >= 0 && nb_streams < vs->nb_streams) { | ||||||
|  |                 for(i = 0; nb_streams > 0 && i < nb_streams; i++) { | ||||||
|  |                     if (vs->streams[i] == s->streams[stream_index]) { | ||||||
|  |                         av_log(s, AV_LOG_ERROR, "Same elementary stream found more than once inside " | ||||||
|  |                                "variant definition #%d\n", nb_varstreams - 1); | ||||||
|  |                         return AVERROR(EINVAL); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 for(j = 0; nb_varstreams > 1 && j < nb_varstreams - 1; j++) { | ||||||
|  |                     for(i = 0; i < hls->var_streams[j].nb_streams; i++) { | ||||||
|  |                         if (hls->var_streams[j].streams[i] == s->streams[stream_index]) { | ||||||
|  |                             av_log(s, AV_LOG_ERROR, "Same elementary stream found more than once " | ||||||
|  |                                    "in two different variant definitions #%d and #%d\n", | ||||||
|  |                                    j, nb_varstreams - 1); | ||||||
|  |                             return AVERROR(EINVAL); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|                 vs->streams[nb_streams++] = s->streams[stream_index]; |                 vs->streams[nb_streams++] = s->streams[stream_index]; | ||||||
|             } else { |             } else { | ||||||
|                 av_log(s, AV_LOG_ERROR, "Unable to map stream at %s\n", keyval); |                 av_log(s, AV_LOG_ERROR, "Unable to map stream at %s\n", keyval); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user