OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include <limits.h> // For INT_MAX | 30 #include <limits.h> // For INT_MAX |
31 #include <math.h> | 31 #include <math.h> |
32 #include <sstream> | 32 #include <sstream> |
33 | 33 |
34 #include "webrtc/base/common.h" | 34 #include "webrtc/base/common.h" |
35 | 35 |
36 namespace cricket { | 36 namespace cricket { |
37 | 37 |
38 struct FourCCAliasEntry { | 38 struct FourCCAliasEntry { |
39 uint32 alias; | 39 uint32_t alias; |
40 uint32 canonical; | 40 uint32_t canonical; |
41 }; | 41 }; |
42 | 42 |
43 static const FourCCAliasEntry kFourCCAliases[] = { | 43 static const FourCCAliasEntry kFourCCAliases[] = { |
44 {FOURCC_IYUV, FOURCC_I420}, | 44 {FOURCC_IYUV, FOURCC_I420}, |
45 {FOURCC_YU16, FOURCC_I422}, | 45 {FOURCC_YU16, FOURCC_I422}, |
46 {FOURCC_YU24, FOURCC_I444}, | 46 {FOURCC_YU24, FOURCC_I444}, |
47 {FOURCC_YUYV, FOURCC_YUY2}, | 47 {FOURCC_YUYV, FOURCC_YUY2}, |
48 {FOURCC_YUVS, FOURCC_YUY2}, | 48 {FOURCC_YUVS, FOURCC_YUY2}, |
49 {FOURCC_HDYC, FOURCC_UYVY}, | 49 {FOURCC_HDYC, FOURCC_UYVY}, |
50 {FOURCC_2VUY, FOURCC_UYVY}, | 50 {FOURCC_2VUY, FOURCC_UYVY}, |
51 {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. | 51 {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. |
52 {FOURCC_DMB1, FOURCC_MJPG}, | 52 {FOURCC_DMB1, FOURCC_MJPG}, |
53 {FOURCC_BA81, FOURCC_BGGR}, | 53 {FOURCC_BA81, FOURCC_BGGR}, |
54 {FOURCC_RGB3, FOURCC_RAW}, | 54 {FOURCC_RGB3, FOURCC_RAW}, |
55 {FOURCC_BGR3, FOURCC_24BG}, | 55 {FOURCC_BGR3, FOURCC_24BG}, |
56 {FOURCC_CM32, FOURCC_BGRA}, | 56 {FOURCC_CM32, FOURCC_BGRA}, |
57 {FOURCC_CM24, FOURCC_RAW}, | 57 {FOURCC_CM24, FOURCC_RAW}, |
58 }; | 58 }; |
59 | 59 |
60 uint32 CanonicalFourCC(uint32 fourcc) { | 60 uint32_t CanonicalFourCC(uint32_t fourcc) { |
61 for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { | 61 for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { |
62 if (kFourCCAliases[i].alias == fourcc) { | 62 if (kFourCCAliases[i].alias == fourcc) { |
63 return kFourCCAliases[i].canonical; | 63 return kFourCCAliases[i].canonical; |
64 } | 64 } |
65 } | 65 } |
66 // Not an alias, so return it as-is. | 66 // Not an alias, so return it as-is. |
67 return fourcc; | 67 return fourcc; |
68 } | 68 } |
69 | 69 |
70 static float kScaleFactors[] = { | 70 static float kScaleFactors[] = { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 *scaled_width = in_width; // Keep width the same. | 216 *scaled_width = in_width; // Keep width the same. |
217 *scaled_height = in_height * pixel_height / pixel_width; | 217 *scaled_height = in_height * pixel_height / pixel_width; |
218 } | 218 } |
219 | 219 |
220 // The C++ standard requires a namespace-scope definition of static const | 220 // The C++ standard requires a namespace-scope definition of static const |
221 // integral types even when they are initialized in the declaration (see | 221 // integral types even when they are initialized in the declaration (see |
222 // [class.static.data]/4), but MSVC with /Ze is non-conforming and treats that | 222 // [class.static.data]/4), but MSVC with /Ze is non-conforming and treats that |
223 // as a multiply defined symbol error. See Also: | 223 // as a multiply defined symbol error. See Also: |
224 // http://msdn.microsoft.com/en-us/library/34h23df8.aspx | 224 // http://msdn.microsoft.com/en-us/library/34h23df8.aspx |
225 #ifndef _MSC_EXTENSIONS | 225 #ifndef _MSC_EXTENSIONS |
226 const int64 VideoFormat::kMinimumInterval; // Initialized in header. | 226 const int64_t VideoFormat::kMinimumInterval; // Initialized in header. |
227 #endif | 227 #endif |
228 | 228 |
229 std::string VideoFormat::ToString() const { | 229 std::string VideoFormat::ToString() const { |
230 std::string fourcc_name = GetFourccName(fourcc) + " "; | 230 std::string fourcc_name = GetFourccName(fourcc) + " "; |
231 for (std::string::const_iterator i = fourcc_name.begin(); | 231 for (std::string::const_iterator i = fourcc_name.begin(); |
232 i < fourcc_name.end(); ++i) { | 232 i < fourcc_name.end(); ++i) { |
233 // Test character is printable; Avoid isprint() which asserts on negatives. | 233 // Test character is printable; Avoid isprint() which asserts on negatives. |
234 if (*i < 32 || *i >= 127) { | 234 if (*i < 32 || *i >= 127) { |
235 fourcc_name = ""; | 235 fourcc_name = ""; |
236 break; | 236 break; |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 std::ostringstream ss; | 240 std::ostringstream ss; |
241 ss << fourcc_name << width << "x" << height << "x" | 241 ss << fourcc_name << width << "x" << height << "x" |
242 << IntervalToFpsFloat(interval); | 242 << IntervalToFpsFloat(interval); |
243 return ss.str(); | 243 return ss.str(); |
244 } | 244 } |
245 | 245 |
246 } // namespace cricket | 246 } // namespace cricket |
OLD | NEW |