Mercurial > libavcodec.hg
comparison parser.c @ 3086:befacb1cb573 libavcodec
faster find_startcode()
| author | michael |
|---|---|
| date | Sat, 04 Feb 2006 20:32:02 +0000 |
| parents | d85afa120256 |
| children | eb3d3988aff2 |
comparison
equal
deleted
inserted
replaced
| 3085:95bee8ba8870 | 3086:befacb1cb573 |
|---|---|
| 270 #endif | 270 #endif |
| 271 | 271 |
| 272 return 0; | 272 return 0; |
| 273 } | 273 } |
| 274 | 274 |
| 275 static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) | |
| 276 { | |
| 277 const uint8_t *buf_ptr; | |
| 278 unsigned int state=0xFFFFFFFF, v; | |
| 279 int val; | |
| 280 | |
| 281 buf_ptr = *pbuf_ptr; | |
| 282 while (buf_ptr < buf_end) { | |
| 283 v = *buf_ptr++; | |
| 284 if (state == 0x000001) { | |
| 285 state = ((state << 8) | v) & 0xffffff; | |
| 286 val = state; | |
| 287 goto found; | |
| 288 } | |
| 289 state = ((state << 8) | v) & 0xffffff; | |
| 290 } | |
| 291 val = -1; | |
| 292 found: | |
| 293 *pbuf_ptr = buf_ptr; | |
| 294 return val; | |
| 295 } | |
| 296 | |
| 297 /* XXX: merge with libavcodec ? */ | 275 /* XXX: merge with libavcodec ? */ |
| 298 #define MPEG1_FRAME_RATE_BASE 1001 | 276 #define MPEG1_FRAME_RATE_BASE 1001 |
| 299 | 277 |
| 300 static const int frame_rate_tab[16] = { | 278 static const int frame_rate_tab[16] = { |
| 301 0, | 279 0, |
| 333 int horiz_size_ext, vert_size_ext, bit_rate_ext; | 311 int horiz_size_ext, vert_size_ext, bit_rate_ext; |
| 334 //FIXME replace the crap with get_bits() | 312 //FIXME replace the crap with get_bits() |
| 335 s->repeat_pict = 0; | 313 s->repeat_pict = 0; |
| 336 buf_end = buf + buf_size; | 314 buf_end = buf + buf_size; |
| 337 while (buf < buf_end) { | 315 while (buf < buf_end) { |
| 338 start_code = find_start_code(&buf, buf_end); | 316 start_code= -1; |
| 317 buf= ff_find_start_code(buf, buf_end, &start_code); | |
| 339 bytes_left = buf_end - buf; | 318 bytes_left = buf_end - buf; |
| 340 switch(start_code) { | 319 switch(start_code) { |
| 341 case PICTURE_START_CODE: | 320 case PICTURE_START_CODE: |
| 342 if (bytes_left >= 2) { | 321 if (bytes_left >= 2) { |
| 343 s->pict_type = (buf[1] >> 3) & 7; | 322 s->pict_type = (buf[1] >> 3) & 7; |
