| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "media/base/sample_format.h" | 5 #include "media/base/sample_format.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 int SampleFormatToBytesPerChannel(SampleFormat sample_format) { | 11 int SampleFormatToBytesPerChannel(SampleFormat sample_format) { |
| 12 switch (sample_format) { | 12 switch (sample_format) { |
| 13 case kUnknownSampleFormat: | 13 case kUnknownSampleFormat: |
| 14 return 0; | 14 return 0; |
| 15 case kSampleFormatU8: | 15 case kSampleFormatU8: |
| 16 return 1; | 16 return 1; |
| 17 case kSampleFormatS16: | 17 case kSampleFormatS16: |
| 18 case kSampleFormatPlanarS16: | 18 case kSampleFormatPlanarS16: |
| 19 return 2; | 19 return 2; |
| 20 case kSampleFormatS24: |
| 20 case kSampleFormatS32: | 21 case kSampleFormatS32: |
| 21 case kSampleFormatF32: | 22 case kSampleFormatF32: |
| 22 case kSampleFormatPlanarF32: | 23 case kSampleFormatPlanarF32: |
| 23 case kSampleFormatPlanarS32: | 24 case kSampleFormatPlanarS32: |
| 24 return 4; | 25 return 4; |
| 25 } | 26 } |
| 26 | 27 |
| 27 NOTREACHED() << "Invalid sample format provided: " << sample_format; | 28 NOTREACHED() << "Invalid sample format provided: " << sample_format; |
| 28 return 0; | 29 return 0; |
| 29 } | 30 } |
| 30 | 31 |
| 31 const char* SampleFormatToString(SampleFormat sample_format) { | 32 const char* SampleFormatToString(SampleFormat sample_format) { |
| 32 switch(sample_format) { | 33 switch(sample_format) { |
| 33 case kUnknownSampleFormat: | 34 case kUnknownSampleFormat: |
| 34 return "Unknown sample format"; | 35 return "Unknown sample format"; |
| 35 case kSampleFormatU8: | 36 case kSampleFormatU8: |
| 36 return "Unsigned 8-bit with bias of 128"; | 37 return "Unsigned 8-bit with bias of 128"; |
| 37 case kSampleFormatS16: | 38 case kSampleFormatS16: |
| 38 return "Signed 16-bit"; | 39 return "Signed 16-bit"; |
| 40 case kSampleFormatS24: |
| 41 return "Signed 24-bit"; |
| 39 case kSampleFormatS32: | 42 case kSampleFormatS32: |
| 40 return "Signed 32-bit"; | 43 return "Signed 32-bit"; |
| 41 case kSampleFormatF32: | 44 case kSampleFormatF32: |
| 42 return "Float 32-bit"; | 45 return "Float 32-bit"; |
| 43 case kSampleFormatPlanarS16: | 46 case kSampleFormatPlanarS16: |
| 44 return "Signed 16-bit planar"; | 47 return "Signed 16-bit planar"; |
| 45 case kSampleFormatPlanarF32: | 48 case kSampleFormatPlanarF32: |
| 46 return "Float 32-bit planar"; | 49 return "Float 32-bit planar"; |
| 47 case kSampleFormatPlanarS32: | 50 case kSampleFormatPlanarS32: |
| 48 return "Signed 32-bit planar"; | 51 return "Signed 32-bit planar"; |
| 49 } | 52 } |
| 50 NOTREACHED() << "Invalid sample format provided: " << sample_format; | 53 NOTREACHED() << "Invalid sample format provided: " << sample_format; |
| 51 return ""; | 54 return ""; |
| 52 } | 55 } |
| 53 | 56 |
| 54 } // namespace media | 57 } // namespace media |
| OLD | NEW |