comparison mpegvideo.c @ 3086:befacb1cb573 libavcodec

faster find_startcode()
author michael
date Sat, 04 Feb 2006 20:32:02 +0000
parents 3c32ecc8eefe
children 526bc949ef31
comparison
equal deleted inserted replaced
3085:95bee8ba8870 3086:befacb1cb573
225 } 225 }
226 }else 226 }else
227 put_bits(pb, 1, 0); 227 put_bits(pb, 1, 0);
228 } 228 }
229 #endif //CONFIG_ENCODERS 229 #endif //CONFIG_ENCODERS
230
231 const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){
232 int i;
233
234 for(i=0; i<3; i++){
235 uint32_t tmp= *state << 8;
236 *state= tmp + *(p++);
237 if(tmp == 0x100 || p==end)
238 return p;
239 }
240 p--; // need to recheck or might miss one
241 end--; // we need the byte after 00 00 01 too
242
243 while(p<end){
244 if (p[ 0] > 1) p+= 3;
245 else if(p[-1] ) p+= 2;
246 else if(p[-2]|(p[0]-1)) p++;
247 else{
248 p++;
249 break;
250 }
251 }
252
253 p= FFMIN(p, end)-3;
254 *state= be2me_32(unaligned32(p));
255
256 return p+4;
257 }
230 258
231 /* init common dct for both encoder and decoder */ 259 /* init common dct for both encoder and decoder */
232 int DCT_common_init(MpegEncContext *s) 260 int DCT_common_init(MpegEncContext *s)
233 { 261 {
234 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; 262 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c;