Add setting for comment padding (untested)
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Mon, 1 May 2017 21:03:24 +0000 (17:03 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Mon, 1 May 2017 21:03:24 +0000 (17:03 -0400)
include/opusenc.h
src/opusenc.c

index 3b8d878..0058352 100644 (file)
@@ -59,11 +59,15 @@ extern "C" {
 #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);
index 0472e1b..c2179bb 100644 (file)
@@ -90,6 +90,7 @@ struct OggOpusEnc {
   OpusEncCallbacks callbacks;
   void *user_data;
   OpusHeader header;
+  int comment_padding;
   char *comment;
   int comment_length;
   ogg_stream_state os;
@@ -174,6 +175,7 @@ OggOpusEnc *ope_create_callbacks(const OpusEncCallbacks *callbacks, void *user_d
   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 @@ static void init_stream(OggOpusEnc *enc) {
     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*/
   {
@@ -525,6 +527,17 @@ int ope_set_params(OggOpusEnc *enc, int request, ...) {
       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;
     default:
       return OPE_UNIMPLEMENTED;
   }