NetDesk 1.5.0 — source release

This commit is contained in:
NetDesk committed 2026-10-18 02:02:46 +00:00
commit 40318aafdd
227 files changed
+80798

No files matched your search

+136
View File
@@ -0,0 +1,136 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\defgroup vp8 VP8
* \ingroup codecs
* VP8 is a video compression algorithm that uses motion
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
* prediction error signal and context dependent entropy coding techniques
* based on arithmetic principles. It features:
* - YUV 4:2:0 image format
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
* - 1/4 (1/8) pixel accuracy motion compensated prediction
* - 4x4 DCT transform
* - 128 level linear quantizer
* - In loop deblocking filter
* - Context-based entropy coding
*
* @{
*/
/*!\file
* \brief Provides controls common to both the VP8 encoder and decoder.
*/
#ifndef VPX_VPX_VP8_H_
#define VPX_VPX_VP8_H_
#include "./vpx_codec.h"
#include "./vpx_image.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Control functions
*
* The set of macros define the control functions of VP8 interface
*/
enum vp8_com_control_id {
/*!\brief pass in an external frame into decoder to be used as reference frame
*/
VP8_SET_REFERENCE = 1,
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
* for its control ids. These should be migrated to something like the
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
*/
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
VP8_COMMON_CTRL_ID_MAX,
VP8_DECODER_CTRL_ID_START = 256
};
/*!\brief post process flags
*
* The set of macros define VP8 decoder post processing flags
*/
enum vp8_postproc_level {
VP8_NOFILTERING = 0,
VP8_DEBLOCK = 1 << 0,
VP8_DEMACROBLOCK = 1 << 1,
VP8_ADDNOISE = 1 << 2,
VP8_MFQE = 1 << 3
};
/*!\brief post process flags
*
* This define a structure that describe the post processing settings. For
* the best objective measure (using the PSNR metric) set post_proc_flag
* to VP8_DEBLOCK and deblocking_level to 1.
*/
typedef struct vp8_postproc_cfg {
/*!\brief the types of post processing to be done, should be combination of
* "vp8_postproc_level" */
int post_proc_flag;
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
} vp8_postproc_cfg_t;
/*!\brief reference frame type
*
* The set of macros define the type of VP8 reference frames
*/
typedef enum vpx_ref_frame_type {
VP8_LAST_FRAME = 1,
VP8_GOLD_FRAME = 2,
VP8_ALTR_FRAME = 4
} vpx_ref_frame_type_t;
/*!\brief reference frame data struct
*
* Define the data struct to access vp8 reference frames.
*/
typedef struct vpx_ref_frame {
vpx_ref_frame_type_t frame_type; /**< which reference frame */
vpx_image_t img; /**< reference frame data in image format */
} vpx_ref_frame_t;
/*!\brief VP9 specific reference frame data struct
*
* Define the data struct to access vp9 reference frames.
*/
typedef struct vp9_ref_frame {
int idx; /**< frame index to get (input) */
vpx_image_t img; /**< img structure to populate (output) */
} vp9_ref_frame_t;
/*!\cond */
/*!\brief vp8 decoder control function parameter type
*
* defines the data type for each of VP8 decoder control function requires
*/
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
#define VPX_CTRL_VP8_SET_REFERENCE
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
#define VPX_CTRL_VP8_COPY_REFERENCE
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
#define VPX_CTRL_VP8_SET_POSTPROC
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
#define VPX_CTRL_VP9_GET_REFERENCE
/*!\endcond */
/*! @} - end defgroup vp8 */
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VP8_H_
File diff suppressed because it is too large. Load diff
+228
View File
@@ -0,0 +1,228 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
* \ingroup vp8
*
* @{
*/
/*!\file
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
* interface.
*/
#ifndef VPX_VPX_VP8DX_H_
#define VPX_VPX_VP8DX_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Include controls common to both the encoder and decoder */
#include "./vp8.h"
/*!\name Algorithm interface for VP8
*
* This interface provides the capability to decode VP8 streams.
* @{
*/
/*!\brief A single instance of the VP8 decoder.
*\deprecated This access mechanism is provided for backwards compatibility;
* prefer vpx_codec_vp8_dx().
*/
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
/*!\brief The interface to the VP8 decoder.
*/
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
/*!@} - end algorithm interface member group*/
/*!\name Algorithm interface for VP9
*
* This interface provides the capability to decode VP9 streams.
* @{
*/
/*!\brief A single instance of the VP9 decoder.
*\deprecated This access mechanism is provided for backwards compatibility;
* prefer vpx_codec_vp9_dx().
*/
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
/*!\brief The interface to the VP9 decoder.
*/
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
/*!@} - end algorithm interface member group*/
/*!\enum vp8_dec_control_id
* \brief VP8 decoder control functions
*
* This set of macros define the control functions available for the VP8
* decoder interface.
*
* \sa #vpx_codec_control
*/
enum vp8_dec_control_id {
/** control function to get info on which reference frames were updated
* by the last decode
*/
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
/** check if the indicated frame is corrupted */
VP8D_GET_FRAME_CORRUPTED,
/** control function to get info on which reference frames were used
* by the last decode
*/
VP8D_GET_LAST_REF_USED,
/** decryption function to decrypt encoded buffer data immediately
* before decoding. Takes a vpx_decrypt_init, which contains
* a callback function and opaque context pointer.
*/
VPXD_SET_DECRYPTOR,
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
/** control function to get the dimensions that the current frame is decoded
* at. This may be different to the intended display size for the frame as
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
VP9D_GET_FRAME_SIZE,
/** control function to get the current frame's intended display dimensions
* (as specified in the wrapper or frame header). This may be different to
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
VP9D_GET_DISPLAY_SIZE,
/** control function to get the bit depth of the stream. */
VP9D_GET_BIT_DEPTH,
/** control function to set the byte alignment of the planes in the reference
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
* follows Y plane, and V plane directly follows U plane. Default value is 0.
*/
VP9_SET_BYTE_ALIGNMENT,
/** control function to invert the decoding order to from right to left. The
* function is used in a test to confirm the decoding independence of tile
* columns. The function may be used in application where this order
* of decoding is desired.
*
* TODO(yaowu): Rework the unit test that uses this control, and in a future
* release, this test-only control shall be removed.
*/
VP9_INVERT_TILE_DECODE_ORDER,
/** control function to set the skip loop filter flag. Valid values are
* integers. The decoder will skip the loop filter when its value is set to
* nonzero. If the loop filter is skipped the decoder may accumulate decode
* artifacts. The default value is 0.
*/
VP9_SET_SKIP_LOOP_FILTER,
/** control function to decode SVC stream up to the x spatial layers,
* where x is passed in through the control, and is 0 for base layer.
*/
VP9_DECODE_SVC_SPATIAL_LAYER,
/*!\brief Codec control function to get last decoded frame quantizer.
*
* Return value uses internal quantizer scale defined by the codec.
*
* Supported in codecs: VP8, VP9
*/
VPXD_GET_LAST_QUANTIZER,
/*!\brief Codec control function to set row level multi-threading.
*
* 0 : off, 1 : on
*
* Supported in codecs: VP9
*/
VP9D_SET_ROW_MT,
/*!\brief Codec control function to set loopfilter optimization.
*
* 0 : off, Loop filter is done after all tiles have been decoded
* 1 : on, Loop filter is done immediately after decode without
* waiting for all threads to sync.
*
* Supported in codecs: VP9
*/
VP9D_SET_LOOP_FILTER_OPT,
VP8_DECODER_CTRL_ID_MAX
};
/** Decrypt n bytes of data from input -> output, using the decrypt_state
* passed in VPXD_SET_DECRYPTOR.
*/
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
unsigned char *output, int count);
/*!\brief Structure to hold decryption state
*
* Defines a structure to hold the decryption state and access function.
*/
typedef struct vpx_decrypt_init {
/*! Decrypt callback. */
vpx_decrypt_cb decrypt_cb;
/*! Decryption state. */
void *decrypt_state;
} vpx_decrypt_init;
/*!\cond */
/*!\brief VP8 decoder control function parameter type
*
* Defines the data types that VP8D control functions take. Note that
* additional common controls are defined in vp8.h
*
*/
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
#define VPX_CTRL_VPXD_SET_DECRYPTOR
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
#define VPX_CTRL_VP8D_SET_DECRYPTOR
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
VPX_CTRL_USE_TYPE(VP9_SET_BYTE_ALIGNMENT, int)
#define VPX_CTRL_VP9_SET_BYTE_ALIGNMENT
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
#define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
#define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
VPX_CTRL_USE_TYPE(VP9D_SET_LOOP_FILTER_OPT, int)
#define VPX_CTRL_VP9_SET_LOOP_FILTER_OPT
/*!\endcond */
/*! @} - end defgroup vp8_decoder */
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VP8DX_H_
+475
View File
@@ -0,0 +1,475 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\defgroup codec Common Algorithm Interface
* This abstraction allows applications to easily support multiple video
* formats with minimal code duplication. This section describes the interface
* common to all codecs (both encoders and decoders).
* @{
*/
/*!\file
* \brief Describes the codec algorithm interface to applications.
*
* This file describes the interface between an application and a
* video codec algorithm.
*
* An application instantiates a specific codec instance by using
* vpx_codec_dec_init() or vpx_codec_enc_init() and a pointer to the
* algorithm's interface structure:
* <pre>
* my_app.c:
* extern vpx_codec_iface_t my_codec;
* {
* vpx_codec_ctx_t algo;
* int threads = 4;
* vpx_codec_dec_cfg_t cfg = { threads, 0, 0 };
* res = vpx_codec_dec_init(&algo, &my_codec, &cfg, 0);
* }
* </pre>
*
* Once initialized, the instance is manged using other functions from
* the vpx_codec_* family.
*/
#ifndef VPX_VPX_VPX_CODEC_H_
#define VPX_VPX_VPX_CODEC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_image.h"
#include "./vpx_integer.h"
/*!\brief Decorator indicating a function is deprecated */
#ifndef VPX_DEPRECATED
#if defined(__GNUC__)
#define VPX_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define VPX_DEPRECATED
#else
#define VPX_DEPRECATED
#endif
#endif /* VPX_DEPRECATED */
#ifndef VPX_DECLSPEC_DEPRECATED
#if defined(__GNUC__)
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
#elif defined(_MSC_VER)
/*!\brief \copydoc #VPX_DEPRECATED */
#define VPX_DECLSPEC_DEPRECATED __declspec(deprecated)
#else
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
#endif
#endif /* VPX_DECLSPEC_DEPRECATED */
/*!\brief Decorator indicating a function is potentially unused */
#ifndef VPX_UNUSED
#if defined(__GNUC__) || defined(__clang__)
#define VPX_UNUSED __attribute__((unused))
#else
#define VPX_UNUSED
#endif
#endif /* VPX_UNUSED */
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_CODEC_ABI_VERSION (4 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
/*!\brief Algorithm return codes */
typedef enum {
/*!\brief Operation completed without error */
VPX_CODEC_OK,
/*!\brief Unspecified error */
VPX_CODEC_ERROR,
/*!\brief Memory operation failed */
VPX_CODEC_MEM_ERROR,
/*!\brief ABI version mismatch */
VPX_CODEC_ABI_MISMATCH,
/*!\brief Algorithm does not have required capability */
VPX_CODEC_INCAPABLE,
/*!\brief The given bitstream is not supported.
*
* The bitstream was unable to be parsed at the highest level. The decoder
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
* stream. */
VPX_CODEC_UNSUP_BITSTREAM,
/*!\brief Encoded bitstream uses an unsupported feature
*
* The decoder does not implement a feature required by the encoder. This
* return code should only be used for features that prevent future
* pictures from being properly decoded. This error \ref MAY be treated as
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
*/
VPX_CODEC_UNSUP_FEATURE,
/*!\brief The coded data for this stream is corrupt or incomplete
*
* There was a problem decoding the current frame. This return code
* should only be used for failures that prevent future pictures from
* being properly decoded. This error \ref MAY be treated as fatal to the
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
* is continued for the current GOP, artifacts may be present.
*/
VPX_CODEC_CORRUPT_FRAME,
/*!\brief An application-supplied parameter is not valid.
*
*/
VPX_CODEC_INVALID_PARAM,
/*!\brief An iterator reached the end of list.
*
*/
VPX_CODEC_LIST_END
} vpx_codec_err_t;
/*! \brief Codec capabilities bitfield
*
* Each codec advertises the capabilities it supports as part of its
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
* or functionality, and are not required to be supported.
*
* The available flags are specified by VPX_CODEC_CAP_* defines.
*/
typedef long vpx_codec_caps_t;
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
/*! Can support images at greater than 8 bitdepth.
*/
#define VPX_CODEC_CAP_HIGHBITDEPTH 0x4
/*! \brief Initialization-time Feature Enabling
*
* Certain codec features must be known at initialization time, to allow for
* proper memory allocation.
*
* The available flags are specified by VPX_CODEC_USE_* defines.
*/
typedef long vpx_codec_flags_t;
/*!\brief Codec interface structure.
*
* Contains function pointers and other data private to the codec
* implementation. This structure is opaque to the application.
*/
typedef const struct vpx_codec_iface vpx_codec_iface_t;
/*!\brief Codec private data structure.
*
* Contains data private to the codec implementation. This structure is opaque
* to the application.
*/
typedef struct vpx_codec_priv vpx_codec_priv_t;
/*!\brief Iterator
*
* Opaque storage used for iterating over lists.
*/
typedef const void *vpx_codec_iter_t;
/*!\brief Codec context structure
*
* All codecs \ref MUST support this context structure fully. In general,
* this data should be considered private to the codec algorithm, and
* not be manipulated or examined by the calling application. Applications
* may reference the 'name' member to get a printable description of the
* algorithm.
*/
typedef struct vpx_codec_ctx {
const char *name; /**< Printable interface name */
vpx_codec_iface_t *iface; /**< Interface pointers */
vpx_codec_err_t err; /**< Last returned error */
const char *err_detail; /**< Detailed info, if available */
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
union {
/**< Decoder Configuration Pointer */
const struct vpx_codec_dec_cfg *dec;
/**< Encoder Configuration Pointer */
const struct vpx_codec_enc_cfg *enc;
const void *raw;
} config; /**< Configuration pointer aliasing union */
vpx_codec_priv_t *priv; /**< Algorithm private storage */
} vpx_codec_ctx_t;
/*!\brief Bit depth for codec
* *
* This enumeration determines the bit depth of the codec.
*/
typedef enum vpx_bit_depth {
VPX_BITS_8 = 8, /**< 8 bits */
VPX_BITS_10 = 10, /**< 10 bits */
VPX_BITS_12 = 12, /**< 12 bits */
} vpx_bit_depth_t;
/*
* Library Version Number Interface
*
* For example, see the following sample return values:
* vpx_codec_version() (1<<16 | 2<<8 | 3)
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
*/
/*!\brief Return the version information (as an integer)
*
* Returns a packed encoding of the library version number. This will only
* include
* the major.minor.patch component of the version number. Note that this encoded
* value should be accessed through the macros provided, as the encoding may
* change
* in the future.
*
*/
int vpx_codec_version(void);
#define VPX_VERSION_MAJOR(v) \
(((v) >> 16) & 0xff) /**< extract major from packed version */
#define VPX_VERSION_MINOR(v) \
(((v) >> 8) & 0xff) /**< extract minor from packed version */
#define VPX_VERSION_PATCH(v) \
(((v) >> 0) & 0xff) /**< extract patch from packed version */
/*!\brief Return the version major number */
#define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
/*!\brief Return the version minor number */
#define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
/*!\brief Return the version patch number */
#define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
/*!\brief Return the version information (as a string)
*
* Returns a printable string containing the full library version number. This
* may
* contain additional text following the three digit version number, as to
* indicate
* release candidates, prerelease versions, etc.
*
*/
const char *vpx_codec_version_str(void);
/*!\brief Return the version information (as a string)
*
* Returns a printable "extra string". This is the component of the string
* returned
* by vpx_codec_version_str() following the three digit version number.
*
*/
const char *vpx_codec_version_extra_str(void);
/*!\brief Return the build configuration
*
* Returns a printable string containing an encoded version of the build
* configuration. This may be useful to vpx support.
*
*/
const char *vpx_codec_build_config(void);
/*!\brief Return the name for a given interface
*
* Returns a human readable string for name of the given codec interface.
*
* \param[in] iface Interface pointer
*
*/
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
/*!\brief Convert error number to printable string
*
* Returns a human readable string for the last error returned by the
* algorithm. The returned error will be one line and will not contain
* any newline characters.
*
*
* \param[in] err Error number.
*
*/
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
/*!\brief Retrieve error synopsis for codec context
*
* Returns a human readable string for the last error returned by the
* algorithm. The returned error will be one line and will not contain
* any newline characters.
*
*
* \param[in] ctx Pointer to this instance's context.
*
*/
const char *vpx_codec_error(const vpx_codec_ctx_t *ctx);
/*!\brief Retrieve detailed error information for codec context
*
* Returns a human readable string providing detailed information about
* the last error. The returned string is only valid until the next
* vpx_codec_* function call (except vpx_codec_error and
* vpx_codec_error_detail) on the codec context.
*
* \param[in] ctx Pointer to this instance's context.
*
* \retval NULL
* No detailed information is available.
*/
const char *vpx_codec_error_detail(const vpx_codec_ctx_t *ctx);
/* REQUIRED FUNCTIONS
*
* The following functions are required to be implemented for all codecs.
* They represent the base case functionality expected of all codecs.
*/
/*!\brief Destroy a codec instance
*
* Destroys a codec context, freeing any associated memory buffers.
*
* \param[in] ctx Pointer to this instance's context
*
* \retval #VPX_CODEC_OK
* The codec instance has been destroyed.
* \retval #VPX_CODEC_INVALID_PARAM
* ctx is a null pointer.
* \retval #VPX_CODEC_ERROR
* Codec context not initialized.
*/
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
/*!\brief Get the capabilities of an algorithm.
*
* Retrieves the capabilities bitfield from the algorithm's interface.
*
* \param[in] iface Pointer to the algorithm interface
*
*/
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
/*!\brief Control algorithm
*
* This function is used to exchange algorithm specific data with the codec
* instance. This can be used to implement features specific to a particular
* algorithm.
*
* This wrapper function dispatches the request to the helper function
* associated with the given ctrl_id. It tries to call this function
* transparently, but will return #VPX_CODEC_ERROR if the request could not
* be dispatched.
*
* Note that this function should not be used directly. Call the
* #vpx_codec_control wrapper macro instead.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] ctrl_id Algorithm specific control identifier
*
* \retval #VPX_CODEC_OK
* The control request was processed.
* \retval #VPX_CODEC_ERROR
* The control request was not processed.
* \retval #VPX_CODEC_INVALID_PARAM
* The data was not valid.
*/
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
#define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
#define VPX_CTRL_USE_TYPE(id, typ)
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
#define VPX_CTRL_VOID(id, typ)
#else
/*!\brief vpx_codec_control wrapper macro
*
* This macro allows for type safe conversions across the variadic parameter
* to vpx_codec_control_().
*
* \internal
* It works by dispatching the call to the control function through a wrapper
* function named with the id parameter.
*/
#define vpx_codec_control(ctx, id, data) \
vpx_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
/*!\brief vpx_codec_control type definition macro
*
* This macro allows for type safe conversions across the variadic parameter
* to vpx_codec_control_(). It defines the type of the argument for a given
* control identifier.
*
* \internal
* It defines a static function with
* the correctly typed arguments as a wrapper to the type-unsafe internal
* function.
*/
#define VPX_CTRL_USE_TYPE(id, typ) \
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
VPX_UNUSED; \
\
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
int ctrl_id, typ data) { \
return vpx_codec_control_(ctx, ctrl_id, data); \
} /**<\hideinitializer*/
/*!\brief vpx_codec_control deprecated type definition macro
*
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
* deprecated and should not be used. Consult the documentation for your
* codec for more information.
*
* \internal
* It defines a static function with the correctly typed arguments as a
* wrapper to the type-unsafe internal function.
*/
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
vpx_codec_ctx_t *, int, typ) VPX_DEPRECATED VPX_UNUSED; \
\
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
return vpx_codec_control_(ctx, ctrl_id, data); \
} /**<\hideinitializer*/
/*!\brief vpx_codec_control void type definition macro
*
* This macro allows for type safe conversions across the variadic parameter
* to vpx_codec_control_(). It indicates that a given control identifier takes
* no argument.
*
* \internal
* It defines a static function without a data argument as a wrapper to the
* type-unsafe internal function.
*/
#define VPX_CTRL_VOID(id) \
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
VPX_UNUSED; \
\
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
int ctrl_id) { \
return vpx_codec_control_(ctx, ctrl_id); \
} /**<\hideinitializer*/
#endif
/*!@} - end defgroup codec*/
#ifdef __cplusplus
}
#endif
#endif // VPX_VPX_VPX_CODEC_H_
+371
View File
@@ -0,0 +1,371 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_DECODER_H_
#define VPX_VPX_VPX_DECODER_H_
/*!\defgroup decoder Decoder Algorithm Interface
* \ingroup codec
* This abstraction allows applications using this decoder to easily support
* multiple video formats with minimal code duplication. This section describes
* the interface common to all decoders.
* @{
*/
/*!\file
* \brief Describes the decoder algorithm interface to applications.
*
* This file describes the interface between an application and a
* video decoder algorithm.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_codec.h" // IWYU pragma: export
#include "./vpx_frame_buffer.h"
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_DECODER_ABI_VERSION \
(3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Decoder capabilities bitfield
*
* Each decoder advertises the capabilities it supports as part of its
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
* or functionality, and are not required to be supported by a decoder.
*
* The available flags are specified by VPX_CODEC_CAP_* defines.
*/
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
/*!\brief Can conceal errors due to packet loss */
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
/*!\brief Can receive encoded frames one fragment at a time */
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
/*!\brief Can support frame-based multi-threading */
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000
/*!\brief Can support external frame buffers */
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
/*! \brief Initialization-time Feature Enabling
*
* Certain codec features must be known at initialization time, to allow for
* proper memory allocation.
*
* The available flags are specified by VPX_CODEC_USE_* defines.
*/
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
/*!\brief Conceal errors in decoded frames */
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
/*!\brief The input frame should be passed to the decoder one fragment at a
* time */
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
/*!\brief Enable frame-based multi-threading */
#define VPX_CODEC_USE_FRAME_THREADING 0x80000
/*!\brief Stream properties
*
* This structure is used to query or set properties of the decoded
* stream. Algorithms may extend this structure with data specific
* to their bitstream by setting the sz member appropriately.
*/
typedef struct vpx_codec_stream_info {
unsigned int sz; /**< Size of this structure */
unsigned int w; /**< Width (or 0 for unknown/default) */
unsigned int h; /**< Height (or 0 for unknown/default) */
unsigned int is_kf; /**< Current frame is a keyframe */
} vpx_codec_stream_info_t;
/* REQUIRED FUNCTIONS
*
* The following functions are required to be implemented for all decoders.
* They represent the base case functionality expected of all decoders.
*/
/*!\brief Initialization Configurations
*
* This structure is used to pass init time configuration options to the
* decoder.
*/
typedef struct vpx_codec_dec_cfg {
unsigned int threads; /**< Maximum number of threads to use, default 1 */
unsigned int w; /**< Width */
unsigned int h; /**< Height */
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
/*!\brief Initialize a decoder instance
*
* Initializes a decoder context using the given interface. Applications
* should call the vpx_codec_dec_init convenience macro instead of this
* function directly, to ensure that the ABI version number parameter
* is properly initialized.
*
* If the library was configured with --disable-multithread, this call
* is not thread safe and should be guarded with a lock if being used
* in a multithreaded context.
*
* On success, vpx_codec_destroy() must be used to free resources allocated for
* the decoder context. If vpx_codec_dec_init_ver() fails, it is not necessary
* to call vpx_codec_destroy() on the decoder context.
*
* \param[in] ctx Pointer to this instance's context.
* \param[in] iface Pointer to the algorithm interface to use.
* \param[in] cfg Configuration to use, if known. May be NULL.
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
* \param[in] ver ABI version number. Must be set to
* VPX_DECODER_ABI_VERSION
* \retval #VPX_CODEC_OK
* The decoder algorithm has been initialized.
* \retval #VPX_CODEC_MEM_ERROR
* Memory allocation failed.
*/
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
vpx_codec_iface_t *iface,
const vpx_codec_dec_cfg_t *cfg,
vpx_codec_flags_t flags, int ver);
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
*
* Ensures the ABI version parameter is properly set.
*/
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
/*!\brief Parse stream info from a buffer
*
* Performs high level parsing of the bitstream. Construction of a decoder
* context is not necessary. Can be used to determine if the bitstream is
* of the proper format, and to extract information from the stream.
*
* \param[in] iface Pointer to the algorithm interface
* \param[in] data Pointer to a block of data to parse
* \param[in] data_sz Size of the data buffer
* \param[in,out] si Pointer to stream info to update. The sz member
* \ref MUST be properly initialized, but \ref MAY be
* clobbered by the algorithm. This parameter \ref MAY
* be NULL.
*
* \retval #VPX_CODEC_OK
* Bitstream is parsable and stream information updated
*/
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
const uint8_t *data,
unsigned int data_sz,
vpx_codec_stream_info_t *si);
/*!\brief Return information about the current stream.
*
* Returns information about the stream that has been parsed during decoding.
*
* \param[in] ctx Pointer to this instance's context
* \param[in,out] si Pointer to stream info to update. The sz member
* \ref MUST be properly initialized, but \ref MAY be
* clobbered by the algorithm. This parameter \ref MAY
* be NULL.
*
* \retval #VPX_CODEC_OK
* Bitstream is parsable and stream information updated
*/
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
vpx_codec_stream_info_t *si);
/*!\brief Decode data
*
* Processes a buffer of coded data. If the processing results in a new
* decoded frame becoming available, put_slice and put_frame callbacks may be
* invoked, as appropriate. Encoded data \ref MUST be passed in DTS (decode
* time stamp) order. Frames produced will always be in PTS (presentation
* time stamp) order.
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
* data and data_sz can contain a fragment of the encoded frame. Fragment
* \#n must contain at least partition \#n, but can also contain subsequent
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
* be empty. When no more data is available, this function should be called
* with NULL as data and 0 as data_sz. The memory passed to this function
* must be available until the frame has been decoded.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] data Pointer to this block of new coded data. If
* NULL, the put_frame callback is invoked for
* the previously decoded frame.
* \param[in] data_sz Size of the coded data, in bytes.
* \param[in] user_priv Application specific data to associate with
* this frame.
* \param[in] deadline Soft deadline the decoder should attempt to meet,
* in us. Set to zero for unlimited.
* NOTE: The deadline parameter is ignored. Always
* pass 0.
*
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
* and future pictures can be decoded without error. Otherwise,
* see the descriptions of the other error codes in ::vpx_codec_err_t
* for recoverability capabilities.
*/
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
unsigned int data_sz, void *user_priv,
long deadline);
/*!\brief Decoded frames iterator
*
* Iterates over a list of the frames available for display. The iterator
* storage should be initialized to NULL to start the iteration. Iteration is
* complete when this function returns NULL.
*
* The list of available frames becomes valid upon completion of the
* vpx_codec_decode call, and remains valid until the next call to
* vpx_codec_decode.
*
* \param[in] ctx Pointer to this instance's context
* \param[in,out] iter Iterator storage, initialized to NULL
*
* \return Returns a pointer to an image, if one is ready for display. Frames
* produced will always be in PTS (presentation time stamp) order.
*/
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
*
* The following function is required to be implemented for all decoders
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling this
* function for codecs that don't advertise this capability will result in
* an error code being returned, usually VPX_CODEC_INCAPABLE.
* @{
*/
/*!\brief put frame callback prototype
*
* This callback is invoked by the decoder to notify the application of
* the availability of decoded image data.
*/
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
const vpx_image_t *img);
/*!\brief Register for notification of frame completion.
*
* Registers a given function to be called when a decoded frame is
* available.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb Pointer to the callback function
* \param[in] user_priv User's private data
*
* \retval #VPX_CODEC_OK
* Callback successfully registered.
* \retval #VPX_CODEC_ERROR
* Decoder context not initialized.
* \retval #VPX_CODEC_INCAPABLE
* Algorithm not capable of posting frame completion.
*/
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
vpx_codec_put_frame_cb_fn_t cb,
void *user_priv);
/*!@} - end defgroup cap_put_frame */
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
*
* The following function is required to be implemented for all decoders
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling this
* function for codecs that don't advertise this capability will result in
* an error code being returned, usually VPX_CODEC_INCAPABLE.
* @{
*/
/*!\brief put slice callback prototype
*
* This callback is invoked by the decoder to notify the application of
* the availability of partially decoded image data.
*/
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
const vpx_image_t *img,
const vpx_image_rect_t *valid,
const vpx_image_rect_t *update);
/*!\brief Register for notification of slice completion.
*
* Registers a given function to be called when a decoded slice is
* available.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb Pointer to the callback function
* \param[in] user_priv User's private data
*
* \retval #VPX_CODEC_OK
* Callback successfully registered.
* \retval #VPX_CODEC_ERROR
* Decoder context not initialized.
* \retval #VPX_CODEC_INCAPABLE
* Algorithm not capable of posting slice completion.
*/
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
vpx_codec_put_slice_cb_fn_t cb,
void *user_priv);
/*!@} - end defgroup cap_put_slice*/
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
*
* The following function is required to be implemented for all decoders
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
* Calling this function for codecs that don't advertise this capability
* will result in an error code being returned, usually VPX_CODEC_INCAPABLE.
*
* \note
* Currently this only works with VP9.
* @{
*/
/*!\brief Pass in external frame buffers for the decoder to use.
*
* Registers functions to be called when libvpx needs a frame buffer
* to decode the current frame and a function to be called when libvpx does
* not internally reference the frame buffer. This set function must
* be called before the first call to decode or libvpx will assume the
* default behavior of allocating frame buffers internally.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb_get Pointer to the get callback function
* \param[in] cb_release Pointer to the release callback function
* \param[in] cb_priv Callback's private data
*
* \retval #VPX_CODEC_OK
* External frame buffers will be used by libvpx.
* \retval #VPX_CODEC_INVALID_PARAM
* One or more of the callbacks were NULL.
* \retval #VPX_CODEC_ERROR
* Decoder context not initialized.
* \retval #VPX_CODEC_INCAPABLE
* Algorithm not capable of using external frame buffers.
*
* \note
* When decoding VP9, the application may be required to pass in at least
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
* buffers.
*/
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
/*!@} - end defgroup cap_external_frame_buffer */
/*!@} - end defgroup decoder*/
#ifdef __cplusplus
}
#endif
#endif // VPX_VPX_VPX_DECODER_H_
File diff suppressed because it is too large. Load diff
+605
View File
@@ -0,0 +1,605 @@
/*
* Copyright (c) 2020 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\file
* \brief Defines structs and callbacks needed for external rate control.
*
*/
#ifndef VPX_VPX_VPX_EXT_RATECTRL_H_
#define VPX_VPX_VPX_EXT_RATECTRL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_integer.h"
#include "./vpx_tpl.h"
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures.
*/
#define VPX_EXT_RATECTRL_ABI_VERSION (7 + VPX_TPL_ABI_VERSION)
/*!\brief Corresponds to MAX_STATIC_GF_GROUP_LENGTH defined in vp9_ratectrl.h
*/
#define VPX_RC_MAX_STATIC_GF_GROUP_LENGTH 250
/*!\brief Max number of ref frames returned by the external RC.
*
* Corresponds to MAX_REF_FRAMES defined in vp9_blockd.h.
*/
#define VPX_RC_MAX_REF_FRAMES 4
/*!\brief The type of the external rate control.
*
* This controls what encoder parameters are determined by the external rate
* control.
*/
typedef enum vpx_rc_type {
/*!
* The external rate control doesn't determine anything.
* This mode is used as baseline.
*/
VPX_RC_NONE = 0,
/*!
* The external rate control model determines the quantization parameter (QP)
* for each frame.
*/
VPX_RC_QP = 1 << 0,
/*!
* The external rate control model determines the group of picture (GOP) of
* the video sequence.
*/
VPX_RC_GOP = 1 << 1,
/*!
* The external rate control model determines the rate-distortion multiplier
* (rdmult) for the current frame.
*/
VPX_RC_RDMULT = 1 << 2,
/*!
* The external rate control model determines both QP and GOP.
*/
VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP,
/*!
* The external rate control model determines the QP, GOP and the rdmult.
*/
VPX_RC_GOP_QP_RDMULT = VPX_RC_QP | VPX_RC_GOP | VPX_RC_RDMULT
} vpx_rc_type_t;
/*!\brief The rate control mode for the external rate control model.
*/
typedef enum vpx_ext_rc_mode {
VPX_RC_QMODE = 0,
VPX_RC_VBR = 1,
VPX_RC_CQ = 2,
} vpx_ext_rc_mode_t;
/*!\brief Corresponds to FRAME_UPDATE_TYPE defined in vp9_firstpass.h.
*/
typedef enum vpx_rc_frame_update_type {
VPX_RC_INVALID_UPDATE_TYPE = -1,
VPX_RC_KF_UPDATE = 0,
VPX_RC_LF_UPDATE = 1,
VPX_RC_GF_UPDATE = 2,
VPX_RC_ARF_UPDATE = 3,
VPX_RC_OVERLAY_UPDATE = 4,
VPX_RC_MID_OVERLAY_UPDATE = 5,
VPX_RC_USE_BUF_FRAME = 6,
} vpx_rc_frame_update_type_t;
/*!\brief Name for the ref frames returned by the external RC.
*
* Corresponds to the ref frames defined in vp9_blockd.h.
*/
typedef enum vpx_rc_ref_name {
VPX_RC_INVALID_REF_FRAME = -1,
VPX_RC_INTRA_FRAME = 0,
VPX_RC_LAST_FRAME = 1,
VPX_RC_GOLDEN_FRAME = 2,
VPX_RC_ALTREF_FRAME = 3,
} vpx_rc_ref_name_t;
/*!\brief Abstract rate control model handler
*
* The encoder will receive the model handler from
* vpx_rc_funcs_t::create_model().
*/
typedef void *vpx_rc_model_t;
/*!\brief A reserved value for the q index.
* If the external rate control model returns this value,
* the encoder will use the default q selected by libvpx's rate control
* system.
*/
#define VPX_DEFAULT_Q -1
/*!\brief A reserved value for the rdmult.
* If the external rate control model returns this value,
* the encoder will use the default rdmult selected by libvpx's rate control
* system.
*/
#define VPX_DEFAULT_RDMULT -1
/*!\brief Superblock quantization parameters
* Store the superblock quantization parameters
*/
typedef struct sb_parameters {
int q_index; /**< Quantizer step index [0..255]*/
int rdmult; /**< Superblock level Lagrangian multiplier*/
} sb_params;
/*!\brief Encode frame decision made by the external rate control model
*
* The encoder will receive the decision from the external rate control model
* through vpx_rc_funcs_t::get_encodeframe_decision().
*/
typedef struct vpx_rc_encodeframe_decision {
int q_index; /**< Required: Quantizer step index [0..255]*/
int rdmult; /**< Required: Frame level Lagrangian multiplier*/
int delta_q_uv; /**< Required: Delta QP for UV */
/*!
* Optional: Superblock quantization parameters
* It is zero initialized by default. It will be set for key and ARF frames
* but not leaf frames.
*/
sb_params *sb_params_list;
} vpx_rc_encodeframe_decision_t;
/*!\brief Information for the frame to be encoded.
*
* The encoder will send the information to external rate control model through
* vpx_rc_funcs_t::get_encodeframe_decision().
*
*/
typedef struct vpx_rc_encodeframe_info {
/*!
* 0: Key frame
* 1: Inter frame
* 2: Alternate reference frame
* 3: Overlay frame
* 4: Golden frame
*/
int frame_type;
int show_index; /**< display index, starts from zero*/
int coding_index; /**< coding index, starts from zero*/
/*!
* index of the current frame in this group of picture, starts from zero.
*/
int gop_index;
int ref_frame_coding_indexes[3]; /**< three reference frames' coding indices*/
/*!
* The validity of the three reference frames.
* 0: Invalid
* 1: Valid
*/
int ref_frame_valid_list[3];
/*!
* The length of the current GOP.
*/
int gop_size;
/*!
* Whether the current GOP uses an alt ref.
*/
int use_alt_ref;
} vpx_rc_encodeframe_info_t;
/*!\brief Frame coding result
*
* The encoder will send the result to the external rate control model through
* vpx_rc_funcs_t::update_encodeframe_result().
*/
typedef struct vpx_rc_encodeframe_result {
int64_t bit_count; /**< number of bits spent on coding the frame*/
int actual_encoding_qindex; /**< the actual qindex used to encode the frame*/
} vpx_rc_encodeframe_result_t;
/*!\brief Status returned by rate control callback functions.
*/
typedef enum vpx_rc_status {
VPX_RC_OK = 0,
VPX_RC_ERROR = 1,
} vpx_rc_status_t;
/*!\brief First pass frame stats
* This is a mirror of vp9's FIRSTPASS_STATS except that spatial_layer_id is
* omitted
*/
typedef struct vpx_rc_frame_stats {
/*!
* Frame number in display order, if stats are for a single frame.
* No real meaning for a collection of frames.
*/
double frame;
/*!
* Weight assigned to this frame (or total weight for the collection of
* frames) currently based on intra factor and brightness factor. This is used
* to distribute bits between easier and harder frames.
*/
double weight;
/*!
* Intra prediction error.
*/
double intra_error;
/*!
* Best of intra pred error and inter pred error using last frame as ref.
*/
double coded_error;
/*!
* Best of intra pred error and inter pred error using golden frame as ref.
*/
double sr_coded_error;
/*!
* Estimate the noise energy of the current frame.
*/
double frame_noise_energy;
/*!
* Percentage of blocks with inter pred error < intra pred error.
*/
double pcnt_inter;
/*!
* Percentage of blocks using (inter prediction and) non-zero motion vectors.
*/
double pcnt_motion;
/*!
* Percentage of blocks where golden frame was better than last or intra:
* inter pred error using golden frame < inter pred error using last frame and
* inter pred error using golden frame < intra pred error
*/
double pcnt_second_ref;
/*!
* Percentage of blocks where intra and inter prediction errors were very
* close.
*/
double pcnt_neutral;
/*!
* Percentage of blocks that have intra error < inter error and inter error <
* LOW_I_THRESH
* - bit_depth 8: LOW_I_THRESH = 24000
* - bit_depth 10: LOW_I_THRESH = 24000 << 4
* - bit_depth 12: LOW_I_THRESH = 24000 << 8
*/
double pcnt_intra_low;
/*!
* Percentage of blocks that have intra error < inter error and intra error <
* LOW_I_THRESH but inter error >= LOW_I_THRESH LOW_I_THRESH
* - bit_depth 8: LOW_I_THRESH = 24000
* - bit_depth 10: LOW_I_THRESH = 24000 << 4
* - bit_depth 12: LOW_I_THRESH = 24000 << 8
*/
double pcnt_intra_high;
/*!
* Percentage of blocks that have almost no intra error residual
* (i.e. are in effect completely flat and untextured in the intra
* domain). In natural videos this is uncommon, but it is much more
* common in animations, graphics and screen content, so may be used
* as a signal to detect these types of content.
*/
double intra_skip_pct;
/*!
* Percentage of blocks that have intra error < SMOOTH_INTRA_THRESH
* - bit_depth 8: SMOOTH_INTRA_THRESH = 4000
* - bit_depth 10: SMOOTH_INTRA_THRESH = 4000 << 4
* - bit_depth 12: SMOOTH_INTRA_THRESH = 4000 << 8
*/
double intra_smooth_pct;
/*!
* Image mask rows top and bottom.
*/
double inactive_zone_rows;
/*!
* Image mask columns at left and right edges.
*/
double inactive_zone_cols;
/*!
* Mean of row motion vectors.
*/
double MVr;
/*!
* Mean of absolute value of row motion vectors.
*/
double mvr_abs;
/*!
* Mean of column motion vectors.
*/
double MVc;
/*!
* Mean of absolute value of column motion vectors.
*/
double mvc_abs;
/*!
* Variance of row motion vectors.
*/
double MVrv;
/*!
* Variance of column motion vectors.
*/
double MVcv;
/*!
* Value in range [-1,1] indicating fraction of row and column motion vectors
* that point inwards (negative MV value) or outwards (positive MV value).
* For example, value of 1 indicates, all row/column MVs are inwards.
*/
double mv_in_out_count;
/*!
* Duration of the frame / collection of frames.
*/
double duration;
/*!
* 1.0 if stats are for a single frame, or
* number of frames whose stats are accumulated.
*/
double count;
/*!
* Number of new mv in a frame.
*/
double new_mv_count;
} vpx_rc_frame_stats_t;
/*!\brief Collection of first pass frame stats
*/
typedef struct vpx_rc_firstpass_stats {
/*!
* Pointer to first pass frame stats.
* The pointed array of vpx_rc_frame_stats_t should have length equal to
* number of show frames in the video.
*/
vpx_rc_frame_stats_t *frame_stats;
/*!
* Number of show frames in the video.
*/
int num_frames;
} vpx_rc_firstpass_stats_t;
/*!\brief Encode config sent to external rate control model
*/
typedef struct vpx_rc_config {
int frame_width; /**< frame width */
int frame_height; /**< frame height */
int show_frame_count; /**< number of visible frames in the video */
int max_gf_interval; /**< max GOP size in number of show frames */
int min_gf_interval; /**< min GOP size in number of show frames */
/*!
* Target bitrate in kilobytes per second
*/
int target_bitrate_kbps;
int frame_rate_num; /**< numerator of frame rate */
int frame_rate_den; /**< denominator of frame rate */
/*!
* The following fields are only for external rate control models that support
* different rate control modes.
*/
vpx_ext_rc_mode_t rc_mode; /**< Q mode or VBR mode */
int overshoot_percent; /**< for VBR mode only */
int undershoot_percent; /**< for VBR mode only */
int min_base_q_index; /**< for VBR mode only */
int max_base_q_index; /**< for VBR mode only */
int base_qp; /**< base QP for leaf frames, 0-255 */
} vpx_rc_config_t;
/*!\brief Control what ref frame to use and its index.
*/
typedef struct vpx_rc_ref_frame {
/*!
* Ref frame index. Corresponding to |lst_fb_idx|, |gld_fb_idx| or
* |alt_fb_idx| in VP9_COMP depending on the ref frame #name.
*/
int index[VPX_RC_MAX_REF_FRAMES];
/*!
* Ref frame name. This decides whether the #index is used as
* |lst_fb_idx|, |gld_fb_idx| or |alt_fb_idx| in VP9_COMP.
*
*/
vpx_rc_ref_name_t name[VPX_RC_MAX_REF_FRAMES];
} vpx_rc_ref_frame_t;
/*!\brief The decision made by the external rate control model to set the
* group of picture.
*/
typedef struct vpx_rc_gop_decision {
int gop_coding_frames; /**< The number of frames of this GOP */
int use_alt_ref; /**< Whether to use alt ref for this GOP */
int use_key_frame; /**< Whether to set key frame for this GOP */
/*!
* Frame type for each frame in this GOP.
* This will be populated to |update_type| in GF_GROUP defined in
* vp9_firstpass.h
*/
vpx_rc_frame_update_type_t update_type[VPX_RC_MAX_STATIC_GF_GROUP_LENGTH + 2];
/*! Ref frame buffer index to be updated for each frame in this GOP. */
int update_ref_index[VPX_RC_MAX_STATIC_GF_GROUP_LENGTH + 2];
/*! Ref frame list to be used for each frame in this GOP. */
vpx_rc_ref_frame_t ref_frame_list[VPX_RC_MAX_STATIC_GF_GROUP_LENGTH + 2];
} vpx_rc_gop_decision_t;
/*!\brief The decision made by the external rate control model to set the
* key frame location and the show frame count in the key frame group
*/
typedef struct vpx_rc_key_frame_decision {
int key_frame_show_index; /**< This key frame's show index in the video */
int key_frame_group_size; /**< Show frame count of this key frame group */
} vpx_rc_key_frame_decision_t;
/*!\brief Create an external rate control model callback prototype
*
* This callback is invoked by the encoder to create an external rate control
* model.
*
* \param[in] priv Callback's private data
* \param[in] ratectrl_config Pointer to vpx_rc_config_t
* \param[out] rate_ctrl_model_ptr Pointer to vpx_rc_model_t
*/
typedef vpx_rc_status_t (*vpx_rc_create_model_cb_fn_t)(
void *priv, const vpx_rc_config_t *ratectrl_config,
vpx_rc_model_t *rate_ctrl_model_ptr);
/*!\brief Send first pass stats to the external rate control model callback
* prototype
*
* This callback is invoked by the encoder to send first pass stats to the
* external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[in] first_pass_stats first pass stats
*/
typedef vpx_rc_status_t (*vpx_rc_send_firstpass_stats_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model,
const vpx_rc_firstpass_stats_t *first_pass_stats);
/*!\brief Send TPL stats for the current GOP to the external rate control model
* callback prototype
*
* This callback is invoked by the encoder to send TPL stats for the GOP to the
* external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[in] tpl_gop_stats TPL stats for current GOP
*/
typedef vpx_rc_status_t (*vpx_rc_send_tpl_gop_stats_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, const VpxTplGopStats *tpl_gop_stats);
/*!\brief Receive encode frame decision callback prototype
*
* This callback is invoked by the encoder to receive encode frame decision from
* the external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[in] frame_gop_index index of the frame in current gop
* \param[out] frame_decision encode decision of the coding frame
*/
typedef vpx_rc_status_t (*vpx_rc_get_encodeframe_decision_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, const int frame_gop_index,
vpx_rc_encodeframe_decision_t *frame_decision);
/*!\brief Update encode frame result callback prototype
*
* This callback is invoked by the encoder to update encode frame result to the
* external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[out] encode_frame_result encode result of the coding frame
*/
typedef vpx_rc_status_t (*vpx_rc_update_encodeframe_result_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model,
const vpx_rc_encodeframe_result_t *encode_frame_result);
/*!\brief Get the key frame decision from the external rate control model.
*
* This callback is invoked by the encoder to get key frame decision from
* the external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[out] key_frame_decision key frame decision from the model
*/
typedef vpx_rc_status_t (*vpx_rc_get_key_frame_decision_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model,
vpx_rc_key_frame_decision_t *key_frame_decision);
/*!\brief Get the GOP structure from the external rate control model.
*
* This callback is invoked by the encoder to get GOP decisions from
* the external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[out] gop_decision GOP decision from the model
*/
typedef vpx_rc_status_t (*vpx_rc_get_gop_decision_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, vpx_rc_gop_decision_t *gop_decision);
/*!\brief Get the frame rdmult from the external rate control model.
*
* This callback is invoked by the encoder to get rdmult from
* the external rate control model.
*
* \param[in] rate_ctrl_model rate control model
* \param[in] frame_info information collected from the encoder
* \param[out] rdmult frame rate-distortion multiplier from the model
*/
typedef vpx_rc_status_t (*vpx_rc_get_frame_rdmult_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info,
int *rdmult);
/*!\brief Delete the external rate control model callback prototype
*
* This callback is invoked by the encoder to delete the external rate control
* model.
*
* \param[in] rate_ctrl_model rate control model
*/
typedef vpx_rc_status_t (*vpx_rc_delete_model_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model);
/*!\brief Callback function set for external rate control.
*
* The user can enable external rate control by registering
* a set of callback functions with the codec control flag
* #VP9E_SET_EXTERNAL_RATE_CONTROL.
*/
typedef struct vpx_rc_funcs {
/*!
* The rate control type of this API.
*/
vpx_rc_type_t rc_type;
/*!
* Create an external rate control model.
*/
vpx_rc_create_model_cb_fn_t create_model;
/*!
* Send first pass stats to the external rate control model.
*/
vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats;
/*!
* Send TPL stats for current GOP to the external rate control model.
*/
vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats;
/*!
* Get encodeframe decision from the external rate control model.
*/
vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision;
/*!
* Update encodeframe result to the external rate control model.
*/
vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result;
/*!
* Get key frame decision from the external rate control model.
*/
vpx_rc_get_key_frame_decision_cb_fn_t get_key_frame_decision;
/*!
* Get GOP decisions from the external rate control model.
*/
vpx_rc_get_gop_decision_cb_fn_t get_gop_decision;
/*!
* Get rdmult for the frame from the external rate control model.
*/
vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult;
/*!
* Delete the external rate control model.
*/
vpx_rc_delete_model_cb_fn_t delete_model;
/*!
* Rate control log path.
*/
const char *rate_ctrl_log_path;
/*!
* Private data for the external rate control model.
*/
void *priv;
} vpx_rc_funcs_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_EXT_RATECTRL_H_
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
#define VPX_VPX_VPX_FRAME_BUFFER_H_
/*!\file
* \brief Describes the decoder external frame buffer interface.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_integer.h"
/*!\brief The maximum number of work buffers used by libvpx.
* Support maximum 4 threads to decode video in parallel.
* Each thread will use one work buffer.
* TODO(hkuang): Add support to set number of worker threads dynamically.
*/
#define VPX_MAXIMUM_WORK_BUFFERS 8
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
*/
#define VP9_MAXIMUM_REF_BUFFERS 8
/*!\brief External frame buffer
*
* This structure holds allocated frame buffers used by the decoder.
*/
typedef struct vpx_codec_frame_buffer {
uint8_t *data; /**< Pointer to the data buffer */
size_t size; /**< Size of data in bytes */
void *priv; /**< Frame's private data */
} vpx_codec_frame_buffer_t;
/*!\brief get frame buffer callback prototype
*
* This callback is invoked by the decoder to retrieve data for the frame
* buffer in order for the decode call to complete. The callback must
* allocate at least min_size in bytes and assign it to fb->data. The callback
* must zero out all the data allocated. Then the callback must set fb->size
* to the allocated size. The application does not need to align the allocated
* data. The callback is triggered when the decoder needs a frame buffer to
* decode a compressed image into. This function may be called more than once
* for every call to vpx_codec_decode. The application may set fb->priv to
* some data which will be passed back in the vpx_image_t and the release
* function call. |fb| is guaranteed to not be NULL. On success the callback
* must return 0. Any failure the callback must return a value less than 0.
*
* \param[in] priv Callback's private data
* \param[in] min_size Size in bytes needed by the buffer
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
*/
typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
vpx_codec_frame_buffer_t *fb);
/*!\brief release frame buffer callback prototype
*
* This callback is invoked by the decoder when the frame buffer is not
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
* success the callback must return 0. Any failure the callback must return
* a value less than 0.
*
* \param[in] priv Callback's private data
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
*/
typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
vpx_codec_frame_buffer_t *fb);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_FRAME_BUFFER_H_
+255
View File
@@ -0,0 +1,255 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\file
* \brief Describes the vpx image descriptor and associated operations
*
*/
#ifndef VPX_VPX_VPX_IMAGE_H_
#define VPX_VPX_VPX_IMAGE_H_
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
/*!\brief List of supported image formats */
typedef enum vpx_img_fmt {
VPX_IMG_FMT_NONE,
VPX_IMG_FMT_YV12 =
VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
VPX_IMG_FMT_NV12 = VPX_IMG_FMT_PLANAR | 9,
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
/*!\brief List of supported color spaces */
typedef enum vpx_color_space {
VPX_CS_UNKNOWN = 0, /**< Unknown */
VPX_CS_BT_601 = 1, /**< BT.601 */
VPX_CS_BT_709 = 2, /**< BT.709 */
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
VPX_CS_BT_2020 = 5, /**< BT.2020 */
VPX_CS_RESERVED = 6, /**< Reserved */
VPX_CS_SRGB = 7 /**< sRGB */
} vpx_color_space_t; /**< alias for enum vpx_color_space */
/*!\brief List of supported color range */
typedef enum vpx_color_range {
VPX_CR_STUDIO_RANGE = 0, /**<- Y [16..235], UV [16..240] (bit depth 8) */
/**<- Y [64..940], UV [64..960] (bit depth 10) */
/**<- Y [256..3760], UV [256..3840] (bit depth 12) */
VPX_CR_FULL_RANGE = 1 /**<- YUV/RGB [0..255] (bit depth 8) */
/**<- YUV/RGB [0..1023] (bit depth 10) */
/**<- YUV/RGB [0..4095] (bit depth 12) */
} vpx_color_range_t; /**< alias for enum vpx_color_range */
/**\brief Image Descriptor */
typedef struct vpx_image {
vpx_img_fmt_t fmt; /**< Image Format */
vpx_color_space_t cs; /**< Color Space */
vpx_color_range_t range; /**< Color Range */
/* Image storage dimensions */
unsigned int w; /**< Stored image width */
unsigned int h; /**< Stored image height */
unsigned int bit_depth; /**< Stored image bit-depth */
/* Image display dimensions */
unsigned int d_w; /**< Displayed image width */
unsigned int d_h; /**< Displayed image height */
/* Image intended rendering dimensions */
unsigned int r_w; /**< Intended rendering image width */
unsigned int r_h; /**< Intended rendering image height */
/* Chroma subsampling info */
unsigned int x_chroma_shift; /**< subsampling order, X */
unsigned int y_chroma_shift; /**< subsampling order, Y */
/* Image data pointers. */
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
/*!Stride between rows for each plane
*
* \note With planar formats, \c stride[VPX_PLANE_U] must be the same as \c
* stride[VPX_PLANE_V].
*/
int stride[4];
int bps; /**< bits per sample (for packed formats) */
/*!\brief The following member may be set by the application to associate
* data with this image.
*/
void *user_priv;
/* The following members should be treated as private. */
unsigned char *img_data; /**< private */
int img_data_owner; /**< private */
int self_allocd; /**< private */
void *fb_priv; /**< Frame buffer data associated with the image. */
} vpx_image_t; /**< alias for struct vpx_image */
/**\brief Representation of a rectangle on a surface */
typedef struct vpx_image_rect {
unsigned int x; /**< leftmost column */
unsigned int y; /**< topmost row */
unsigned int w; /**< width */
unsigned int h; /**< height */
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
/*!\brief Open a descriptor, allocating storage for the underlying image
*
* Returns a descriptor for storing an image of the given format. The
* storage for the image is allocated on the heap.
*
* \param[in] img Pointer to storage for descriptor. If this parameter
* is NULL, the storage for the descriptor will be
* allocated on the heap.
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image. Must not exceed 0x08000000
* (2^27).
* \param[in] d_h Height of the image. Must not exceed 0x08000000
* (2^27).
* \param[in] align Alignment, in bytes, of the image buffer and
* each row in the image (stride). Must not exceed
* 65536.
*
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
* returned.
*/
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align);
/*!\brief Open a descriptor, using existing storage for the underlying image
*
* Returns a descriptor for storing an image of the given format. The
* storage for the image has been allocated elsewhere, and a descriptor is
* desired to "wrap" that storage.
*
* \param[in] img Pointer to storage for descriptor. If this
* parameter is NULL, the storage for the descriptor
* will be allocated on the heap.
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image. Must not exceed 0x08000000
* (2^27).
* \param[in] d_h Height of the image. Must not exceed 0x08000000
* (2^27).
* \param[in] stride_align Alignment, in bytes, of each row in the image
* (stride). Must not exceed 65536.
* \param[in] img_data Storage to use for the image. The storage must
* outlive the returned image descriptor; it can be
* disposed of after calling vpx_img_free().
*
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
* returned.
*
* \note \a img_data is required to have a minimum allocation size that
* satisfies the requirements of the \a fmt, \a d_w, \a d_h and \a
* stride_align parameters. This size can be calculated as follows (see
* \c img_alloc_helper in the vpx_image.c file in the libvpx source tree
* for more detail):
* \code
* align = (1 << x_chroma_shift) - 1;
* w = (d_w + align) & ~align;
* align = (1 << y_chroma_shift) - 1;
* h = (d_h + align) & ~align;
*
* s = (fmt & VPX_IMG_FMT_PLANAR) ? w : (uint64_t)bps * w / 8;
* s = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s;
* s = (s + stride_align - 1) & ~((uint64_t)stride_align - 1);
* s = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s / 2 : s;
* alloc_size = (fmt & VPX_IMG_FMT_PLANAR) ? (uint64_t)h * s * bps / 8
* : (uint64_t)h * s;
* \endcode
* \a x_chroma_shift, \a y_chroma_shift and \a bps can be obtained by calling
* \ref vpx_img_wrap with a non-\c NULL \a img_data parameter. The \c
* vpx_image_t pointer should \em not be used in other API calls until \em after
* a successful call to \ref vpx_img_wrap with a valid image buffer. For
* example:
* \code
* vpx_img_wrap(img, fmt, d_w, d_h, stride_align, (unsigned char *)1);
* ... calculate buffer size and allocate buffer as described earlier
* vpx_img_wrap(img, fmt, d_w, d_h, stride_align, img_data);
* \endcode
*/
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
unsigned int d_h, unsigned int stride_align,
unsigned char *img_data);
/*!\brief Set the rectangle identifying the displayed portion of the image
*
* Updates the displayed rectangle (aka viewport) on the image surface to
* match the specified coordinates and size. Specifically, sets img->d_w,
* img->d_h, and elements of the img->planes[] array.
*
* \param[in] img Image descriptor
* \param[in] x leftmost column
* \param[in] y topmost row
* \param[in] w width
* \param[in] h height
*
* \return 0 if the requested rectangle is valid, nonzero (-1) otherwise.
*/
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
unsigned int w, unsigned int h);
/*!\brief Flip the image vertically (top for bottom)
*
* Adjusts the image descriptor's pointers and strides to make the image
* be referenced upside-down.
*
* \param[in] img Image descriptor
*/
void vpx_img_flip(vpx_image_t *img);
/*!\brief Close an image descriptor
*
* Frees all allocated storage associated with an image descriptor.
*
* \param[in] img Image descriptor
*/
void vpx_img_free(vpx_image_t *img);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_IMAGE_H_
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_INTEGER_H_
#define VPX_VPX_VPX_INTEGER_H_
/* get ptrdiff_t, size_t, wchar_t, NULL */
#include <stddef.h> // IWYU pragma: export
#if defined(_MSC_VER)
#define VPX_FORCE_INLINE __forceinline
#define VPX_INLINE __inline
#else
#define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
// TODO(jbb): Allow a way to force inline off for older compilers.
#define VPX_INLINE inline
#endif
/* Assume platforms have the C99 standard integer types. */
#if defined(__cplusplus)
#if !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
#if !defined(__STDC_LIMIT_MACROS)
#define __STDC_LIMIT_MACROS
#endif
#endif // __cplusplus
#include <inttypes.h> // IWYU pragma: export
#include <stdint.h> // IWYU pragma: export
#endif // VPX_VPX_VPX_INTEGER_H_
+69
View File
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2023 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\file
* \brief Describes the TPL stats descriptor and associated operations
*
*/
#ifndef VPX_VPX_VPX_TPL_H_
#define VPX_VPX_VPX_TPL_H_
#include "./vpx_integer.h"
#include "./vpx_codec.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_TPL_ABI_VERSION 5 /**<\hideinitializer*/
/*!\brief Temporal dependency model stats for each block before propagation */
typedef struct VpxTplBlockStats {
int16_t row; /**< Pixel row of the top left corner */
int16_t col; /**< Pixel col of the top left corner */
int64_t intra_cost; /**< Intra cost */
int64_t inter_cost; /**< Inter cost */
int16_t mv_r; /**< Motion vector row in pixel */
int16_t mv_c; /**< Motion vector col in pixel */
int64_t srcrf_rate; /**< Rate from source ref frame */
int64_t srcrf_dist; /**< Distortion from source ref frame */
int64_t pred_error; /**< Prediction error */
int64_t inter_pred_err; /**< Inter prediction error */
int64_t intra_pred_err; /**< Intra prediction error */
int ref_frame_index; /**< Ref frame index in the ref frame buffer */
} VpxTplBlockStats;
/*!\brief Temporal dependency model stats for each frame before propagation */
typedef struct VpxTplFrameStats {
int frame_width; /**< Frame width */
int frame_height; /**< Frame height */
int num_blocks; /**< Number of blocks. Size of block_stats_list */
VpxTplBlockStats *block_stats_list; /**< List of tpl stats for each block */
} VpxTplFrameStats;
/*!\brief Temporal dependency model stats for each GOP before propagation */
typedef struct VpxTplGopStats {
int size; /**< GOP size, also the size of frame_stats_list. */
VpxTplFrameStats *frame_stats_list; /**< List of tpl stats for each frame */
} VpxTplGopStats;
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_TPL_H_