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

Side by Side Diff: webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc

Issue 2281453002: Moved codec-specific audio packet splitting into decoders. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" 11 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
12 12
13 #include "webrtc/modules/audio_coding/codecs/g711/g711_interface.h" 13 #include "webrtc/modules/audio_coding/codecs/g711/g711_interface.h"
14 14
15 namespace webrtc { 15 namespace webrtc {
16 16
17 void AudioDecoderPcmU::Reset() {} 17 void AudioDecoderPcmU::Reset() {}
18 18
19 AudioDecoder::PacketSplits AudioDecoderPcmU::SplitPacket(
20 const uint8_t* payload,
21 size_t payload_len) const {
22 return SplitBySamples(payload, payload_len, 8 * num_channels_, 8);
23 }
24
19 int AudioDecoderPcmU::SampleRateHz() const { 25 int AudioDecoderPcmU::SampleRateHz() const {
20 return 8000; 26 return 8000;
21 } 27 }
22 28
23 size_t AudioDecoderPcmU::Channels() const { 29 size_t AudioDecoderPcmU::Channels() const {
24 return num_channels_; 30 return num_channels_;
25 } 31 }
26 32
27 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded, 33 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded,
28 size_t encoded_len, 34 size_t encoded_len,
29 int sample_rate_hz, 35 int sample_rate_hz,
30 int16_t* decoded, 36 int16_t* decoded,
31 SpeechType* speech_type) { 37 SpeechType* speech_type) {
32 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); 38 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
33 int16_t temp_type = 1; // Default is speech. 39 int16_t temp_type = 1; // Default is speech.
34 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type); 40 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type);
35 *speech_type = ConvertSpeechType(temp_type); 41 *speech_type = ConvertSpeechType(temp_type);
36 return static_cast<int>(ret); 42 return static_cast<int>(ret);
37 } 43 }
38 44
39 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, 45 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded,
40 size_t encoded_len) const { 46 size_t encoded_len) const {
41 // One encoded byte per sample per channel. 47 // One encoded byte per sample per channel.
42 return static_cast<int>(encoded_len / Channels()); 48 return static_cast<int>(encoded_len / Channels());
43 } 49 }
44 50
45 void AudioDecoderPcmA::Reset() {} 51 void AudioDecoderPcmA::Reset() {}
46 52
53 AudioDecoder::PacketSplits AudioDecoderPcmA::SplitPacket(
54 const uint8_t* payload,
55 size_t payload_len) const {
56 return SplitBySamples(payload, payload_len, 8 * num_channels_, 8);
57 }
58
47 int AudioDecoderPcmA::SampleRateHz() const { 59 int AudioDecoderPcmA::SampleRateHz() const {
48 return 8000; 60 return 8000;
49 } 61 }
50 62
51 size_t AudioDecoderPcmA::Channels() const { 63 size_t AudioDecoderPcmA::Channels() const {
52 return num_channels_; 64 return num_channels_;
53 } 65 }
54 66
55 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, 67 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded,
56 size_t encoded_len, 68 size_t encoded_len,
57 int sample_rate_hz, 69 int sample_rate_hz,
58 int16_t* decoded, 70 int16_t* decoded,
59 SpeechType* speech_type) { 71 SpeechType* speech_type) {
60 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); 72 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz);
61 int16_t temp_type = 1; // Default is speech. 73 int16_t temp_type = 1; // Default is speech.
62 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); 74 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type);
63 *speech_type = ConvertSpeechType(temp_type); 75 *speech_type = ConvertSpeechType(temp_type);
64 return static_cast<int>(ret); 76 return static_cast<int>(ret);
65 } 77 }
66 78
67 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, 79 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded,
68 size_t encoded_len) const { 80 size_t encoded_len) const {
69 // One encoded byte per sample per channel. 81 // One encoded byte per sample per channel.
70 return static_cast<int>(encoded_len / Channels()); 82 return static_cast<int>(encoded_len / Channels());
71 } 83 }
72 84
73 } // namespace webrtc 85 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698