ref: 0886828eed7a293f556ad45a70d8d7ab04325c9d
parent: 5160d7fdfada61e48d4c3df110cd773ec5e9ce7e
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Wed Aug 9 14:17:06 EDT 2023
Making it easier to remove DRED experimental ID When ready, change DRED_EXTENSION_ID to the final ID, remove DRED_EXPERIMENTAL_VERSION completely, and change DRED_EXPERIMENTAL_BYTES to zero (eventually remove it).
--- a/silk/dred_config.h
+++ b/silk/dred_config.h
@@ -28,7 +28,14 @@
#ifndef DRED_CONFIG_H
#define DRED_CONFIG_H
-#define DRED_VERSION 1
+/* Change this once DRED gets an extension number assigned. */
+#define DRED_EXTENSION_ID 127
+
+/* Remove these two completely once DRED gets an extension number assigned. */
+#define DRED_EXPERIMENTAL_VERSION 1
+#define DRED_EXPERIMENTAL_BYTES 2
+
+
#define DRED_MIN_BYTES 16
/* these are inpart duplicates to the values defined in dred_rdovae_constants.h */
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -1280,18 +1280,25 @@
} else {
frame += data[1];
}
- } else if (id == 127)
+ } else if (id == DRED_EXTENSION_ID)
{
const unsigned char *curr_payload;
opus_int32 curr_payload_len;
curr_payload = data0+header_size;
curr_payload_len = (data-data0)-header_size;
+#ifdef DRED_EXPERIMENTAL_VERSION
/* 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) {
+ if (curr_payload_len > DRED_EXPERIMENTAL_BYTES && curr_payload[0] == 'D' && curr_payload[1] == DRED_EXPERIMENTAL_VERSION) {
*payload = curr_payload+2;
return curr_payload_len-2;
}
+#else
+ if (curr_payload_len > 0) {
+ *payload = curr_payload;
+ return curr_payload_len;
+ }
+#endif
}
}
return 0;
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -2259,16 +2259,18 @@
/* Remaining space for DRED, accounting for cost the 3 extra bytes for code 3, padding length, and extension number. */
dred_bytes_left = IMIN(DRED_MAX_DATA_SIZE, max_data_bytes-ret-3);
/* Check whether we actually have something to encode. */
- if (dred_chunks >= 1 && dred_bytes_left >= DRED_MIN_BYTES+2) {
+ if (dred_chunks >= 1 && dred_bytes_left >= DRED_MIN_BYTES+DRED_EXPERIMENTAL_BYTES) {
int dred_bytes;
+#ifdef DRED_EXPERIMENTAL_VERSION
/* 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(&st->dred_encoder, buf+2, dred_chunks, dred_bytes_left-2);
- dred_bytes += 2;
+ buf[1] = DRED_EXPERIMENTAL_VERSION;
+#endif
+ dred_bytes = dred_encode_silk_frame(&st->dred_encoder, buf+DRED_EXPERIMENTAL_BYTES, dred_chunks, dred_bytes_left-DRED_EXPERIMENTAL_BYTES);
+ dred_bytes += DRED_EXPERIMENTAL_BYTES;
celt_assert(dred_bytes <= dred_bytes_left);
- extension.id = 127;
+ extension.id = DRED_EXTENSION_ID;
extension.frame = 0;
extension.data = buf;
extension.len = dred_bytes;
--
⑨