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

Side by Side Diff: media/base/sample_format.cc

Issue 2466463005: Support (E)AC3 passthrough
Patch Set: Improve CastMediaClient::IsSupportedPassthroughAudio() Created 4 years, 1 month 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 // 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 case kSampleFormatRaw:
16 return 1; 17 return 1;
17 case kSampleFormatS16: 18 case kSampleFormatS16:
18 case kSampleFormatPlanarS16: 19 case kSampleFormatPlanarS16:
19 return 2; 20 return 2;
20 case kSampleFormatS24: 21 case kSampleFormatS24:
21 case kSampleFormatS32: 22 case kSampleFormatS32:
22 case kSampleFormatF32: 23 case kSampleFormatF32:
23 case kSampleFormatPlanarF32: 24 case kSampleFormatPlanarF32:
24 case kSampleFormatPlanarS32: 25 case kSampleFormatPlanarS32:
25 return 4; 26 return 4;
(...skipping 16 matching lines...) Expand all
42 case kSampleFormatS32: 43 case kSampleFormatS32:
43 return "Signed 32-bit"; 44 return "Signed 32-bit";
44 case kSampleFormatF32: 45 case kSampleFormatF32:
45 return "Float 32-bit"; 46 return "Float 32-bit";
46 case kSampleFormatPlanarS16: 47 case kSampleFormatPlanarS16:
47 return "Signed 16-bit planar"; 48 return "Signed 16-bit planar";
48 case kSampleFormatPlanarF32: 49 case kSampleFormatPlanarF32:
49 return "Float 32-bit planar"; 50 return "Float 32-bit planar";
50 case kSampleFormatPlanarS32: 51 case kSampleFormatPlanarS32:
51 return "Signed 32-bit planar"; 52 return "Signed 32-bit planar";
53 case kSampleFormatRaw:
54 return "Raw compressed bitstream";
52 } 55 }
53 NOTREACHED() << "Invalid sample format provided: " << sample_format; 56 NOTREACHED() << "Invalid sample format provided: " << sample_format;
54 return ""; 57 return "";
55 } 58 }
56 59
57 bool IsPlanar(SampleFormat sample_format) { 60 bool IsPlanar(SampleFormat sample_format) {
58 switch (sample_format) { 61 switch (sample_format) {
59 case kSampleFormatPlanarS16: 62 case kSampleFormatPlanarS16:
60 case kSampleFormatPlanarF32: 63 case kSampleFormatPlanarF32:
61 case kSampleFormatPlanarS32: 64 case kSampleFormatPlanarS32:
62 return true; 65 return true;
63 case kUnknownSampleFormat: 66 case kUnknownSampleFormat:
64 case kSampleFormatU8: 67 case kSampleFormatU8:
65 case kSampleFormatS16: 68 case kSampleFormatS16:
66 case kSampleFormatS24: 69 case kSampleFormatS24:
67 case kSampleFormatS32: 70 case kSampleFormatS32:
68 case kSampleFormatF32: 71 case kSampleFormatF32:
72 case kSampleFormatRaw:
69 return false; 73 return false;
70 } 74 }
71 75
72 NOTREACHED() << "Invalid sample format provided: " << sample_format; 76 NOTREACHED() << "Invalid sample format provided: " << sample_format;
73 return false; 77 return false;
74 } 78 }
75 79
76 bool IsInterleaved(SampleFormat sample_format) { 80 bool IsInterleaved(SampleFormat sample_format) {
77 switch (sample_format) { 81 switch (sample_format) {
78 case kSampleFormatU8: 82 case kSampleFormatU8:
79 case kSampleFormatS16: 83 case kSampleFormatS16:
80 case kSampleFormatS24: 84 case kSampleFormatS24:
81 case kSampleFormatS32: 85 case kSampleFormatS32:
82 case kSampleFormatF32: 86 case kSampleFormatF32:
87 case kSampleFormatRaw:
83 return true; 88 return true;
84 case kUnknownSampleFormat: 89 case kUnknownSampleFormat:
85 case kSampleFormatPlanarS16: 90 case kSampleFormatPlanarS16:
86 case kSampleFormatPlanarF32: 91 case kSampleFormatPlanarF32:
87 case kSampleFormatPlanarS32: 92 case kSampleFormatPlanarS32:
88 return false; 93 return false;
89 } 94 }
90 95
91 NOTREACHED() << "Invalid sample format provided: " << sample_format; 96 NOTREACHED() << "Invalid sample format provided: " << sample_format;
92 return false; 97 return false;
93 } 98 }
94 99
95 } // namespace media 100 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698