Branch Coverage

src/id3.c
Criterion Covered Total %
branch 391 532 73.5


line true false branch
30 500 0 if (buf) {
31 1984 500 for ( i = 0; i < length; i++ ) {
61 92 6 if ( !seek ) {
64 0 92 if ( !_check_buf(infile, id3->buf, 128, 128) ) {
70 16 76 if (bptr[0] == 'T' && bptr[1] == 'A' && bptr[2] == 'G') {
16 0 if (bptr[0] == 'T' && bptr[1] == 'A' && bptr[2] == 'G') {
16 0 if (bptr[0] == 'T' && bptr[1] == 'A' && bptr[2] == 'G') {
80 0 98 if ( !_check_buf(infile, id3->buf, 14, ID3_BLOCK_SIZE) ) {
86 83 15 if (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') {
83 0 if (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') {
83 0 if (bptr[0] == 'I' && bptr[1] == 'D' && bptr[2] == '3') {
94 85 13 if (id3->utf8->alloc)
115 16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
9 7 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
120 7 0 if (tmp) SvREFCNT_dec(tmp);
122 13 3 if (read < 30) {
128 16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
9 7 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
134 7 0 if (tmp) SvREFCNT_dec(tmp);
136 13 3 if (read < 30) {
142 16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
9 7 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
148 7 0 if (tmp) SvREFCNT_dec(tmp);
150 13 3 if (read < 30) {
156 16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
8 8 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
162 8 0 if (tmp) SvREFCNT_dec(tmp);
164 7 9 if (read < 4) {
169 14 2 if (bptr[28] == 0 && bptr[29] != 0) {
4 10 if (bptr[28] == 0 && bptr[29] != 0) {
182 16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
16 0 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
5 11 if (tmp && SvPOK(tmp) && sv_len(tmp)) {
192 11 0 if (tmp) SvREFCNT_dec(tmp);
194 14 2 if (read < 30) {
199 8 8 if (genre < NGENRES) {
203 0 8 else if (genre < 255) {
218 83 0 if ( !(
0 83 if ( !(
219 83 0 bptr[3] < 0xff && bptr[4] < 0xff &&
83 0 bptr[3] < 0xff && bptr[4] < 0xff &&
220 83 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
83 0 bptr[6] < 0x80 && bptr[7] < 0x80 && bptr[8] < 0x80 && bptr[9] < 0x80
235 0 83 if (id3->flags & ID3_TAG_FLAG_FOOTERPRESENT) {
241 13 70 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 3 80 if (id3->flags & ID3_TAG_FLAG_EXTENDEDHEADER) {
270 0 3 if (id3->version_major == 2) {
281 1 2 if (ehsize > id3->size_remain - 4) {
289 0 2 if ( !_check_buf(id3->infile, id3->buf, ehsize, ID3_BLOCK_SIZE) ) {
299 998 10 while (id3->size_remain > 0) {
301 72 926 if ( !_id3_parse_v2_frame(id3) ) {
306 50 32 if (id3->version_major < 4) {
316 11 71 if ( my_hv_exists(id3->info, "id3_version") ) {
318 11 0 if (entry != NULL) {
349 0 998 if ( !_check_buf(id3->infile, id3->buf, 10, ID3_BLOCK_SIZE) ) {
354 88 910 if (id3->version_major == 2) {
362 4 84 if (id[0] == 0) {
375 84 0 if (compat && compat->equiv) {
84 0 if (compat && compat->equiv) {
394 0 84 if (size > id3->size_remain) {
405 66 844 if (id[0] == 0) {
414 373 471 if (id3->version_major == 3) {
424 6 367 if (id[3] == ' ') {
432 83 290 if (compat && compat->equiv) {
44 39 if (compat && compat->equiv) {
441 0 373 if (size > id3->size_remain) {
447 1 372 if (flags & ID3_FRAME_FLAG_V23_COMPRESSION) {
454 1 372 if (flags & ID3_FRAME_FLAG_V23_ENCRYPTION) {
471 1 371 if (flags & ID3_FRAME_FLAG_V23_GROUPINGIDENTITY) {
485 1 371 if (flags & ID3_FRAME_FLAG_V23_COMPRESSION && decoded_size) {
1 0 if (flags & ID3_FRAME_FLAG_V23_COMPRESSION && decoded_size) {
488 0 1 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
499 1 0 if (
501 0 1 ||
519 2 469 if ( _varint(buffer_ptr(id3->buf), 4) & 0x80 ) {
533 2 469 if (size > id3->size_remain) {
541 3 466 if (id[3] == ' ') {
544 3 0 if (compat && compat->equiv) {
3 0 if (compat && compat->equiv) {
552 1 468 if (flags & ID3_FRAME_FLAG_V24_GROUPINGIDENTITY) {
563 1 468 if (flags & ID3_FRAME_FLAG_V24_ENCRYPTION) {
580 12 456 if (flags & ID3_FRAME_FLAG_V24_DATALENGTHINDICATOR) {
588 12 456 if (flags & ID3_FRAME_FLAG_V24_UNSYNCHRONISATION) {
591 4 8 if ( !strcmp(id, "APIC") && _env_true("AUDIO_SCAN_NO_ARTWORK") ) {
1 3 if ( !strcmp(id, "APIC") && _env_true("AUDIO_SCAN_NO_ARTWORK") ) {
602 0 11 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
615 1 467 if (flags & ID3_FRAME_FLAG_V24_COMPRESSION) {
620 0 1 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
631 1 0 if (
633 0 1 ||
651 923 1 if ( !strcmp(id, "XHD3") || !strcmp(id, "NCON") ) {
0 923 if ( !strcmp(id, "XHD3") || !strcmp(id, "NCON") ) {
659 62 861 if (frametype == 0) {
693 2 921 if (decompressed) {
698 13 910 if ( !_id3_parse_v2_frame_data(id3, (char *)&id, decoded_size ? decoded_size : size, frametype) ) {
0 923 if ( !_id3_parse_v2_frame_data(id3, (char *)&id, decoded_size ? decoded_size : size, frametype) ) {
704 913 10 if (id3->size_remain > size) {
712 11 912 if (unsync_extra) {
718 2 996 if (decompressed) {
738 27 896 uint8_t skip_art = ( buffer_art && _env_true("AUDIO_SCAN_NO_ARTWORK") ) ? 1 : 0;
5 22 uint8_t skip_art = ( buffer_art && _env_true("AUDIO_SCAN_NO_ARTWORK") ) ? 1 : 0;
741 1 922 if (!size)
744 5 917 if (skip_art) {
747 0 5 if ( !_check_buf(id3->infile, id3->buf, 128, ID3_BLOCK_SIZE) ) {
755 22 895 if (buffer_art) {
757 0 22 if ( !_check_buf(id3->infile, id3->buf, 128, ID3_BLOCK_SIZE) ) {
763 0 895 if ( !_check_buf(id3->infile, id3->buf, size, ID3_BLOCK_SIZE) ) {
769 827 95 if ( frametype->fields[0] == ID3_FIELD_TYPE_TEXTENCODING ) {
775 827 0 if (encoding < 0 || encoding > 3) {
824 3 if (encoding < 0 || encoding > 3) {
782 788 131 if ( !strcmp(id, "TXXX") || !strcmp(id, "WXXX") ) {
19 769 if ( !strcmp(id, "TXXX") || !strcmp(id, "WXXX") ) {
789 150 0 if (key != NULL && SvPOK(key) && sv_len(key)) {
150 0 if (key != NULL && SvPOK(key) && sv_len(key)) {
145 5 if (key != NULL && SvPOK(key) && sv_len(key)) {
793 14 131 if (frametype->fields[2] == ID3_FIELD_TYPE_LATIN1) {
803 145 0 if (value != NULL && SvPOK(value) && sv_len(value)) {
145 0 if (value != NULL && SvPOK(value) && sv_len(value)) {
145 0 if (value != NULL && SvPOK(value) && sv_len(value)) {
808 0 0 if (value) SvREFCNT_dec(value);
815 150 0 if (key) SvREFCNT_dec(key);
819 71 698 else if ( !strcmp(id, "TCON") ) {
823 72 71 while (read < size) {
829 71 1 if (value != NULL && SvPOK(value)) {
71 0 if (value != NULL && SvPOK(value)) {
837 2 69 if ( tmp == end ) {
844 30 39 else if ( *sptr == '(' ) {
847 17 13 if (id3->version_major < 4) {
852 80 17 while (end - ptr > 0) {
853 20 60 if ( *ptr++ == '(' ) {
855 0 20 if (paren == NULL)
858 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) ) {
872 0 13 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) ) {
885 39 0 if ( !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
0 39 if ( !strncmp(sptr, "RX", 2) || !strncmp(sptr, "CR", 2) ) {
899 6 65 if (av_len(genres) > 0) {
902 62 3 else if (av_len(genres) == 0) {
914 658 40 else if (
915 553 105 frametype->nfields == 1 ||
916 515 38 (frametype->nfields == 2 && frametype->fields[0] == ID3_FIELD_TYPE_TEXTENCODING)
926 28 0 if (value != NULL && SvPOK(value))
28 0 if (value != NULL && SvPOK(value))
933 529 515 while (read < size) {
934 4 525 if (count++ == 1 && value != NULL) {
4 0 if (count++ == 1 && value != NULL) {
943 34 495 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)) {
946 4 30 if (sv_len(value) > 0)
951 4 511 if (array != NULL) {
952 2 2 if (av_len(array) == 0) {
961 488 23 else if (value != NULL && SvPOK(value)) {
488 0 else if (value != NULL && SvPOK(value)) {
979 3 2 if ( !strcmp(id, "RVAD") ) {
985 1 1 else if ( !strcmp(id, "RGAD") ) {
1019 88 55 if (encoding >= 0)
1022 424 143 for (; i < frametype->nfields; i++) {
1029 5 79 if ( id3->version_major == 2 && !strcmp(id, "APIC") ) {
3 2 if ( id3->version_major == 2 && !strcmp(id, "APIC") ) {
1037 81 0 if (value != NULL && SvPOK(value))
81 0 if (value != NULL && SvPOK(value))
1045 1 2 while (read < size) {
1047 1 0 if (value != NULL && SvPOK(value))
1 0 if (value != NULL && SvPOK(value))
1056 91 0 if (value != NULL && SvPOK(value)) {
91 0 if (value != NULL && SvPOK(value)) {
1062 0 0 if (value) SvREFCNT_dec(value);
1069 62 57 while (read < size) {
1071 62 0 if (value != NULL && SvPOK(value)) {
62 0 if (value != NULL && SvPOK(value)) {
1085 58 0 if (size - read >= 3) {
1096 2 0 uint8_t len = (id3->version_major == 3) ? 3 : 4;
1097 2 0 if (size - read >= len) {
1107 0 0 if (size - read >= 8) {
1117 44 0 if (size - read >= 1) {
1125 0 2 if (size - read >= 2) {
1133 0 0 if (size - read >= 3) {
1141 0 0 if (size - read >= 4) {
1149 14 0 if (size - read >= 4) {
1160 5 65 if (skip_art) {
1165 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) {
1170 3 1 if (id3->tag_data_safe && (size - read) > 0)
3 0 if (id3->tag_data_safe && (size - read) > 0)
1179 22 43 else if (buffer_art) {
1184 103 22 while (read < size) {
1185 0 103 if ( !_check_buf(id3->infile, id3->buf, 1, ID3_BLOCK_SIZE) ) {
1189 81 22 chunk_size = remain < buffer_len(id3->buf) ? remain : buffer_len(id3->buf);
1204 10 33 else if ( !strcmp(id, "RVA2") ) {
1209 1 32 else if ( !strcmp(id, "SYLT") ) {
1214 1 31 else if ( !strcmp(id, "ETCO") ) {
1220 30 1 if (size - read > 1) {
1238 8 914 if (read < size) {
1249 143 0 if ( av_len(framedata) != -1 ) {
1250 35 108 if ( my_hv_exists( id3->tags, id ) ) {
1253 35 0 if (entry != NULL) {
1254 0 35 if ( SvTYPE( SvRV(*entry) ) == SVt_PV ) {
1265 35 0 else if ( SvTYPE( SvRV(*entry) ) == SVt_PVAV ) {
1268 35 0 if ( first == NULL || ( SvROK(*first) && SvTYPE( SvRV(*first) ) == SVt_PVAV ) ) {
14 21 if ( first == NULL || ( SvROK(*first) && SvTYPE( SvRV(*first) ) == SVt_PVAV ) ) {
14 0 if ( first == NULL || ( SvROK(*first) && SvTYPE( SvRV(*first) ) == SVt_PVAV ) ) {
1300 80 0 if (read) {
1302 80 0 if (*string != NULL) {
1306 284 40 while (ptr > str && ptr[-1] == ' ')
244 40 while (ptr > str && ptr[-1] == ' ')
1325 85 1170 if ( !id3->utf8->alloc ) {
1328 63 22 buffer_init( id3->utf8, encoding == ISO_8859_1 ? len * 2 : len );
1335 0 1255 if ( *string != NULL ) {
1369 9 129 if (byteorder == UTF16_BYTEORDER_ANY) {
1385 1255 0 if (read) {
1386 1251 4 if ( buffer_len(id3->utf8) ) {
1403 0 3 int sign_r = rva[0] & 0x01 ? 1 : -1;
1404 0 3 int sign_l = rva[0] & 0x02 ? 1 : -1;
1412 2 1 if (rva[0] & 0xFE || rva[1] == 0) {
0 2 if (rva[0] & 0xFE || rva[1] == 0) {
1417 0 2 if (size != 2 + (bytes * 4)) {
1431 4 2 for (i = 0; i < 2; i++) {
1432 0 4 if ( vol[i] == -255 ) {
1476 1 0 if (sign == 1) radio *= -1.0;
1495 1 0 if (sign == 1) audiophile *= -1.0;
1532 10 0 if (4 + (peakbits + 7) / 8 <= len) {
1534 2 8 if (peakbits > 0) {
1538 2 8 if (peakbits > 8) {
1542 0 10 if (peakbits > 16) {
1547 2 8 if (peakbits > 0)
1563 16 1 while (read < len) {
1568 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)) {
1573 0 0 if (value) SvREFCNT(value);
1581 16 0 if ( len - read > 0 && bptr[0] == 0x0a ) {
16 0 if ( len - read > 0 && bptr[0] == 0x0a ) {
1600 1 1 while (read < len) {
1620 34 16 if ( my_hv_exists(id3->tags, "TYER") ) {
1622 34 0 if (SvPOK(tyer) && sv_len(tyer) == 4) {
34 0 if (SvPOK(tyer) && sv_len(tyer) == 4) {
1632 4 46 if ( my_hv_exists(id3->tags, "TDAT") ) {
1634 4 0 if (SvPOK(tdat) && sv_len(tdat) == 4) {
4 0 if (SvPOK(tdat) && sv_len(tdat) == 4) {
1646 3 47 if ( my_hv_exists(id3->tags, "TIME") ) {
1648 3 0 if (SvPOK(time) && sv_len(time) == 4) {
3 0 if (SvPOK(time) && sv_len(time) == 4) {
1660 34 16 if (timestamp[0]) {
1673 0 15 if (length == 0)
1676 140688 15 for (old = new = data; old < end - 1; ++old) {
1678 1456 139232 if (old[0] == 0xff && old[1] == 0x00)
1389 67 if (old[0] == 0xff && old[1] == 0x00)
1690 6 2 if ( buffer_len(id3->buf) >= size ) {
1707 17 0 return (index < NGENRES) ? genre_table[index] : 0;
1718 34 0 if (string == 0 || *string == 0)
0 34 if (string == 0 || *string == 0)
1721 1 33 if (string[0] == 'R' && string[1] == 'X')
1 0 if (string[0] == 'R' && string[1] == 'X')
1723 1 32 if (string[0] == 'C' && string[1] == 'R')
1 0 if (string[0] == 'C' && string[1] == 'R')
1728 32 0 return (number < NGENRES) ? genre_table[number] : string;