17c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar/*
27c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Copyright (C) 2016 The Android Open Source Project
37c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar *
47c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Licensed under the Apache License, Version 2.0 (the "License");
57c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * you may not use this file except in compliance with the License.
67c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * You may obtain a copy of the License at
77c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar *
87c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar *      http://www.apache.org/licenses/LICENSE-2.0
97c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar *
107c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Unless required by applicable law or agreed to in writing, software
117c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * distributed under the License is distributed on an "AS IS" BASIS,
127c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * See the License for the specific language governing permissions and
147c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * limitations under the License.
157c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar */
167c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
177c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar#ifndef VIDEO_API_H_
187c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
197c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar#define VIDEO_API_H_
207c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
217c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarnamespace android {
227c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
237c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar/**
247c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Structure describing a media image (frame)
257c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Currently only supporting YUV
267c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * @deprecated. Use MediaImage2 instead
277c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar */
287c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarstruct MediaImage {
297c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum Type {
307c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_UNKNOWN = 0,
317c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_YUV,
327c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
337c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
347c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum PlaneIndex {
357c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        Y = 0,
367c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        U,
377c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        V,
387c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MAX_NUM_PLANES
397c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
407c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
417c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    Type mType;
427c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mNumPlanes;              // number of planes
437c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mWidth;                  // width of largest plane (unpadded, as in nFrameWidth)
447c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mHeight;                 // height of largest plane (unpadded, as in nFrameHeight)
457c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mBitDepth;               // useable bit depth
467c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    struct PlaneInfo {
477c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mOffset;             // offset of first pixel of the plane in bytes
487c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar                                      // from buffer offset
497c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mColInc;             // column increment in bytes
507c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mRowInc;             // row increment in bytes
517c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mHorizSubsampling;   // subsampling compared to the largest plane
527c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mVertSubsampling;    // subsampling compared to the largest plane
537c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
547c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    PlaneInfo mPlane[MAX_NUM_PLANES];
557c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar};
567c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
577c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar/**
587c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Structure describing a media image (frame)
597c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar */
60b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstruct __attribute__ ((__packed__)) MediaImage2 {
617c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum Type : uint32_t {
627c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_UNKNOWN = 0,
637c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_YUV,
647c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_YUVA,
657c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_RGB,
667c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_RGBA,
677c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MEDIA_IMAGE_TYPE_Y,
687c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
697c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
707c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum PlaneIndex : uint32_t {
717c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        Y = 0,
727c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        U = 1,
737c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        V = 2,
747c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        R = 0,
757c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        G = 1,
767c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        B = 2,
777c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        A = 3,
787c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MAX_NUM_PLANES = 4,
797c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
807c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
817c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    Type mType;
827c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mNumPlanes;              // number of planes
837c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mWidth;                  // width of largest plane (unpadded, as in nFrameWidth)
847c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mHeight;                 // height of largest plane (unpadded, as in nFrameHeight)
857c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mBitDepth;               // useable bit depth (always MSB)
867c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    uint32_t mBitDepthAllocated;      // bits per component (must be 8 or 16)
877c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
88b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    struct __attribute__ ((__packed__)) PlaneInfo {
897c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mOffset;             // offset of first pixel of the plane in bytes
907c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar                                      // from buffer offset
917c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        int32_t mColInc;              // column increment in bytes
927c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        int32_t mRowInc;              // row increment in bytes
937c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mHorizSubsampling;   // subsampling compared to the largest plane
947c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        uint32_t mVertSubsampling;    // subsampling compared to the largest plane
957c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
967c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    PlaneInfo mPlane[MAX_NUM_PLANES];
977c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
987c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    void initFromV1(const MediaImage&); // for internal use only
997c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar};
1007c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
101b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstatic_assert(sizeof(MediaImage2::PlaneInfo) == 20, "wrong struct size");
102b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstatic_assert(sizeof(MediaImage2) == 104, "wrong struct size");
103b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
1047c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar/**
1057c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar * Aspects of color.
1067c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar */
1077c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1087c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar// NOTE: this structure is expected to grow in the future if new color aspects are
1097c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar// added to codec bitstreams. OMX component should not require a specific nSize
1107c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar// though could verify that nSize is at least the size of the structure at the
1117c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar// time of implementation. All new fields will be added at the end of the structure
1127c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar// ensuring backward compatibility.
1132c9c0125ca6f88d41f0daa4307450fd5f40d495eStephen Hinesstruct __attribute__ ((__packed__, aligned(alignof(uint32_t)))) ColorAspects {
1147c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    // this is in sync with the range values in graphics.h
1157c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum Range : uint32_t {
1167c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        RangeUnspecified,
1177c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        RangeFull,
1187c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        RangeLimited,
1197c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        RangeOther = 0xff,
1207c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
1217c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1227c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum Primaries : uint32_t {
1237c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesUnspecified,
1247c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesBT709_5,       // Rec.ITU-R BT.709-5 or equivalent
1257c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesBT470_6M,      // Rec.ITU-R BT.470-6 System M or equivalent
1267c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesBT601_6_625,   // Rec.ITU-R BT.601-6 625 or equivalent
1277c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesBT601_6_525,   // Rec.ITU-R BT.601-6 525 or equivalent
1287c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesGenericFilm,   // Generic Film
1297c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesBT2020,        // Rec.ITU-R BT.2020 or equivalent
1307c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        PrimariesOther = 0xff,
1317c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
1327c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1337c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    // this partially in sync with the transfer values in graphics.h prior to the transfers
1347c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    // unlikely to be required by Android section
1357c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum Transfer : uint32_t {
1367c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferUnspecified,
1377c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferLinear,         // Linear transfer characteristics
1387c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferSRGB,           // sRGB or equivalent
1397c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferSMPTE170M,      // SMPTE 170M or equivalent (e.g. BT.601/709/2020)
1407c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferGamma22,        // Assumed display gamma 2.2
1417c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferGamma28,        // Assumed display gamma 2.8
1427c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferST2084,         // SMPTE ST 2084 for 10/12/14/16 bit systems
1437c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferHLG,            // ARIB STD-B67 hybrid-log-gamma
1447c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1457c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        // transfers unlikely to be required by Android
1467c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferSMPTE240M = 0x40, // SMPTE 240M
1477c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferXvYCC,          // IEC 61966-2-4
1487c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferBT1361,         // Rec.ITU-R BT.1361 extended gamut
1497c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferST428,          // SMPTE ST 428-1
1507c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        TransferOther = 0xff,
1517c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
1527c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1537c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum MatrixCoeffs : uint32_t {
1547c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixUnspecified,
1557c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixBT709_5,          // Rec.ITU-R BT.709-5 or equivalent
1567c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixBT470_6M,         // KR=0.30, KB=0.11 or equivalent
1577c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixBT601_6,          // Rec.ITU-R BT.601-6 625 or equivalent
1587c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixSMPTE240M,        // SMPTE 240M or equivalent
1597c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixBT2020,           // Rec.ITU-R BT.2020 non-constant luminance
1607c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixBT2020Constant,   // Rec.ITU-R BT.2020 constant luminance
1617c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MatrixOther = 0xff,
1627c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
1637c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1647c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    // this is in sync with the standard values in graphics.h
1657c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    enum Standard : uint32_t {
1667c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardUnspecified,
1677c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT709,                  // PrimariesBT709_5 and MatrixBT709_5
1687c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT601_625,              // PrimariesBT601_6_625 and MatrixBT601_6
1697c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT601_625_Unadjusted,   // PrimariesBT601_6_625 and KR=0.222, KB=0.071
1707c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT601_525,              // PrimariesBT601_6_525 and MatrixBT601_6
1717c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT601_525_Unadjusted,   // PrimariesBT601_6_525 and MatrixSMPTE240M
1727c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT2020,                 // PrimariesBT2020 and MatrixBT2020
1737c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT2020Constant,         // PrimariesBT2020 and MatrixBT2020Constant
1747c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardBT470M,                 // PrimariesBT470_6M and MatrixBT470_6M
1757c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardFilm,                   // PrimariesGenericFilm and KR=0.253, KB=0.068
1767c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        StandardOther = 0xff,
1777c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    };
1787c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
1797c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    Range mRange;                // IN/OUT
1807c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    Primaries mPrimaries;        // IN/OUT
1817c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    Transfer mTransfer;          // IN/OUT
1827c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    MatrixCoeffs mMatrixCoeffs;  // IN/OUT
1837c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar};
1847c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
185b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstatic_assert(sizeof(ColorAspects) == 16, "wrong struct size");
186b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
187b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar/**
188b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar * HDR Metadata.
189b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar */
190b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
191b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar// HDR Static Metadata Descriptor as defined by CTA-861-3.
192b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstruct __attribute__ ((__packed__)) HDRStaticInfo {
193b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    // Static_Metadata_Descriptor_ID
194b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    enum ID : uint8_t {
195b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        kType1 = 0, // Static Metadata Type 1
196b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    } mID;
197b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
198b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    struct __attribute__ ((__packed__)) Primaries1 {
199b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        // values are in units of 0.00002
200b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        uint16_t x;
201b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        uint16_t y;
202b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    };
203b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
204b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    // Static Metadata Descriptor Type 1
205b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    struct __attribute__ ((__packed__)) Type1 {
206b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        Primaries1 mR; // display primary 0
207b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        Primaries1 mG; // display primary 1
208b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        Primaries1 mB; // display primary 2
209b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        Primaries1 mW; // white point
210b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        uint16_t mMaxDisplayLuminance; // in cd/m^2
211b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        uint16_t mMinDisplayLuminance; // in 0.0001 cd/m^2
212b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        uint16_t mMaxContentLightLevel; // in cd/m^2
213b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar        uint16_t mMaxFrameAverageLightLevel; // in cd/m^2
214b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    };
215b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
216b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    union {
217b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar         Type1 sType1;
218b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar    };
219b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar};
220b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
221b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstatic_assert(sizeof(HDRStaticInfo::Primaries1) == 4, "wrong struct size");
222b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstatic_assert(sizeof(HDRStaticInfo::Type1) == 24, "wrong struct size");
223b4e0bce8404071958366573c2029a205336b6de2Lajos Molnarstatic_assert(sizeof(HDRStaticInfo) == 25, "wrong struct size");
224b4e0bce8404071958366573c2029a205336b6de2Lajos Molnar
2257c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar#ifdef STRINGIFY_ENUMS
2267c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2277c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(MediaImage::Type i, const char *def = "??") {
2287c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
2297c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage::MEDIA_IMAGE_TYPE_UNKNOWN: return "Unknown";
2307c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage::MEDIA_IMAGE_TYPE_YUV:     return "YUV";
2317c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                                   return def;
2327c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
2337c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
2347c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2357c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(MediaImage::PlaneIndex i, const char *def = "??") {
2367c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
2377c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage::Y: return "Y";
2387c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage::U: return "U";
2397c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage::V: return "V";
2407c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:            return def;
2417c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
2427c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
2437c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2447c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(MediaImage2::Type i, const char *def = "??") {
2457c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
2467c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN: return "Unknown";
2477c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage2::MEDIA_IMAGE_TYPE_YUV:     return "YUV";
2487c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage2::MEDIA_IMAGE_TYPE_YUVA:    return "YUVA";
2497c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage2::MEDIA_IMAGE_TYPE_RGB:     return "RGB";
2507c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage2::MEDIA_IMAGE_TYPE_RGBA:    return "RGBA";
2517c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case MediaImage2::MEDIA_IMAGE_TYPE_Y:       return "Y";
2527c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                                    return def;
2537c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
2547c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
2557c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2567c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static char asChar2(
2577c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        MediaImage2::PlaneIndex i, MediaImage2::Type j, char def = '?') {
2587c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    const char *planes = asString(j, NULL);
2597c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    // handle unknown values
2607c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    if (j == MediaImage2::MEDIA_IMAGE_TYPE_UNKNOWN || planes == NULL || i >= strlen(planes)) {
2617c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        return def;
2627c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
2637c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    return planes[i];
2647c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
2657c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2667c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(ColorAspects::Range i, const char *def = "??") {
2677c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
2687c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::RangeUnspecified: return "Unspecified";
2697c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::RangeFull:        return "Full";
2707c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::RangeLimited:     return "Limited";
2717c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::RangeOther:       return "Other";
2727c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                             return def;
2737c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
2747c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
2757c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2767c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(ColorAspects::Primaries i, const char *def = "??") {
2777c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
2787c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesUnspecified: return "Unspecified";
2797c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesBT709_5:     return "BT709_5";
2807c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesBT470_6M:    return "BT470_6M";
2817c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesBT601_6_625: return "BT601_6_625";
2827c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesBT601_6_525: return "BT601_6_525";
2837c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesGenericFilm: return "GenericFilm";
2847c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesBT2020:      return "BT2020";
2857c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::PrimariesOther:       return "Other";
2867c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                                 return def;
2877c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
2887c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
2897c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
2907c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(ColorAspects::Transfer i, const char *def = "??") {
2917c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
2927c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferUnspecified: return "Unspecified";
2937c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferLinear:      return "Linear";
2947c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferSRGB:        return "SRGB";
2957c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferSMPTE170M:   return "SMPTE170M";
2967c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferGamma22:     return "Gamma22";
2977c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferGamma28:     return "Gamma28";
2987c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferST2084:      return "ST2084";
2997c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferHLG:         return "HLG";
3007c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferSMPTE240M:   return "SMPTE240M";
3017c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferXvYCC:       return "XvYCC";
3027c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferBT1361:      return "BT1361";
3037c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferST428:       return "ST428";
3047c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::TransferOther:       return "Other";
3057c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                                return def;
3067c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
3077c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
3087c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
3097c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(ColorAspects::MatrixCoeffs i, const char *def = "??") {
3107c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
3117c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixUnspecified:    return "Unspecified";
3127c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixBT709_5:        return "BT709_5";
3137c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixBT470_6M:       return "BT470_6M";
3147c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixBT601_6:        return "BT601_6";
3157c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixSMPTE240M:      return "SMPTE240M";
3167c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixBT2020:         return "BT2020";
3177c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixBT2020Constant: return "BT2020Constant";
3187c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::MatrixOther:          return "Other";
3197c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                                 return def;
3207c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
3217c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
3227c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
3237c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnarinline static const char *asString(ColorAspects::Standard i, const char *def = "??") {
3247c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    switch (i) {
3257c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardUnspecified:          return "Unspecified";
3267c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT709:                return "BT709";
3277c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT601_625:            return "BT601_625";
3287c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT601_625_Unadjusted: return "BT601_625_Unadjusted";
3297c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT601_525:            return "BT601_525";
3307c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT601_525_Unadjusted: return "BT601_525_Unadjusted";
3317c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT2020:               return "BT2020";
3327c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT2020Constant:       return "BT2020Constant";
3337c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardBT470M:               return "BT470M";
3347c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardFilm:                 return "Film";
3357c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        case ColorAspects::StandardOther:                return "Other";
3367c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar        default:                                         return def;
3377c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar    }
3387c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}
3397c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
3407c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar#endif
3417c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
3427c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar}  // namespace android
3437c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar
3447c357a75991d6b0ae260d9e2b730bcfe7181f899Lajos Molnar#endif  // VIDEO_API_H_
345