Branch Coverage

src/id3.c
Criterion Covered Total %
branch 408 552 73.9


line true false branch
30 521 0 if (buf) {
31 2068 521 for ( i = 0; i < length; i++ ) {
61 100 6 if ( !seek ) {
64 0 100 if ( !_check_buf(infile, id3->buf, 128, 128) ) {
70 17 83 if (bptr[0] == 'T' && bptr[1] == 'A' && bptr[2] == 'G') {
17 0 if (bptr[0] == 'T' && bptr[1] == 'A' && bptr[2] == 'G') {
17 0 if (bptr[0] == 'T' && bptr[1] == 'A' && bptr[2] == 'G') {
80 0 106 if ( !_check_buf(infile, id3->buf, 14, ID3_BLOCK_SIZE) ) {
86 15 91 if (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') {
0 91 if (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') {
0 91 if (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') {
94 91 15 if (id3->utf8->alloc)
115 17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
10 7 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
120 7 0 if (tmp) SvREFCNT_dec(tmp);
122 14 3 if (read < 30) {
128 17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
10 7 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
134 7 0 if (tmp) SvREFCNT_dec(tmp);
136 14 3 if (read < 30) {
142 17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
10 7 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
148 7 0 if (tmp) SvREFCNT_dec(tmp);
150 14 3 if (read < 30) {
156 17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
9 8 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
162 8 0 if (tmp) SvREFCNT_dec(tmp);
164 7 10 if (read < 4) {
169 15 2 if (bptr[28] == 0 && bptr[29] != 0) {
5 10 if (bptr[28] == 0 && bptr[29] != 0) {
182 17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
17 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
6 11 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
192 11 0 if (tmp) SvREFCNT_dec(tmp);
194 15 2 if (read < 30) {
199 8 9 if (genre < NGENRES) {
203 0 9 else if (genre < 255) {
219 91 0 bptr[3] < 0xff && bptr[4] < 0xff &&
91 0 bptr[3] < 0xff && bptr[4] < 0xff &&
220 91 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
91 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
91 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
0 91 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
235 0 91 if (id3->flags & ID3_TAG_FLAG_FOOTERPRESENT) {
241 13 78 if (id3->flags & ID3_TAG_FLAG_UNSYNCHRONISATION) {
242 4 9 if (id3->version_major < 4) {
250 0 4 if ( !_check_buf(id3->infile, id3->buf, id3->size, id3->size) ) {
266 6 85 if (id3->flags & ID3_TAG_FLAG_EXTENDEDHEADER) {
270 0 6 if (id3->version_major == 2) {
279 2 4 if (id3->version_major == 3) {
287 1 3 if (ehsize < 4 ) {
296 2 3 if (ehsize > id3->size_remain - 4) {
304 0 3 if ( !_check_buf(id3->infile, id3->buf, ehsize, ID3_BLOCK_SIZE) ) {
314 1040 13 while (id3->size_remain > 0) {
316 75 965 if ( !_id3_parse_v2_frame(id3) ) {
321 51 37 if (id3->version_major < 4) {
331 12 76 if ( my_hv_exists(id3->info, "id3_version") ) {
333 12 0 if (entry != NULL) {
364 0 1040 if ( !_check_buf(id3->infile, id3->buf, 10, ID3_BLOCK_SIZE) ) {
369 88 952 if (id3->version_major == 2) {
377 4 84 if (id[0] == 0) {
390 84 0 if (compat && compat->equiv) {
84 0 if (compat && compat->equiv) {
409 0 84 if (size > id3->size_remain) {
420 69 883 if (id[0] == 0) {
429 392 491 if (id3->version_major == 3) {
439 6 386 if (id[3] == ' ') {
447 85 307 if (compat && compat->equiv) {
45 40 if (compat && compat->equiv) {
456 0 392 if (size > id3->size_remain) {
462 1 391 if (flags & ID3_FRAME_FLAG_V23_COMPRESSION) {
469 1 391 if (flags & ID3_FRAME_FLAG_V23_ENCRYPTION) {
486 1 390 if (flags & ID3_FRAME_FLAG_V23_GROUPINGIDENTITY) {
500 1 390 if (flags & ID3_FRAME_FLAG_V23_COMPRESSION && decoded_size) {
1 0 if (flags & ID3_FRAME_FLAG_V23_COMPRESSION && decoded_size) {
503 0 1 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
514 1 0 if (
517 0 1 tmp_size != decoded_size
534 3 488 if ( _varint(buffer_ptr(id3->buf), 4) & 0x80 ) {
548 2 489 if (size > id3->size_remain) {
556 3 486 if (id[3] == ' ') {
559 3 0 if (compat && compat->equiv) {
3 0 if (compat && compat->equiv) {
567 1 488 if (flags & ID3_FRAME_FLAG_V24_GROUPINGIDENTITY) {
578 1 488 if (flags & ID3_FRAME_FLAG_V24_ENCRYPTION) {
595 12 476 if (flags & ID3_FRAME_FLAG_V24_DATALENGTHINDICATOR) {
603 12 476 if (flags & ID3_FRAME_FLAG_V24_UNSYNCHRONISATION) {
606 4 8 if ( !strcmp(id, "APIC") && _env_true("AUDIO_SCAN_NO_ARTWORK") ) {
1 3 if ( !strcmp(id, "APIC") && _env_true("AUDIO_SCAN_NO_ARTWORK") ) {
617 0 11 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
630 1 487 if (flags & ID3_FRAME_FLAG_V24_COMPRESSION) {
635 0 1 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
646 1 0 if (
649 0 1 tmp_size != decoded_size
666 962 1 if ( !strcmp(id, "XHD3") || !strcmp(id, "NCON") ) {
0 962 if ( !strcmp(id, "XHD3") || !strcmp(id, "NCON") ) {
674 63 899 if (frametype == 0) {
708 2 960 if (decompressed) {
713 13 949 if ( !_id3_parse_v2_frame_data(id3, (char *)&id, decoded_size ? decoded_size : size, frametype) ) {
0 962 if ( !_id3_parse_v2_frame_data(id3, (char *)&id, decoded_size ? decoded_size : size, frametype) ) {
719 949 13 if (id3->size_remain > size) {
727 951 11 if (unsync_extra) {
733 2 1038 if (decompressed) {
753 28 934 uint8_t skip_art = ( buffer_art && _env_true("AUDIO_SCAN_NO_ARTWORK") ) ? 1 : 0;
5 23 uint8_t skip_art = ( buffer_art && _env_true("AUDIO_SCAN_NO_ARTWORK") ) ? 1 : 0;
756 1 961 if (!size)
759 5 956 if (skip_art) {
762 0 5 if ( !_check_buf(id3->infile, id3->buf, 128, ID3_BLOCK_SIZE) ) {
770 23 933 if (buffer_art) {
772 0 23 if ( !_check_buf(id3->infile, id3->buf, 128, ID3_BLOCK_SIZE) ) {
778 0 933 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
784 864 97 if ( frametype->fields[0] == ID3_FIELD_TYPE_TEXTENCODING ) {
790 864 0 if (encoding < 0 || encoding > 3) {
3 861 if (encoding < 0 || encoding > 3) {
797 816 142 if ( !strcmp(id, "TXXX") || !strcmp(id, "WXXX") ) {
20 796 if ( !strcmp(id, "TXXX") || !strcmp(id, "WXXX") ) {
806 162 0 if (key != NULL && SvPOK(key) && sv_len(key)) {
162 0 if (key != NULL && SvPOK(key) && sv_len(key)) {
156 6 if (key != NULL && SvPOK(key) && sv_len(key)) {
810 14 142 if (frametype->fields[2] == ID3_FIELD_TYPE_LATIN1) {
817 166 156 while (read < size) {
818 8 158 if (count++ == 1 && value != NULL) {
8 0 if (count++ == 1 && value != NULL) {
826 10 156 if (array != NULL && value != NULL && SvPOK(value)) {
10 0 if (array != NULL && value != NULL && SvPOK(value)) {
10 0 if (array != NULL && value != NULL && SvPOK(value)) {
828 9 1 if (sv_len(value) > 0)
833 8 148 if (array != NULL) {
834 0 8 if (av_len(array) == 0) {
844 148 0 else if (value != NULL && SvPOK(value)) {
148 0 else if (value != NULL && SvPOK(value)) {
848 0 0 if (value) SvREFCNT_dec(value);
855 162 0 if (key) SvREFCNT_dec(key);
859 74 722 else if ( !strcmp(id, "TCON") ) {
863 75 74 while (read < size) {
869 74 1 if (value != NULL && SvPOK(value)) {
74 0 if (value != NULL && SvPOK(value)) {
877 2 72 if ( tmp == end ) {
884 31 41 else if ( *sptr == '(' ) {
887 17 14 if (id3->version_major < 4) {
892 80 17 while (end - ptr > 0) {
893 20 60 if ( *ptr++ == '(' ) {
895 0 20 if (paren == NULL)
898 3 17 if ( isdigit(*ptr) || !strncmp((char *)ptr, "RX", 2) || !strncmp((char *)ptr, "CR", 2) ) {
2 1 if ( isdigit(*ptr) || !strncmp((char *)ptr, "RX", 2) || !strncmp((char *)ptr, "CR", 2) ) {
1 1 if ( isdigit(*ptr) || !strncmp((char *)ptr, "RX", 2) || !strncmp((char *)ptr, "CR", 2) ) {
912 0 14 if ( isdigit(*sptr) || !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
0 0 if ( isdigit(*sptr) || !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
0 0 if ( isdigit(*sptr) || !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
925 41 0 if ( !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
0 41 if ( !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
939 6 68 if (av_len(genres) > 0) {
942 65 3 else if (av_len(genres) == 0) {
955 682 40 frametype->nfields == 1 ||
956 572 110 (frametype->nfields == 2 && frametype->fields[0] == ID3_FIELD_TYPE_TEXTENCODING)
533 39 (frametype->nfields == 2 && frametype->fields[0] == ID3_FIELD_TYPE_TEXTENCODING)
966 28 0 if (value != NULL && SvPOK(value))
28 0 if (value != NULL && SvPOK(value))
973 547 533 while (read < size) {
974 4 543 if (count++ == 1 && value != NULL) {
4 0 if (count++ == 1 && value != NULL) {
983 34 513 if (array != NULL && value != NULL && SvPOK(value)) {
34 0 if (array != NULL && value != NULL && SvPOK(value)) {
34 0 if (array != NULL && value != NULL && SvPOK(value)) {
986 4 30 if (sv_len(value) > 0)
991 4 529 if (array != NULL) {
992 2 2 if (av_len(array) == 0) {
1001 506 23 else if (value != NULL && SvPOK(value)) {
506 0 else if (value != NULL && SvPOK(value)) {
1019 3 2 if ( !strcmp(id, "RVAD") ) {
1025 1 1 else if ( !strcmp(id, "RGAD") ) {
1059 92 57 if (encoding >= 0)
1062 442 149 for (; i < frametype->nfields; i++) {
1069 5 82 if ( id3->version_major == 2 && !strcmp(id, "APIC") ) {
3 2 if ( id3->version_major == 2 && !strcmp(id, "APIC") ) {
1077 84 0 if (value != NULL && SvPOK(value))
84 0 if (value != NULL && SvPOK(value))
1085 1 2 while (read < size) {
1087 1 0 if (value != NULL && SvPOK(value))
1 0 if (value != NULL && SvPOK(value))
1096 95 0 if (value != NULL && SvPOK(value)) {
95 0 if (value != NULL && SvPOK(value)) {
1102 0 0 if (value) SvREFCNT_dec(value);
1109 65 60 while (read < size) {
1111 65 0 if (value != NULL && SvPOK(value)) {
65 0 if (value != NULL && SvPOK(value)) {
1125 61 0 if (size - read >= 3) {
1136 2 0 uint8_t len = (id3->version_major == 3) ? 3 : 4;
1137 2 0 if (size - read >= len) {
1147 0 0 if (size - read >= 8) {
1157 46 0 if (size - read >= 1) {
1165 0 2 if (size - read >= 2) {
1173 0 0 if (size - read >= 3) {
1181 0 0 if (size - read >= 4) {
1189 15 0 if (size - read >= 4) {
1200 5 67 if (skip_art) {
1205 2 3 if (id3->flags & ID3_TAG_FLAG_UNSYNCHRONISATION && id3->version_major < 4) {
1 1 if (id3->flags & ID3_TAG_FLAG_UNSYNCHRONISATION && id3->version_major < 4) {
1210 3 1 if (id3->tag_data_safe && (size - read) > 0)
3 0 if (id3->tag_data_safe && (size - read) > 0)
1219 23 44 else if (buffer_art) {
1224 248 23 while (read < size) {
1225 0 248 if ( !_check_buf(id3->infile, id3->buf, 1, ID3_BLOCK_SIZE) ) {
1229 225 23 chunk_size = remain < buffer_len(id3->buf) ? remain : buffer_len(id3->buf);
1244 10 34 else if ( !strcmp(id, "RVA2") ) {
1249 1 33 else if ( !strcmp(id, "SYLT") ) {
1254 1 32 else if ( !strcmp(id, "ETCO") ) {
1260 31 1 if (size - read > 1) {
1278 8 953 if (read < size) {
1289 149 0 if ( av_len(framedata) != -1 ) {
1290 37 112 if ( my_hv_exists( id3->tags, id ) ) {
1293 37 0 if (entry != NULL) {
1294 0 37 if ( SvTYPE( SvRV(*entry) ) == SVt_PV ) {
1305 37 0 else if ( SvTYPE( SvRV(*entry) ) == SVt_PVAV ) {
1308 37 0 if ( first == NULL || ( SvROK(*first) && SvTYPE( SvRV(*first) ) == SVt_PVAV ) ) {
15 22 if ( first == NULL || ( SvROK(*first) && SvTYPE( SvRV(*first) ) == SVt_PVAV ) ) {
15 0 if ( first == NULL || ( SvROK(*first) && SvTYPE( SvRV(*first) ) == SVt_PVAV ) ) {
1340 85 0 if (read) {
1342 85 0 if (*string != NULL) {
1346 289 40 while (ptr > str && ptr[-1] == ' ')
244 45 while (ptr > str && ptr[-1] == ' ')
1365 91 1233 if ( !id3->utf8->alloc ) {
1368 65 26 buffer_init( id3->utf8, encoding == ISO_8859_1 ? len * 2 : len );
1375 0 1324 if ( *string != NULL ) {
1409 10 147 if (byteorder == UTF16_BYTEORDER_ANY) {
1425 1324 0 if (read) {
1426 1320 4 if ( buffer_len(id3->utf8) ) {
1443 0 3 int sign_r = rva[0] & 0x01 ? 1 : -1;
1444 0 3 int sign_l = rva[0] & 0x02 ? 1 : -1;
1452 2 1 if (rva[0] & 0xFE || rva[1] == 0) {
0 2 if (rva[0] & 0xFE || rva[1] == 0) {
1457 0 2 if (size != 2 + (bytes * 4)) {
1471 4 2 for (i = 0; i < 2; i++) {
1472 0 4 if ( vol[i] == -255 ) {
1516 1 0 if (sign == 1) radio *= -1.0;
1535 1 0 if (sign == 1) audiophile *= -1.0;
1572 10 0 if (4 + (peakbits + 7) / 8 <= len) {
1574 2 8 if (peakbits > 0) {
1578 2 8 if (peakbits > 8) {
1582 0 10 if (peakbits > 16) {
1587 2 8 if (peakbits > 0)
1603 16 1 while (read < len) {
1608 16 0 if (value != NULL && SvPOK(value) && sv_len(value)) {
16 0 if (value != NULL && SvPOK(value) && sv_len(value)) {
16 0 if (value != NULL && SvPOK(value) && sv_len(value)) {
1613 0 0 if (value) SvREFCNT(value);
1621 16 0 if ( len - read > 0 && bptr[0] == 0x0a ) {
16 0 if ( len - read > 0 && bptr[0] == 0x0a ) {
1640 1 1 while (read < len) {
1660 35 16 if ( my_hv_exists(id3->tags, "TYER") ) {
1662 35 0 if (SvPOK(tyer) && sv_len(tyer) == 4) {
35 0 if (SvPOK(tyer) && sv_len(tyer) == 4) {
1672 4 47 if ( my_hv_exists(id3->tags, "TDAT") ) {
1674 4 0 if (SvPOK(tdat) && sv_len(tdat) == 4) {
4 0 if (SvPOK(tdat) && sv_len(tdat) == 4) {
1686 3 48 if ( my_hv_exists(id3->tags, "TIME") ) {
1688 3 0 if (SvPOK(time) && sv_len(time) == 4) {
3 0 if (SvPOK(time) && sv_len(time) == 4) {
1700 35 16 if (timestamp[0]) {
1713 0 15 if (length == 0)
1716 140688 15 for (old = new = data; old < end - 1; ++old) {
1718 1456 139232 if (old[0] == 0xff && old[1] == 0x00)
1389 67 if (old[0] == 0xff && old[1] == 0x00)
1730 6 2 if ( buffer_len(id3->buf) >= size ) {
1747 17 0 return (index < NGENRES) ? genre_table[index] : 0;
1758 35 0 if (string == 0 || *string == 0)
0 35 if (string == 0 || *string == 0)
1761 1 34 if (string[0] == 'R' && string[1] == 'X')
1 0 if (string[0] == 'R' && string[1] == 'X')
1763 1 33 if (string[0] == 'C' && string[1] == 'R')
1 0 if (string[0] == 'C' && string[1] == 'R')
1768 33 0 return (number < NGENRES) ? genre_table[number] : string;