avcodec/dca_parser: skip initial padding
Padding before the first sync word can be very large for DTS-in-WAV streams. There is no reason to include this padding in parsed packet. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
		
							parent
							
								
									1f7b67a1ca
								
							
						
					
					
						commit
						214e63f851
					
				| @ -33,6 +33,7 @@ typedef struct DCAParseContext { | |||||||
|     uint32_t lastmarker; |     uint32_t lastmarker; | ||||||
|     int size; |     int size; | ||||||
|     int framesize; |     int framesize; | ||||||
|  |     unsigned int startpos; | ||||||
|     DCAExssParser exss; |     DCAExssParser exss; | ||||||
|     unsigned int sr_code; |     unsigned int sr_code; | ||||||
| } DCAParseContext; | } DCAParseContext; | ||||||
| @ -75,23 +76,30 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, | |||||||
| 
 | 
 | ||||||
|     i = 0; |     i = 0; | ||||||
|     if (!start_found) { |     if (!start_found) { | ||||||
|         for (i = 0; i < buf_size; i++) { |         for (; i < buf_size; i++) { | ||||||
|  |             size++; | ||||||
|             state = (state << 8) | buf[i]; |             state = (state << 8) | buf[i]; | ||||||
|             if (IS_MARKER(state)) { | 
 | ||||||
|                 if (!pc1->lastmarker || |             if (IS_MARKER(state) && | ||||||
|  |                 (!pc1->lastmarker || | ||||||
|                   pc1->lastmarker == CORE_MARKER(state) || |                   pc1->lastmarker == CORE_MARKER(state) || | ||||||
|                     pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) { |                   pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) { | ||||||
|                     start_found = 1; |                 if (!pc1->lastmarker) | ||||||
|  |                     pc1->startpos = IS_EXSS_MARKER(state) ? size - 4 : size - 6; | ||||||
|  | 
 | ||||||
|                 if (IS_EXSS_MARKER(state)) |                 if (IS_EXSS_MARKER(state)) | ||||||
|                     pc1->lastmarker = EXSS_MARKER(state); |                     pc1->lastmarker = EXSS_MARKER(state); | ||||||
|                 else |                 else | ||||||
|                     pc1->lastmarker = CORE_MARKER(state); |                     pc1->lastmarker = CORE_MARKER(state); | ||||||
|  | 
 | ||||||
|  |                 start_found = 1; | ||||||
|  |                 size        = 0; | ||||||
|  | 
 | ||||||
|                 i++; |                 i++; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     if (start_found) { |     if (start_found) { | ||||||
|         for (; i < buf_size; i++) { |         for (; i < buf_size; i++) { | ||||||
| @ -284,6 +292,13 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, | |||||||
|             *poutbuf_size = 0; |             *poutbuf_size = 0; | ||||||
|             return buf_size; |             return buf_size; | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         /* skip initial padding */ | ||||||
|  |         if (buf_size  > pc1->startpos) { | ||||||
|  |             buf      += pc1->startpos; | ||||||
|  |             buf_size -= pc1->startpos; | ||||||
|  |         } | ||||||
|  |         pc1->startpos = 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* read the duration and sample rate from the frame header */ |     /* read the duration and sample rate from the frame header */ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user