Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Unified Diff: webrtc/modules/audio_coding/codecs/opus/opus_interface.c

Issue 1225173002: Update audio code to use size_t more correctly, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Review comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/opus/opus_interface.c
diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
index e2506166a923a07b3599c5d3728f0ae40328facd..e2a8383c4b665da3982843be94a360946d4f8d49 100644
--- a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
+++ b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c
@@ -80,8 +80,8 @@ int16_t WebRtcOpus_EncoderFree(OpusEncInst* inst) {
int WebRtcOpus_Encode(OpusEncInst* inst,
const int16_t* audio_in,
- int16_t samples,
- int16_t length_encoded_buffer,
+ size_t samples,
+ size_t length_encoded_buffer,
uint8_t* encoded) {
int res;
@@ -91,9 +91,9 @@ int WebRtcOpus_Encode(OpusEncInst* inst,
res = opus_encode(inst->encoder,
(const opus_int16*)audio_in,
- samples,
+ (int)samples,
encoded,
- length_encoded_buffer);
+ (opus_int32)length_encoded_buffer);
if (res == 1) {
// Indicates DTX since the packet has nothing but a header. In principle,
@@ -260,7 +260,7 @@ int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst) {
}
/* For decoder to determine if it is to output speech or comfort noise. */
-static int16_t DetermineAudioType(OpusDecInst* inst, int16_t encoded_bytes) {
+static int16_t DetermineAudioType(OpusDecInst* inst, size_t encoded_bytes) {
// Audio type becomes comfort noise if |encoded_byte| is 1 and keeps
// to be so if the following |encoded_byte| are 0 or 1.
if (encoded_bytes == 0 && inst->in_dtx_mode) {
@@ -278,9 +278,9 @@ static int16_t DetermineAudioType(OpusDecInst* inst, int16_t encoded_bytes) {
* is set to the number of samples needed for PLC in case of losses.
* It is up to the caller to make sure the value is correct. */
static int DecodeNative(OpusDecInst* inst, const uint8_t* encoded,
- int16_t encoded_bytes, int frame_size,
+ size_t encoded_bytes, int frame_size,
int16_t* decoded, int16_t* audio_type, int decode_fec) {
- int res = opus_decode(inst->decoder, encoded, encoded_bytes,
+ int res = opus_decode(inst->decoder, encoded, (opus_int32)encoded_bytes,
(opus_int16*)decoded, frame_size, decode_fec);
if (res <= 0)
@@ -292,7 +292,7 @@ static int DecodeNative(OpusDecInst* inst, const uint8_t* encoded,
}
int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
- int16_t encoded_bytes, int16_t* decoded,
+ size_t encoded_bytes, int16_t* decoded,
int16_t* audio_type) {
int decoded_samples;
@@ -340,7 +340,7 @@ int WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
}
int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
- int16_t encoded_bytes, int16_t* decoded,
+ size_t encoded_bytes, int16_t* decoded,
int16_t* audio_type) {
int decoded_samples;
int fec_samples;
@@ -362,9 +362,9 @@ int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
int WebRtcOpus_DurationEst(OpusDecInst* inst,
const uint8_t* payload,
- int payload_length_bytes) {
+ size_t payload_length_bytes) {
int frames, samples;
- frames = opus_packet_get_nb_frames(payload, payload_length_bytes);
+ frames = opus_packet_get_nb_frames(payload, (opus_int32)payload_length_bytes);
if (frames < 0) {
/* Invalid payload data. */
return 0;
@@ -378,7 +378,7 @@ int WebRtcOpus_DurationEst(OpusDecInst* inst,
}
int WebRtcOpus_FecDurationEst(const uint8_t* payload,
- int payload_length_bytes) {
+ size_t payload_length_bytes) {
int samples;
if (WebRtcOpus_PacketHasFec(payload, payload_length_bytes) != 1) {
return 0;
@@ -393,13 +393,13 @@ int WebRtcOpus_FecDurationEst(const uint8_t* payload,
}
int WebRtcOpus_PacketHasFec(const uint8_t* payload,
- int payload_length_bytes) {
+ size_t payload_length_bytes) {
int frames, channels, payload_length_ms;
int n;
opus_int16 frame_sizes[48];
const unsigned char *frame_data[48];
- if (payload == NULL || payload_length_bytes <= 0)
+ if (payload == NULL || payload_length_bytes == 0)
return 0;
/* In CELT_ONLY mode, packets should not have FEC. */
@@ -432,8 +432,8 @@ int WebRtcOpus_PacketHasFec(const uint8_t* payload,
}
/* The following is to parse the LBRR flags. */
- if (opus_packet_parse(payload, payload_length_bytes, NULL, frame_data,
- frame_sizes, NULL) < 0) {
+ if (opus_packet_parse(payload, (opus_int32)payload_length_bytes, NULL,
+ frame_data, frame_sizes, NULL) < 0) {
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698