Video Player: Enable chromecast support by default
[chromium-blink-merge.git] / media / base / sample_format.cc
blobcf8f20f5632f2c8d19531c35433f3968c46f5261
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/base/sample_format.h"
7 #include "base/logging.h"
9 namespace media {
11 int SampleFormatToBytesPerChannel(SampleFormat sample_format) {
12 switch (sample_format) {
13 case kUnknownSampleFormat:
14 return 0;
15 case kSampleFormatU8:
16 return 1;
17 case kSampleFormatS16:
18 case kSampleFormatPlanarS16:
19 return 2;
20 case kSampleFormatS32:
21 case kSampleFormatF32:
22 case kSampleFormatPlanarF32:
23 return 4;
26 NOTREACHED() << "Invalid sample format provided: " << sample_format;
27 return 0;
30 const char* SampleFormatToString(SampleFormat sample_format) {
31 switch(sample_format) {
32 case kUnknownSampleFormat:
33 return "Unknown sample format";
34 case kSampleFormatU8:
35 return "Unsigned 8-bit with bias of 128";
36 case kSampleFormatS16:
37 return "Signed 16-bit";
38 case kSampleFormatS32:
39 return "Signed 32-bit";
40 case kSampleFormatF32:
41 return "Float 32-bit";
42 case kSampleFormatPlanarS16:
43 return "Signed 16-bit planar";
44 case kSampleFormatPlanarF32:
45 return "Float 32-bit planar";
47 NOTREACHED() << "Invalid sample format provided: " << sample_format;
48 return "";
51 } // namespace media