ref: 04b6487308d2f981afe7c94147cf58c56aaf0615
parent: 2809e5c22ca797313230f652eba645062f290994
author: Jean-Marc Valin <[email protected]>
date: Mon May 1 13:03:24 EDT 2017
Add setting for comment padding (untested)
--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -59,11 +59,15 @@
#define OPE_GET_DECISION_DELAY_REQUEST 14001
#define OPE_SET_MUXING_DELAY_REQUEST 14002
#define OPE_GET_MUXING_DELAY_REQUEST 14003
+#define OPE_SET_COMMENT_PADDING_REQUEST 14004
+#define OPE_GET_COMMENT_PADDING_REQUEST 14005
#define OPE_SET_DECISION_DELAY(x) OPE_SET_DECISION_DELAY_REQUEST, __opus_check_int(x)
#define OPE_GET_DECISION_DELAY(x) OPE_GET_DECISION_DELAY_REQUEST, __opus_check_int_ptr(x)
#define OPE_SET_MUXING_DELAY(x) OPE_SET_MUXING_DELAY_REQUEST, __opus_check_int(x)
#define OPE_GET_MUXING_DELAY(x) OPE_GET_MUXING_DELAY_REQUEST, __opus_check_int_ptr(x)
+#define OPE_SET_COMMENT_PADDING(x) OPE_SET_COMMENT_PADDING_REQUEST, __opus_check_int(x)
+#define OPE_GET_COMMENT_PADDING(x) OPE_GET_COMMENT_PADDING_REQUEST, __opus_check_int_ptr(x)
typedef int (*ope_write_func)(void *user_data, const unsigned char *ptr, int len);
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -90,6 +90,7 @@
OpusEncCallbacks callbacks;
void *user_data;
OpusHeader header;
+ int comment_padding;
char *comment;
int comment_length;
ogg_stream_state os;
@@ -174,6 +175,7 @@
enc->frame_size = 960;
enc->decision_delay = 96000;
enc->max_ogg_delay = 48000;
+ enc->comment_padding = 512;
enc->header.channels=channels;
enc->header.channel_mapping=family;
enc->header.input_sample_rate=rate;
@@ -241,7 +243,7 @@
assert(0);
/* FIXME: How the hell do we handle that? */
}
- comment_pad(&enc->comment, &enc->comment_length, 512);
+ comment_pad(&enc->comment, &enc->comment_length, enc->comment_padding);
/*Write header*/
{
@@ -522,6 +524,17 @@
break;
}
enc->max_ogg_delay = value;
+ ret = OPE_OK;
+ }
+ break;
+ case OPE_SET_COMMENT_PADDING_REQUEST:
+ {
+ opus_int32 value = va_arg(ap, opus_int32);
+ if (value < 0) {
+ ret = OPE_BAD_ARG;
+ break;
+ }
+ enc->comment_padding = value;
ret = OPE_OK;
}
break;