blob: e6141a69b3600b6808cdc6a5e8939677ab0d4a0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// 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:
case kSampleFormatAc3:
case kSampleFormatEac3:
return 1;
case kSampleFormatS16:
case kSampleFormatPlanarS16:
return 2;
case kSampleFormatS24:
case kSampleFormatS32:
case kSampleFormatF32:
case kSampleFormatPlanarF32:
case kSampleFormatPlanarS32:
return 4;
}
NOTREACHED() << "Invalid sample format provided: " << sample_format;
return 0;
}
const char* SampleFormatToString(SampleFormat sample_format) {
switch(sample_format) {
case kUnknownSampleFormat:
return "Unknown sample format";
case kSampleFormatU8:
return "Unsigned 8-bit with bias of 128";
case kSampleFormatS16:
return "Signed 16-bit";
case kSampleFormatS24:
return "Signed 24-bit";
case kSampleFormatS32:
return "Signed 32-bit";
case kSampleFormatF32:
return "Float 32-bit";
case kSampleFormatPlanarS16:
return "Signed 16-bit planar";
case kSampleFormatPlanarF32:
return "Float 32-bit planar";
case kSampleFormatPlanarS32:
return "Signed 32-bit planar";
case kSampleFormatAc3:
return "Compressed AC3 bitstream";
case kSampleFormatEac3:
return "Compressed E-AC3 bitstream";
}
NOTREACHED() << "Invalid sample format provided: " << sample_format;
return "";
}
bool IsPlanar(SampleFormat sample_format) {
switch (sample_format) {
case kSampleFormatPlanarS16:
case kSampleFormatPlanarF32:
case kSampleFormatPlanarS32:
return true;
case kUnknownSampleFormat:
case kSampleFormatU8:
case kSampleFormatS16:
case kSampleFormatS24:
case kSampleFormatS32:
case kSampleFormatF32:
case kSampleFormatAc3:
case kSampleFormatEac3:
return false;
}
NOTREACHED() << "Invalid sample format provided: " << sample_format;
return false;
}
bool IsInterleaved(SampleFormat sample_format) {
switch (sample_format) {
case kSampleFormatU8:
case kSampleFormatS16:
case kSampleFormatS24:
case kSampleFormatS32:
case kSampleFormatF32:
case kSampleFormatAc3:
case kSampleFormatEac3:
return true;
case kUnknownSampleFormat:
case kSampleFormatPlanarS16:
case kSampleFormatPlanarF32:
case kSampleFormatPlanarS32:
return false;
}
NOTREACHED() << "Invalid sample format provided: " << sample_format;
return false;
}
bool IsBitstream(SampleFormat sample_format) {
switch (sample_format) {
case kSampleFormatAc3:
case kSampleFormatEac3:
return true;
case kUnknownSampleFormat:
case kSampleFormatU8:
case kSampleFormatS16:
case kSampleFormatS24:
case kSampleFormatS32:
case kSampleFormatF32:
case kSampleFormatPlanarS16:
case kSampleFormatPlanarF32:
case kSampleFormatPlanarS32:
return false;
}
NOTREACHED() << "Invalid sample format provided: " << sample_format;
return false;
}
} // namespace media
|