Ocean
PixelFormats.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_MEDIA_ANDROID_PIXEL_FORMATS_H
9 #define META_OCEAN_MEDIA_ANDROID_PIXEL_FORMATS_H
10 
12 
13 #include "ocean/base/Frame.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Media
19 {
20 
21 namespace Android
22 {
23 
24 /**
25  * This class defines conversions to/from Android color format types for video data; see the associated definitions in android.media.MediaCodecInfo.CodecCapabilities.
26  * @ingroup mediaandroid
27  */
29 {
30  public:
31 
32  /**
33  * Set of Ocean-supported Android pixel formats for Android MediaCodec objects.
34  * The naming conventions match those defined in the Java class android.media.MediaCodecInfo.CodecCapabilities:
35  * https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities
36  */
37  enum class AndroidMediaCodecColorFormat : int32_t
38  {
39  /// Unknown color format.
40  UNKNOWN = 0,
41  /// Android identifier for YUV420 color formats, deprecated use COLOR_FormatYUV420Flexible if possible.
43  // Android identifier for YUV420 color formats, identical to FORMAT_Y_UV12_LIMITED_RANGE, deprecated use COLOR_FormatYUV420Flexible if possible.
45  /// Android identifier for YUV420 color formats, identical to FORMAT_Y_U_V12_LIMITED_RANGE
46  COLOR_FormatYUV420Flexible = 0x7f420888
47  };
48 
49  /**
50  * Definition of individual constants for Android MediaFormat color ranges.
51  * https://developer.android.com/reference/android/media/MediaFormat#COLOR_RANGE_FULL
52  */
54  {
55  /// Unknown color range.
56  UNKNOWN = 0,
57  /// Full range. Y, Cr and Cb component values range from 0 to 255 for 8-bit content.
59  /// Limited range. Y component values range from 16 to 235 for 8-bit content. Cr, Cy values range from 16 to 240 for 8-bit content. This is the default for video content.
61  };
62 
63  public:
64 
65  /**
66  * Translates an Android pixel format to an Ocean pixel format for video data.
67  * @param androidFormat The Android pixel format to translate
68  * @param androidColorRange The Android Media Format color range associated with the Android pixel format
69  * @return The corresponding Ocean pixel format, FORMAT_UNDEFINED if no corresponding Ocean pixel format exists
70  */
72 
73  /**
74  * Translates an Ocean pixel format to an Android pixel format for video data.
75  * @param pixelFormat The Ocean pixel format to translate
76  * @param androidColorRange The resulting Android Media Format color range associated with the Android pixel format
77  * @return The corresponding Android pixel format, UNKNOWN if no corresponding Android pixel format exists
78  */
80 };
81 
82 }
83 
84 }
85 
86 }
87 
88 #endif // META_OCEAN_MEDIA_ANDROID_PIXEL_FORMATS_H
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
This class defines conversions to/from Android color format types for video data; see the associated ...
Definition: PixelFormats.h:29
AndroidMediaFormatColorRange
Definition of individual constants for Android MediaFormat color ranges.
Definition: PixelFormats.h:54
@ UNKNOWN
Unknown color range.
Definition: PixelFormats.h:56
@ UNKNOWN
Unknown color format.
@ COLOR_RANGE_LIMITED
Limited range. Y component values range from 16 to 235 for 8-bit content. Cr, Cy values range from 16...
Definition: PixelFormats.h:60
@ COLOR_RANGE_FULL
Full range. Y, Cr and Cb component values range from 0 to 255 for 8-bit content.
Definition: PixelFormats.h:58
static AndroidMediaCodecColorFormat pixelFormatToAndroidMediaCodecColorFormat(const FrameType::PixelFormat pixelFormat, AndroidMediaFormatColorRange &androidColorRange)
Translates an Ocean pixel format to an Android pixel format for video data.
AndroidMediaCodecColorFormat
Set of Ocean-supported Android pixel formats for Android MediaCodec objects.
Definition: PixelFormats.h:38
@ COLOR_FormatYUV420Flexible
Android identifier for YUV420 color formats, identical to FORMAT_Y_U_V12_LIMITED_RANGE.
@ COLOR_FormatYUV420Planar
Android identifier for YUV420 color formats, deprecated use COLOR_FormatYUV420Flexible if possible.
static FrameType::PixelFormat androidMediaCodecColorFormatToPixelFormat(const AndroidMediaCodecColorFormat androidFormat, const AndroidMediaFormatColorRange androidColorRange)
Translates an Android pixel format to an Ocean pixel format for video data.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15