| @@ -1656,7 +1656,7 @@ static char *wav_header(int hz, int ch, int bips, int data_bytes) · 1655 unmodified lines |
| 1656 | return hdr; | 1656 | return hdr; |
| 1657 | } | 1657 | } |
| 1658 | | 1658 | |
| 1659 | static void decode_file(FILE *file_mp3, FILE *file_wav, FILE *file_ref) | 1659 | static void decode_file(FILE *file_mp3, FILE *file_ref, FILE *file_out) |
| 1660 | { | 1660 | { |
| 1661 | static mp3dec_t mp3d = { 0, }; | 1661 | static mp3dec_t mp3d = { 0, }; |
| 1662 | mp3dec_frame_info_t info; | 1662 | mp3dec_frame_info_t info; |
| @@ -1684,7 +1684,8 @@ static void decode_file(FILE *file_mp3, FILE *file_wav, FILE *file_ref) · 21 unmodified lines |
| 1684 | maxdiff = MSEtemp; | 1684 | maxdiff = MSEtemp; |
| 1685 | MSE += MSEtemp*MSEtemp; | 1685 | MSE += MSEtemp*MSEtemp; |
| 1686 | } | 1686 | } |
| 1687 | fwrite(pcm, samples, 2*info.channels, file_wav); | 1687 | if (file_out) |
| | 1688 | fwrite(pcm, samples, 2*info.channels, file_out); |
| 1688 | } | 1689 | } |
| 1689 | memmove(buf, buf + info.frame_bytes, nbuf -= info.frame_bytes); | 1690 | memmove(buf, buf + info.frame_bytes, nbuf -= info.frame_bytes); |
| 1690 | } while (info.frame_bytes); | 1691 | } while (info.frame_bytes); |
| @@ -1704,21 +1705,23 @@ static void decode_file(FILE *file_mp3, FILE *file_wav, FILE *file_ref) · 13 unmodified lines |
| 1704 | //data_bytes = ftell(file_wav) - 44; | 1705 | //data_bytes = ftell(file_wav) - 44; |
| 1705 | //rewind(file_wav); | 1706 | //rewind(file_wav); |
| 1706 | //fwrite(wav_header(info.hz, info.channels, 16, data_bytes), 1, 44, file_wav); | 1707 | //fwrite(wav_header(info.hz, info.channels, 16, data_bytes), 1, 44, file_wav); |
| 1707 | fclose(file_wav); | | |
| 1708 | fclose(file_mp3); | 1708 | fclose(file_mp3); |
| | 1709 | fclose(file_ref); |
| | 1710 | if (file_out) |
| | 1711 | fclose(file_out); |
| 1709 | } | 1712 | } |
| 1710 | | 1713 | |
| 1711 | int main(int argc, char *argv[]) | 1714 | int main(int argc, char *argv[]) |
| 1712 | { | 1715 | { |
| 1713 | char *input_file_name = (argc > 1) ? argv[1] : NULL; | 1716 | char *input_file_name = (argc > 1) ? argv[1] : NULL; |
| 1714 | char *output_file_name = (argc > 2) ? argv[2] : NULL; | 1717 | char *ref_file_name = (argc > 2) ? argv[2] : NULL; |
| 1715 | char *ref_file_name = (argc > 3) ? argv[3] : NULL; | 1718 | char *output_file_name = (argc > 3) ? argv[3] : NULL; |
| 1716 | if (!input_file_name || !output_file_name || !ref_file_name) | 1719 | if (!input_file_name || !ref_file_name) |
| 1717 | { | 1720 | { |
| 1718 | printf("error: no file names given\n"); | 1721 | printf("error: no file names given\n"); |
| 1719 | return 1; | 1722 | return 1; |
| 1720 | } | 1723 | } |
| 1721 | decode_file(fopen(input_file_name, "rb"), fopen(output_file_name, "wb"), fopen(ref_file_name, "rb")); | 1724 | decode_file(fopen(input_file_name, "rb"), fopen(ref_file_name, "rb"), output_file_name ? fopen(output_file_name, "wb") : NULL); |
| 1722 | return 0; | 1725 | return 0; |
| 1723 | } | 1726 | } |
| 1724 | #endif | 1727 | #endif |