aboutsummaryrefslogtreecommitdiffstats
path: root/dabp-decode/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dabp-decode/main.cpp')
-rw-r--r--dabp-decode/main.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/dabp-decode/main.cpp b/dabp-decode/main.cpp
new file mode 100644
index 0000000..e674f74
--- /dev/null
+++ b/dabp-decode/main.cpp
@@ -0,0 +1,42 @@
+#include <iostream>
+#include <string>
+#include <vector>
+#include "AACDecoder.h"
+
+int main(int argc, char **argv)
+{
+ if (argc != 4) {
+ std::cerr << "Usage: " << argv[0] << " INFILE FRAME_SIZE OUTFILE\n";
+ return 1;
+ }
+
+ auto frame_size = std::stol(argv[2]);
+ if (frame_size == 0) {
+ std::cerr << "Frame size 0 !\n";
+ return 1;
+ }
+
+ FILE *fd = fopen(argv[1], "r");
+ if (fd == nullptr) {
+ std::cerr << "Could not open file !\n";
+ return 1;
+ }
+
+ AACDecoder aacdec(argv[3]);
+
+ std::vector<uint8_t> buf;
+ buf.resize(frame_size);
+
+ while (not feof(fd)) {
+ if (fread(buf.data(), buf.size(), 1, fd) == 0) {
+ std::cerr << "fread 0\n";
+ break;
+ }
+
+ aacdec.decode_frame(buf.data(), buf.size());
+ }
+
+ fclose(fd);
+
+ return 0;
+}