diff options
author | jrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-12 21:42:10 +0000 |
---|---|---|
committer | jrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-12 21:42:10 +0000 |
commit | d1d4595ae1cee37c14b800b3cde15a2798129a39 (patch) | |
tree | ef639b5099bf86c60eccbe1fff0eb257b506fdd3 /media/base/sample_format.cc | |
parent | cadd30fea95dbec58c69078b959789be93917c37 (diff) | |
download | chromium_src-d1d4595ae1cee37c14b800b3cde15a2798129a39.zip chromium_src-d1d4595ae1cee37c14b800b3cde15a2798129a39.tar.gz chromium_src-d1d4595ae1cee37c14b800b3cde15a2798129a39.tar.bz2 |
Expose SampleFormat -> bytes per frame calculations.
First part of converting audio streams to reduce copying the data.
BUG=248989
Review URL: https://chromiumcodereview.appspot.com/16404013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/sample_format.cc')
-rw-r--r-- | media/base/sample_format.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/media/base/sample_format.cc b/media/base/sample_format.cc new file mode 100644 index 0000000..3fdcf101 --- /dev/null +++ b/media/base/sample_format.cc @@ -0,0 +1,32 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/sample_format.h" + +#include "base/logging.h" + +namespace media { + +int SampleFormatToBytesPerChannel(SampleFormat sample_format) { + switch (sample_format) { + case kUnknownSampleFormat: + return 0; + case kSampleFormatU8: + return 1; + case kSampleFormatS16: + case kSampleFormatPlanarS16: + return 2; + case kSampleFormatS32: + case kSampleFormatF32: + case kSampleFormatPlanarF32: + return 4; + case kSampleFormatMax: + break; + } + + NOTREACHED() << "Invalid sample format provided: " << sample_format; + return 0; +} + +} // namespace media |