lavf/srtdec: simplify start/end computation.
Also fix potential overflow (CID733778)
This commit is contained in:
		
							parent
							
								
									a945607a78
								
							
						
					
					
						commit
						a96b39de62
					
				| @ -53,19 +53,16 @@ static int srt_read_header(AVFormatContext *s) | |||||||
| 
 | 
 | ||||||
| static int64_t get_pts(const char *buf, int *duration) | static int64_t get_pts(const char *buf, int *duration) | ||||||
| { | { | ||||||
|     int i, hour, min, sec, hsec; |     int i; | ||||||
|     int he, me, se, mse; |  | ||||||
| 
 | 
 | ||||||
|     for (i=0; i<2; i++) { |     for (i=0; i<2; i++) { | ||||||
|         int64_t start, end; |         int hh1, mm1, ss1, ms1; | ||||||
|  |         int hh2, mm2, ss2, ms2; | ||||||
|         if (sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d", |         if (sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d", | ||||||
|                    &hour, &min, &sec, &hsec, &he, &me, &se, &mse) == 8) { |                    &hh1, &mm1, &ss1, &ms1, | ||||||
|             min += 60*hour; |                    &hh2, &mm2, &ss2, &ms2) == 8) { | ||||||
|             sec += 60*min; |             int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1; | ||||||
|             start = sec*1000+hsec; |             int64_t end   = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2; | ||||||
|             me += 60*he; |  | ||||||
|             se += 60*me; |  | ||||||
|             end = se*1000+mse; |  | ||||||
|             *duration = end - start; |             *duration = end - start; | ||||||
|             return start; |             return start; | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user