26 #define VPX_CODEC_DISABLE_COMPAT 1
27 #include <vpx/vpx_decoder.h>
28 #include <vpx/vp8dx.h>
38 typedef struct VPxDecoderContext {
40 struct vpx_codec_ctx decoder_alpha;
45 const struct vpx_codec_iface *iface,
49 struct vpx_codec_dec_cfg deccfg = {
57 if (vpx_codec_dec_init(
59 iface, &deccfg, 0) != VPX_CODEC_OK) {
71 int has_alpha_channel)
73 #if VPX_IMAGE_ABI_VERSION >= 3
78 #if VPX_IMAGE_ABI_VERSION >= 4
89 case VPX_IMG_FMT_I420:
95 #if CONFIG_LIBVPX_VP9_DECODER
96 case VPX_IMG_FMT_I422:
100 #if VPX_IMAGE_ABI_VERSION >= 3
101 case VPX_IMG_FMT_I440:
106 case VPX_IMG_FMT_I444:
108 #if VPX_IMAGE_ABI_VERSION >= 3
115 #ifdef VPX_IMG_FMT_HIGHBITDEPTH
116 case VPX_IMG_FMT_I42016:
118 if (img->bit_depth == 10) {
121 }
else if (img->bit_depth == 12) {
127 case VPX_IMG_FMT_I42216:
129 if (img->bit_depth == 10) {
132 }
else if (img->bit_depth == 12) {
138 #if VPX_IMAGE_ABI_VERSION >= 3
139 case VPX_IMG_FMT_I44016:
141 if (img->bit_depth == 10) {
144 }
else if (img->bit_depth == 12) {
151 case VPX_IMG_FMT_I44416:
153 if (img->bit_depth == 10) {
154 #if VPX_IMAGE_ABI_VERSION >= 3
161 }
else if (img->bit_depth == 12) {
162 #if VPX_IMAGE_ABI_VERSION >= 3
182 if (vpx_codec_decode(decoder, data, data_sz,
NULL, 0) != VPX_CODEC_OK) {
183 const char *
error = vpx_codec_error(decoder);
184 const char *detail = vpx_codec_error_detail(decoder);
201 const void *iter =
NULL;
202 const void *iter_alpha =
NULL;
203 struct vpx_image *
img, *img_alpha;
206 int side_data_size = 0;
215 if (side_data_size > 1) {
216 const uint64_t additional_id =
AV_RB64(side_data);
219 if (additional_id == 1) {
223 #
if CONFIG_LIBVPX_VP8_DECODER && CONFIG_LIBVPX_VP9_DECODER
225 &vpx_codec_vp8_dx_algo : &vpx_codec_vp9_dx_algo,
226 #elif CONFIG_LIBVPX_VP8_DECODER
227 &vpx_codec_vp8_dx_algo,
229 &vpx_codec_vp9_dx_algo,
242 if ((img = vpx_codec_get_frame(&ctx->
decoder, &iter)) &&
244 (img_alpha = vpx_codec_get_frame(&ctx->
decoder_alpha, &iter_alpha)))) {
248 if (img->d_w > img->w || img->d_h > img->h) {
250 img->d_w, img->d_h, img->w, img->h);
255 #ifdef VPX_IMG_FMT_HIGHBITDEPTH
257 img->fmt, img->bit_depth);
265 if ((
int) img->d_w != avctx->
width || (
int) img->d_h != avctx->
height) {
275 planes[0] = img->planes[VPX_PLANE_Y];
276 planes[1] = img->planes[VPX_PLANE_U];
277 planes[2] = img->planes[VPX_PLANE_V];
280 linesizes[0] = img->stride[VPX_PLANE_Y];
281 linesizes[1] = img->stride[VPX_PLANE_U];
282 linesizes[2] = img->stride[VPX_PLANE_V];
286 linesizes, avctx->
pix_fmt, img->d_w, img->d_h);
295 vpx_codec_destroy(&ctx->
decoder);
301 #if CONFIG_LIBVPX_VP8_DECODER
304 return vpx_init(avctx, &vpx_codec_vp8_dx_algo, 0);
307 AVCodec ff_libvpx_vp8_decoder = {
320 #if CONFIG_LIBVPX_VP9_DECODER
323 return vpx_init(avctx, &vpx_codec_vp9_dx_algo, 0);
326 AVCodec ff_libvpx_vp9_decoder = {
327 .
name =
"libvpx-vp9",
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_PIX_FMT_YUV440P10
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static av_cold int vpx_free(AVCodecContext *avctx)
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.
static av_cold int init(AVCodecContext *avctx)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AV_PIX_FMT_GBRP10
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_PIX_FMT_YUV420P12
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
functionally identical to above
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
AVColorSpace
YUV colorspace type.
#define AV_LOG_VERBOSE
Detailed information.
AVColorRange
MPEG vs JPEG YUV range.
#define AV_PIX_FMT_YUV422P12
static int vpx_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static av_cold int vpx_init(AVCodecContext *avctx, const struct vpx_codec_iface *iface, int is_alpha_decoder)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
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.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
struct vpx_codec_ctx decoder
struct vpx_codec_ctx decoder_alpha
static const chunk_decoder decoder[8]
int width
picture width / height.
ITU-R BT2020 non-constant luminance system.
static void error(const char *err)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
the normal 2^n-1 "JPEG" YUV ranges
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
av_cold void ff_vp9_init_static(AVCodec *codec)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static av_cold int vp9_init(AVFormatContext *ctx, int st_index, PayloadContext *data)
static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img, int has_alpha_channel)
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Data found in BlockAdditional element of matroska container.
#define AV_PIX_FMT_YUV420P10
static const AVProfile profiles[]
enum AVColorSpace colorspace
YUV colorspace type.
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
the normal 219*2^(n-8) "MPEG" YUV ranges
static av_cold int vp8_init(AVFormatContext *s, int st_index, PayloadContext *vp8)
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int decode_frame(AVCodecContext *avctx, vpx_codec_ctx_t *decoder, uint8_t *data, uint32_t data_sz)
common internal api header.
common internal and external API header
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const AVProfile ff_vp9_profiles[]
#define AVERROR_EXTERNAL
Generic error in an external library.
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.