History

make write output optional

lieff committed 8 years ago

Commit 9c7ce371 parent 64a369d2 files · +11 −8Browse files

Unified · Split

2 files
  1. minimp3.c +10 −7
  2. scripts/build.sh +1 −1
minimp3.c+10−7
@@ -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
1659static void decode_file(FILE *file_mp3, FILE *file_wav, FILE *file_ref)1659static 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
1711int main(int argc, char *argv[])1714int 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#endif1727#endif
scripts/build.sh+1−1
@@ -11,7 +11,7 @@ APP=./minimp3 · 10 unmodified lines
11 11
12set +e12set +e
13for i in fate-suite.ffmpeg.org/mp3-conformance/*.bit; do13for i in fate-suite.ffmpeg.org/mp3-conformance/*.bit; do
14$APP $i $i.out ${i%.*}.pcm14$APP $i ${i%.*}.pcm
15retval=$?15retval=$?
16echo $i exited with code=$retval16echo $i exited with code=$retval
17if [ ! $retval -eq 0 ]; then17if [ ! $retval -eq 0 ]; then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t