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 347bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*! Temporal Scalability: Maximum length of the sequence defining frame 357bc9febe8749e98a3812a0dc4380ceae75c29450Johann * layer membership 367bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 371b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_TS_MAX_PERIODICITY 16 381b362b15af34006e6a11974088a46d42b903418eJohann 397bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*! Temporal Scalability: Maximum number of coding layers */ 407bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_TS_MAX_LAYERS 5 411b362b15af34006e6a11974088a46d42b903418eJohann 427bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\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 */ 467bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed. 47da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 48da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian/*!\deprecated Use #VPX_MAX_LAYERS instead. */ 497bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define MAX_LAYERS VPX_MAX_LAYERS // 3 temporal + 4 spatial layers allowed. 5090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 511184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/*! Spatial Scalability: Maximum number of coding layers */ 527bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_SS_MAX_LAYERS 5 531184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 541184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/*! Spatial Scalability: Default number of coding layers */ 557bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_SS_DEFAULT_LAYERS 1 5690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 577bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Current ABI version number 587bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 597bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \internal 607bc9febe8749e98a3812a0dc4380ceae75c29450Johann * If this file is altered in any way that changes the ABI, this value 617bc9febe8749e98a3812a0dc4380ceae75c29450Johann * must be bumped. Examples include, but are not limited to, changing 627bc9febe8749e98a3812a0dc4380ceae75c29450Johann * types, removing or reassigning enums, adding/removing/rearranging 637bc9febe8749e98a3812a0dc4380ceae75c29450Johann * fields to structures 647bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 657bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_ENCODER_ABI_VERSION \ 66df37111358d02836cb29bbcb9c6e4c95dff90a16Johann (6 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ 6790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 687bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*! \brief Encoder capabilities bitfield 697bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 707bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Each encoder advertises the capabilities it supports as part of its 717bc9febe8749e98a3812a0dc4380ceae75c29450Johann * ::vpx_codec_iface_t interface structure. Capabilities are extra 727bc9febe8749e98a3812a0dc4380ceae75c29450Johann * interfaces or functionality, and are not required to be supported 737bc9febe8749e98a3812a0dc4380ceae75c29450Johann * by an encoder. 747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The available flags are specified by VPX_CODEC_CAP_* defines. 767bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 777bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */ 7890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 797bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*! Can output one partition at a time. Each partition is returned in its 807bc9febe8749e98a3812a0dc4380ceae75c29450Johann * own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for 817bc9febe8749e98a3812a0dc4380ceae75c29450Johann * every partition but the last. In this mode all frames are always 827bc9febe8749e98a3812a0dc4380ceae75c29450Johann * returned partition by partition. 837bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 847bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000 851b362b15af34006e6a11974088a46d42b903418eJohann 867bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*! \brief Initialization-time Feature Enabling 877bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 887bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Certain codec features must be known at initialization time, to allow 897bc9febe8749e98a3812a0dc4380ceae75c29450Johann * for proper memory allocation. 907bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 917bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The available flags are specified by VPX_CODEC_USE_* defines. 927bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 937bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */ 947bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Make the encoder output one partition at a time. */ 957bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000 96da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */ 97ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 987bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Generic fixed size buffer structure 997bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 1007bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This structure is able to hold a reference to any fixed size buffer. 1017bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 1027bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef struct vpx_fixed_buf { 1037bc9febe8749e98a3812a0dc4380ceae75c29450Johann void *buf; /**< Pointer to the data */ 1047bc9febe8749e98a3812a0dc4380ceae75c29450Johann size_t sz; /**< Length of the buffer, in chars */ 1057bc9febe8749e98a3812a0dc4380ceae75c29450Johann} vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */ 106ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1077bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Time Stamp Type 1087bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 1097bc9febe8749e98a3812a0dc4380ceae75c29450Johann * An integer, which when multiplied by the stream's time base, provides 1107bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the absolute time of a sample. 1117bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 1127bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef int64_t vpx_codec_pts_t; 113ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1147bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Compressed Frame Flags 1157bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 1167bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This type represents a bitfield containing information about a compressed 1177bc9febe8749e98a3812a0dc4380ceae75c29450Johann * frame that may be useful to an application. The most significant 16 bits 1187bc9febe8749e98a3812a0dc4380ceae75c29450Johann * can be used by an algorithm to provide additional detail, for example to 1197bc9febe8749e98a3812a0dc4380ceae75c29450Johann * support frame types that are codec specific (MPEG-1 D-frames for example) 1207bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 1217bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef uint32_t vpx_codec_frame_flags_t; 1227bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */ 1237bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief frame can be dropped without affecting the stream (no future frame 1247bc9febe8749e98a3812a0dc4380ceae75c29450Johann * depends on this one) */ 1257bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_FRAME_IS_DROPPABLE 0x2 1267bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief frame should be decoded but will not be shown */ 1277bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_FRAME_IS_INVISIBLE 0x4 1287bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief this is a fragment of the encoded frame */ 1297bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_FRAME_IS_FRAGMENT 0x8 1307bc9febe8749e98a3812a0dc4380ceae75c29450Johann 1317bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Error Resilient flags 1327bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 1337bc9febe8749e98a3812a0dc4380ceae75c29450Johann * These flags define which error resilient features to enable in the 1347bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoder. The flags are specified through the 1357bc9febe8749e98a3812a0dc4380ceae75c29450Johann * vpx_codec_enc_cfg::g_error_resilient variable. 1367bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 1377bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef uint32_t vpx_codec_er_flags_t; 1387bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Improve resiliency against losses of whole frames */ 1397bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_ERROR_RESILIENT_DEFAULT 0x1 1407bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief The frame partitions are independently decodable by the bool decoder, 1417bc9febe8749e98a3812a0dc4380ceae75c29450Johann * meaning that partitions can be decoded even though earlier partitions have 1427bc9febe8749e98a3812a0dc4380ceae75c29450Johann * been lost. Note that intra prediction is still done over the partition 1437bc9febe8749e98a3812a0dc4380ceae75c29450Johann * boundary. */ 1447bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_ERROR_RESILIENT_PARTITIONS 0x2 1457bc9febe8749e98a3812a0dc4380ceae75c29450Johann 1467bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encoder output packet variants 1477bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 1487bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This enumeration lists the different kinds of data packets that can be 1497bc9febe8749e98a3812a0dc4380ceae75c29450Johann * returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY 1507bc9febe8749e98a3812a0dc4380ceae75c29450Johann * extend this list to provide additional functionality. 1517bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 1527bc9febe8749e98a3812a0dc4380ceae75c29450Johannenum vpx_codec_cx_pkt_kind { 1537bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */ 1547bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */ 1557bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */ 1567bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */ 157df37111358d02836cb29bbcb9c6e4c95dff90a16Johann// Spatial SVC is still experimental and may be removed. 158df37111358d02836cb29bbcb9c6e4c95dff90a16Johann#if defined(VPX_TEST_SPATIAL_SVC) 1597bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_SPATIAL_SVC_LAYER_SIZES, /**< Sizes for each layer in this frame*/ 1607bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_SPATIAL_SVC_LAYER_PSNR, /**< PSNR for each layer in this frame*/ 1617bc9febe8749e98a3812a0dc4380ceae75c29450Johann#endif 1627bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */ 1637bc9febe8749e98a3812a0dc4380ceae75c29450Johann}; 164ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1657bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encoder output packet 1667bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 1677bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This structure contains the different kinds of output data the encoder 1687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * may produce while compressing a frame. 1697bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 1707bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef struct vpx_codec_cx_pkt { 1717bc9febe8749e98a3812a0dc4380ceae75c29450Johann enum vpx_codec_cx_pkt_kind kind; /**< packet variant */ 1727bc9febe8749e98a3812a0dc4380ceae75c29450Johann union { 1737bc9febe8749e98a3812a0dc4380ceae75c29450Johann struct { 1747bc9febe8749e98a3812a0dc4380ceae75c29450Johann void *buf; /**< compressed data buffer */ 1757bc9febe8749e98a3812a0dc4380ceae75c29450Johann size_t sz; /**< length of compressed data */ 1767bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief time stamp to show frame (in timebase units) */ 1777bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_pts_t pts; 1787bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief duration to show frame (in timebase units) */ 1797bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned long duration; 1807bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_frame_flags_t flags; /**< flags for this frame */ 1817bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief the partition id defines the decoding order of the partitions. 1827bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Only applicable when "output partition" mode is enabled. First 1837bc9febe8749e98a3812a0dc4380ceae75c29450Johann * partition has id 0.*/ 1847bc9febe8749e98a3812a0dc4380ceae75c29450Johann int partition_id; 1857bc9febe8749e98a3812a0dc4380ceae75c29450Johann } frame; /**< data for compressed frame packet */ 1867bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */ 1877bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */ 1887bc9febe8749e98a3812a0dc4380ceae75c29450Johann struct vpx_psnr_pkt { 1897bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int samples[4]; /**< Number of samples, total/y/u/v */ 1907bc9febe8749e98a3812a0dc4380ceae75c29450Johann uint64_t sse[4]; /**< sum squared error, total/y/u/v */ 1917bc9febe8749e98a3812a0dc4380ceae75c29450Johann double psnr[4]; /**< PSNR, total/y/u/v */ 1927bc9febe8749e98a3812a0dc4380ceae75c29450Johann } psnr; /**< data for PSNR packet */ 1937bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_fixed_buf_t raw; /**< data for arbitrary packets */ 194df37111358d02836cb29bbcb9c6e4c95dff90a16Johann// Spatial SVC is still experimental and may be removed. 195df37111358d02836cb29bbcb9c6e4c95dff90a16Johann#if defined(VPX_TEST_SPATIAL_SVC) 1967bc9febe8749e98a3812a0dc4380ceae75c29450Johann size_t layer_sizes[VPX_SS_MAX_LAYERS]; 1977bc9febe8749e98a3812a0dc4380ceae75c29450Johann struct vpx_psnr_pkt layer_psnr[VPX_SS_MAX_LAYERS]; 1987bc9febe8749e98a3812a0dc4380ceae75c29450Johann#endif 199ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 2007bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* This packet size is fixed to allow codecs to extend this 2017bc9febe8749e98a3812a0dc4380ceae75c29450Johann * interface without having to manage storage for raw packets, 2027bc9febe8749e98a3812a0dc4380ceae75c29450Johann * i.e., if it's smaller than 128 bytes, you can store in the 2037bc9febe8749e98a3812a0dc4380ceae75c29450Johann * packet list directly. 2047bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 2057bc9febe8749e98a3812a0dc4380ceae75c29450Johann char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */ 2067bc9febe8749e98a3812a0dc4380ceae75c29450Johann } data; /**< packet data */ 2077bc9febe8749e98a3812a0dc4380ceae75c29450Johann} vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */ 208ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 2097bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encoder return output buffer callback 2107bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 2117bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This callback function, when registered, returns with packets when each 2127bc9febe8749e98a3812a0dc4380ceae75c29450Johann * spatial layer is encoded. 2137bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 2147bc9febe8749e98a3812a0dc4380ceae75c29450Johann// putting the definitions here for now. (agrange: find if there 2157bc9febe8749e98a3812a0dc4380ceae75c29450Johann// is a better place for this) 2167bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef void (*vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt, 2177bc9febe8749e98a3812a0dc4380ceae75c29450Johann void *user_data); 2187bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2197bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Callback function pointer / user data pair storage */ 2207bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef struct vpx_codec_enc_output_cx_cb_pair { 2217bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */ 2227bc9febe8749e98a3812a0dc4380ceae75c29450Johann void *user_priv; /**< Pointer to private data */ 2237bc9febe8749e98a3812a0dc4380ceae75c29450Johann} vpx_codec_priv_output_cx_pkt_cb_pair_t; 2247bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2257bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Rational Number 2267bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 2277bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This structure holds a fractional value. 2287bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 2297bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef struct vpx_rational { 2307bc9febe8749e98a3812a0dc4380ceae75c29450Johann int num; /**< fraction numerator */ 2317bc9febe8749e98a3812a0dc4380ceae75c29450Johann int den; /**< fraction denominator */ 2327bc9febe8749e98a3812a0dc4380ceae75c29450Johann} vpx_rational_t; /**< alias for struct vpx_rational */ 2337bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2347bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Multi-pass Encoding Pass */ 2357bc9febe8749e98a3812a0dc4380ceae75c29450Johannenum vpx_enc_pass { 2367bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_RC_ONE_PASS, /**< Single pass mode */ 2377bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */ 2387bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */ 2397bc9febe8749e98a3812a0dc4380ceae75c29450Johann}; 2407bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2417bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Rate control mode */ 2427bc9febe8749e98a3812a0dc4380ceae75c29450Johannenum vpx_rc_mode { 2437bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_VBR, /**< Variable Bit Rate (VBR) mode */ 2447bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CBR, /**< Constant Bit Rate (CBR) mode */ 2457bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_CQ, /**< Constrained Quality (CQ) mode */ 2467bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_Q, /**< Constant Quality (Q) mode */ 2477bc9febe8749e98a3812a0dc4380ceae75c29450Johann}; 2487bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2497bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Keyframe placement mode. 2507bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 2517bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This enumeration determines whether keyframes are placed automatically by 2527bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the encoder or whether this behavior is disabled. Older releases of this 2537bc9febe8749e98a3812a0dc4380ceae75c29450Johann * SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled. 2547bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This name is confusing for this behavior, so the new symbols to be used 2557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * are VPX_KF_AUTO and VPX_KF_DISABLED. 2567bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 2577bc9febe8749e98a3812a0dc4380ceae75c29450Johannenum vpx_kf_mode { 2587bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */ 2597bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */ 2607bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */ 2617bc9febe8749e98a3812a0dc4380ceae75c29450Johann}; 2627bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2637bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encoded Frame Flags 2647bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 2657bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This type indicates a bitfield to be passed to vpx_codec_encode(), defining 2667bc9febe8749e98a3812a0dc4380ceae75c29450Johann * per-frame boolean values. By convention, bits common to all codecs will be 2677bc9febe8749e98a3812a0dc4380ceae75c29450Johann * named VPX_EFLAG_*, and bits specific to an algorithm will be named 2687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * /algo/_eflag_*. The lower order 16 bits are reserved for common use. 2697bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 2707bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef long vpx_enc_frame_flags_t; 2717bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */ 2727bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2737bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encoder configuration structure 2747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 2757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This structure contains the encoder settings that have common representations 2767bc9febe8749e98a3812a0dc4380ceae75c29450Johann * across all codecs. This doesn't imply that all codecs support all features, 2777bc9febe8749e98a3812a0dc4380ceae75c29450Johann * however. 2787bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 2797bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef struct vpx_codec_enc_cfg { 2807bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 2817bc9febe8749e98a3812a0dc4380ceae75c29450Johann * generic settings (g) 282ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 2837bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2847bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Algorithm specific "usage" value 285ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 2867bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Algorithms may define multiple values for usage, which may convey the 2877bc9febe8749e98a3812a0dc4380ceae75c29450Johann * intent of how the application intends to use the stream. If this value 2887bc9febe8749e98a3812a0dc4380ceae75c29450Johann * is non-zero, consult the documentation for the codec to determine its 2897bc9febe8749e98a3812a0dc4380ceae75c29450Johann * meaning. 290ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 2917bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_usage; 2927bc9febe8749e98a3812a0dc4380ceae75c29450Johann 2937bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Maximum number of threads to use 294ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 2957bc9febe8749e98a3812a0dc4380ceae75c29450Johann * For multi-threaded implementations, use no more than this number of 2967bc9febe8749e98a3812a0dc4380ceae75c29450Johann * threads. The codec may use fewer threads than allowed. The value 2977bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 0 is equivalent to the value 1. 298ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 2997bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_threads; 300ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3017bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Bitstream profile to use 302ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 3037bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Some codecs support a notion of multiple bitstream profiles. Typically 3047bc9febe8749e98a3812a0dc4380ceae75c29450Johann * this maps to a set of features that are turned on or off. Often the 3057bc9febe8749e98a3812a0dc4380ceae75c29450Johann * profile to use is determined by the features of the intended decoder. 3067bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Consult the documentation for the codec to determine the valid values 3077bc9febe8749e98a3812a0dc4380ceae75c29450Johann * for this parameter, or set to zero for a sane default. 308ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 3097bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_profile; /**< profile of bitstream to use */ 310ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3117bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Width of the frame 312da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 3137bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value identifies the presentation resolution of the frame, 3147bc9febe8749e98a3812a0dc4380ceae75c29450Johann * in pixels. Note that the frames passed as input to the encoder must 3157bc9febe8749e98a3812a0dc4380ceae75c29450Johann * have this resolution. Frames will be presented by the decoder in this 3167bc9febe8749e98a3812a0dc4380ceae75c29450Johann * resolution, independent of any spatial resampling the encoder may do. 317da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 3187bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_w; 3197bc9febe8749e98a3812a0dc4380ceae75c29450Johann 3207bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Height of the frame 321ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 3227bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value identifies the presentation resolution of the frame, 3237bc9febe8749e98a3812a0dc4380ceae75c29450Johann * in pixels. Note that the frames passed as input to the encoder must 3247bc9febe8749e98a3812a0dc4380ceae75c29450Johann * have this resolution. Frames will be presented by the decoder in this 3257bc9febe8749e98a3812a0dc4380ceae75c29450Johann * resolution, independent of any spatial resampling the encoder may do. 326ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 3277bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_h; 328ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3297bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Bit-depth of the codec 330ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 3317bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value identifies the bit_depth of the codec, 3327bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Only certain bit-depths are supported as identified in the 3337bc9febe8749e98a3812a0dc4380ceae75c29450Johann * vpx_bit_depth_t enum. 334ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 3357bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_bit_depth_t g_bit_depth; 336ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3377bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Bit-depth of the input frames 338ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 3397bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value identifies the bit_depth of the input frames in bits. 3407bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Note that the frames passed as input to the encoder must have 3417bc9febe8749e98a3812a0dc4380ceae75c29450Johann * this bit-depth. 342ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 3437bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_input_bit_depth; 3447bc9febe8749e98a3812a0dc4380ceae75c29450Johann 3457bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Stream timebase units 3467bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 3477bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Indicates the smallest interval of time, in seconds, used by the stream. 3487bc9febe8749e98a3812a0dc4380ceae75c29450Johann * For fixed frame rate material, or variable frame rate material where 3497bc9febe8749e98a3812a0dc4380ceae75c29450Johann * frames are timed at a multiple of a given clock (ex: video capture), 3507bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the \ref RECOMMENDED method is to set the timebase to the reciprocal 3517bc9febe8749e98a3812a0dc4380ceae75c29450Johann * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the 3527bc9febe8749e98a3812a0dc4380ceae75c29450Johann * pts to correspond to the frame number, which can be handy. For 3537bc9febe8749e98a3812a0dc4380ceae75c29450Johann * re-encoding video from containers with absolute time timestamps, the 3547bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \ref RECOMMENDED method is to set the timebase to that of the parent 3557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * container or multimedia framework (ex: 1/1000 for ms, as in FLV). 3567bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 3577bc9febe8749e98a3812a0dc4380ceae75c29450Johann struct vpx_rational g_timebase; 35890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 3597bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Enable error resilient modes. 360ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 3617bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The error resilient bitfield indicates to the encoder which features 3627bc9febe8749e98a3812a0dc4380ceae75c29450Johann * it should enable to take measures for streaming over lossy or noisy 3637bc9febe8749e98a3812a0dc4380ceae75c29450Johann * links. 364ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 3657bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_er_flags_t g_error_resilient; 366ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3677bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Multi-pass Encoding Mode 3687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 3697bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value should be set to the current phase for multi-pass encoding. 3707bc9febe8749e98a3812a0dc4380ceae75c29450Johann * For single pass, set to #VPX_RC_ONE_PASS. 3717bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 3727bc9febe8749e98a3812a0dc4380ceae75c29450Johann enum vpx_enc_pass g_pass; 373ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3747bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Allow lagged encoding 3757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 3767bc9febe8749e98a3812a0dc4380ceae75c29450Johann * If set, this value allows the encoder to consume a number of input 3777bc9febe8749e98a3812a0dc4380ceae75c29450Johann * frames before producing output frames. This allows the encoder to 3787bc9febe8749e98a3812a0dc4380ceae75c29450Johann * base decisions for the current frame on future frames. This does 3797bc9febe8749e98a3812a0dc4380ceae75c29450Johann * increase the latency of the encoding pipeline, so it is not appropriate 3807bc9febe8749e98a3812a0dc4380ceae75c29450Johann * in all situations (ex: realtime encoding). 3817bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 3827bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Note that this is a maximum value -- the encoder may produce frames 3837bc9febe8749e98a3812a0dc4380ceae75c29450Johann * sooner than the given limit. Set this value to 0 to disable this 3847bc9febe8749e98a3812a0dc4380ceae75c29450Johann * feature. 3857bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 3867bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int g_lag_in_frames; 387ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3887bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 3897bc9febe8749e98a3812a0dc4380ceae75c29450Johann * rate control settings (rc) 3907bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 391ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 3927bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Temporal resampling configuration, if supported by the codec. 3937bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 3947bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Temporal resampling allows the codec to "drop" frames as a strategy to 3957bc9febe8749e98a3812a0dc4380ceae75c29450Johann * meet its target data rate. This can cause temporal discontinuities in 3967bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the encoded video, which may appear as stuttering during playback. This 3977bc9febe8749e98a3812a0dc4380ceae75c29450Johann * trade-off is often acceptable, but for many applications is not. It can 3987bc9febe8749e98a3812a0dc4380ceae75c29450Johann * be disabled in these cases. 3997bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4007bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Note that not all codecs support this feature. All vpx VPx codecs do. 4017bc9febe8749e98a3812a0dc4380ceae75c29450Johann * For other codecs, consult the documentation for that algorithm. 4027bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4037bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This threshold is described as a percentage of the target data buffer. 4047bc9febe8749e98a3812a0dc4380ceae75c29450Johann * When the data buffer falls below this percentage of fullness, a 4057bc9febe8749e98a3812a0dc4380ceae75c29450Johann * dropped frame is indicated. Set the threshold to zero (0) to disable 4067bc9febe8749e98a3812a0dc4380ceae75c29450Johann * this feature. 4077bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4087bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_dropframe_thresh; 409ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4107bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Enable/disable spatial resampling, if supported by the codec. 4117bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4127bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Spatial resampling allows the codec to compress a lower resolution 4137bc9febe8749e98a3812a0dc4380ceae75c29450Johann * version of the frame, which is then upscaled by the encoder to the 4147bc9febe8749e98a3812a0dc4380ceae75c29450Johann * correct presentation resolution. This increases visual quality at 4157bc9febe8749e98a3812a0dc4380ceae75c29450Johann * low data rates, at the expense of CPU time on the encoder/decoder. 4167bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4177bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_resize_allowed; 418ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4197bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Internal coded frame width. 4207bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4217bc9febe8749e98a3812a0dc4380ceae75c29450Johann * If spatial resampling is enabled this specifies the width of the 4227bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoded frame. 4237bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4247bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_scaled_width; 425ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4267bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Internal coded frame height. 4277bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4287bc9febe8749e98a3812a0dc4380ceae75c29450Johann * If spatial resampling is enabled this specifies the height of the 4297bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoded frame. 4307bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4317bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_scaled_height; 43290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 4337bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Spatial resampling up watermark. 4347bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4357bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This threshold is described as a percentage of the target data buffer. 4367bc9febe8749e98a3812a0dc4380ceae75c29450Johann * When the data buffer rises above this percentage of fullness, the 4377bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoder will step up to a higher resolution version of the frame. 4387bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4397bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_resize_up_thresh; 44090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 4417bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Spatial resampling down watermark. 4427bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4437bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This threshold is described as a percentage of the target data buffer. 4447bc9febe8749e98a3812a0dc4380ceae75c29450Johann * When the data buffer falls below this percentage of fullness, the 4457bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoder will step down to a lower resolution version of the frame. 4467bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4477bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_resize_down_thresh; 448ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4497bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Rate control algorithm to use. 4507bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4517bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Indicates whether the end usage of this stream is to be streamed over 4527bc9febe8749e98a3812a0dc4380ceae75c29450Johann * a bandwidth constrained link, indicating that Constant Bit Rate (CBR) 4537bc9febe8749e98a3812a0dc4380ceae75c29450Johann * mode should be used, or whether it will be played back on a high 4547bc9febe8749e98a3812a0dc4380ceae75c29450Johann * bandwidth link, as from a local disk, where higher variations in 4557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * bitrate are acceptable. 4567bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4577bc9febe8749e98a3812a0dc4380ceae75c29450Johann enum vpx_rc_mode rc_end_usage; 4581184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 4597bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Two-pass stats buffer. 4607bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4617bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A buffer containing all of the stats packets produced in the first 4627bc9febe8749e98a3812a0dc4380ceae75c29450Johann * pass, concatenated. 4637bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4647bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_fixed_buf_t rc_twopass_stats_in; 465ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4667bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief first pass mb stats buffer. 4677bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A buffer containing all of the first pass mb stats packets produced 4697bc9febe8749e98a3812a0dc4380ceae75c29450Johann * in the first pass, concatenated. 4707bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4717bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_fixed_buf_t rc_firstpass_mb_stats_in; 472ba6c59e9d7d7013b3906b6f4230b663422681848Vignesh Venkatasubramanian 4737bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Target data rate 4747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Target bandwidth to use for this stream, in kilobits per second. 4767bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4777bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_target_bitrate; 4782ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian 4797bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 4807bc9febe8749e98a3812a0dc4380ceae75c29450Johann * quantizer settings 4817bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 482ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4837bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Minimum (Best Quality) Quantizer 4847bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4857bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The quantizer is the most direct control over the quality of the 4867bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoded image. The range of valid values for the quantizer is codec 4877bc9febe8749e98a3812a0dc4380ceae75c29450Johann * specific. Consult the documentation for the codec to determine the 4887bc9febe8749e98a3812a0dc4380ceae75c29450Johann * values to use. To determine the range programmatically, call 4897bc9febe8749e98a3812a0dc4380ceae75c29450Johann * vpx_codec_enc_config_default() with a usage value of 0. 4907bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 4917bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_min_quantizer; 492ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 4937bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Maximum (Worst Quality) Quantizer 4947bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 4957bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The quantizer is the most direct control over the quality of the 4967bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoded image. The range of valid values for the quantizer is codec 4977bc9febe8749e98a3812a0dc4380ceae75c29450Johann * specific. Consult the documentation for the codec to determine the 4987bc9febe8749e98a3812a0dc4380ceae75c29450Johann * values to use. To determine the range programmatically, call 4997bc9febe8749e98a3812a0dc4380ceae75c29450Johann * vpx_codec_enc_config_default() with a usage value of 0. 5007bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 5017bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_max_quantizer; 502da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian 5037bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 5047bc9febe8749e98a3812a0dc4380ceae75c29450Johann * bitrate tolerance 5057bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 506ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5077bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Rate control adaptation undershoot control 508da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian * 509df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * VP8: Expressed as a percentage of the target bitrate, 5107bc9febe8749e98a3812a0dc4380ceae75c29450Johann * controls the maximum allowed adaptation speed of the codec. 5117bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This factor controls the maximum amount of bits that can 5127bc9febe8749e98a3812a0dc4380ceae75c29450Johann * be subtracted from the target bitrate in order to compensate 5137bc9febe8749e98a3812a0dc4380ceae75c29450Johann * for prior overshoot. 514df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * VP9: Expressed as a percentage of the target bitrate, a threshold 515df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * undershoot level (current rate vs target) beyond which more agressive 516df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * corrective measures are taken. 517df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * * 518df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * Valid values in the range VP8:0-1000 VP9: 0-100. 519da49e34c1fb5e99681f4ad99c21d9cfd83eddb96Vignesh Venkatasubramanian */ 5207bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_undershoot_pct; 521ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5227bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Rate control adaptation overshoot control 523ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 524df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * VP8: Expressed as a percentage of the target bitrate, 5257bc9febe8749e98a3812a0dc4380ceae75c29450Johann * controls the maximum allowed adaptation speed of the codec. 5267bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This factor controls the maximum amount of bits that can 5277bc9febe8749e98a3812a0dc4380ceae75c29450Johann * be added to the target bitrate in order to compensate for 5287bc9febe8749e98a3812a0dc4380ceae75c29450Johann * prior undershoot. 529df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * VP9: Expressed as a percentage of the target bitrate, a threshold 530df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * overshoot level (current rate vs target) beyond which more agressive 531df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * corrective measures are taken. 532ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 533df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * Valid values in the range VP8:0-1000 VP9: 0-100. 534ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5357bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_overshoot_pct; 536ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5377bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 5387bc9febe8749e98a3812a0dc4380ceae75c29450Johann * decoder buffer model parameters 5397bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 540ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5417bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Decoder Buffer Size 542ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 5437bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value indicates the amount of data that may be buffered by the 5447bc9febe8749e98a3812a0dc4380ceae75c29450Johann * decoding application. Note that this value is expressed in units of 5457bc9febe8749e98a3812a0dc4380ceae75c29450Johann * time (milliseconds). For example, a value of 5000 indicates that the 5467bc9febe8749e98a3812a0dc4380ceae75c29450Johann * client will buffer (at least) 5000ms worth of encoded data. Use the 5477bc9febe8749e98a3812a0dc4380ceae75c29450Johann * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if 5487bc9febe8749e98a3812a0dc4380ceae75c29450Johann * necessary. 549ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5507bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_buf_sz; 551ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5527bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Decoder Buffer Initial Size 553ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 5547bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value indicates the amount of data that will be buffered by the 5557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * decoding application prior to beginning playback. This value is 5567bc9febe8749e98a3812a0dc4380ceae75c29450Johann * expressed in units of time (milliseconds). Use the target bitrate 5577bc9febe8749e98a3812a0dc4380ceae75c29450Johann * (#rc_target_bitrate) to convert to bits/bytes, if necessary. 558ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5597bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_buf_initial_sz; 560ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5617bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Decoder Buffer Optimal Size 562ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 5637bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value indicates the amount of data that the encoder should try 5647bc9febe8749e98a3812a0dc4380ceae75c29450Johann * to maintain in the decoder's buffer. This value is expressed in units 5657bc9febe8749e98a3812a0dc4380ceae75c29450Johann * of time (milliseconds). Use the target bitrate (#rc_target_bitrate) 5667bc9febe8749e98a3812a0dc4380ceae75c29450Johann * to convert to bits/bytes, if necessary. 567ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5687bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_buf_optimal_sz; 569ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5707bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 5717bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 2 pass rate control parameters 5727bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 573ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5747bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Two-pass mode CBR/VBR bias 575ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 5767bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Bias, expressed on a scale of 0 to 100, for determining target size 5777bc9febe8749e98a3812a0dc4380ceae75c29450Johann * for the current frame. The value 0 indicates the optimal CBR mode 5787bc9febe8749e98a3812a0dc4380ceae75c29450Johann * value should be used. The value 100 indicates the optimal VBR mode 5797bc9febe8749e98a3812a0dc4380ceae75c29450Johann * value should be used. Values in between indicate which way the 5807bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoder should "lean." 581ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5827bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_2pass_vbr_bias_pct; 583ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 5847bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Two-pass mode per-GOP minimum bitrate 585ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 5867bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value, expressed as a percentage of the target bitrate, indicates 5877bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the minimum bitrate to be used for a single GOP (aka "section") 5887bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 5897bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_2pass_vbr_minsection_pct; 5907bc9febe8749e98a3812a0dc4380ceae75c29450Johann 5917bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Two-pass mode per-GOP maximum bitrate 592ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 5937bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value, expressed as a percentage of the target bitrate, indicates 5947bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the maximum bitrate to be used for a single GOP (aka "section") 595ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5967bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int rc_2pass_vbr_maxsection_pct; 597ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 598df37111358d02836cb29bbcb9c6e4c95dff90a16Johann /*!\brief Two-pass corpus vbr mode complexity control 599df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * Used only in VP9: A value representing the corpus midpoint complexity 600df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * for corpus vbr mode. This value defaults to 0 which disables corpus vbr 601df37111358d02836cb29bbcb9c6e4c95dff90a16Johann * mode in favour of normal vbr mode. 602df37111358d02836cb29bbcb9c6e4c95dff90a16Johann */ 603df37111358d02836cb29bbcb9c6e4c95dff90a16Johann unsigned int rc_2pass_vbr_corpus_complexity; 604df37111358d02836cb29bbcb9c6e4c95dff90a16Johann 6057bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 6067bc9febe8749e98a3812a0dc4380ceae75c29450Johann * keyframing settings (kf) 6077bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 608ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 6097bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Keyframe placement mode 610ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6117bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value indicates whether the encoder should place keyframes at a 6127bc9febe8749e98a3812a0dc4380ceae75c29450Johann * fixed interval, or determine the optimal placement automatically 6137bc9febe8749e98a3812a0dc4380ceae75c29450Johann * (as governed by the #kf_min_dist and #kf_max_dist parameters) 6147bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6157bc9febe8749e98a3812a0dc4380ceae75c29450Johann enum vpx_kf_mode kf_mode; 6167bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6177bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Keyframe minimum interval 618ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6197bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value, expressed as a number of frames, prevents the encoder from 6207bc9febe8749e98a3812a0dc4380ceae75c29450Johann * placing a keyframe nearer than kf_min_dist to the previous keyframe. At 6217bc9febe8749e98a3812a0dc4380ceae75c29450Johann * least kf_min_dist frames non-keyframes will be coded before the next 6227bc9febe8749e98a3812a0dc4380ceae75c29450Johann * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval. 6237bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6247bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int kf_min_dist; 6257bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6267bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Keyframe maximum interval 627ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6287bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value, expressed as a number of frames, forces the encoder to code 6297bc9febe8749e98a3812a0dc4380ceae75c29450Johann * a keyframe if one has not been coded in the last kf_max_dist frames. 6307bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A value of 0 implies all frames will be keyframes. Set kf_min_dist 6317bc9febe8749e98a3812a0dc4380ceae75c29450Johann * equal to kf_max_dist for a fixed interval. 632ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 6337bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int kf_max_dist; 63490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 6357bc9febe8749e98a3812a0dc4380ceae75c29450Johann /* 6367bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Spatial scalability settings (ss) 6377bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 63890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 6397bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Number of spatial coding layers. 640ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6417bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value specifies the number of spatial coding layers to be used. 642ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 6437bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ss_number_layers; 6447bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6457bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Enable auto alt reference flags for each spatial layer. 646ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6477bc9febe8749e98a3812a0dc4380ceae75c29450Johann * These values specify if auto alt reference frame is enabled for each 6487bc9febe8749e98a3812a0dc4380ceae75c29450Johann * spatial layer. 649ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 6507bc9febe8749e98a3812a0dc4380ceae75c29450Johann int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS]; 651ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 6527bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Target bitrate for each spatial layer. 6537bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 6547bc9febe8749e98a3812a0dc4380ceae75c29450Johann * These values specify the target coding bitrate to be used for each 6557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * spatial layer. 6567bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6577bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS]; 658ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 6597bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Number of temporal coding layers. 660ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6617bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value specifies the number of temporal layers to be used. 6627bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6637bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ts_number_layers; 6647bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6657bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Target bitrate for each temporal layer. 666ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6677bc9febe8749e98a3812a0dc4380ceae75c29450Johann * These values specify the target coding bitrate to be used for each 6687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * temporal layer. 6697bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6707bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS]; 6717bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6727bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Frame rate decimation factor for each temporal layer. 673ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * These values specify the frame rate decimation factors to apply 6757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * to each temporal layer. 6767bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6777bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS]; 6787bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6797bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Length of the sequence defining frame temporal layer membership. 680ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6817bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This value specifies the length of the sequence that defines the 6827bc9febe8749e98a3812a0dc4380ceae75c29450Johann * membership of frames to temporal layers. For example, if the 6837bc9febe8749e98a3812a0dc4380ceae75c29450Johann * ts_periodicity = 8, then the frames are assigned to coding layers with a 6847bc9febe8749e98a3812a0dc4380ceae75c29450Johann * repeated sequence of length 8. 6857bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6867bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ts_periodicity; 6877bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6887bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Template defining the membership of frames to temporal layers. 689ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6907bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This array defines the membership of frames to temporal coding layers. 6917bc9febe8749e98a3812a0dc4380ceae75c29450Johann * For a 2-layer encoding that assigns even numbered frames to one temporal 6927bc9febe8749e98a3812a0dc4380ceae75c29450Johann * layer (0) and odd numbered frames to a second temporal layer (1) with 6937bc9febe8749e98a3812a0dc4380ceae75c29450Johann * ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1). 6947bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 6957bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY]; 6967bc9febe8749e98a3812a0dc4380ceae75c29450Johann 6977bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Target bitrate for each spatial/temporal layer. 698ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 6997bc9febe8749e98a3812a0dc4380ceae75c29450Johann * These values specify the target coding bitrate to be used for each 7007bc9febe8749e98a3812a0dc4380ceae75c29450Johann * spatial/temporal layer. 701ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 702ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 7037bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int layer_target_bitrate[VPX_MAX_LAYERS]; 704ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7057bc9febe8749e98a3812a0dc4380ceae75c29450Johann /*!\brief Temporal layering mode indicating which temporal layering scheme to 7067bc9febe8749e98a3812a0dc4380ceae75c29450Johann * use. 707ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 7087bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the 7097bc9febe8749e98a3812a0dc4380ceae75c29450Johann * temporal layering mode to use. 710ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 711ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 7127bc9febe8749e98a3812a0dc4380ceae75c29450Johann int temporal_layering_mode; 7137bc9febe8749e98a3812a0dc4380ceae75c29450Johann} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */ 714ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7157bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief vp9 svc extra configure parameters 7167bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7177bc9febe8749e98a3812a0dc4380ceae75c29450Johann * This defines max/min quantizers and scale factors for each layer 7187bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7197bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 7207bc9febe8749e98a3812a0dc4380ceae75c29450Johanntypedef struct vpx_svc_parameters { 7217bc9febe8749e98a3812a0dc4380ceae75c29450Johann int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */ 7227bc9febe8749e98a3812a0dc4380ceae75c29450Johann int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */ 7237bc9febe8749e98a3812a0dc4380ceae75c29450Johann int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */ 7247bc9febe8749e98a3812a0dc4380ceae75c29450Johann int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */ 7257bc9febe8749e98a3812a0dc4380ceae75c29450Johann int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */ 7267bc9febe8749e98a3812a0dc4380ceae75c29450Johann int temporal_layering_mode; /**< Temporal layering mode */ 7277bc9febe8749e98a3812a0dc4380ceae75c29450Johann} vpx_svc_extra_cfg_t; 7287bc9febe8749e98a3812a0dc4380ceae75c29450Johann 7297bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Initialize an encoder instance 7307bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7317bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Initializes a encoder context using the given interface. Applications 7327bc9febe8749e98a3812a0dc4380ceae75c29450Johann * should call the vpx_codec_enc_init convenience macro instead of this 7337bc9febe8749e98a3812a0dc4380ceae75c29450Johann * function directly, to ensure that the ABI version number parameter 7347bc9febe8749e98a3812a0dc4380ceae75c29450Johann * is properly initialized. 7357bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7367bc9febe8749e98a3812a0dc4380ceae75c29450Johann * If the library was configured with --disable-multithread, this call 7377bc9febe8749e98a3812a0dc4380ceae75c29450Johann * is not thread safe and should be guarded with a lock if being used 7387bc9febe8749e98a3812a0dc4380ceae75c29450Johann * in a multithreaded context. 7397bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7407bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context. 7417bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] iface Pointer to the algorithm interface to use. 7427bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] cfg Configuration to use, if known. May be NULL. 7437bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] flags Bitfield of VPX_CODEC_USE_* flags 7447bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ver ABI version number. Must be set to 7457bc9febe8749e98a3812a0dc4380ceae75c29450Johann * VPX_ENCODER_ABI_VERSION 7467bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_OK 7477bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The decoder algorithm initialized. 7487bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_MEM_ERROR 7497bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Memory allocation failed. 7507bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 7517bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx, 7527bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_iface_t *iface, 7537bc9febe8749e98a3812a0dc4380ceae75c29450Johann const vpx_codec_enc_cfg_t *cfg, 7547bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_flags_t flags, int ver); 755ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7567bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Convenience macro for vpx_codec_enc_init_ver() 7577bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7587bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Ensures the ABI version parameter is properly set. 7597bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 7607bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define vpx_codec_enc_init(ctx, iface, cfg, flags) \ 7617bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION) 7627bc9febe8749e98a3812a0dc4380ceae75c29450Johann 7637bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Initialize multi-encoder instance 7647bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7657bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Initializes multi-encoder context using the given interface. 7667bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Applications should call the vpx_codec_enc_init_multi convenience macro 7677bc9febe8749e98a3812a0dc4380ceae75c29450Johann * instead of this function directly, to ensure that the ABI version number 7687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * parameter is properly initialized. 7697bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7707bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context. 7717bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] iface Pointer to the algorithm interface to use. 7727bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] cfg Configuration to use, if known. May be NULL. 7737bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] num_enc Total number of encoders. 7747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] flags Bitfield of VPX_CODEC_USE_* flags 7757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] dsf Pointer to down-sampling factors. 7767bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ver ABI version number. Must be set to 7777bc9febe8749e98a3812a0dc4380ceae75c29450Johann * VPX_ENCODER_ABI_VERSION 7787bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_OK 7797bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The decoder algorithm initialized. 7807bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_MEM_ERROR 7817bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Memory allocation failed. 7827bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 7837bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_codec_err_t vpx_codec_enc_init_multi_ver( 7847bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, 7857bc9febe8749e98a3812a0dc4380ceae75c29450Johann int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver); 7867bc9febe8749e98a3812a0dc4380ceae75c29450Johann 7877bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Convenience macro for vpx_codec_enc_init_multi_ver() 7887bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7897bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Ensures the ABI version parameter is properly set. 7907bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 7917bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \ 7927bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \ 7937bc9febe8749e98a3812a0dc4380ceae75c29450Johann VPX_ENCODER_ABI_VERSION) 7947bc9febe8749e98a3812a0dc4380ceae75c29450Johann 7957bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Get a default configuration 7967bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 7977bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Initializes a encoder configuration structure with default values. Supports 7987bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the notion of "usages" so that an algorithm may offer different default 7997bc9febe8749e98a3812a0dc4380ceae75c29450Johann * settings depending on the user's intended goal. This function \ref SHOULD 8007bc9febe8749e98a3812a0dc4380ceae75c29450Johann * be called by all applications to initialize the configuration structure 8017bc9febe8749e98a3812a0dc4380ceae75c29450Johann * before specializing the configuration with application specific values. 8027bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8037bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] iface Pointer to the algorithm interface to use. 8047bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[out] cfg Configuration buffer to populate. 8057bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] reserved Must set to 0 for VP8 and VP9. 8067bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8077bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_OK 8087bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The configuration was populated. 8097bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INCAPABLE 8107bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Interface is not an encoder interface. 8117bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INVALID_PARAM 8127bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A parameter was NULL, or the usage value was not recognized. 8137bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 8147bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface, 8157bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_enc_cfg_t *cfg, 8167bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int reserved); 8177bc9febe8749e98a3812a0dc4380ceae75c29450Johann 8187bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Set or change configuration 8197bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8207bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Reconfigures an encoder instance according to the given configuration. 8217bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8227bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context 8237bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] cfg Configuration buffer to use 8247bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8257bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_OK 8267bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The configuration was populated. 8277bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INCAPABLE 8287bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Interface is not an encoder interface. 8297bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INVALID_PARAM 8307bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A parameter was NULL, or the usage value was not recognized. 8317bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 8327bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx, 8337bc9febe8749e98a3812a0dc4380ceae75c29450Johann const vpx_codec_enc_cfg_t *cfg); 8347bc9febe8749e98a3812a0dc4380ceae75c29450Johann 8357bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Get global stream headers 8367bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8377bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Retrieves a stream level global header packet, if supported by the codec. 8387bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8397bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context 8407bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8417bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval NULL 8427bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Encoder does not support global header 8437bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval Non-NULL 8447bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Pointer to buffer containing global header packet 8457bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 8467bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx); 8477bc9febe8749e98a3812a0dc4380ceae75c29450Johann 8487bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief deadline parameter analogous to VPx REALTIME mode. */ 8497bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_DL_REALTIME (1) 8507bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief deadline parameter analogous to VPx GOOD QUALITY mode. */ 8517bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_DL_GOOD_QUALITY (1000000) 8527bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief deadline parameter analogous to VPx BEST QUALITY mode. */ 8537bc9febe8749e98a3812a0dc4380ceae75c29450Johann#define VPX_DL_BEST_QUALITY (0) 8547bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encode a frame 8557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8567bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Encodes a video frame at the given "presentation time." The presentation 8577bc9febe8749e98a3812a0dc4380ceae75c29450Johann * time stamp (PTS) \ref MUST be strictly increasing. 8587bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8597bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The encoder supports the notion of a soft real-time deadline. Given a 8607bc9febe8749e98a3812a0dc4380ceae75c29450Johann * non-zero value to the deadline parameter, the encoder will make a "best 8617bc9febe8749e98a3812a0dc4380ceae75c29450Johann * effort" guarantee to return before the given time slice expires. It is 8627bc9febe8749e98a3812a0dc4380ceae75c29450Johann * implicit that limiting the available time to encode will degrade the 8637bc9febe8749e98a3812a0dc4380ceae75c29450Johann * output quality. The encoder can be given an unlimited time to produce the 8647bc9febe8749e98a3812a0dc4380ceae75c29450Johann * best possible frame by specifying a deadline of '0'. This deadline 8657bc9febe8749e98a3812a0dc4380ceae75c29450Johann * supercedes the VPx notion of "best quality, good quality, realtime". 8667bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Applications that wish to map these former settings to the new deadline 8677bc9febe8749e98a3812a0dc4380ceae75c29450Johann * based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY, 8687bc9febe8749e98a3812a0dc4380ceae75c29450Johann * and #VPX_DL_BEST_QUALITY. 8697bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8707bc9febe8749e98a3812a0dc4380ceae75c29450Johann * When the last frame has been passed to the encoder, this function should 8717bc9febe8749e98a3812a0dc4380ceae75c29450Johann * continue to be called, with the img parameter set to NULL. This will 8727bc9febe8749e98a3812a0dc4380ceae75c29450Johann * signal the end-of-stream condition to the encoder and allow it to encode 8737bc9febe8749e98a3812a0dc4380ceae75c29450Johann * any held buffers. Encoding is complete when vpx_codec_encode() is called 8747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * and vpx_codec_get_cx_data() returns no data. 8757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8767bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context 8777bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] img Image data to encode, NULL to flush. 8787bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] pts Presentation time stamp, in timebase units. 8797bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] duration Duration to show frame, in timebase units. 8807bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] flags Flags to use for encoding this frame. 8817bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] deadline Time to spend encoding, in microseconds. (0=infinite) 8827bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8837bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_OK 8847bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The configuration was populated. 8857bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INCAPABLE 8867bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Interface is not an encoder interface. 8877bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INVALID_PARAM 8887bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A parameter was NULL, the image format is unsupported, etc. 8897bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 8907bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img, 8917bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_pts_t pts, unsigned long duration, 8927bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_enc_frame_flags_t flags, 8937bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned long deadline); 8947bc9febe8749e98a3812a0dc4380ceae75c29450Johann 8957bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Set compressed data output buffer 8967bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 8977bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Sets the buffer that the codec should output the compressed data 8987bc9febe8749e98a3812a0dc4380ceae75c29450Johann * into. This call effectively sets the buffer pointer returned in the 8997bc9febe8749e98a3812a0dc4380ceae75c29450Johann * next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be 9007bc9febe8749e98a3812a0dc4380ceae75c29450Johann * appended into this buffer. The buffer is preserved across frames, 9017bc9febe8749e98a3812a0dc4380ceae75c29450Johann * so applications must periodically call this function after flushing 9027bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the accumulated compressed data to disk or to the network to reset 9037bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the pointer to the buffer's head. 9047bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9057bc9febe8749e98a3812a0dc4380ceae75c29450Johann * `pad_before` bytes will be skipped before writing the compressed 9067bc9febe8749e98a3812a0dc4380ceae75c29450Johann * data, and `pad_after` bytes will be appended to the packet. The size 9077bc9febe8749e98a3812a0dc4380ceae75c29450Johann * of the packet will be the sum of the size of the actual compressed 9087bc9febe8749e98a3812a0dc4380ceae75c29450Johann * data, pad_before, and pad_after. The padding bytes will be preserved 9097bc9febe8749e98a3812a0dc4380ceae75c29450Johann * (not overwritten). 9107bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9117bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Note that calling this function does not guarantee that the returned 9127bc9febe8749e98a3812a0dc4380ceae75c29450Johann * compressed data will be placed into the specified buffer. In the 9137bc9febe8749e98a3812a0dc4380ceae75c29450Johann * event that the encoded data will not fit into the buffer provided, 9147bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the returned packet \ref MAY point to an internal buffer, as it would 9157bc9febe8749e98a3812a0dc4380ceae75c29450Johann * if this call were never used. In this event, the output packet will 9167bc9febe8749e98a3812a0dc4380ceae75c29450Johann * NOT have any padding, and the application must free space and copy it 9177bc9febe8749e98a3812a0dc4380ceae75c29450Johann * to the proper place. This is of particular note in configurations 9187bc9febe8749e98a3812a0dc4380ceae75c29450Johann * that may output multiple packets for a single encoded frame (e.g., lagged 9197bc9febe8749e98a3812a0dc4380ceae75c29450Johann * encoding) or if the application does not reset the buffer periodically. 9207bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9217bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Applications may restore the default behavior of the codec providing 9227bc9febe8749e98a3812a0dc4380ceae75c29450Johann * the compressed data buffer by calling this function with a NULL 9237bc9febe8749e98a3812a0dc4380ceae75c29450Johann * buffer. 9247bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9257bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Applications \ref MUSTNOT call this function during iteration of 9267bc9febe8749e98a3812a0dc4380ceae75c29450Johann * vpx_codec_get_cx_data(). 9277bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9287bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context 9297bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] buf Buffer to store compressed data into 9307bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] pad_before Bytes to skip before writing compressed data 9317bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] pad_after Bytes to skip after writing compressed data 9327bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9337bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_OK 9347bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The buffer was set successfully. 9357bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \retval #VPX_CODEC_INVALID_PARAM 9367bc9febe8749e98a3812a0dc4380ceae75c29450Johann * A parameter was NULL, the image format is unsupported, etc. 9377bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 9387bc9febe8749e98a3812a0dc4380ceae75c29450Johannvpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx, 9397bc9febe8749e98a3812a0dc4380ceae75c29450Johann const vpx_fixed_buf_t *buf, 9407bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int pad_before, 9417bc9febe8749e98a3812a0dc4380ceae75c29450Johann unsigned int pad_after); 9427bc9febe8749e98a3812a0dc4380ceae75c29450Johann 9437bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Encoded data iterator 9447bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9457bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Iterates over a list of data packets to be passed from the encoder to the 9467bc9febe8749e98a3812a0dc4380ceae75c29450Johann * application. The different kinds of packets available are enumerated in 9477bc9febe8749e98a3812a0dc4380ceae75c29450Johann * #vpx_codec_cx_pkt_kind. 9487bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9497bc9febe8749e98a3812a0dc4380ceae75c29450Johann * #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's 9507bc9febe8749e98a3812a0dc4380ceae75c29450Johann * muxer. Multiple compressed frames may be in the list. 9517bc9febe8749e98a3812a0dc4380ceae75c29450Johann * #VPX_CODEC_STATS_PKT packets should be appended to a global buffer. 9527bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9537bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The application \ref MUST silently ignore any packet kinds that it does 9547bc9febe8749e98a3812a0dc4380ceae75c29450Johann * not recognize or support. 9557bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9567bc9febe8749e98a3812a0dc4380ceae75c29450Johann * The data buffers returned from this function are only guaranteed to be 9577bc9febe8749e98a3812a0dc4380ceae75c29450Johann * valid until the application makes another call to any vpx_codec_* function. 9587bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9597bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context 9607bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in,out] iter Iterator storage, initialized to NULL 9617bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9627bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \return Returns a pointer to an output data packet (compressed frame data, 9637bc9febe8749e98a3812a0dc4380ceae75c29450Johann * two-pass statistics, etc.) or NULL to signal end-of-list. 9647bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9657bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 9667bc9febe8749e98a3812a0dc4380ceae75c29450Johannconst vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx, 9677bc9febe8749e98a3812a0dc4380ceae75c29450Johann vpx_codec_iter_t *iter); 9687bc9febe8749e98a3812a0dc4380ceae75c29450Johann 9697bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!\brief Get Preview Frame 9707bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9717bc9febe8749e98a3812a0dc4380ceae75c29450Johann * Returns an image that can be used as a preview. Shows the image as it would 9727bc9febe8749e98a3812a0dc4380ceae75c29450Johann * exist at the decompressor. The application \ref MUST NOT write into this 9737bc9febe8749e98a3812a0dc4380ceae75c29450Johann * image buffer. 9747bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9757bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \param[in] ctx Pointer to this instance's context 9767bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9777bc9febe8749e98a3812a0dc4380ceae75c29450Johann * \return Returns a pointer to a preview image, or NULL if no image is 9787bc9febe8749e98a3812a0dc4380ceae75c29450Johann * available. 9797bc9febe8749e98a3812a0dc4380ceae75c29450Johann * 9807bc9febe8749e98a3812a0dc4380ceae75c29450Johann */ 9817bc9febe8749e98a3812a0dc4380ceae75c29450Johannconst vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx); 9827bc9febe8749e98a3812a0dc4380ceae75c29450Johann 9837bc9febe8749e98a3812a0dc4380ceae75c29450Johann/*!@} - end defgroup encoder*/ 98490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#ifdef __cplusplus 98590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 98690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#endif 9872ec72e65689c948e92b826ae1e867bf369e72f13Vignesh Venkatasubramanian#endif // VPX_VPX_ENCODER_H_ 988