vpx_encoder.h revision da49e34c1fb5e99681f4ad99c21d9cfd83eddb96
190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber/* 2f71323e297a928af368937089d3ed71239786f86Andreas Huber * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 4f71323e297a928af368937089d3ed71239786f86Andreas Huber * Use of this source code is governed by a BSD-style license 5f71323e297a928af368937089d3ed71239786f86Andreas Huber * that can be found in the LICENSE file in the root of the source 6f71323e297a928af368937089d3ed71239786f86Andreas Huber * tree. An additional intellectual property rights grant can be found 7f71323e297a928af368937089d3ed71239786f86Andreas Huber * in the file PATENTS. All contributing project authors may 8f71323e297a928af368937089d3ed71239786f86Andreas Huber * be found in the AUTHORS file in the root of the source tree. 990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 102ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian#ifndef VPX_VPX_ENCODER_H_ 112ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian#define VPX_VPX_ENCODER_H_ 1290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 1390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber/*!\defgroup encoder Encoder Algorithm Interface 1490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * \ingroup codec 1590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * This abstraction allows applications using this encoder to easily support 1690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * multiple video formats with minimal code duplication. This section describes 1790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * the interface common to all encoders. 1890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * @{ 1990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 2090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 2179f15823c34ae1e423108295e416213200bb280fAndreas Huber/*!\file 2290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * \brief Describes the encoder algorithm interface to applications. 2390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 2490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * This file describes the interface between an application and a 2590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * video encoder algorithm. 2690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 2790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 2890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#ifdef __cplusplus 2990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberextern "C" { 3090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#endif 3190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 322ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian#include "./vpx_codec.h" 3390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 34ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! Temporal Scalability: Maximum length of the sequence defining frame 35ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * layer membership 36ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 371b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_TS_MAX_PERIODICITY 16 381b362b15af34006e6a11974088a46d42b903418eJohann 39ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! Temporal Scalability: Maximum number of coding layers */ 401b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_TS_MAX_LAYERS 5 411b362b15af34006e6a11974088a46d42b903418eJohann 42ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\deprecated Use #VPX_TS_MAX_PERIODICITY instead. */ 431b362b15af34006e6a11974088a46d42b903418eJohann#define MAX_PERIODICITY VPX_TS_MAX_PERIODICITY 441b362b15af34006e6a11974088a46d42b903418eJohann 45da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian/*! Temporal+Spatial Scalability: Maximum number of coding layers */ 46da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed. 47da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 48da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian/*!\deprecated Use #VPX_MAX_LAYERS instead. */ 49da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#define MAX_LAYERS VPX_MAX_LAYERS // 3 temporal + 4 spatial layers allowed. 5090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 511184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/*! Spatial Scalability: Maximum number of coding layers */ 521184aebb761cbeac9124c37189a80a1a58f04b6bhkuang#define VPX_SS_MAX_LAYERS 5 531184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 541184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/*! Spatial Scalability: Default number of coding layers */ 552ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian#define VPX_SS_DEFAULT_LAYERS 1 561184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 57ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Current ABI version number 58ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 59ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \internal 60ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * If this file is altered in any way that changes the ABI, this value 61ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * must be bumped. Examples include, but are not limited to, changing 62ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * types, removing or reassigning enums, adding/removing/rearranging 63ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * fields to structures 64ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 65da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#define VPX_ENCODER_ABI_VERSION (5 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ 6690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 6790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 68ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! \brief Encoder capabilities bitfield 69ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 70ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Each encoder advertises the capabilities it supports as part of its 71ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * ::vpx_codec_iface_t interface structure. Capabilities are extra 72ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * interfaces or functionality, and are not required to be supported 73ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * by an encoder. 74ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 75ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The available flags are specified by VPX_CODEC_CAP_* defines. 76ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 7790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */ 7890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 79ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! Can output one partition at a time. Each partition is returned in its 80ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for 81ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * every partition but the last. In this mode all frames are always 82ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * returned partition by partition. 83ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 841b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000 851b362b15af34006e6a11974088a46d42b903418eJohann 86da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian/*! Can support input images at greater than 8 bitdepth. 87da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 88da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#define VPX_CODEC_CAP_HIGHBITDEPTH 0x40000 8990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 90ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! \brief Initialization-time Feature Enabling 91ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 92ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Certain codec features must be known at initialization time, to allow 93ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for proper memory allocation. 94ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 95ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The available flags are specified by VPX_CODEC_USE_* defines. 96ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 9790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */ 981b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000 /**< Make the encoder output one 99ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang partition at a time. */ 100da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */ 101ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 102ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 103ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Generic fixed size buffer structure 104ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 105ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This structure is able to hold a reference to any fixed size buffer. 106ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 107ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef struct vpx_fixed_buf { 108ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void *buf; /**< Pointer to the data */ 109ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang size_t sz; /**< Length of the buffer, in chars */ 110ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */ 111ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 112ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 113ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Time Stamp Type 114ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 115ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * An integer, which when multiplied by the stream's time base, provides 116ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the absolute time of a sample. 117ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 118ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef int64_t vpx_codec_pts_t; 119ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 120ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 121ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Compressed Frame Flags 122ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 123ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This type represents a bitfield containing information about a compressed 124ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * frame that may be useful to an application. The most significant 16 bits 125ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * can be used by an algorithm to provide additional detail, for example to 126ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * support frame types that are codec specific (MPEG-1 D-frames for example) 127ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 128ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef uint32_t vpx_codec_frame_flags_t; 12990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */ 13090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_FRAME_IS_DROPPABLE 0x2 /**< frame can be dropped without affecting 131ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang the stream (no future frame depends on 132ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang this one) */ 13390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_FRAME_IS_INVISIBLE 0x4 /**< frame should be decoded but will not 134ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang be shown */ 1351b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_FRAME_IS_FRAGMENT 0x8 /**< this is a fragment of the encoded 136ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang frame */ 137ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 138ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Error Resilient flags 139ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 140ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * These flags define which error resilient features to enable in the 141ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoder. The flags are specified through the 142ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * vpx_codec_enc_cfg::g_error_resilient variable. 143ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 144ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef uint32_t vpx_codec_er_flags_t; 1451b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_ERROR_RESILIENT_DEFAULT 0x1 /**< Improve resiliency against 146ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang losses of whole frames */ 1471b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_ERROR_RESILIENT_PARTITIONS 0x2 /**< The frame partitions are 148ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang independently decodable by the 149ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool decoder, meaning that 150ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang partitions can be decoded even 151ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang though earlier partitions have 152ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang been lost. Note that intra 153ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang predicition is still done over 154ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang the partition boundary. */ 155ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 156ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Encoder output packet variants 157ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 158ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This enumeration lists the different kinds of data packets that can be 159ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY 160ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * extend this list to provide additional functionality. 161ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 162ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_codec_cx_pkt_kind { 163ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */ 164ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */ 165ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */ 166ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */ 167da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian // Spatial SVC is still experimental and may be removed before the next ABI 168da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian // bump. 169da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION) 170ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian VPX_CODEC_SPATIAL_SVC_LAYER_SIZES, /**< Sizes for each layer in this frame*/ 171da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian VPX_CODEC_SPATIAL_SVC_LAYER_PSNR, /**< PSNR for each layer in this frame*/ 172ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian#endif 173ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */ 174ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang }; 175ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 176ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 177ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Encoder output packet 178ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 179ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This structure contains the different kinds of output data the encoder 180ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * may produce while compressing a frame. 181ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 182ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef struct vpx_codec_cx_pkt { 183ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_codec_cx_pkt_kind kind; /**< packet variant */ 184ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang union { 185ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang struct { 186ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void *buf; /**< compressed data buffer */ 187ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang size_t sz; /**< length of compressed data */ 188ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_pts_t pts; /**< time stamp to show frame 18990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber (in timebase units) */ 190ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned long duration; /**< duration to show frame 19190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber (in timebase units) */ 192ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_frame_flags_t flags; /**< flags for this frame */ 193ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int partition_id; /**< the partition id 1941b362b15af34006e6a11974088a46d42b903418eJohann defines the decoding order 1951b362b15af34006e6a11974088a46d42b903418eJohann of the partitions. Only 1961b362b15af34006e6a11974088a46d42b903418eJohann applicable when "output partition" 1971b362b15af34006e6a11974088a46d42b903418eJohann mode is enabled. First partition 1981b362b15af34006e6a11974088a46d42b903418eJohann has id 0.*/ 1991b362b15af34006e6a11974088a46d42b903418eJohann 200ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } frame; /**< data for compressed frame packet */ 201da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */ 202da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */ 203ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang struct vpx_psnr_pkt { 204ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int samples[4]; /**< Number of samples, total/y/u/v */ 205ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang uint64_t sse[4]; /**< sum squared error, total/y/u/v */ 206ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang double psnr[4]; /**< PSNR, total/y/u/v */ 207ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } psnr; /**< data for PSNR packet */ 208da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_fixed_buf_t raw; /**< data for arbitrary packets */ 209da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian // Spatial SVC is still experimental and may be removed before the next 210da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian // ABI bump. 211da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#if VPX_ENCODER_ABI_VERSION > (5 + VPX_CODEC_ABI_VERSION) 212ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian size_t layer_sizes[VPX_SS_MAX_LAYERS]; 213da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian struct vpx_psnr_pkt layer_psnr[VPX_SS_MAX_LAYERS]; 214ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian#endif 215ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 216ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* This packet size is fixed to allow codecs to extend this 217ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * interface without having to manage storage for raw packets, 218ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * i.e., if it's smaller than 128 bytes, you can store in the 219ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * packet list directly. 220ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 221ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */ 222ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } data; /**< packet data */ 223ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */ 224ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 225ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 226da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief Encoder return output buffer callback 227da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 228da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * This callback function, when registered, returns with packets when each 229da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * spatial layer is encoded. 230da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 231da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian // putting the definitions here for now. (agrange: find if there 232da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian // is a better place for this) 233da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian typedef void (* vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt, 234da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian void *user_data); 235da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 236da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief Callback function pointer / user data pair storage */ 237da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian typedef struct vpx_codec_enc_output_cx_cb_pair { 238da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */ 239da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian void *user_priv; /**< Pointer to private data */ 240da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian } vpx_codec_priv_output_cx_pkt_cb_pair_t; 241da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 242ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Rational Number 243ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 244ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This structure holds a fractional value. 245ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 246ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef struct vpx_rational { 247ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int num; /**< fraction numerator */ 248ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int den; /**< fraction denominator */ 249ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } vpx_rational_t; /**< alias for struct vpx_rational */ 250ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 251ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 252ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Multi-pass Encoding Pass */ 253ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_enc_pass { 254ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_RC_ONE_PASS, /**< Single pass mode */ 255ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */ 256ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */ 257ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang }; 258ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 259ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 260ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Rate control mode */ 261ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_rc_mode { 2621184aebb761cbeac9124c37189a80a1a58f04b6bhkuang VPX_VBR, /**< Variable Bit Rate (VBR) mode */ 263ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_CBR, /**< Constant Bit Rate (CBR) mode */ 2641184aebb761cbeac9124c37189a80a1a58f04b6bhkuang VPX_CQ, /**< Constrained Quality (CQ) mode */ 2651184aebb761cbeac9124c37189a80a1a58f04b6bhkuang VPX_Q, /**< Constant Quality (Q) mode */ 266ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang }; 267ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 268ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 269ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Keyframe placement mode. 270ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 271ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This enumeration determines whether keyframes are placed automatically by 272ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the encoder or whether this behavior is disabled. Older releases of this 273ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled. 274ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This name is confusing for this behavior, so the new symbols to be used 275ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * are VPX_KF_AUTO and VPX_KF_DISABLED. 276ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 277ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_kf_mode { 278ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */ 279ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */ 280ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */ 281ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang }; 282ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 283ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 284ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Encoded Frame Flags 285ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 286ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This type indicates a bitfield to be passed to vpx_codec_encode(), defining 287ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * per-frame boolean values. By convention, bits common to all codecs will be 288ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * named VPX_EFLAG_*, and bits specific to an algorithm will be named 289ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * /algo/_eflag_*. The lower order 16 bits are reserved for common use. 290ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 291ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef long vpx_enc_frame_flags_t; 292ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VPX_EFLAG_FORCE_KF (1<<0) /**< Force this frame to be a keyframe */ 29390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 29490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 295ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Encoder configuration structure 296ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 297ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This structure contains the encoder settings that have common representations 298ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * across all codecs. This doesn't imply that all codecs support all features, 299ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * however. 300ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 301ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef struct vpx_codec_enc_cfg { 302ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 303ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * generic settings (g) 304ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 30590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 306ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Algorithm specific "usage" value 30790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 308ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Algorithms may define multiple values for usage, which may convey the 309ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * intent of how the application intends to use the stream. If this value 310ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * is non-zero, consult the documentation for the codec to determine its 311ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * meaning. 31290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 313ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int g_usage; 31490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 31590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 316ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Maximum number of threads to use 317ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 318ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * For multi-threaded implementations, use no more than this number of 319ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * threads. The codec may use fewer threads than allowed. The value 320ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 0 is equivalent to the value 1. 321ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 322ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int g_threads; 323ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 32490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 325ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Bitstream profile to use 326ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 327ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Some codecs support a notion of multiple bitstream profiles. Typically 328ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * this maps to a set of features that are turned on or off. Often the 329ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * profile to use is determined by the features of the intended decoder. 330ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Consult the documentation for the codec to determine the valid values 331ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for this parameter, or set to zero for a sane default. 332ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 333ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int g_profile; /**< profile of bitstream to use */ 33490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 33590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 33690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 337ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Width of the frame 33890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 339ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value identifies the presentation resolution of the frame, 340ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * in pixels. Note that the frames passed as input to the encoder must 341ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * have this resolution. Frames will be presented by the decoder in this 342ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * resolution, independent of any spatial resampling the encoder may do. 34390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 344ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int g_w; 34590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 34690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 347ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Height of the frame 34890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 349ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value identifies the presentation resolution of the frame, 350ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * in pixels. Note that the frames passed as input to the encoder must 351ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * have this resolution. Frames will be presented by the decoder in this 352ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * resolution, independent of any spatial resampling the encoder may do. 35390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 354ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int g_h; 35590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 356da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief Bit-depth of the codec 357da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 358da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * This value identifies the bit_depth of the codec, 359da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * Only certain bit-depths are supported as identified in the 360da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * vpx_bit_depth_t enum. 361da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 362da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_bit_depth_t g_bit_depth; 363da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 364da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief Bit-depth of the input frames 365da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 366da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * This value identifies the bit_depth of the input frames in bits. 367da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * Note that the frames passed as input to the encoder must have 368da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * this bit-depth. 369da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 370da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian unsigned int g_input_bit_depth; 37190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 372ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Stream timebase units 373ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 374ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Indicates the smallest interval of time, in seconds, used by the stream. 375ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * For fixed frame rate material, or variable frame rate material where 376ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * frames are timed at a multiple of a given clock (ex: video capture), 377ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the \ref RECOMMENDED method is to set the timebase to the reciprocal 378ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the 379ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * pts to correspond to the frame number, which can be handy. For 380ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * re-encoding video from containers with absolute time timestamps, the 381ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \ref RECOMMENDED method is to set the timebase to that of the parent 382ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * container or multimedia framework (ex: 1/1000 for ms, as in FLV). 38390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 384ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang struct vpx_rational g_timebase; 38590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 38690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 387ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Enable error resilient modes. 3881b362b15af34006e6a11974088a46d42b903418eJohann * 389ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The error resilient bitfield indicates to the encoder which features 390ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * it should enable to take measures for streaming over lossy or noisy 391ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * links. 392ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 393ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_er_flags_t g_error_resilient; 394ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 395ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 396ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Multi-pass Encoding Mode 3971b362b15af34006e6a11974088a46d42b903418eJohann * 398ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value should be set to the current phase for multi-pass encoding. 399ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * For single pass, set to #VPX_RC_ONE_PASS. 4001b362b15af34006e6a11974088a46d42b903418eJohann */ 401ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_enc_pass g_pass; 4021b362b15af34006e6a11974088a46d42b903418eJohann 4031b362b15af34006e6a11974088a46d42b903418eJohann 404ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Allow lagged encoding 405ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 406ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * If set, this value allows the encoder to consume a number of input 407ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * frames before producing output frames. This allows the encoder to 408ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * base decisions for the current frame on future frames. This does 409ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * increase the latency of the encoding pipeline, so it is not appropriate 410ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * in all situations (ex: realtime encoding). 4111b362b15af34006e6a11974088a46d42b903418eJohann * 412ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Note that this is a maximum value -- the encoder may produce frames 413ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * sooner than the given limit. Set this value to 0 to disable this 414ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * feature. 4151b362b15af34006e6a11974088a46d42b903418eJohann */ 416ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int g_lag_in_frames; 4171b362b15af34006e6a11974088a46d42b903418eJohann 4181b362b15af34006e6a11974088a46d42b903418eJohann 419ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 420ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * rate control settings (rc) 421ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 422ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 423ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Temporal resampling configuration, if supported by the codec. 42490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 425ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Temporal resampling allows the codec to "drop" frames as a strategy to 426ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * meet its target data rate. This can cause temporal discontinuities in 427ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the encoded video, which may appear as stuttering during playback. This 428ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * trade-off is often acceptable, but for many applications is not. It can 429ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be disabled in these cases. 43090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 431ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Note that not all codecs support this feature. All vpx VPx codecs do. 432ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * For other codecs, consult the documentation for that algorithm. 43390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 434ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This threshold is described as a percentage of the target data buffer. 435ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * When the data buffer falls below this percentage of fullness, a 436ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * dropped frame is indicated. Set the threshold to zero (0) to disable 437ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * this feature. 43890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 439ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_dropframe_thresh; 44090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 44190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 442ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Enable/disable spatial resampling, if supported by the codec. 44390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 444ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Spatial resampling allows the codec to compress a lower resolution 445ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * version of the frame, which is then upscaled by the encoder to the 446ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * correct presentation resolution. This increases visual quality at 447ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * low data rates, at the expense of CPU time on the encoder/decoder. 448ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 449ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_resize_allowed; 450ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 451ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian /*!\brief Internal coded frame width. 452ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * 453ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * If spatial resampling is enabled this specifies the width of the 454ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * encoded frame. 455ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian */ 456ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian unsigned int rc_scaled_width; 457ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian 458ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian /*!\brief Internal coded frame height. 459ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * 460ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * If spatial resampling is enabled this specifies the height of the 461ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * encoded frame. 462ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian */ 463ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian unsigned int rc_scaled_height; 464ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 465ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Spatial resampling up watermark. 46690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 467ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This threshold is described as a percentage of the target data buffer. 468ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * When the data buffer rises above this percentage of fullness, the 469ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoder will step up to a higher resolution version of the frame. 470ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 471ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_resize_up_thresh; 472ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 473ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 474ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Spatial resampling down watermark. 47590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 476ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This threshold is described as a percentage of the target data buffer. 477ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * When the data buffer falls below this percentage of fullness, the 478ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoder will step down to a lower resolution version of the frame. 47990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 480ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_resize_down_thresh; 48190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 48290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 483ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Rate control algorithm to use. 48490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 485ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Indicates whether the end usage of this stream is to be streamed over 486ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * a bandwidth constrained link, indicating that Constant Bit Rate (CBR) 487ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * mode should be used, or whether it will be played back on a high 488ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * bandwidth link, as from a local disk, where higher variations in 489ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * bitrate are acceptable. 490ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 491ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_rc_mode rc_end_usage; 492ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 493ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 494ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Two-pass stats buffer. 49590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 496ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * A buffer containing all of the stats packets produced in the first 497ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * pass, concatenated. 498ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 499da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_fixed_buf_t rc_twopass_stats_in; 500ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 501ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian /*!\brief first pass mb stats buffer. 502ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * 503ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * A buffer containing all of the first pass mb stats packets produced 504ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * in the first pass, concatenated. 505ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian */ 506da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian vpx_fixed_buf_t rc_firstpass_mb_stats_in; 507ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 508ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Target data rate 50990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 510ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Target bandwidth to use for this stream, in kilobits per second. 51190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 512ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_target_bitrate; 51390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 51490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 515ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 516ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * quantizer settings 51790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 51890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 519ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 520ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Minimum (Best Quality) Quantizer 52190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 522ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The quantizer is the most direct control over the quality of the 523ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoded image. The range of valid values for the quantizer is codec 524ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * specific. Consult the documentation for the codec to determine the 525ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * values to use. To determine the range programmatically, call 526ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * vpx_codec_enc_config_default() with a usage value of 0. 527ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 528ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_min_quantizer; 529ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 530ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 531ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Maximum (Worst Quality) Quantizer 53290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 533ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The quantizer is the most direct control over the quality of the 534ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoded image. The range of valid values for the quantizer is codec 535ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * specific. Consult the documentation for the codec to determine the 536ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * values to use. To determine the range programmatically, call 537ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * vpx_codec_enc_config_default() with a usage value of 0. 538ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 539ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_max_quantizer; 540ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 541ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 542ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 543ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * bitrate tolerance 544ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 545ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 546ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 547ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Rate control adaptation undershoot control 54890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 549ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value, expressed as a percentage of the target bitrate, 550ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * controls the maximum allowed adaptation speed of the codec. 551ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This factor controls the maximum amount of bits that can 552ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be subtracted from the target bitrate in order to compensate 553ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for prior overshoot. 55490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 555ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Valid values in the range 0-1000. 556ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 557ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_undershoot_pct; 558ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 559ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 560ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Rate control adaptation overshoot control 56190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 562ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value, expressed as a percentage of the target bitrate, 563ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * controls the maximum allowed adaptation speed of the codec. 564ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This factor controls the maximum amount of bits that can 565ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be added to the target bitrate in order to compensate for 566ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * prior undershoot. 56790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 568ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Valid values in the range 0-1000. 569ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 570ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_overshoot_pct; 571ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 572ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 573ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 574ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * decoder buffer model parameters 575ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 576ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 577ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 578ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Decoder Buffer Size 57990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 580ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value indicates the amount of data that may be buffered by the 581ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * decoding application. Note that this value is expressed in units of 582ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * time (milliseconds). For example, a value of 5000 indicates that the 583ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * client will buffer (at least) 5000ms worth of encoded data. Use the 584ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if 585ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * necessary. 58690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 587ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_buf_sz; 58890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 58990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 590ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Decoder Buffer Initial Size 59190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 592ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value indicates the amount of data that will be buffered by the 593ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * decoding application prior to beginning playback. This value is 594ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * expressed in units of time (milliseconds). Use the target bitrate 595ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * (#rc_target_bitrate) to convert to bits/bytes, if necessary. 596ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 597ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_buf_initial_sz; 598ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 599ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 600ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Decoder Buffer Optimal Size 60190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 602ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value indicates the amount of data that the encoder should try 603ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * to maintain in the decoder's buffer. This value is expressed in units 604ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * of time (milliseconds). Use the target bitrate (#rc_target_bitrate) 605ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * to convert to bits/bytes, if necessary. 606ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 607ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_buf_optimal_sz; 608ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 609ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 610ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 611ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 2 pass rate control parameters 612ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 613ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 614ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 615ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Two-pass mode CBR/VBR bias 61690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 617ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Bias, expressed on a scale of 0 to 100, for determining target size 618ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for the current frame. The value 0 indicates the optimal CBR mode 619ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * value should be used. The value 100 indicates the optimal VBR mode 620ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * value should be used. Values in between indicate which way the 621ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoder should "lean." 622ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 623ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_2pass_vbr_bias_pct; /**< RC mode bias between CBR and VBR(0-100: 0->CBR, 100->VBR) */ 624ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 625ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 626ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Two-pass mode per-GOP minimum bitrate 62790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 628ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value, expressed as a percentage of the target bitrate, indicates 629ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the minimum bitrate to be used for a single GOP (aka "section") 630ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 631ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_2pass_vbr_minsection_pct; 632ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 633ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 634ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Two-pass mode per-GOP maximum bitrate 63590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 636ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value, expressed as a percentage of the target bitrate, indicates 637ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the maximum bitrate to be used for a single GOP (aka "section") 638ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 639ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int rc_2pass_vbr_maxsection_pct; 640ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 641ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 642ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 643ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * keyframing settings (kf) 644ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 645ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 646ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Keyframe placement mode 64790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 648ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value indicates whether the encoder should place keyframes at a 649ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * fixed interval, or determine the optimal placement automatically 650ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * (as governed by the #kf_min_dist and #kf_max_dist parameters) 651ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 652ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang enum vpx_kf_mode kf_mode; 653ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 654ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 655ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Keyframe minimum interval 65690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 657ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value, expressed as a number of frames, prevents the encoder from 658ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * placing a keyframe nearer than kf_min_dist to the previous keyframe. At 659ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * least kf_min_dist frames non-keyframes will be coded before the next 660ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval. 66190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 662ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int kf_min_dist; 66390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 66490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 665ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Keyframe maximum interval 66690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 667ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value, expressed as a number of frames, forces the encoder to code 668ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * a keyframe if one has not been coded in the last kf_max_dist frames. 669ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * A value of 0 implies all frames will be keyframes. Set kf_min_dist 670ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * equal to kf_max_dist for a fixed interval. 671ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 672ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int kf_max_dist; 673ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 674ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* 6751184aebb761cbeac9124c37189a80a1a58f04b6bhkuang * Spatial scalability settings (ss) 6761184aebb761cbeac9124c37189a80a1a58f04b6bhkuang */ 6771184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 6782ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Number of spatial coding layers. 6791184aebb761cbeac9124c37189a80a1a58f04b6bhkuang * 6802ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * This value specifies the number of spatial coding layers to be used. 681ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 6821184aebb761cbeac9124c37189a80a1a58f04b6bhkuang unsigned int ss_number_layers; 683ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 684ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian /*!\brief Enable auto alt reference flags for each spatial layer. 685ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * 686ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * These values specify if auto alt reference frame is enabled for each 687ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian * spatial layer. 688ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian */ 689ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS]; 690ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian 6912ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Target bitrate for each spatial layer. 69290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 6932ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * These values specify the target coding bitrate to be used for each 6942ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * spatial layer. 6952ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian */ 6962ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS]; 6972ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian 6982ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Number of temporal coding layers. 6992ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * 7002ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * This value specifies the number of temporal layers to be used. 701ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 702ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int ts_number_layers; 703ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7042ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Target bitrate for each temporal layer. 705ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 7062ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * These values specify the target coding bitrate to be used for each 7072ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * temporal layer. 708ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 709ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS]; 710ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7112ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Frame rate decimation factor for each temporal layer. 712ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 713ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * These values specify the frame rate decimation factors to apply 7142ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * to each temporal layer. 715ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 716ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS]; 717ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7182ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Length of the sequence defining frame temporal layer membership. 71990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 720ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This value specifies the length of the sequence that defines the 7212ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * membership of frames to temporal layers. For example, if the 7222ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * ts_periodicity = 8, then the frames are assigned to coding layers with a 7232ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * repeated sequence of length 8. 7242ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian */ 725ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int ts_periodicity; 726ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7272ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian /*!\brief Template defining the membership of frames to temporal layers. 72890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 7292ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * This array defines the membership of frames to temporal coding layers. 7302ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * For a 2-layer encoding that assigns even numbered frames to one temporal 7312ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * layer (0) and odd numbered frames to a second temporal layer (1) with 7322ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian * ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1). 7332ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian */ 734ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY]; 735da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 736da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief Target bitrate for each spatial/temporal layer. 737da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 738da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * These values specify the target coding bitrate to be used for each 739da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * spatial/temporal layer. 740da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 741da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 742da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian unsigned int layer_target_bitrate[VPX_MAX_LAYERS]; 743da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 744da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief Temporal layering mode indicating which temporal layering scheme to use. 745da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 746da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the 747da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * temporal layering mode to use. 748da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 749da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 750da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian int temporal_layering_mode; 751ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */ 752ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 753da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian /*!\brief vp9 svc extra configure parameters 754da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 755da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * This defines max/min quantizers and scale factors for each layer 756da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 757da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 758da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian typedef struct vpx_svc_parameters { 759da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */ 760da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */ 761da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */ 762da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */ 763da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian int temporal_layering_mode; /**< Temporal layering mode */ 764da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian } vpx_svc_extra_cfg_t; 765da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 766ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 767ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Initialize an encoder instance 768ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 769ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Initializes a encoder context using the given interface. Applications 770ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * should call the vpx_codec_enc_init convenience macro instead of this 771ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * function directly, to ensure that the ABI version number parameter 772ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * is properly initialized. 773ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 774ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * If the library was configured with --disable-multithread, this call 775ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * is not thread safe and should be guarded with a lock if being used 776ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * in a multithreaded context. 777ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 778ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context. 779ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] iface Pointer to the algorithm interface to use. 780ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] cfg Configuration to use, if known. May be NULL. 781ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] flags Bitfield of VPX_CODEC_USE_* flags 782ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ver ABI version number. Must be set to 783ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * VPX_ENCODER_ABI_VERSION 784ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 785ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The decoder algorithm initialized. 786ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_MEM_ERROR 787ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Memory allocation failed. 788ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 789ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, 790ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_iface_t *iface, 791da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian const vpx_codec_enc_cfg_t *cfg, 792ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_flags_t flags, 793ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int ver); 794ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 795ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 796ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Convenience macro for vpx_codec_enc_init_ver() 797ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 798ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Ensures the ABI version parameter is properly set. 799ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 800ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define vpx_codec_enc_init(ctx, iface, cfg, flags) \ 801ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION) 802ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 803ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 804ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Initialize multi-encoder instance 805ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 806ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Initializes multi-encoder context using the given interface. 807ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Applications should call the vpx_codec_enc_init_multi convenience macro 808ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * instead of this function directly, to ensure that the ABI version number 809ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * parameter is properly initialized. 810ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 811ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context. 812ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] iface Pointer to the algorithm interface to use. 813ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] cfg Configuration to use, if known. May be NULL. 814ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] num_enc Total number of encoders. 815ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] flags Bitfield of VPX_CODEC_USE_* flags 816ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] dsf Pointer to down-sampling factors. 817ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ver ABI version number. Must be set to 818ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * VPX_ENCODER_ABI_VERSION 819ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 820ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The decoder algorithm initialized. 821ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_MEM_ERROR 822ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Memory allocation failed. 823ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 824ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, 825ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_iface_t *iface, 826ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_enc_cfg_t *cfg, 827ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int num_enc, 828ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_flags_t flags, 829ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_rational_t *dsf, 830ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int ver); 831ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 832ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 833ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Convenience macro for vpx_codec_enc_init_multi_ver() 834ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 835ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Ensures the ABI version parameter is properly set. 836ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 837ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \ 838ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \ 839ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang VPX_ENCODER_ABI_VERSION) 840ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 841ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 842ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Get a default configuration 843ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 844ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Initializes a encoder configuration structure with default values. Supports 845ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the notion of "usages" so that an algorithm may offer different default 846ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * settings depending on the user's intended goal. This function \ref SHOULD 847ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be called by all applications to initialize the configuration structure 848ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * before specializing the configuration with application specific values. 849ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 850da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * \param[in] iface Pointer to the algorithm interface to use. 851da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * \param[out] cfg Configuration buffer to populate. 852da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * \param[in] reserved Must set to 0 for VP8 and VP9. 853ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 854ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 855ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The configuration was populated. 856ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INCAPABLE 857ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Interface is not an encoder interface. 858ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INVALID_PARAM 859ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * A parameter was NULL, or the usage value was not recognized. 860ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 861ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, 862ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_enc_cfg_t *cfg, 863da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian unsigned int reserved); 864ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 865ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 866ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Set or change configuration 867ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 868ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Reconfigures an encoder instance according to the given configuration. 869ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 870ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 871ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] cfg Configuration buffer to use 872ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 873ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 874ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The configuration was populated. 875ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INCAPABLE 876ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Interface is not an encoder interface. 877ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INVALID_PARAM 878ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * A parameter was NULL, or the usage value was not recognized. 879ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 880ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx, 881ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_codec_enc_cfg_t *cfg); 882ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 883ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 884ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Get global stream headers 885ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 886ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Retrieves a stream level global header packet, if supported by the codec. 887ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 888ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 889ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 890ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval NULL 891ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Encoder does not support global header 892ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval Non-NULL 893ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Pointer to buffer containing global header packet 894ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 895ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx); 89690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 89790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 898ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VPX_DL_REALTIME (1) /**< deadline parameter analogous to 899ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * VPx REALTIME mode. */ 900ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VPX_DL_GOOD_QUALITY (1000000) /**< deadline parameter analogous to 901ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * VPx GOOD QUALITY mode. */ 902ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VPX_DL_BEST_QUALITY (0) /**< deadline parameter analogous to 903ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * VPx BEST QUALITY mode. */ 904ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Encode a frame 905ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 906ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Encodes a video frame at the given "presentation time." The presentation 907ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * time stamp (PTS) \ref MUST be strictly increasing. 908ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 909ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The encoder supports the notion of a soft real-time deadline. Given a 910ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * non-zero value to the deadline parameter, the encoder will make a "best 911ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * effort" guarantee to return before the given time slice expires. It is 912ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * implicit that limiting the available time to encode will degrade the 913ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * output quality. The encoder can be given an unlimited time to produce the 914ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * best possible frame by specifying a deadline of '0'. This deadline 915ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * supercedes the VPx notion of "best quality, good quality, realtime". 916ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Applications that wish to map these former settings to the new deadline 917ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY, 918ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * and #VPX_DL_BEST_QUALITY. 919ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 920ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * When the last frame has been passed to the encoder, this function should 921ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * continue to be called, with the img parameter set to NULL. This will 922ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * signal the end-of-stream condition to the encoder and allow it to encode 923ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * any held buffers. Encoding is complete when vpx_codec_encode() is called 924ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * and vpx_codec_get_cx_data() returns no data. 925ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 926ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 927ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] img Image data to encode, NULL to flush. 928ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] pts Presentation time stamp, in timebase units. 929ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] duration Duration to show frame, in timebase units. 930ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] flags Flags to use for encoding this frame. 931ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] deadline Time to spend encoding, in microseconds. (0=infinite) 932ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 933ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 934ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The configuration was populated. 935ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INCAPABLE 936ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Interface is not an encoder interface. 937ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INVALID_PARAM 938ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * A parameter was NULL, the image format is unsupported, etc. 939ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 940ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, 941ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_image_t *img, 942ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_pts_t pts, 943ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned long duration, 944ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_enc_frame_flags_t flags, 945ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned long deadline); 946ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 947ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Set compressed data output buffer 948ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 949ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Sets the buffer that the codec should output the compressed data 950ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * into. This call effectively sets the buffer pointer returned in the 951ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be 952ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * appended into this buffer. The buffer is preserved across frames, 953ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * so applications must periodically call this function after flushing 954ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the accumulated compressed data to disk or to the network to reset 955ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the pointer to the buffer's head. 956ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 957ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * `pad_before` bytes will be skipped before writing the compressed 958ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * data, and `pad_after` bytes will be appended to the packet. The size 959ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * of the packet will be the sum of the size of the actual compressed 960ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * data, pad_before, and pad_after. The padding bytes will be preserved 961ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * (not overwritten). 962ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 963ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Note that calling this function does not guarantee that the returned 964ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * compressed data will be placed into the specified buffer. In the 965ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * event that the encoded data will not fit into the buffer provided, 966ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the returned packet \ref MAY point to an internal buffer, as it would 967ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * if this call were never used. In this event, the output packet will 968ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * NOT have any padding, and the application must free space and copy it 969ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * to the proper place. This is of particular note in configurations 970ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * that may output multiple packets for a single encoded frame (e.g., lagged 971ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * encoding) or if the application does not reset the buffer periodically. 972ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 973ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Applications may restore the default behavior of the codec providing 974ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the compressed data buffer by calling this function with a NULL 975ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * buffer. 976ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 977ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Applications \ref MUSTNOT call this function during iteration of 978ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * vpx_codec_get_cx_data(). 979ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 980ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 981ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] buf Buffer to store compressed data into 982ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] pad_before Bytes to skip before writing compressed data 983ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] pad_after Bytes to skip after writing compressed data 984ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 985ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 986ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The buffer was set successfully. 987ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_INVALID_PARAM 988ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * A parameter was NULL, the image format is unsupported, etc. 989ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 990ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx, 991ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_fixed_buf_t *buf, 992ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int pad_before, 993ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int pad_after); 994ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 995ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 996ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Encoded data iterator 997ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 998ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Iterates over a list of data packets to be passed from the encoder to the 999ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * application. The different kinds of packets available are enumerated in 1000ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * #vpx_codec_cx_pkt_kind. 1001ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1002ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's 1003ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * muxer. Multiple compressed frames may be in the list. 1004ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * #VPX_CODEC_STATS_PKT packets should be appended to a global buffer. 1005ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1006ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The application \ref MUST silently ignore any packet kinds that it does 1007ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * not recognize or support. 1008ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1009ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The data buffers returned from this function are only guaranteed to be 1010ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * valid until the application makes another call to any vpx_codec_* function. 1011ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1012ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 1013ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in,out] iter Iterator storage, initialized to NULL 1014ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1015ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \return Returns a pointer to an output data packet (compressed frame data, 1016ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * two-pass statistics, etc.) or NULL to signal end-of-list. 1017ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1018ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 1019ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, 1020ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_iter_t *iter); 1021ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1022ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1023ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Get Preview Frame 1024ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1025ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Returns an image that can be used as a preview. Shows the image as it would 1026ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * exist at the decompressor. The application \ref MUST NOT write into this 1027ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * image buffer. 1028ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1029ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 1030ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1031ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \return Returns a pointer to a preview image, or NULL if no image is 1032ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * available. 1033ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 1034ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 1035ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx); 1036ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1037ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1038ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!@} - end defgroup encoder*/ 103990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#ifdef __cplusplus 104090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 104190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#endif 10422ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian#endif // VPX_VPX_ENCODER_H_ 10435ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 1044