25 #include <vpx/vpx_decoder.h> 26 #include <vpx/vp8dx.h> 45 bool init(vpx_codec_iface_t *iface);
73 vpx_codec_dec_cfg config;
74 memset(&config, 0,
sizeof(config));
78 vpx_codec_err_t result = vpx_codec_dec_init(&
_context, iface, &config, 0);
79 if (result != VPX_CODEC_OK)
93 dataStream.
read(data.get(), dataStream.
size());
96 vpx_codec_err_t result = vpx_codec_decode(&
_context, data.get(), dataStream.
size(), 0, 0);
97 if (result != VPX_CODEC_OK)
101 vpx_codec_iter_t iter = 0;
102 vpx_image_t *image = vpx_codec_get_frame(&
_context, &iter);
108 switch (image->range) {
109 case VPX_CR_STUDIO_RANGE:
112 case VPX_CR_FULL_RANGE:
124 switch (image->fmt) {
125 case VPX_IMG_FMT_I420:
126 YUVToRGBMan.convert420(scale,
_surface->getData(),
_surface->getPitch(), image->planes[0], image->planes[1], image->planes[2], image->w, image->h, image->stride[0], image->stride[1]);
133 for (
int y = 0; y < surface.
getHeight(); y++)
134 memcpy(surface.
getData() + y * surface.
getPitch(),
_surface->getData() + (y * image->d_h) * image->d_w * 4, image->d_w * 4);
139 if (!decoder->init(&vpx_codec_vp8_dx_algo))
147 if (!decoder->init(&vpx_codec_vp9_dx_algo))
LuminanceScale
The scale of the luminance values.
Luminance values range from [0, 255].
void reset(PointerType o=0)
Resets the pointer with the new value.
PointerType release()
Returns the plain pointer value and releases ScopedPtr.
A simple scoped smart pointer template.
bool init(vpx_codec_iface_t *iface)
Common::ScopedPtr< Graphics::Surface > _surface
void decodeFrame(Graphics::Surface &surface, Common::SeekableReadStream &dataStream)
virtual size_t read(void *dataPtr, size_t dataSize)=0
Read data from the stream.
Efficient YUV to RGB conversion.
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
Basic reading stream interfaces.
An image surface, in BGRA format.
Codec * makeVP8Decoder()
Create a codec capable of decoding VP8 frames.
Codec * makeVP9Decoder()
Create a codec capable of decoding VP9 frames.
Interface for a seekable & readable data stream.