26 #define VPX_CODEC_DISABLE_COMPAT 1
27 #include <vpx/vpx_decoder.h>
28 #include <vpx/vp8dx.h>
30 #include "libavutil/common.h"
31 #include "libavutil/imgutils.h"
35 typedef struct VP8DecoderContext {
40 const struct vpx_codec_iface *iface)
43 struct vpx_codec_dec_cfg deccfg = {
51 if (vpx_codec_dec_init(&ctx->
decoder, iface, &deccfg, 0) != VPX_CODEC_OK) {
52 const char *error = vpx_codec_error(&ctx->
decoder);
67 const void *iter = NULL;
68 struct vpx_image *
img;
71 if (vpx_codec_decode(&ctx->
decoder, avpkt->
data, avpkt->
size, NULL, 0) !=
73 const char *error = vpx_codec_error(&ctx->
decoder);
74 const char *detail = vpx_codec_error_detail(&ctx->
decoder);
83 if ((img = vpx_codec_get_frame(&ctx->
decoder, &iter))) {
84 if (img->fmt != VPX_IMG_FMT_I420) {
90 if ((
int) img->d_w != avctx->
width || (
int) img->d_h != avctx->
height) {
100 img->stride, avctx->
pix_fmt, img->d_w, img->d_h);
109 vpx_codec_destroy(&ctx->
decoder);
113 #if CONFIG_LIBVPX_VP8_DECODER
116 return vpx_init(avctx, &vpx_codec_vp8_dx_algo);
119 AVCodec ff_libvpx_vp8_decoder = {
132 #if CONFIG_LIBVPX_VP9_DECODER
135 return vpx_init(avctx, &vpx_codec_vp9_dx_algo);
138 AVCodec ff_libvpx_vp9_decoder = {
139 .
name =
"libvpx-vp9",
This structure describes decoded (raw) audio or video data.
struct vpx_codec_ctx decoder
static av_cold int init(AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
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 av_cold int vp8_free(AVCodecContext *avctx)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
static const chunk_decoder decoder[8]
int width
picture width / height.
static av_cold int vpx_init(AVCodecContext *avctx, const struct vpx_codec_iface *iface)
#define CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
static int vp8_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_LOG_INFO
Standard information.
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
common internal api header.
#define CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define AVERROR_INVALIDDATA
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.