mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-11-01 04:53:04 +08:00 
			
		
		
		
	avcodec/parser: optimize ff_mpeg4video_split()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		 Zhaoxiu Zeng
					Zhaoxiu Zeng
				
			
				
					committed by
					
						 Michael Niedermayer
						Michael Niedermayer
					
				
			
			
				
	
			
			
			 Michael Niedermayer
						Michael Niedermayer
					
				
			
						parent
						
							ba22295e76
						
					
				
				
					commit
					3b5ad8fbf7
				
			| @@ -28,6 +28,7 @@ | ||||
| #include "libavutil/mem.h" | ||||
|  | ||||
| #include "parser.h" | ||||
| #include "internal.h" | ||||
|  | ||||
| static AVCodecParser *av_first_parser = NULL; | ||||
|  | ||||
| @@ -308,13 +309,14 @@ void ff_parse_close(AVCodecParserContext *s) | ||||
|  | ||||
| int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) | ||||
| { | ||||
|     int i; | ||||
|     uint32_t state = -1; | ||||
|     const uint8_t *ptr = buf, *end = buf + buf_size; | ||||
|  | ||||
|     for (i = 0; i < buf_size; i++) { | ||||
|         state = state << 8 | buf[i]; | ||||
|     while (ptr < end) { | ||||
|         ptr = avpriv_find_start_code(ptr, end, &state); | ||||
|         if (state == 0x1B3 || state == 0x1B6) | ||||
|             return i - 3; | ||||
|             return ptr - 4 - buf; | ||||
|     } | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user