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

Side by Side Diff: media/audio/audio_util.h

Issue 7601002: Revert r95841 due to failing media_unittests on linux_shared bot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_parameters.h ('k') | media/audio/fake_audio_output_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_
6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ 6 #define MEDIA_AUDIO_AUDIO_UTIL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "media/base/media_export.h"
12 11
13 namespace media { 12 namespace media {
14 13
15 // For all audio functions 3 audio formats are supported: 14 // For all audio functions 3 audio formats are supported:
16 // 8 bits unsigned 0 to 255. 15 // 8 bits unsigned 0 to 255.
17 // 16 bit signed (little endian). 16 // 16 bit signed (little endian).
18 // 32 bit signed (little endian) 17 // 32 bit signed (little endian)
19 18
20 // AdjustVolume() does a software volume adjustment of a sample buffer. 19 // AdjustVolume() does a software volume adjustment of a sample buffer.
21 // The samples are multiplied by the volume, which should range from 20 // The samples are multiplied by the volume, which should range from
22 // 0.0 (mute) to 1.0 (full volume). 21 // 0.0 (mute) to 1.0 (full volume).
23 // Using software allows each audio and video to have its own volume without 22 // Using software allows each audio and video to have its own volume without
24 // affecting the master volume. 23 // affecting the master volume.
25 // In the future the function may be used to adjust the sample format to 24 // In the future the function may be used to adjust the sample format to
26 // simplify hardware requirements and to support a wider variety of input 25 // simplify hardware requirements and to support a wider variety of input
27 // formats. 26 // formats.
28 // The buffer is modified in-place to avoid memory management, as this 27 // The buffer is modified in-place to avoid memory management, as this
29 // function may be called in performance critical code. 28 // function may be called in performance critical code.
30 MEDIA_EXPORT bool AdjustVolume(void* buf, 29 bool AdjustVolume(void* buf,
31 size_t buflen, 30 size_t buflen,
32 int channels, 31 int channels,
33 int bytes_per_sample, 32 int bytes_per_sample,
34 float volume); 33 float volume);
35 34
36 // FoldChannels() does a software multichannel folding down to stereo. 35 // FoldChannels() does a software multichannel folding down to stereo.
37 // Channel order is assumed to be 5.1 Dolby standard which is 36 // Channel order is assumed to be 5.1 Dolby standard which is
38 // front left, front right, center, surround left, surround right. 37 // front left, front right, center, surround left, surround right.
39 // The subwoofer is ignored. 38 // The subwoofer is ignored.
40 // 6.1 adds a rear center speaker, and 7.1 has 2 rear speakers. These 39 // 6.1 adds a rear center speaker, and 7.1 has 2 rear speakers. These
41 // channels are rare and ignored. 40 // channels are rare and ignored.
42 // After summing the channels, volume is adjusted and the samples are 41 // After summing the channels, volume is adjusted and the samples are
43 // clipped to the maximum value. 42 // clipped to the maximum value.
44 // Volume should normally range from 0.0 (mute) to 1.0 (full volume), but 43 // Volume should normally range from 0.0 (mute) to 1.0 (full volume), but
45 // since clamping is performed a value of more than 1 is allowed to increase 44 // since clamping is performed a value of more than 1 is allowed to increase
46 // volume. 45 // volume.
47 // The buffer is modified in-place to avoid memory management, as this 46 // The buffer is modified in-place to avoid memory management, as this
48 // function may be called in performance critical code. 47 // function may be called in performance critical code.
49 MEDIA_EXPORT bool FoldChannels(void* buf, 48 bool FoldChannels(void* buf,
50 size_t buflen, 49 size_t buflen,
51 int channels, 50 int channels,
52 int bytes_per_sample, 51 int bytes_per_sample,
53 float volume); 52 float volume);
54 53
55 // DeinterleaveAudioChannel() takes interleaved audio buffer |source| 54 // DeinterleaveAudioChannel() takes interleaved audio buffer |source|
56 // of the given |sample_fmt| and |number_of_channels| and extracts 55 // of the given |sample_fmt| and |number_of_channels| and extracts
57 // |number_of_frames| data for the given |channel_index| and 56 // |number_of_frames| data for the given |channel_index| and
58 // puts it in the floating point |destination|. 57 // puts it in the floating point |destination|.
59 // It returns |true| on success, or |false| if the |sample_fmt| is 58 // It returns |true| on success, or |false| if the |sample_fmt| is
60 // not recognized. 59 // not recognized.
61 bool DeinterleaveAudioChannel(void* source, 60 bool DeinterleaveAudioChannel(void* source,
62 float* destination, 61 float* destination,
63 int channels, 62 int channels,
64 int channel_index, 63 int channel_index,
65 int bytes_per_sample, 64 int bytes_per_sample,
66 size_t number_of_frames); 65 size_t number_of_frames);
67 66
68 // InterleaveFloatToInt16 scales, clips, and interleaves the planar 67 // InterleaveFloatToInt16 scales, clips, and interleaves the planar
69 // floating-point audio contained in |source| to the int16 |destination|. 68 // floating-point audio contained in |source| to the int16 |destination|.
70 // The floating-point data is in a canonical range of -1.0 -> +1.0. 69 // The floating-point data is in a canonical range of -1.0 -> +1.0.
71 // The size of the |source| vector determines the number of channels. 70 // The size of the |source| vector determines the number of channels.
72 // The |destination| buffer is assumed to be large enough to hold the 71 // The |destination| buffer is assumed to be large enough to hold the
73 // result. Thus it must be at least size: number_of_frames * source.size() 72 // result. Thus it must be at least size: number_of_frames * source.size()
74 MEDIA_EXPORT void InterleaveFloatToInt16(const std::vector<float*>& source, 73 void InterleaveFloatToInt16(const std::vector<float*>& source,
75 int16* destination, 74 int16* destination,
76 size_t number_of_frames); 75 size_t number_of_frames);
77 76
78 // Returns the default audio hardware sample-rate. 77 // Returns the default audio hardware sample-rate.
79 MEDIA_EXPORT double GetAudioHardwareSampleRate(); 78 double GetAudioHardwareSampleRate();
80 79
81 } // namespace media 80 } // namespace media
82 81
83 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ 82 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_
OLDNEW
« no previous file with comments | « media/audio/audio_parameters.h ('k') | media/audio/fake_audio_output_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698