/* * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ // Common definition for video, including fourcc and VideoFormat. #ifndef MEDIA_BASE_VIDEO_COMMON_H_ #define MEDIA_BASE_VIDEO_COMMON_H_ #include <stdint.h> #include <string> #include "rtc_base/system/rtc_export.h" #include "rtc_base/time_utils.h" namespace cricket { ////////////////////////////////////////////////////////////////////////////// // Definition of FourCC codes ////////////////////////////////////////////////////////////////////////////// // Convert four characters to a FourCC code. // Needs to be a macro otherwise the OS X compiler complains when the kFormat* // constants are used in a switch. #define CRICKET_FOURCC … // Some pages discussing FourCC codes: // http://www.fourcc.org/yuv.php // http://v4l2spec.bytesex.org/spec/book1.htm // http://developer.apple.com/quicktime/icefloe/dispatch020.html // http://msdn.microsoft.com/library/windows/desktop/dd206750.aspx#nv12 // http://people.xiph.org/~xiphmont/containers/nut/nut4cc.txt // FourCC codes grouped according to implementation efficiency. // Primary formats should convert in 1 efficient step. // Secondary formats are converted in 2 steps. // Auxilliary formats call primary converters. enum FourCC { … }; #undef CRICKET_FOURCC // Match any fourcc. // We move this out of the enum because using it in many places caused // the compiler to get grumpy, presumably since the above enum is // backed by an int. static const uint32_t FOURCC_ANY = …; // Converts fourcc aliases into canonical ones. uint32_t CanonicalFourCC(uint32_t fourcc); // Get FourCC code as a string. inline std::string GetFourccName(uint32_t fourcc) { … } ////////////////////////////////////////////////////////////////////////////// // Definition of VideoFormat. ////////////////////////////////////////////////////////////////////////////// // VideoFormat with Plain Old Data for global variables. struct VideoFormatPod { … }; struct RTC_EXPORT VideoFormat : VideoFormatPod { … }; // Returns the largest positive integer that divides both `a` and `b`. int GreatestCommonDivisor(int a, int b); // Returns the smallest positive integer that is divisible by both `a` and `b`. int LeastCommonMultiple(int a, int b); } // namespace cricket #endif // MEDIA_BASE_VIDEO_COMMON_H_