Changeset 2815
- Timestamp:
- 2007-05-31 01:49:07 (2 years ago)
- Files:
-
- liboggz/trunk/src/liboggz/oggz_auto.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
liboggz/trunk/src/liboggz/oggz_auto.c
r2733 r2815 368 368 int keyframe_shift; 369 369 unsigned char first_byte; 370 371 if (now > (ogg_int64_t)(-1))372 return now;373 370 374 371 first_byte = op->packet[0]; 375 372 373 /* header packet */ 376 374 if (first_byte & 0x80) 377 375 { 378 /* header packet */ 379 return (ogg_int64_t)0; 380 } 381 376 stream->last_granulepos = -1; 377 return (ogg_int64_t)-1; 378 } 379 380 /* known granulepos */ 381 if (now > (ogg_int64_t)(-1)) { 382 return now; 383 } 384 385 /* last granulepos unknown */ 386 if (stream->last_granulepos == -1) { 387 return (ogg_int64_t)-1; 388 } 389 390 391 /* inter-coded packet */ 382 392 if (first_byte & 0x40) 383 393 { 384 /* inter-coded packet */385 394 return stream->last_granulepos + 1; 386 }387 388 /* intra-coded packet */389 if (stream->last_granulepos == 0)390 {391 /* first intra-coded packet */392 return (ogg_int64_t)0;393 395 } 394 396 … … 629 631 info = (auto_calc_vorbis_info_t *)stream->calculate_data; 630 632 633 631 634 if (now > -1) 632 635 { 633 info->encountered_first_data_packet = 1; 634 //return now; 636 return now; 635 637 } 636 638 … … 649 651 size = info->mode_sizes[mode]; 650 652 653 info->last_was_long = size; 654 651 655 /* 652 * the first packet is always 0656 * if we have a working granulepos, we use it. 653 657 */ 654 if ( !info->encountered_first_data_packet) {658 if (now > -1) { 655 659 info->encountered_first_data_packet = 1; 656 info->last_was_long = size; 657 return 0; 660 return now; 658 661 } 659 662 663 if (info->encountered_first_data_packet == 0) { 664 info->encountered_first_data_packet = 1; 665 return -1; 666 } 667 660 668 /* 661 * the second pos is an increment of half the current packetsize only 669 * otherwise, if we haven't yet had a working granulepos, we return 670 * -1 662 671 */ 663 if (stream->last_granulepos == 0) { 664 info->last_was_long = size; 665 return (size ? info->long_size : info->short_size) / 2; 672 if (stream->last_granulepos == -1) { 673 return -1; 666 674 } 667 668 /*669 * if it's a short packet, then we can just use nsn_increment670 *671 if (size == 0)672 {673 return stream->last_granulepos + info->nsn_increment;674 }675 * actually, this is not how the decoder behaves. It always decodes676 * no further than the middle of the current packet, regardless of the677 * number of additional samples that could be fully decoded.678 */679 675 680 676 result = stream->last_granulepos + … … 688 684 return result; 689 685 690 /* 691 * I'll keep this around for now - it might come in handy if the 692 * specification and the vorbis code ever match 693 * 694 prev_bit = info->log2_num_modes + 1; 695 next_bit = prev_bit + 1; 696 697 prev_bit = (op->packet[0] >> prev_bit) & 0x1; 698 699 if (next_bit == 8) 700 { 701 next_bit = op->packet[1] & 0x1; 702 } 703 else 704 { 705 next_bit = (op->packet[0] >> next_bit) & 0x1; 706 } 707 708 return stream->last_granulepos + 709 info->nln_increments[(prev_bit << 1) | next_bit]; 710 */ 711 } 712 713 714 return now; 686 } 715 687 716 688 } … … 898 870 * page. 899 871 */ 872 /* 900 873 if (now != -1LL) { 901 874 return op->granulepos; 902 875 } 876 */ 903 877 return r; 904 878 }