media/libyuv/source/video_common.cc

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /*
     2  *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
     3  *
     4  *  Use of this source code is governed by a BSD-style license
     5  *  that can be found in the LICENSE file in the root of the source
     6  *  tree. An additional intellectual property rights grant can be found
     7  *  in the file PATENTS. All contributing project authors may
     8  *  be found in the AUTHORS file in the root of the source tree.
     9  */
    12 #include "libyuv/video_common.h"
    14 #ifdef __cplusplus
    15 namespace libyuv {
    16 extern "C" {
    17 #endif
    19 #define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
    21 struct FourCCAliasEntry {
    22   uint32 alias;
    23   uint32 canonical;
    24 };
    26 static const struct FourCCAliasEntry kFourCCAliases[] = {
    27   {FOURCC_IYUV, FOURCC_I420},
    28   {FOURCC_YU16, FOURCC_I422},
    29   {FOURCC_YU24, FOURCC_I444},
    30   {FOURCC_YUYV, FOURCC_YUY2},
    31   {FOURCC_YUVS, FOURCC_YUY2},  // kCMPixelFormat_422YpCbCr8_yuvs
    32   {FOURCC_HDYC, FOURCC_UYVY},
    33   {FOURCC_2VUY, FOURCC_UYVY},  // kCMPixelFormat_422YpCbCr8
    34   {FOURCC_JPEG, FOURCC_MJPG},  // Note: JPEG has DHT while MJPG does not.
    35   {FOURCC_DMB1, FOURCC_MJPG},
    36   {FOURCC_BA81, FOURCC_BGGR},
    37   {FOURCC_RGB3, FOURCC_RAW },
    38   {FOURCC_BGR3, FOURCC_24BG},
    39   {FOURCC_CM32, FOURCC_BGRA},  // kCMPixelFormat_32ARGB
    40   {FOURCC_CM24, FOURCC_RAW },  // kCMPixelFormat_24RGB
    41   {FOURCC_L555, FOURCC_RGBO},  // kCMPixelFormat_16LE555
    42   {FOURCC_L565, FOURCC_RGBP},  // kCMPixelFormat_16LE565
    43   {FOURCC_5551, FOURCC_RGBO},  // kCMPixelFormat_16LE5551
    44 };
    45 // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB.
    46 //  {FOURCC_BGRA, FOURCC_ARGB},  // kCMPixelFormat_32BGRA
    48 LIBYUV_API
    49 uint32 CanonicalFourCC(uint32 fourcc) {
    50   int i;
    51   for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) {
    52     if (kFourCCAliases[i].alias == fourcc) {
    53       return kFourCCAliases[i].canonical;
    54     }
    55   }
    56   // Not an alias, so return it as-is.
    57   return fourcc;
    58 }
    60 #ifdef __cplusplus
    61 }  // extern "C"
    62 }  // namespace libyuv
    63 #endif

mercurial