ref: cd5b26887964c8f276fac9a1e30d6ef093fbe126
parent: 0f0ee98386d82f257f35aa1700d90c83e3483d45
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Thu Apr 13 20:55:46 EDT 2023
DRED versioning in bitstream Adding a 'D' byte to signal the DRED experiment, along with a version number byte. This entire commit will be reverted once DRED is finalized and given a non-experimental extension number.
--- a/silk/dred_config.h
+++ b/silk/dred_config.h
@@ -25,6 +25,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define DRED_VERSION 0
+
/* these are inpart duplicates to the values defined in dred_rdovae_constants.h */
#define DRED_NUM_FEATURES 20
#define DRED_LATENT_DIM 80
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -1112,9 +1112,17 @@
}
} else if (id == 127)
{
- payload = data0+header_size;
- payload_len = (data-data0)-header_size;
- break;
+ const unsigned char *curr_payload;
+ opus_int32 curr_payload_len;
+ curr_payload = data0+header_size;
+ curr_payload_len = (data-data0)-header_size;
+ /* Check that temporary extension type and version match.
+ This check will be removed once extension is finalized. */
+ if (curr_payload_len > 2 && curr_payload[0] == 'D' && curr_payload[1] == DRED_VERSION) {
+ payload = curr_payload+2;
+ payload_len = curr_payload_len-2;
+ break;
+ }
}
}
if (payload != NULL)
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -2199,8 +2199,13 @@
dred_chunks = IMIN(st->dred_duration/4, DRED_NUM_REDUNDANCY_FRAMES/2);
dred_bytes = IMIN(DRED_MAX_DATA_SIZE, max_data_bytes-ret-2);
/* Check whether we actually have something to encode. */
- if (dred_chunks >= 1 && dred_bytes >= 3) {
- dred_bytes = dred_encode_silk_frame(dred, buf, dred_chunks, dred_bytes);
+ if (dred_chunks >= 1 && dred_bytes >= 5) {
+ /* Add temporary extension type and version.
+ These bytes will be removed once extension is finalized. */
+ buf[0] = 'D';
+ buf[1] = DRED_VERSION;
+ dred_bytes = dred_encode_silk_frame(dred, buf+2, dred_chunks, dred_bytes-2);
+ dred_bytes += 2;
extension.id = 127;
extension.frame = 0;
extension.data = buf;
--
⑨