Go to the documentation of this file.
26 #define VPX_CODEC_DISABLE_COMPAT 1
27 #include <vpx/vpx_decoder.h>
28 #include <vpx/vpx_frame_buffer.h>
29 #include <vpx/vp8dx.h>
52 VPxContext *
ctx = priv;
55 if (min_size >
ctx->pool_size) {
63 ctx->pool_size = min_size;
71 fb->size =
ctx->pool_size;
86 const struct vpx_codec_iface *iface)
88 struct vpx_codec_dec_cfg deccfg = {
95 if (vpx_codec_dec_init(
decoder, iface, &deccfg, 0) != VPX_CODEC_OK) {
110 int has_alpha_channel)
116 #if VPX_IMAGE_ABI_VERSION >= 4
126 case VPX_IMG_FMT_I420:
132 #if CONFIG_LIBVPX_VP9_DECODER
133 case VPX_IMG_FMT_I422:
137 case VPX_IMG_FMT_I440:
141 case VPX_IMG_FMT_I444:
146 case VPX_IMG_FMT_I42016:
148 if (
img->bit_depth == 10) {
151 }
else if (
img->bit_depth == 12) {
157 case VPX_IMG_FMT_I42216:
159 if (
img->bit_depth == 10) {
162 }
else if (
img->bit_depth == 12) {
168 case VPX_IMG_FMT_I44016:
170 if (
img->bit_depth == 10) {
173 }
else if (
img->bit_depth == 12) {
179 case VPX_IMG_FMT_I44416:
181 if (
img->bit_depth == 10) {
185 }
else if (
img->bit_depth == 12) {
199 uint8_t *
data, uint32_t data_sz)
201 if (vpx_codec_decode(
decoder,
data, data_sz,
NULL, 0) != VPX_CODEC_OK) {
203 const char *detail = vpx_codec_error_detail(
decoder);
220 const void *iter =
NULL;
221 const void *iter_alpha =
NULL;
222 struct vpx_image *
img, *img_alpha;
224 uint8_t *side_data =
NULL;
225 size_t side_data_size;
234 if (side_data_size >= 8) {
235 const uint64_t additional_id =
AV_RB64(side_data);
238 if (additional_id == 1) {
239 if (!
ctx->has_alpha_channel) {
240 ctx->has_alpha_channel = 1;
243 #
if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER
245 vpx_codec_vp8_dx() : vpx_codec_vp9_dx()
246 #elif CONFIG_LIBVPX_VP8_DECODER
262 if ((
img = vpx_codec_get_frame(&
ctx->decoder, &iter)) &&
263 (!
ctx->has_alpha_channel ||
264 (img_alpha = vpx_codec_get_frame(&
ctx->decoder_alpha, &iter_alpha)))) {
276 img->fmt,
img->bit_depth);
288 if (
ctx->has_alpha_channel &&
289 (
img->d_w != img_alpha->d_w ||
290 img->d_h != img_alpha->d_h ||
291 img->bit_depth != img_alpha->bit_depth)) {
293 "Video dimensions %dx%d@%dbpc differ from alpha dimensions %dx%d@%dbpc\n",
295 img_alpha->d_w, img_alpha->d_h, img_alpha->bit_depth);
303 ctx->has_alpha_channel ? img_alpha->planes[VPX_PLANE_Y] :
NULL;
304 linesizes[0] =
img->stride[VPX_PLANE_Y];
305 linesizes[1] =
img->stride[VPX_PLANE_U];
306 linesizes[2] =
img->stride[VPX_PLANE_V];
308 ctx->has_alpha_channel ? img_alpha->stride[VPX_PLANE_Y] : 0;
310 if (
img->fb_priv && (!
ctx->has_alpha_channel || img_alpha->fb_priv)) {
315 if (!picture->
buf[0])
317 if (
ctx->has_alpha_channel) {
319 if (!picture->
buf[1]) {
324 for (
int i = 0;
i < 4;
i++) {
342 vpx_codec_destroy(&
ctx->decoder);
343 if (
ctx->has_alpha_channel)
344 vpx_codec_destroy(&
ctx->decoder_alpha);
349 #if CONFIG_LIBVPX_VP8_DECODER
353 return vpx_init(avctx, &
ctx->decoder, vpx_codec_vp8_dx());
361 .priv_data_size =
sizeof(VPxContext),
367 .wrapper_name =
"libvpx",
371 #if CONFIG_LIBVPX_VP9_DECODER
375 return vpx_init(avctx, &
ctx->decoder, vpx_codec_vp9_dx());
379 .
name =
"libvpx-vp9",
383 .priv_data_size =
sizeof(VPxContext),
391 .wrapper_name =
"libvpx",
static void error(const char *err)
AVBufferPool * av_buffer_pool_init(size_t size, AVBufferRef *(*alloc)(size_t size))
Allocate and initialize a buffer pool.
static av_cold int vp9_init(AVFormatContext *ctx, int st_index, PayloadContext *data)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVColorSpace colorspace
YUV colorspace type.
uint8_t * data
The data buffer.
This structure describes decoded (raw) audio or video data.
@ AVCOL_RANGE_JPEG
Full range content.
static int release_frame_buffer(void *priv, vpx_codec_frame_buffer_t *fb)
#define AV_PIX_FMT_YUV420P10
#define AV_LOG_VERBOSE
Detailed information.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
static const chunk_decoder decoder[8]
static av_cold void init_static_data(void)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
#define AV_PIX_FMT_GBRP10
static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, int has_alpha_channel)
#define AV_PIX_FMT_YUV444P10
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static const struct @321 planes[]
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
av_cold void ff_vp9_init_static(AVCodec *codec)
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
#define AV_PIX_FMT_YUV440P10
static av_cold int vpx_free(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV422P10
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
struct vpx_codec_ctx decoder
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV422P12
static av_cold int vpx_init(AVCodecContext *avctx, struct vpx_codec_ctx *decoder, const struct vpx_codec_iface *iface)
#define AV_PIX_FMT_YUV444P12
#define AVERROR_EXTERNAL
Generic error in an external library.
const AVCodec ff_libvpx_vp8_decoder
#define AV_LOG_INFO
Standard information.
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
#define i(width, name, range_min, range_max)
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
#define AV_PIX_FMT_GBRP12
AVColorSpace
YUV colorspace type.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
const char * name
Name of the codec implementation.
struct vpx_codec_ctx decoder_alpha
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
#define AV_PIX_FMT_YUV420P12
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
main external API structure.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
static int vpx_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int get_frame_buffer(void *priv, size_t min_size, vpx_codec_frame_buffer_t *fb)
static const AVProfile profiles[]
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int decode_frame(AVCodecContext *avctx, vpx_codec_ctx_t *decoder, uint8_t *data, uint32_t data_sz)
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
AVCodec ff_libvpx_vp9_decoder
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
A reference to a data buffer.
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_PIX_FMT_YUV440P12
static av_cold int vp8_init(AVFormatContext *s, int st_index, PayloadContext *vp8)
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
AVColorRange
Visual content value range.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
const AVProfile ff_vp9_profiles[]