Branch Coverage

src/mp3.c
Criterion Covered Total %
branch 290 398 72.8


line true false branch
46 6 91 if ( _has_ape(infile, file_size, info) ) {
58 7 184 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 97 if ( (PerlIO_seek(infile, file_size - 160, SEEK_SET)) == -1 ) {
84 0 97 if ( !_check_buf(infile, &buf, 136, 136) ) {
90 3 94 if ( _is_ape_header(bptr) ) {
97 1 93 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")) {
141 91 2 if ( _is_ape_header(bptr) ) {
175 1707 32 && (frame->layerID != ILLEGAL_LAYER_ID)
176 1704 3 && (frame->bitrate_index != 0)
177 1674 30 && (frame->bitrate_index != 15)
178 1739 4 && (frame->samplingrate_index != ILLEGAL_SR);
1669 5 && (frame->samplingrate_index != ILLEGAL_SR);
180 74 1669 if (!frame->valid) {
186 114 1555 if (frame->mpegID == MPEG2_ID)
189 35 1634 if (frame->mpegID == MPEG25_ID)
192 118 1551 frame->channels = (frame->mode == MODE_MONO) ? 1 : 2;
196 5 1664 if (frame->layerID == LAYER1_ID) {
204 148 1516 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 1664 if (frame->bytes_per_slot > 1)
213 189 1480 if (frame->padding)
246 91 29 while ( done < audio_size - 4 ) {
248 0 91 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE * 3) ) {
255 32 59 if (wrap_skip) {
262 1357 61 while ( buffer_len(mp3->buf) >= 4 ) {
264 125 1356 while ( *bptr != 0xFF ) {
267 1 124 if ( buffer_len(mp3->buf) < 4 ) {
275 1356 0 if ( !_decode_mp3_frame( buffer_ptr(mp3->buf), &frame ) ) {
280 768 588 if ( !vbr ) {
284 709 59 if (prev_bitrate > 0 && prev_bitrate != frame.bitrate_kbps) {
13 696 if (prev_bitrate > 0 && prev_bitrate != frame.bitrate_kbps) {
289 29 726 if (frame_count > 20) {
300 44 1283 if (frame.frame_size > buffer_len(mp3->buf)) {
317 0 59 if (err) return err;
319 0 59 if (!frame_count) return -1;
333 76 15 if (mp3->first_frame->mpegID == MPEG1_ID) {
334 73 3 xing_offset += mp3->first_frame->channels == 2 ? 32 : 17;
337 7 8 xing_offset += mp3->first_frame->channels == 2 ? 17 : 9;
340 0 91 if ( !_check_buf(mp3->infile, mp3->buf, 4 + xing_offset, MP3_BLOCK_SIZE) ) {
348 69 22 if ( bptr[0] == 'X' || bptr[0] == 'I' ) {
8 61 if ( bptr[0] == 'X' || bptr[0] == 'I' ) {
350 22 8 ( bptr[1] == 'i' && bptr[2] == 'n' && bptr[3] == 'g' )
22 0 ( bptr[1] == 'i' && bptr[2] == 'n' && bptr[3] == 'g' )
0 22 ( bptr[1] == 'i' && bptr[2] == 'n' && bptr[3] == 'g' )
352 8 0 ( bptr[1] == 'n' && bptr[2] == 'f' && bptr[3] == 'o' )
8 0 ( bptr[1] == 'n' && bptr[2] == 'f' && bptr[3] == 'o' )
8 0 ( bptr[1] == 'n' && bptr[2] == 'f' && bptr[3] == 'o' )
360 0 30 if ( !_check_buf(mp3->infile, mp3->buf, 160, MP3_BLOCK_SIZE) ) {
365 22 8 mp3->vbr = bptr[1] == 'i' ? VBR : CBR;
371 30 0 if (mp3->xing_frame->flags & XING_FRAMES) {
375 30 0 if ( mp3->xing_frame->flags & XING_BYTES) {
379 30 0 if (mp3->xing_frame->flags & XING_TOC) {
382 3000 30 for (i = 0; i < 100; i++) {
391 29 1 if (mp3->xing_frame->flags & XING_QUALITY) {
397 20 10 if ( bptr[0] == 'L' && bptr[1] == 'A' && bptr[2] == 'M' && bptr[3] == 'E' ) {
19 1 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 59 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 89 if (mp3->first_frame->layerID != LAYER3_ID)
538 14 75 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 81 2 if (mp3->first_frame->samplerate != 16000
542 77 4 && mp3->first_frame->samplerate != 22050
543 75 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 81 if (mp3->first_frame->layerID != LAYER3_ID)
558 6 75 if (mp3->first_frame->mpegID != MPEG1_ID)
561 40 35 if (mp3->first_frame->samplerate != 32000
562 1 39 && mp3->first_frame->samplerate != 44100
563 0 1 && mp3->first_frame->samplerate != 48000)
566 75 0 if (mp3->bitrate >= 32 && mp3->bitrate <= 320)
75 0 if (mp3->bitrate >= 32 && mp3->bitrate <= 320)
604 0 92 if ( !_check_buf(mp3->infile, mp3->buf, 10, MP3_BLOCK_SIZE) ) {
611 71 21 (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') &&
71 0 (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') &&
71 0 (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') &&
612 71 0 bptr[3] < 0xff && bptr[4] < 0xff &&
71 0 bptr[3] < 0xff && bptr[4] < 0xff &&
613 71 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
71 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
71 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
71 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
618 0 71 if (bptr[5] & 0x10) {
628 0 71 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE) ) {
636 170 91 while ( !found_first_frame && buffer_len(mp3->buf) ) {
170 0 while ( !found_first_frame && buffer_len(mp3->buf) ) {
639 16007 169 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 169 if ( !_check_buf(mp3->infile, mp3->buf, 4, MP3_BLOCK_SIZE) ) {
667 115 54 if ( !_decode_mp3_frame( (unsigned char *)buffer_ptr(mp3->buf), &frame ) ) {
671 115 0 if ( _check_buf(mp3->infile, mp3->buf, frame.frame_size, MP3_BLOCK_SIZE)
675 115 0 && (
677 103 12 || (
679 91 12 && frame.samplerate == frame2.samplerate
680 91 0 && frame.channels == frame2.channels
686 91 0 && (
688 91 0 || (
690 91 0 && frame.samplerate == frame3.samplerate
691 91 0 && frame.channels == frame3.channels
705 78 91 if (!found_first_frame) {
714 0 91 if ( !found_first_frame ) {
724 0 91 if ( !_parse_xing(mp3) ) {
729 83 8 if ( (mp3->vbr == CBR || mp3->vbr == ABR) && mp3->xing_frame->lame_abr_rate ) {
3 80 if ( (mp3->vbr == CBR || mp3->vbr == ABR) && mp3->xing_frame->lame_abr_rate ) {
10 1 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 81 10 if (!mp3->bitrate && (mp3->xing_frame->xing_frames && mp3->xing_frame->xing_bytes)) {
20 61 if (!mp3->bitrate && (mp3->xing_frame->xing_frames && mp3->xing_frame->xing_bytes)) {
20 0 if (!mp3->bitrate && (mp3->xing_frame->xing_frames && mp3->xing_frame->xing_bytes)) {
745 17 3 float mfs = (float)frame.samplerate / ( frame.mpegID == MPEG2_ID || frame.mpegID == MPEG25_ID ? 72000. : 144000. );
5 12 float mfs = (float)frame.samplerate / ( frame.mpegID == MPEG2_ID || frame.mpegID == MPEG25_ID ? 72000. : 144000. );
751 2 69 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 91 0 if (PerlIO_read(infile, id3v1taghdr, 4) == 4) {
760 14 77 if (id3v1taghdr[0]=='T' && id3v1taghdr[1]=='A' && id3v1taghdr[2]=='G') {
14 0 if (id3v1taghdr[0]=='T' && id3v1taghdr[1]=='A' && id3v1taghdr[2]=='G') {
14 0 if (id3v1taghdr[0]=='T' && id3v1taghdr[1]=='A' && id3v1taghdr[2]=='G') {
767 59 32 if ( !mp3->bitrate ) {
771 0 59 if (mp3->bitrate <= 0) {
779 30 61 if (mp3->xing_frame->xing_frames) {
782 19 11 if (mp3->xing_frame->lame_tag) {
789 2 59 else if (mp3->xing_frame->vbri_frames) {
811 69 22 if (mp3->xing_frame->xing_tag || mp3->xing_frame->info_tag) {
8 61 if (mp3->xing_frame->xing_tag || mp3->xing_frame->info_tag) {
812 30 0 if (mp3->xing_frame->xing_frames) {
816 30 0 if (mp3->xing_frame->xing_bytes) {
820 30 0 if (mp3->xing_frame->has_toc) {
824 3000 30 for (i = 0; i < 100; i++) {
831 22 8 if (mp3->xing_frame->xing_quality) {
836 2 89 if (mp3->xing_frame->vbri_tag) {
843 19 72 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 88 3 if (mp3->vbr == ABR || mp3->vbr == VBR) {
21 67 if (mp3->vbr == ABR || mp3->vbr == VBR) {
896 8 83 if (_is_mp3x_profile(mp3))
898 8 75 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 (
1014 12 1496 ( bptr[0] == 0xFF && !_decode_mp3_frame( bptr, &frame ) )
8 4 ( bptr[0] == 0xFF && !_decode_mp3_frame( bptr, &frame ) )
1023 4 0 if (buf_size >= 4) {
1049 47 24 if ( buffer_len(mp3->buf) >= size ) {