Mercurial > libavcodec.hg
comparison mpeg12.c @ 6380:464938b9c2b0 libavcodec
Make find_frame_end() merge 2 mpeg2 field pictures. This should make mpeg2
field pictures much more digestable.
author | michael |
---|---|
date | Wed, 20 Feb 2008 19:45:38 +0000 |
parents | 48a6bbc1c633 |
children | 493dc59d469a |
comparison
equal
deleted
inserted
replaced
6379:9f4f88218b78 | 6380:464938b9c2b0 |
---|---|
2180 int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) | 2180 int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) |
2181 { | 2181 { |
2182 int i; | 2182 int i; |
2183 uint32_t state= pc->state; | 2183 uint32_t state= pc->state; |
2184 | 2184 |
2185 i=0; | 2185 /* EOF considered as end of frame */ |
2186 if(!pc->frame_start_found){ | 2186 if (buf_size == 0) |
2187 for(i=0; i<buf_size; i++){ | 2187 return 0; |
2188 | |
2189 /* | |
2190 0 frame start -> 1/4 | |
2191 1 first_SEQEXT -> 0/2 | |
2192 2 first field start -> 3/0 | |
2193 3 second_SEQEXT -> 2/0 | |
2194 4 searching end | |
2195 */ | |
2196 | |
2197 for(i=0; i<buf_size; i++){ | |
2198 assert(pc->frame_start_found>=0 && pc->frame_start_found<=4); | |
2199 if(pc->frame_start_found&1){ | |
2200 if(state == EXT_START_CODE && (buf[i]&0xF0) != 0x80) | |
2201 pc->frame_start_found--; | |
2202 else if(state == EXT_START_CODE+2){ | |
2203 if((buf[i]&3) == 3) pc->frame_start_found= 0; | |
2204 else pc->frame_start_found= (pc->frame_start_found+1)&3; | |
2205 } | |
2206 state++; | |
2207 }else{ | |
2188 i= ff_find_start_code(buf+i, buf+buf_size, &state) - buf - 1; | 2208 i= ff_find_start_code(buf+i, buf+buf_size, &state) - buf - 1; |
2189 if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){ | 2209 if(pc->frame_start_found==0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){ |
2190 i++; | 2210 i++; |
2191 pc->frame_start_found=1; | 2211 pc->frame_start_found=4; |
2192 break; | |
2193 } | 2212 } |
2194 if(state == SEQ_END_CODE){ | 2213 if(state == SEQ_END_CODE){ |
2195 pc->state=-1; | 2214 pc->state=-1; |
2196 return i+1; | 2215 return i+1; |
2197 } | 2216 } |
2198 } | 2217 if(pc->frame_start_found==2 && state == SEQ_START_CODE) |
2199 } | 2218 pc->frame_start_found= 0; |
2200 | 2219 if(pc->frame_start_found<4 && state == EXT_START_CODE) |
2201 if(pc->frame_start_found){ | 2220 pc->frame_start_found++; |
2202 /* EOF considered as end of frame */ | 2221 if(pc->frame_start_found == 4 && (state&0xFFFFFF00) == 0x100){ |
2203 if (buf_size == 0) | |
2204 return 0; | |
2205 for(; i<buf_size; i++){ | |
2206 i= ff_find_start_code(buf+i, buf+buf_size, &state) - buf - 1; | |
2207 if((state&0xFFFFFF00) == 0x100){ | |
2208 if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){ | 2222 if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){ |
2209 pc->frame_start_found=0; | 2223 pc->frame_start_found=0; |
2210 pc->state=-1; | 2224 pc->state=-1; |
2211 return i-3; | 2225 return i-3; |
2212 } | 2226 } |