summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dabplus-enc.cpp8
-rw-r--r--src/utils.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp
index dfca4f1..e9aea14 100644
--- a/src/dabplus-enc.cpp
+++ b/src/dabplus-enc.cpp
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
}
if (subchannel_index < 1 || subchannel_index > 24) {
- fprintf(stderr, "Bad subchannels number: %d, try other bitrate.\n",
+ fprintf(stderr, "Bad subchannel index: %d, must be between 1 and 24. Try other bitrate.\n",
subchannel_index);
return 1;
}
@@ -534,10 +534,10 @@ int main(int argc, char *argv[])
}
int outbuf_size = subchannel_index*120;
- uint8_t zmqframebuf[2048];
+ uint8_t zmqframebuf[ZMQ_HEADER_SIZE + 24*120];
zmq_frame_header_t *zmq_frame_header = (zmq_frame_header_t*)zmqframebuf;
- uint8_t outbuf[2048];
+ uint8_t outbuf[24*120];
if(outbuf_size % 5 != 0) {
fprintf(stderr, "(outbuf_size mod 5) = %d\n", outbuf_size % 5);
@@ -755,6 +755,8 @@ int main(int argc, char *argv[])
zmq_frame_header->audiolevel_left = peak_left;
zmq_frame_header->audiolevel_right = peak_right;
+ assert(ZMQ_FRAME_SIZE(zmq_frame_header) <= NUMOF(zmqframebuf));
+
memcpy(ZMQ_FRAME_DATA(zmq_frame_header),
outbuf, outbuf_size);
diff --git a/src/utils.h b/src/utils.h
index a5aaf8c..7cd9a96 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -36,6 +36,8 @@ struct zmq_frame_header_t
#define ZMQ_ENCODER_FDK 1
+#define ZMQ_HEADER_SIZE sizeof(struct zmq_frame_header_t)
+
/* The expected frame size incl data of the given frame */
#define ZMQ_FRAME_SIZE(f) (sizeof(struct zmq_frame_header_t) + f->datasize)