Branch Coverage

src/mp3.c
Criterion Covered Total %
branch 288 400 72.0


line true false branch
46 6 83 if ( _has_ape(infile, file_size, info) ) {
58 7 168 if ( bptr[0] == 'A' && bptr[1] == 'P' && bptr[2] == 'E'
6 1 if ( bptr[0] == 'A' && bptr[1] == 'P' && bptr[2] == 'E'
6 0 if ( bptr[0] == 'A' && bptr[1] == 'P' && bptr[2] == 'E'
59 6 0 && bptr[3] == 'T' && bptr[4] == 'A' && bptr[5] == 'G'
6 0 && bptr[3] == 'T' && bptr[4] == 'A' && bptr[5] == 'G'
6 0 && bptr[3] == 'T' && bptr[4] == 'A' && bptr[5] == 'G'
60 6 0 && bptr[6] == 'E' && bptr[7] == 'X'
6 0 && bptr[6] == 'E' && bptr[7] == 'X'
75 0 89 if ( (PerlIO_seek(infile, file_size - 160, SEEK_SET)) == -1 ) {
84 0 89 if ( !_check_buf(infile, &buf, 136, 136) ) {
90 3 86 if ( _is_ape_header(bptr) ) {
97 1 85 if ( bptr[0] == 'L' && bptr[1] == 'Y' && bptr[2] == 'R'
1 0 if ( bptr[0] == 'L' && bptr[1] == 'Y' && bptr[2] == 'R'
1 0 if ( bptr[0] == 'L' && bptr[1] == 'Y' && bptr[2] == 'R'
98 1 0 && bptr[3] == 'I' && bptr[4] == 'C' && bptr[5] == 'S'
1 0 && bptr[3] == 'I' && bptr[4] == 'C' && bptr[5] == 'S'
1 0 && bptr[3] == 'I' && bptr[4] == 'C' && bptr[5] == 'S'
99 1 0 && bptr[6] == '2' && bptr[7] == '0' && bptr[8] == '0'
1 0 && bptr[6] == '2' && bptr[7] == '0' && bptr[8] == '0'
1 0 && bptr[6] == '2' && bptr[7] == '0' && bptr[8] == '0'
111 0 1 if ( (PerlIO_seek(infile, file_size - (160 + lyrics_size + 15), SEEK_SET)) == -1 ) {
118 0 1 if ( !_check_buf(infile, &buf, 136, 136) ) {
122 1 0 if ( _is_ape_header( buffer_ptr(&buf) ) ) {
129 0 0 if (my_hv_exists(info, "audio_size")) {
130 0 0 int audio_size = SvIV(*(my_hv_fetch(info, "audio_size")));
141 2 83 if ( _is_ape_header(bptr) ) {
175 1620 32 && (frame->layerID != ILLEGAL_LAYER_ID)
176 1617 3 && (frame->bitrate_index != 0)
177 1587 30 && (frame->bitrate_index != 15)
178 1652 4 && (frame->samplingrate_index != ILLEGAL_SR);
1582 5 && (frame->samplingrate_index != ILLEGAL_SR);
180 74 1582 if (!frame->valid) {
186 114 1468 if (frame->mpegID == MPEG2_ID)
189 35 1547 if (frame->mpegID == MPEG25_ID)
192 115 1467 frame->channels = (frame->mode == MODE_MONO) ? 1 : 2;
196 5 1577 if (frame->layerID == LAYER1_ID) {
204 148 1429 frame->samples_per_frame = ((frame->mpegID == MPEG1_ID) || (frame->layerID == LAYER2_ID)) ? 1152 : 576;
35 113 frame->samples_per_frame = ((frame->mpegID == MPEG1_ID) || (frame->layerID == LAYER2_ID)) ? 1152 : 576;
210 5 1577 if (frame->bytes_per_slot > 1)
213 176 1406 if (frame->padding)
246 86 27 while ( done < audio_size - 4 ) {
248 0 86 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE * 3) ) {
255 32 54 if (wrap_skip) {
262 1288 59 while ( buffer_len(mp3->buf) >= 4 ) {
264 125 1287 while ( *bptr != 0xFF ) {
267 1 124 if ( buffer_len(mp3->buf) < 4 ) {
275 1287 0 if ( !_decode_mp3_frame( buffer_ptr(mp3->buf), &frame ) ) {
280 699 588 if ( !vbr ) {
284 645 54 if (prev_bitrate > 0 && prev_bitrate != frame.bitrate_kbps) {
13 632 if (prev_bitrate > 0 && prev_bitrate != frame.bitrate_kbps) {
289 26 660 if (frame_count > 20) {
300 44 1217 if (frame.frame_size > buffer_len(mp3->buf)) {
317 0 54 if (err) return err;
319 0 54 if (!frame_count) return -1;
333 70 15 if (mp3->first_frame->mpegID == MPEG1_ID) {
334 68 2 xing_offset += mp3->first_frame->channels == 2 ? 32 : 17;
337 7 8 xing_offset += mp3->first_frame->channels == 2 ? 17 : 9;
340 0 85 if ( !_check_buf(mp3->infile, mp3->buf, 4 + xing_offset, MP3_BLOCK_SIZE) ) {
348 63 22 if ( bptr[0] == 'X' || bptr[0] == 'I' ) {
7 56 if ( bptr[0] == 'X' || bptr[0] == 'I' ) {
349 22 7 if (
350 22 0 ( bptr[1] == 'i' && bptr[2] == 'n' && bptr[3] == 'g' )
0 22 ( bptr[1] == 'i' && bptr[2] == 'n' && bptr[3] == 'g' )
351 7 0 ||
352 7 0 ( bptr[1] == 'n' && bptr[2] == 'f' && bptr[3] == 'o' )
7 0 ( bptr[1] == 'n' && bptr[2] == 'f' && bptr[3] == 'o' )
360 0 29 if ( !_check_buf(mp3->infile, mp3->buf, 160, MP3_BLOCK_SIZE) ) {
365 22 7 mp3->vbr = bptr[1] == 'i' ? VBR : CBR;
371 29 0 if (mp3->xing_frame->flags & XING_FRAMES) {
375 29 0 if ( mp3->xing_frame->flags & XING_BYTES) {
379 29 0 if (mp3->xing_frame->flags & XING_TOC) {
382 2900 29 for (i = 0; i < 100; i++) {
391 28 1 if (mp3->xing_frame->flags & XING_QUALITY) {
397 19 10 if ( bptr[0] == 'L' && bptr[1] == 'A' && bptr[2] == 'M' && bptr[3] == 'E' ) {
19 0 if ( bptr[0] == 'L' && bptr[1] == 'A' && bptr[2] == 'M' && bptr[3] == 'E' ) {
19 0 if ( bptr[0] == 'L' && bptr[1] == 'A' && bptr[2] == 'M' && bptr[3] == 'E' ) {
19 0 if ( bptr[0] == 'L' && bptr[1] == 'A' && bptr[2] == 'M' && bptr[3] == 'E' ) {
431 38 19 for (i=0; i<2; i++) {
438 15 23 if (origin != 0) {
441 15 0 if (gt == 1)
443 0 0 else if (gt == 2)
449 15 0 = (( (bptr[0] & 0x4) >> 2 ) ? -0.1 : 0.1)
467 19 0 if (mp3->xing_frame->lame_encoder_delay < 0 || mp3->xing_frame->lame_encoder_delay > 3000) {
0 19 if (mp3->xing_frame->lame_encoder_delay < 0 || mp3->xing_frame->lame_encoder_delay > 3000) {
470 19 0 if (mp3->xing_frame->lame_encoder_padding < 0 || mp3->xing_frame->lame_encoder_padding > 3000) {
0 19 if (mp3->xing_frame->lame_encoder_padding < 0 || mp3->xing_frame->lame_encoder_padding > 3000) {
510 2 54 else if ( bptr[0] == 'V' && bptr[1] == 'B' && bptr[2] == 'R' && bptr[3] == 'I' ) {
2 0 else if ( bptr[0] == 'V' && bptr[1] == 'B' && bptr[2] == 'R' && bptr[3] == 'I' ) {
2 0 else if ( bptr[0] == 'V' && bptr[1] == 'B' && bptr[2] == 'R' && bptr[3] == 'I' ) {
2 0 else if ( bptr[0] == 'V' && bptr[1] == 'B' && bptr[2] == 'R' && bptr[3] == 'I' ) {
516 0 2 if ( !_check_buf(mp3->infile, mp3->buf, 14, MP3_BLOCK_SIZE) ) {
535 2 83 if (mp3->first_frame->layerID != LAYER3_ID)
538 14 69 if (mp3->first_frame->mpegID != MPEG1_ID && mp3->first_frame->mpegID != MPEG2_ID)
6 8 if (mp3->first_frame->mpegID != MPEG1_ID && mp3->first_frame->mpegID != MPEG2_ID)
541 75 2 if (mp3->first_frame->samplerate != 16000
542 71 4 && mp3->first_frame->samplerate != 22050
543 69 2 && mp3->first_frame->samplerate != 24000)
546 8 0 if (mp3->bitrate >= 8 && mp3->bitrate <= 320)
8 0 if (mp3->bitrate >= 8 && mp3->bitrate <= 320)
555 2 75 if (mp3->first_frame->layerID != LAYER3_ID)
558 6 69 if (mp3->first_frame->mpegID != MPEG1_ID)
561 37 32 if (mp3->first_frame->samplerate != 32000
562 1 36 && mp3->first_frame->samplerate != 44100
563 0 1 && mp3->first_frame->samplerate != 48000)
566 69 0 if (mp3->bitrate >= 32 && mp3->bitrate <= 320)
69 0 if (mp3->bitrate >= 32 && mp3->bitrate <= 320)
604 0 86 if ( !_check_buf(mp3->infile, mp3->buf, 10, MP3_BLOCK_SIZE) ) {
610 65 21 if (
611 65 0 (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') &&
65 0 (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') &&
65 0 (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') &&
612 65 0 bptr[3] < 0xff && bptr[4] < 0xff &&
65 0 bptr[3] < 0xff && bptr[4] < 0xff &&
613 65 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
65 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
65 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
618 0 65 if (bptr[5] & 0x10) {
628 0 65 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE) ) {
636 164 85 while ( !found_first_frame && buffer_len(mp3->buf) ) {
164 0 while ( !found_first_frame && buffer_len(mp3->buf) ) {
639 16007 163 while ( *bptr != 0xFF ) {
644 3 16004 if ( !buffer_len(mp3->buf) ) {
645 1 2 if (mp3->audio_offset >= mp3->file_size - 4) {
651 0 2 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE) ) {
663 0 163 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE) ) {
667 109 54 if ( !_decode_mp3_frame( (unsigned char *)buffer_ptr(mp3->buf), &frame ) ) {
671 109 0 if ( _check_buf(mp3->infile, mp3->buf, frame.frame_size, MP3_BLOCK_SIZE)
675 109 0 && (
677 97 12 || (
679 85 12 && frame.samplerate == frame2.samplerate
680 85 0 && frame.channels == frame2.channels
686 85 0 && (
688 85 0 || (
690 85 0 && frame.samplerate == frame3.samplerate
691 85 0 && frame.channels == frame3.channels
705 78 85 if (!found_first_frame) {
714 0 85 if ( !found_first_frame ) {
724 0 85 if ( !_parse_xing(mp3) ) {
729 78 7 if ( (mp3->vbr == CBR || mp3->vbr == ABR) && mp3->xing_frame->lame_abr_rate ) {
3 75 if ( (mp3->vbr == CBR || mp3->vbr == ABR) && mp3->xing_frame->lame_abr_rate ) {
10 0 if ( (mp3->vbr == CBR || mp3->vbr == ABR) && mp3->xing_frame->lame_abr_rate ) {
730 2 8 if (mp3->xing_frame->lame_abr_rate >= 255) {
732 2 0 if (mp3->xing_frame->lame_preset <= 320) {
744 75 10 if (!mp3->bitrate && (mp3->xing_frame->xing_frames && mp3->xing_frame->xing_bytes)) {
19 56 if (!mp3->bitrate && (mp3->xing_frame->xing_frames && mp3->xing_frame->xing_bytes)) {
19 0 if (!mp3->bitrate && (mp3->xing_frame->xing_frames && mp3->xing_frame->xing_bytes)) {
745 16 3 float mfs = (float)frame.samplerate / ( frame.mpegID == MPEG2_ID || frame.mpegID == MPEG25_ID ? 72000. : 144000. );
5 11 float mfs = (float)frame.samplerate / ( frame.mpegID == MPEG2_ID || frame.mpegID == MPEG25_ID ? 72000. : 144000. );
751 2 64 else if (mp3->xing_frame->vbri_frames && mp3->xing_frame->vbri_bytes) {
2 0 else if (mp3->xing_frame->vbri_frames && mp3->xing_frame->vbri_bytes) {
752 2 0 float mfs = (float)frame.samplerate / ( frame.mpegID == MPEG2_ID || frame.mpegID == MPEG25_ID ? 72000. : 144000. );
0 2 float mfs = (float)frame.samplerate / ( frame.mpegID == MPEG2_ID || frame.mpegID == MPEG25_ID ? 72000. : 144000. );
759 85 0 if (PerlIO_read(infile, id3v1taghdr, 4) == 4) {
760 13 72 if (id3v1taghdr[0]=='T' && id3v1taghdr[1]=='A' && id3v1taghdr[2]=='G') {
13 0 if (id3v1taghdr[0]=='T' && id3v1taghdr[1]=='A' && id3v1taghdr[2]=='G') {
13 0 if (id3v1taghdr[0]=='T' && id3v1taghdr[1]=='A' && id3v1taghdr[2]=='G') {
767 54 31 if ( !mp3->bitrate ) {
771 0 54 if (mp3->bitrate <= 0) {
779 29 56 if (mp3->xing_frame->xing_frames) {
782 19 10 if (mp3->xing_frame->lame_tag) {
789 2 54 else if (mp3->xing_frame->vbri_frames) {
811 63 22 if (mp3->xing_frame->xing_tag || mp3->xing_frame->info_tag) {
7 56 if (mp3->xing_frame->xing_tag || mp3->xing_frame->info_tag) {
812 29 0 if (mp3->xing_frame->xing_frames) {
816 29 0 if (mp3->xing_frame->xing_bytes) {
820 29 0 if (mp3->xing_frame->has_toc) {
824 2900 29 for (i = 0; i < 100; i++) {
831 22 7 if (mp3->xing_frame->xing_quality) {
836 2 83 if (mp3->xing_frame->vbri_tag) {
843 19 66 if (mp3->xing_frame->lame_tag) {
849 15 4 if (mp3->xing_frame->lame_replay_gain[0]) {
853 0 19 if (mp3->xing_frame->lame_replay_gain[1]) {
870 1 18 if (mp3->xing_frame->lame_preset < 8) {
873 10 8 else if (mp3->xing_frame->lame_preset <= 320) {
876 8 0 else if (mp3->xing_frame->lame_preset <= 500) {
879 8 0 if ( presets_v[mp3->xing_frame->lame_preset] ) {
883 0 0 else if (mp3->xing_frame->lame_preset >= 1000 && mp3->xing_frame->lame_preset <= 1007) {
0 0 else if (mp3->xing_frame->lame_preset >= 1000 && mp3->xing_frame->lame_preset <= 1007) {
885 0 0 if ( presets_old[mp3->xing_frame->lame_preset] ) {
891 82 3 if (mp3->vbr == ABR || mp3->vbr == VBR) {
21 61 if (mp3->vbr == ABR || mp3->vbr == VBR) {
896 8 77 if (_is_mp3x_profile(mp3))
898 69 8 else if (_is_mp3_profile(mp3))
920 0 4 if (!mp3->song_length_ms)
925 1 3 if (offset < 0) {
927 0 1 if (frame_offset < mp3->audio_offset) {
934 0 3 if (offset >= mp3->song_length_ms) {
939 1 2 if ( mp3->xing_frame->has_toc ) {
949 0 1 if (ipercent > 99)
954 1 0 if (ipercent < 99) {
968 0 1 if (frame_offset == mp3->audio_offset) {
992 1 3 if ((mp3->file_size - frame_offset) < 1000) {
994 0 1 if (frame_offset < 0)
1001 0 4 if ( !_check_buf(infile, &mp3_buf, 4, MP3_BLOCK_SIZE) ) {
1011 1508 0 if (
1013 12 1496 ||
1014 8 4 ( bptr[0] == 0xFF && !_decode_mp3_frame( bptr, &frame ) )
1023 4 0 if (buf_size >= 4) {
1049 42 23 if ( buffer_len(mp3->buf) >= size ) {