Unverified Commit 79c0e61a authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Add support for header gain

parent 469caffa
......@@ -111,6 +111,8 @@ extern "C" {
#define OPE_GET_SERIALNO_REQUEST 14007
#define OPE_SET_PACKET_CALLBACK_REQUEST 14008
#define OPE_GET_PACKET_CALLBACK_REQUEST 14009
#define OPE_SET_HEADER_GAIN_REQUEST 14010
#define OPE_GET_HEADER_GAIN_REQUEST 14011
/**\defgroup encoder_ctl Encoding Options*/
/*@{*/
......@@ -131,6 +133,8 @@ extern "C" {
/* FIXME: Add type-checking macros to these. */
#define OPE_SET_PACKET_CALLBACK(x,u) OPE_SET_PACKET_CALLBACK_REQUEST, (x), (u)
#define OPE_GET_PACKET_CALLBACK(x,u) OPE_GET_PACKET_CALLBACK_REQUEST, (x), (u)
#define OPE_SET_HEADER_GAIN(x,u) OPE_SET_HEADER_GAIN_REQUEST, (x), (u)
#define OPE_GET_HEADER_GAIN(x,u) OPE_GET_HEADER_GAIN_REQUEST, (x), (u)
/*@}*/
/*@}*/
......
......@@ -36,7 +36,7 @@ typedef struct {
int channels; /* Number of channels: 1..255 */
int preskip;
opus_uint32 input_sample_rate;
int gain; /* in dB S7.8 should be zero whenever possible */
opus_int32 gain; /* in dB S7.8 should be zero whenever possible */
int channel_mapping;
/* The rest is only used if channel_mapping != 0 */
int nb_streams;
......
......@@ -762,7 +762,10 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
case OPE_SET_SERIALNO_REQUEST:
{
opus_int32 value = va_arg(ap, opus_int32);
if (enc->last_stream->header_is_frozen) return OPE_TOO_LATE;
if (!enc->last_stream || enc->last_stream->header_is_frozen) {
ret = OPE_TOO_LATE;
break;
}
enc->last_stream->serialno = value;
enc->last_stream->serialno_is_set = 1;
ret = OPE_OK;
......@@ -777,8 +780,19 @@ int ope_encoder_ctl(OggOpusEnc *enc, int request, ...) {
ret = OPE_OK;
}
break;
case OPE_SET_HEADER_GAIN_REQUEST:
{
opus_int32 value = va_arg(ap, opus_int32);
if (!enc->last_stream || enc->last_stream->header_is_frozen) {
ret = OPE_TOO_LATE;
break;
}
enc->header.gain = value;
ret = OPE_OK;
}
break;
default:
return OPE_UNIMPLEMENTED;
ret = OPE_UNIMPLEMENTED;
}
va_end(ap);
translate = ret != 0 && (request < 14000 || (ret < 0 && ret >= -10));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment