2015-05-18 08:43:10 +00:00
|
|
|
#ifndef KVAZAAR_H_
|
|
|
|
#define KVAZAAR_H_
|
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
|
|
|
|
* COPYING file).
|
|
|
|
*
|
|
|
|
* Kvazaar is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2.1 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-12-17 11:42:57 +00:00
|
|
|
/**
|
|
|
|
* \ingroup Control
|
2015-05-18 08:43:10 +00:00
|
|
|
* \file
|
2015-12-17 11:42:57 +00:00
|
|
|
* This file defines the public API of Kvazaar when used as a library.
|
2015-05-18 08:43:10 +00:00
|
|
|
*/
|
|
|
|
|
2016-01-22 13:07:49 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
2015-05-18 08:43:10 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-12-21 12:38:59 +00:00
|
|
|
#if defined(KVZ_DLL_EXPORTS)
|
|
|
|
#if !defined(PIC)
|
|
|
|
// Building static kvazaar library.
|
|
|
|
#define KVZ_PUBLIC
|
|
|
|
#elif defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
// Building kvazaar DLL on Windows.
|
2015-07-13 11:20:21 +00:00
|
|
|
#define KVZ_PUBLIC __declspec(dllexport)
|
2015-12-21 12:38:59 +00:00
|
|
|
#elif defined(__GNUC__)
|
|
|
|
// Building kvazaar shared library with GCC.
|
|
|
|
#define KVZ_PUBLIC __attribute__ ((visibility ("default")))
|
2015-07-13 11:20:21 +00:00
|
|
|
#else
|
2015-12-21 12:38:59 +00:00
|
|
|
#define KVZ_PUBLIC
|
2015-07-13 11:20:21 +00:00
|
|
|
#endif
|
|
|
|
#else
|
2015-12-21 12:38:59 +00:00
|
|
|
#if defined(KVZ_STATIC_LIB)
|
|
|
|
// Using static kvazaar library.
|
|
|
|
#define KVZ_PUBLIC
|
|
|
|
#elif defined(_WIN32) || defined(__CYGWIN__)
|
|
|
|
// Using kvazaar DLL on Windows.
|
|
|
|
#define KVZ_PUBLIC __declspec(dllimport)
|
|
|
|
#else
|
|
|
|
// Using kvazaar shared library and not on Windows.
|
|
|
|
#define KVZ_PUBLIC
|
|
|
|
#endif
|
2015-07-13 11:20:21 +00:00
|
|
|
#endif
|
|
|
|
|
2015-06-30 07:32:51 +00:00
|
|
|
/**
|
|
|
|
* Maximum length of a GoP structure.
|
|
|
|
*/
|
2015-06-30 07:36:09 +00:00
|
|
|
#define KVZ_MAX_GOP_LENGTH 32
|
2015-05-18 15:21:23 +00:00
|
|
|
|
2015-06-30 09:04:00 +00:00
|
|
|
/**
|
|
|
|
* Size of data chunks.
|
|
|
|
*/
|
|
|
|
#define KVZ_DATA_CHUNK_SIZE 4096
|
|
|
|
|
2015-06-30 07:38:17 +00:00
|
|
|
#define KVZ_BIT_DEPTH 8
|
|
|
|
#if KVZ_BIT_DEPTH == 8
|
2015-06-30 08:43:48 +00:00
|
|
|
typedef uint8_t kvz_pixel;
|
2015-05-18 15:21:23 +00:00
|
|
|
#else
|
2015-06-30 08:43:48 +00:00
|
|
|
typedef uint16_t kvz_pixel;
|
2015-05-18 15:21:23 +00:00
|
|
|
#endif
|
|
|
|
|
2015-06-30 10:14:24 +00:00
|
|
|
/**
|
2015-07-06 06:47:18 +00:00
|
|
|
* \brief Opaque data structure representing one instance of the encoder.
|
2015-06-30 10:14:24 +00:00
|
|
|
*/
|
|
|
|
typedef struct kvz_encoder kvz_encoder;
|
|
|
|
|
2015-07-06 06:47:18 +00:00
|
|
|
/**
|
|
|
|
* \brief Integer motion estimation algorithms.
|
|
|
|
*/
|
|
|
|
enum kvz_ime_algorithm {
|
|
|
|
KVZ_IME_HEXBS = 0,
|
|
|
|
KVZ_IME_TZ = 1,
|
2015-11-20 07:50:01 +00:00
|
|
|
KVZ_IME_FULL = 2,
|
2015-07-06 06:47:18 +00:00
|
|
|
};
|
|
|
|
|
2015-06-30 07:32:51 +00:00
|
|
|
/**
|
|
|
|
* \brief GoP picture configuration.
|
|
|
|
*/
|
2015-06-30 08:03:26 +00:00
|
|
|
typedef struct kvz_gop_config {
|
2015-06-30 07:32:51 +00:00
|
|
|
double qp_factor;
|
|
|
|
int8_t qp_offset; /*!< \brief QP offset */
|
|
|
|
int8_t poc_offset; /*!< \brief POC offset */
|
|
|
|
int8_t layer; /*!< \brief Current layer */
|
|
|
|
int8_t is_ref; /*!< \brief Flag if this picture is used as a reference */
|
|
|
|
int8_t ref_pos_count;/*!< \brief Reference picture count */
|
|
|
|
int8_t ref_pos[16]; /*!< \brief reference picture offset list */
|
|
|
|
int8_t ref_neg_count;/*!< \brief Reference picture count */
|
|
|
|
int8_t ref_neg[16]; /*!< \brief reference picture offset list */
|
2015-06-30 08:03:26 +00:00
|
|
|
} kvz_gop_config;
|
2015-06-30 07:32:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Struct which contains all configuration data
|
2015-08-25 09:49:17 +00:00
|
|
|
*
|
2016-01-21 13:08:34 +00:00
|
|
|
* Functions config_alloc, config_init and config_destroy must be used to
|
|
|
|
* maintain ABI compatibility. Do not copy this struct, as the size might
|
|
|
|
* change.
|
2015-06-30 07:32:51 +00:00
|
|
|
*/
|
2015-06-30 08:03:26 +00:00
|
|
|
typedef struct kvz_config
|
2015-06-30 07:32:51 +00:00
|
|
|
{
|
|
|
|
int32_t qp; /*!< \brief Quantization parameter */
|
|
|
|
int32_t intra_period; /*!< \brief the period of intra frames in stream */
|
2015-10-15 12:11:12 +00:00
|
|
|
|
|
|
|
/** \brief How often the VPS, SPS and PPS are re-sent
|
|
|
|
*
|
|
|
|
* -1: never
|
|
|
|
* 0: first frame only
|
|
|
|
* 1: every intra frame
|
|
|
|
* 2: every other intra frame
|
|
|
|
* 3: every third intra frame
|
|
|
|
* and so on
|
|
|
|
*/
|
|
|
|
int32_t vps_period;
|
|
|
|
|
2015-08-25 09:49:17 +00:00
|
|
|
int32_t width; /*!< \brief frame width, must be a multiple of 8 */
|
|
|
|
int32_t height; /*!< \brief frame height, must be a multiple of 8 */
|
2016-01-14 20:08:35 +00:00
|
|
|
double framerate; /*!< \brief Deprecated, will be removed. */
|
|
|
|
int32_t framerate_num; /*!< \brief Framerate numerator */
|
|
|
|
int32_t framerate_denom; /*!< \brief Framerate denominator */
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t deblock_enable; /*!< \brief Flag to enable deblocking filter */
|
|
|
|
int32_t sao_enable; /*!< \brief Flag to enable sample adaptive offset filter */
|
|
|
|
int32_t rdoq_enable; /*!< \brief Flag to enable RD optimized quantization. */
|
|
|
|
int32_t signhide_enable; /*!< \brief Flag to enable sign hiding. */
|
2015-12-15 05:57:38 +00:00
|
|
|
int32_t smp_enable; /*!< \brief Flag to enable SMP blocks. */
|
2015-12-01 12:37:58 +00:00
|
|
|
int32_t amp_enable; /*!< \brief Flag to enable AMP blocks. */
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t rdo; /*!< \brief RD-calculation level (0..2) */
|
|
|
|
int32_t full_intra_search; /*!< \brief If true, don't skip modes in intra search. */
|
|
|
|
int32_t trskip_enable; /*!< \brief Flag to enable transform skip (for 4x4 blocks). */
|
|
|
|
int32_t tr_depth_intra; /*!< \brief Maximum transform depth for intra. */
|
2015-07-06 06:47:18 +00:00
|
|
|
enum kvz_ime_algorithm ime_algorithm; /*!< \brief Integer motion estimation algorithm. */
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t fme_level; /*!< \brief Fractional pixel motion estimation level (0: disabled, 1: enabled). */
|
2015-08-13 09:53:14 +00:00
|
|
|
int8_t source_scan_type; /*!< \brief Source scan type (0: progressive, 1: top field first, 2: bottom field first).*/
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t bipred; /*!< \brief Bi-prediction (0: disabled, 1: enabled). */
|
|
|
|
int32_t deblock_beta; /*!< \brief (deblocking) beta offset (div 2), range -6...6 */
|
|
|
|
int32_t deblock_tc; /*!< \brief (deblocking) tc offset (div 2), range -6...6 */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int32_t sar_width; /*!< \brief the horizontal size of the sample aspect ratio (in arbitrary units) */
|
|
|
|
int32_t sar_height; /*!< \brief the vertical size of the sample aspect ratio (in the same arbitrary units as sar_width). */
|
|
|
|
int8_t overscan; /*!< \brief Crop overscan setting */
|
|
|
|
int8_t videoformat; /*!< \brief Video format */
|
|
|
|
int8_t fullrange; /*!< \brief Flag to indicate full-range */
|
|
|
|
int8_t colorprim; /*!< \brief Color primaries */
|
|
|
|
int8_t transfer; /*!< \brief Transfer characteristics */
|
|
|
|
int8_t colormatrix; /*!< \brief Color matrix coefficients */
|
|
|
|
int32_t chroma_loc; /*!< \brief Chroma sample location */
|
|
|
|
} vui;
|
|
|
|
int32_t aud_enable; /*!< \brief Flag to use access unit delimiters */
|
|
|
|
int32_t ref_frames; /*!< \brief number of reference frames to use */
|
|
|
|
char * cqmfile; /*!< \brief Pointer to custom quantization matrices filename */
|
2015-07-06 06:47:18 +00:00
|
|
|
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t tiles_width_count; /*!< \brief number of tiles separation in x direction */
|
|
|
|
int32_t tiles_height_count; /*!< \brief number of tiles separation in y direction */
|
|
|
|
int32_t* tiles_width_split; /*!< \brief tiles split x coordinates (dimension: tiles_width_count) */
|
|
|
|
int32_t* tiles_height_split; /*!< \brief tiles split y coordinates (dimension: tiles_height_count) */
|
2015-07-06 06:47:18 +00:00
|
|
|
|
2015-06-30 07:32:51 +00:00
|
|
|
int wpp;
|
|
|
|
int owf;
|
2015-07-06 06:47:18 +00:00
|
|
|
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t slice_count;
|
|
|
|
int32_t* slice_addresses_in_ts;
|
2015-07-06 06:47:18 +00:00
|
|
|
|
2015-06-30 07:32:51 +00:00
|
|
|
int32_t threads;
|
|
|
|
int32_t cpuid;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int32_t min;
|
|
|
|
int32_t max;
|
|
|
|
} pu_depth_inter, pu_depth_intra;
|
|
|
|
|
|
|
|
int32_t add_encoder_info;
|
|
|
|
int8_t gop_len; /*!< \brief length of GOP for the video sequence */
|
2015-11-02 10:22:25 +00:00
|
|
|
int8_t gop_lowdelay; /*!< \brief specifies that the GOP does not use future pictures */
|
2015-06-30 08:03:26 +00:00
|
|
|
kvz_gop_config gop[KVZ_MAX_GOP_LENGTH]; /*!< \brief Array of GOP settings */
|
2015-06-30 07:32:51 +00:00
|
|
|
|
|
|
|
int32_t target_bitrate;
|
2015-11-05 10:24:03 +00:00
|
|
|
|
|
|
|
int8_t mv_rdo; /*!< \brief MV RDO calculation in search (0: estimation, 1: RDO). */
|
2016-01-21 13:08:34 +00:00
|
|
|
int8_t calc_psnr; /*!< \since 3.1.0 \brief Print PSNR in CLI. */
|
2015-06-30 08:03:26 +00:00
|
|
|
} kvz_config;
|
2015-06-30 07:32:51 +00:00
|
|
|
|
2015-05-18 15:21:23 +00:00
|
|
|
/**
|
2015-08-25 09:49:17 +00:00
|
|
|
* \brief Struct which contains all picture data
|
|
|
|
*
|
|
|
|
* Function picture_alloc in kvz_api must be used for allocation.
|
|
|
|
*/
|
2015-06-30 07:56:29 +00:00
|
|
|
typedef struct kvz_picture {
|
2015-06-30 08:43:48 +00:00
|
|
|
kvz_pixel *fulldata; //!< \brief Allocated buffer (only used in the base_image)
|
2015-05-18 15:21:23 +00:00
|
|
|
|
2015-06-30 08:43:48 +00:00
|
|
|
kvz_pixel *y; //!< \brief Pointer to luma pixel array.
|
|
|
|
kvz_pixel *u; //!< \brief Pointer to chroma U pixel array.
|
|
|
|
kvz_pixel *v; //!< \brief Pointer to chroma V pixel array.
|
|
|
|
kvz_pixel *data[3]; //!< \brief Alternate access method to same data.
|
2015-05-18 15:21:23 +00:00
|
|
|
|
|
|
|
int32_t width; //!< \brief Luma pixel array width.
|
|
|
|
int32_t height; //!< \brief Luma pixel array height.
|
|
|
|
|
|
|
|
int32_t stride; //!< \brief Luma pixel array width for the full picture (should be used as stride)
|
|
|
|
|
2015-06-30 07:56:29 +00:00
|
|
|
struct kvz_picture *base_image; //!< \brief Pointer to the picture which owns the pixels
|
2015-06-17 08:06:09 +00:00
|
|
|
int32_t refcount; //!< \brief Number of references to the picture
|
2015-09-07 08:56:49 +00:00
|
|
|
|
|
|
|
int64_t pts; //!< \brief Presentation timestamp. Should be set for input frames.
|
2015-09-08 08:58:35 +00:00
|
|
|
int64_t dts; //!< \brief Decompression timestamp.
|
2015-06-30 07:56:29 +00:00
|
|
|
} kvz_picture;
|
2015-05-18 08:43:10 +00:00
|
|
|
|
2015-09-15 07:29:10 +00:00
|
|
|
/**
|
|
|
|
* \brief NAL unit type codes.
|
|
|
|
*
|
|
|
|
* These are the nal_unit_type codes from Table 7-1 ITU-T H.265 v1.0.
|
|
|
|
*/
|
|
|
|
enum kvz_nal_unit_type {
|
|
|
|
|
|
|
|
// Trailing pictures
|
|
|
|
|
|
|
|
KVZ_NAL_TRAIL_N = 0,
|
|
|
|
KVZ_NAL_TRAIL_R = 1,
|
|
|
|
|
|
|
|
KVZ_NAL_TSA_N = 2,
|
|
|
|
KVZ_NAL_TSA_R = 3,
|
|
|
|
|
|
|
|
KVZ_NAL_STSA_N = 4,
|
|
|
|
KVZ_NAL_STSA_R = 5,
|
|
|
|
|
|
|
|
// Leading pictures
|
|
|
|
|
|
|
|
KVZ_NAL_RADL_N = 6,
|
|
|
|
KVZ_NAL_RADL_R = 7,
|
|
|
|
|
|
|
|
KVZ_NAL_RASL_N = 8,
|
|
|
|
KVZ_NAL_RASL_R = 9,
|
|
|
|
|
|
|
|
// Reserved non-IRAP RSV_VCL_N/R 10-15
|
|
|
|
|
|
|
|
// Intra random access point pictures
|
|
|
|
|
|
|
|
KVZ_NAL_BLA_W_LP = 16,
|
|
|
|
KVZ_NAL_BLA_W_RADL = 17,
|
|
|
|
KVZ_NAL_BLA_N_LP = 18,
|
|
|
|
|
|
|
|
KVZ_NAL_IDR_W_RADL = 19,
|
|
|
|
KVZ_NAL_IDR_N_LP = 20,
|
|
|
|
|
|
|
|
KVZ_NAL_CRA_NUT = 21,
|
|
|
|
|
|
|
|
// Reserved IRAP
|
|
|
|
|
|
|
|
KVZ_NAL_RSV_IRAP_VCL22 = 22,
|
|
|
|
KVZ_NAL_RSV_IRAP_VCL23 = 23,
|
|
|
|
|
|
|
|
// Reserved non-IRAP RSV_VCL 24-32
|
|
|
|
|
|
|
|
// non-VCL
|
|
|
|
|
|
|
|
KVZ_NAL_VPS_NUT = 32,
|
|
|
|
KVZ_NAL_SPS_NUT = 33,
|
|
|
|
KVZ_NAL_PPS_NUT = 34,
|
|
|
|
|
|
|
|
KVZ_NAL_AUD_NUT = 35,
|
|
|
|
KVZ_NAL_EOS_NUT = 36,
|
|
|
|
KVZ_NAL_EOB_NUT = 37,
|
|
|
|
KVZ_NAL_FD_NUT = 38,
|
|
|
|
|
|
|
|
KVZ_NAL_PREFIX_SEI_NUT = 39,
|
|
|
|
KVZ_NAL_SUFFIX_SEI_NUT = 40,
|
|
|
|
|
|
|
|
// Reserved RSV_NVCL 41-47
|
|
|
|
// Unspecified UNSPEC 48-63
|
|
|
|
};
|
|
|
|
|
2015-09-08 10:59:55 +00:00
|
|
|
enum kvz_slice_type {
|
|
|
|
KVZ_SLICE_B = 0,
|
|
|
|
KVZ_SLICE_P = 1,
|
|
|
|
KVZ_SLICE_I = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Other information about an encoded frame
|
|
|
|
*/
|
|
|
|
typedef struct kvz_frame_info {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Picture order count
|
|
|
|
*/
|
|
|
|
int32_t poc;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Quantization parameter
|
|
|
|
*/
|
|
|
|
int8_t qp;
|
|
|
|
|
2015-09-15 07:29:10 +00:00
|
|
|
/**
|
|
|
|
* \brief Type of the NAL VCL unit
|
|
|
|
*/
|
|
|
|
enum kvz_nal_unit_type nal_unit_type;
|
|
|
|
|
2015-09-08 10:59:55 +00:00
|
|
|
/**
|
|
|
|
* \brief Type of the slice
|
|
|
|
*/
|
|
|
|
enum kvz_slice_type slice_type;
|
|
|
|
|
2015-09-09 07:16:59 +00:00
|
|
|
/**
|
|
|
|
* \brief Reference picture lists
|
|
|
|
*
|
|
|
|
* The first list contains the reference picture POCs that are less than the
|
|
|
|
* POC of this frame and the second one contains those that are greater.
|
|
|
|
*/
|
|
|
|
int ref_list[2][16];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Lengths of the reference picture lists
|
|
|
|
*/
|
|
|
|
int ref_list_len[2];
|
|
|
|
|
2015-09-08 10:59:55 +00:00
|
|
|
} kvz_frame_info;
|
|
|
|
|
2015-06-30 09:04:00 +00:00
|
|
|
/**
|
|
|
|
* \brief A linked list of chunks of data.
|
|
|
|
*
|
|
|
|
* Used for returning the encoded data.
|
|
|
|
*/
|
|
|
|
typedef struct kvz_data_chunk {
|
|
|
|
/// \brief Buffer for the data.
|
|
|
|
uint8_t data[KVZ_DATA_CHUNK_SIZE];
|
|
|
|
|
|
|
|
/// \brief Number of bytes filled in this chunk.
|
|
|
|
uint32_t len;
|
|
|
|
|
|
|
|
/// \brief Next chunk in the list.
|
|
|
|
struct kvz_data_chunk *next;
|
|
|
|
} kvz_data_chunk;
|
|
|
|
|
2015-05-18 08:43:10 +00:00
|
|
|
typedef struct kvz_api {
|
2015-08-25 09:49:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Allocate a kvz_config structure.
|
|
|
|
*
|
|
|
|
* The returned structure should be deallocated by calling config_destroy.
|
|
|
|
*
|
|
|
|
* \return allocated config, or NULL if allocation failed.
|
|
|
|
*/
|
2015-06-30 08:03:26 +00:00
|
|
|
kvz_config * (*config_alloc)(void);
|
2015-05-18 08:43:10 +00:00
|
|
|
|
2015-08-25 09:49:17 +00:00
|
|
|
/**
|
|
|
|
* \brief Deallocate a kvz_config structure.
|
|
|
|
*
|
|
|
|
* If cfg is NULL, do nothing. Otherwise, the given structure must have been
|
|
|
|
* returned from config_alloc.
|
|
|
|
*
|
|
|
|
* \param cfg configuration
|
|
|
|
* \return 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int (*config_destroy)(kvz_config *cfg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Initialize a config structure
|
|
|
|
*
|
|
|
|
* Set all fields in the given config to default values.
|
|
|
|
*
|
|
|
|
* \param cfg configuration
|
|
|
|
* \return 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int (*config_init)(kvz_config *cfg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Set an option.
|
|
|
|
*
|
|
|
|
* \param cfg configuration
|
|
|
|
* \param name name of the option to set
|
|
|
|
* \param value value to set
|
|
|
|
* \return 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int (*config_parse)(kvz_config *cfg, const char *name, const char *value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Allocate a kvz_picture.
|
|
|
|
*
|
|
|
|
* The returned kvz_picture should be deallocated by calling picture_free.
|
|
|
|
*
|
|
|
|
* \param width width of luma pixel array to allocate
|
|
|
|
* \param height height of luma pixel array to allocate
|
|
|
|
* \return allocated picture, or NULL if allocation failed.
|
|
|
|
*/
|
2015-06-30 09:11:58 +00:00
|
|
|
kvz_picture * (*picture_alloc)(int32_t width, int32_t height);
|
2015-08-25 09:49:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Deallocate a kvz_picture.
|
|
|
|
*
|
|
|
|
* If pic is NULL, do nothing. Otherwise, the picture must have been returned
|
|
|
|
* from picture_alloc.
|
|
|
|
*/
|
2015-06-30 09:11:58 +00:00
|
|
|
void (*picture_free)(kvz_picture *pic);
|
|
|
|
|
2015-06-30 09:04:00 +00:00
|
|
|
/**
|
2015-08-25 09:49:17 +00:00
|
|
|
* \brief Deallocate a list of data chunks.
|
|
|
|
*
|
|
|
|
* Deallocates the given chunk and all chunks that follow it in the linked
|
|
|
|
* list.
|
2015-06-30 09:04:00 +00:00
|
|
|
*/
|
|
|
|
void (*chunk_free)(kvz_data_chunk *chunk);
|
|
|
|
|
2015-08-25 09:49:17 +00:00
|
|
|
/**
|
|
|
|
* \brief Create an encoder.
|
|
|
|
*
|
|
|
|
* The returned encoder should be closed by calling encoder_close.
|
|
|
|
*
|
|
|
|
* Only one encoder may be open at a time.
|
|
|
|
*
|
|
|
|
* The caller must not modify the config between passing it to this function
|
|
|
|
* and calling encoder_close.
|
|
|
|
*
|
|
|
|
* \param cfg encoder configuration
|
|
|
|
* \return created encoder, or NULL if creation failed.
|
|
|
|
*/
|
|
|
|
kvz_encoder * (*encoder_open)(const kvz_config *cfg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Deallocate an encoder.
|
|
|
|
*
|
|
|
|
* If encoder is NULL, do nothing. Otherwise, the encoder must have been
|
|
|
|
* returned from encoder_open.
|
|
|
|
*/
|
|
|
|
void (*encoder_close)(kvz_encoder *encoder);
|
2015-05-18 08:43:10 +00:00
|
|
|
|
2015-10-14 10:47:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Get parameter sets.
|
|
|
|
*
|
|
|
|
* Encode the VPS, SPS and PPS.
|
|
|
|
*
|
|
|
|
* If data_out is set to non-NULL values, the caller is responsible for
|
|
|
|
* calling chunk_free on it.
|
|
|
|
*
|
|
|
|
* A null pointer may be passed in place of the parameter data_out or len_out
|
|
|
|
* to skip returning the corresponding value.
|
|
|
|
*
|
|
|
|
* \param encoder encoder
|
|
|
|
* \param data_out Returns the encoded parameter sets.
|
|
|
|
* \param len_out Returns number of bytes in the encoded data.
|
|
|
|
* \return 1 on success, 0 on error.
|
|
|
|
*/
|
|
|
|
int (*encoder_headers)(kvz_encoder *encoder,
|
|
|
|
kvz_data_chunk **data_out,
|
|
|
|
uint32_t *len_out);
|
|
|
|
|
2015-06-30 09:04:00 +00:00
|
|
|
/**
|
2015-08-25 09:49:17 +00:00
|
|
|
* \brief Encode one frame.
|
|
|
|
*
|
|
|
|
* Add pic_in to the encoding pipeline. If an encoded frame is ready, return
|
2015-09-09 08:21:39 +00:00
|
|
|
* the bitstream, length of the bitstream, the reconstructed frame, the
|
|
|
|
* original frame and frame info in data_out, len_out, pic_out, src_out and
|
|
|
|
* info_out, respectively. Otherwise, set the output parameters to NULL.
|
2015-08-25 09:49:17 +00:00
|
|
|
*
|
|
|
|
* After passing all of the input frames, the caller should keep calling this
|
|
|
|
* function with pic_in set to NULL, until no more data is returned in the
|
|
|
|
* output parameters.
|
2015-06-30 09:04:00 +00:00
|
|
|
*
|
|
|
|
* The caller must not modify pic_in after passing it to this function.
|
|
|
|
*
|
2015-09-09 08:21:39 +00:00
|
|
|
* If data_out, pic_out and src_out are set to non-NULL values, the caller is
|
|
|
|
* responsible for calling chunk_free and picture_free on them.
|
2015-06-30 09:04:00 +00:00
|
|
|
*
|
2015-08-25 09:49:17 +00:00
|
|
|
* A null pointer may be passed in place of any of the parameters data_out,
|
2015-09-09 08:21:39 +00:00
|
|
|
* len_out, pic_out, src_out or info_out to skip returning the corresponding
|
|
|
|
* value.
|
2015-08-25 09:49:17 +00:00
|
|
|
*
|
|
|
|
* \param encoder encoder
|
|
|
|
* \param pic_in input frame or NULL
|
2015-06-30 09:04:00 +00:00
|
|
|
* \param data_out Returns the encoded data.
|
2015-06-30 09:22:30 +00:00
|
|
|
* \param len_out Returns number of bytes in the encoded data.
|
|
|
|
* \param pic_out Returns the reconstructed picture.
|
2015-09-09 08:21:39 +00:00
|
|
|
* \param src_out Returns the original picture.
|
2015-09-08 10:59:55 +00:00
|
|
|
* \param info_out Returns information about the encoded picture.
|
2015-08-25 09:49:17 +00:00
|
|
|
* \return 1 on success, 0 on error.
|
2015-06-30 09:04:00 +00:00
|
|
|
*/
|
|
|
|
int (*encoder_encode)(kvz_encoder *encoder,
|
|
|
|
kvz_picture *pic_in,
|
2015-06-30 09:22:30 +00:00
|
|
|
kvz_data_chunk **data_out,
|
|
|
|
uint32_t *len_out,
|
2015-09-08 10:59:55 +00:00
|
|
|
kvz_picture **pic_out,
|
2015-09-09 08:21:39 +00:00
|
|
|
kvz_picture **src_out,
|
2015-09-08 10:59:55 +00:00
|
|
|
kvz_frame_info *info_out);
|
2015-05-18 08:43:10 +00:00
|
|
|
} kvz_api;
|
|
|
|
|
2015-07-13 11:20:21 +00:00
|
|
|
|
|
|
|
KVZ_PUBLIC const kvz_api * kvz_api_get(int bit_depth);
|
2015-05-18 08:43:10 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // KVAZAAR_H_
|