content/media/fmp4/demuxer/video_decoder_config.h

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
     2 // Use of this source code is governed by a BSD-style license that can be
     3 // found in the LICENSE file.
     5 #ifndef MEDIA_BASE_VIDEO_DECODER_CONFIG_H_
     6 #define MEDIA_BASE_VIDEO_DECODER_CONFIG_H_
     8 #include <string>
     9 #include <vector>
    11 #include "mp4_demuxer/basictypes.h"
    13 namespace mp4_demuxer {
    15 enum VideoCodec {
    16   // These values are histogrammed over time; do not change their ordinal
    17   // values.  When deleting a codec replace it with a dummy value; when adding a
    18   // codec, do so at the bottom (and update kVideoCodecMax).
    19   kUnknownVideoCodec = 0,
    20   kCodecH264,
    21   kCodecVC1,
    22   kCodecMPEG2,
    23   kCodecMPEG4,
    24   kCodecTheora,
    25   kCodecVP8,
    26   kCodecVP9,
    27   // DO NOT ADD RANDOM VIDEO CODECS!
    28   //
    29   // The only acceptable time to add a new codec is if there is production code
    30   // that uses said codec in the same CL.
    32   kVideoCodecMax = kCodecVP9  // Must equal the last "real" codec above.
    33 };
    35 // Video stream profile.  This *must* match PP_VideoDecoder_Profile.
    36 // (enforced in webkit/plugins/ppapi/ppb_video_decoder_impl.cc)
    37 enum VideoCodecProfile {
    38   // Keep the values in this enum unique, as they imply format (h.264 vs. VP8,
    39   // for example), and keep the values for a particular format grouped
    40   // together for clarity.
    41   VIDEO_CODEC_PROFILE_UNKNOWN = -1,
    42   H264PROFILE_MIN = 0,
    43   H264PROFILE_BASELINE = H264PROFILE_MIN,
    44   H264PROFILE_MAIN = 1,
    45   H264PROFILE_EXTENDED = 2,
    46   H264PROFILE_HIGH = 3,
    47   H264PROFILE_HIGH10PROFILE = 4,
    48   H264PROFILE_HIGH422PROFILE = 5,
    49   H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
    50   H264PROFILE_SCALABLEBASELINE = 7,
    51   H264PROFILE_SCALABLEHIGH = 8,
    52   H264PROFILE_STEREOHIGH = 9,
    53   H264PROFILE_MULTIVIEWHIGH = 10,
    54   H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH,
    55   VP8PROFILE_MIN = 11,
    56   VP8PROFILE_MAIN = VP8PROFILE_MIN,
    57   VP8PROFILE_MAX = VP8PROFILE_MAIN,
    58   VP9PROFILE_MIN = 12,
    59   VP9PROFILE_MAIN = VP9PROFILE_MIN,
    60   VP9PROFILE_MAX = VP9PROFILE_MAIN,
    61   VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_MAX,
    62 };
    64 // Surface formats roughly based on FOURCC labels, see:
    65 // http://www.fourcc.org/rgb.php
    66 // http://www.fourcc.org/yuv.php
    67 enum VideoFrameFormat { // VideoFrame::Format
    68   INVALID = 0,  // Invalid format value.  Used for error reporting.
    69   RGB32 = 4,  // 32bpp RGB packed with extra byte 8:8:8
    70   YV12 = 6,  // 12bpp YVU planar 1x1 Y, 2x2 VU samples
    71   YV16 = 7,  // 16bpp YVU planar 1x1 Y, 2x1 VU samples
    72   EMPTY = 9,  // An empty frame.
    73   I420 = 11,  // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
    74   NATIVE_TEXTURE = 12,  // Native texture.  Pixel-format agnostic.
    75 #if defined(GOOGLE_TV)
    76   HOLE = 13,  // Hole frame.
    77 #endif
    78   YV12A = 14,  // 20bpp YUVA planar 1x1 Y, 2x2 VU, 1x1 A samples.
    79 };
    81 class VideoDecoderConfig {
    82  public:
    83   // Constructs an uninitialized object. Clients should call Initialize() with
    84   // appropriate values before using.
    85   VideoDecoderConfig();
    87   // Constructs an initialized object. It is acceptable to pass in NULL for
    88   // |extra_data|, otherwise the memory is copied.
    89   VideoDecoderConfig(VideoCodec codec,
    90                      VideoCodecProfile profile,
    91                      VideoFrameFormat format,
    92                      const IntSize& coded_size,
    93                      const IntRect& visible_rect,
    94                      const IntSize& natural_size,
    95                      const uint8_t* extra_data, size_t extra_data_size,
    96                      bool is_encrypted);
    98   ~VideoDecoderConfig();
   100   // Resets the internal state of this object.
   101   void Initialize(VideoCodec codec,
   102                   VideoCodecProfile profile,
   103                   VideoFrameFormat format,
   104                   const IntSize& coded_size,
   105                   const IntRect& visible_rect,
   106                   const IntSize& natural_size,
   107                   const uint8_t* extra_data, size_t extra_data_size,
   108                   bool is_encrypted,
   109                   bool record_stats);
   111   // Returns true if this object has appropriate configuration values, false
   112   // otherwise.
   113   bool IsValidConfig() const;
   115   // Returns true if all fields in |config| match this config.
   116   // Note: The contents of |extra_data_| are compared not the raw pointers.
   117   bool Matches(const VideoDecoderConfig& config) const;
   119   // Returns a human-readable string describing |*this|.  For debugging & test
   120   // output only.
   121   std::string AsHumanReadableString() const;
   123   VideoCodec codec() const;
   124   VideoCodecProfile profile() const;
   126   // Video format used to determine YUV buffer sizes.
   127   VideoFrameFormat format() const;
   129   // Width and height of video frame immediately post-decode. Not all pixels
   130   // in this region are valid.
   131   IntSize coded_size() const;
   133   // Region of |coded_size_| that is visible.
   134   IntRect visible_rect() const;
   136   // Final visible width and height of a video frame with aspect ratio taken
   137   // into account.
   138   IntSize natural_size() const;
   140   // Optional byte data required to initialize video decoders, such as H.264
   141   // AAVC data.
   142   const uint8_t* extra_data() const;
   143   size_t extra_data_size() const;
   145   // Whether the video stream is potentially encrypted.
   146   // Note that in a potentially encrypted video stream, individual buffers
   147   // can be encrypted or not encrypted.
   148   bool is_encrypted() const;
   150  private:
   151   VideoCodec codec_;
   152   VideoCodecProfile profile_;
   154   VideoFrameFormat format_;
   156   IntSize coded_size_;
   157   IntRect visible_rect_;
   158   IntSize natural_size_;
   160   std::vector<uint8_t> extra_data_;
   162   bool is_encrypted_;
   164   // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
   165   // generated copy constructor and assignment operator. Since the extra data is
   166   // typically small, the performance impact is minimal.
   167 };
   169 }  // namespace mp4_demuxer
   171 #endif  // MEDIA_BASE_VIDEO_DECODER_CONFIG_H_

mercurial