2011-07-18 19:06:29 +00:00
|
|
|
#ifndef USE_OPENGL
|
|
|
|
# error "VP8 support requires OpenGL"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ANIM_VPX_H
|
|
|
|
#define ANIM_VPX_H
|
|
|
|
|
|
|
|
#define VPX_CODEC_DISABLE_COMPAT 1
|
2012-11-08 21:54:17 +00:00
|
|
|
#ifndef ANIMVPX_STANDALONE
|
2015-05-19 21:56:03 +00:00
|
|
|
# undef UNUSED
|
2012-11-08 21:54:17 +00:00
|
|
|
# include <vpx/vpx_decoder.h>
|
2011-07-18 19:06:29 +00:00
|
|
|
//#include <vpx/vp8dx.h>
|
2012-11-08 21:54:17 +00:00
|
|
|
#endif
|
2011-07-18 19:06:29 +00:00
|
|
|
|
|
|
|
// IVF format: http://wiki.multimedia.cx/index.php?title=IVF
|
|
|
|
#pragma pack(push,1)
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char magic[4];
|
|
|
|
uint16_t version;
|
|
|
|
uint16_t hdrlen;
|
|
|
|
|
|
|
|
char fourcc[4];
|
|
|
|
uint16_t width;
|
|
|
|
uint16_t height;
|
|
|
|
|
|
|
|
uint32_t fpsnumer;
|
|
|
|
uint32_t fpsdenom;
|
|
|
|
|
|
|
|
uint32_t numframes;
|
|
|
|
uint32_t unused_;
|
|
|
|
} animvpx_ivf_header_t;
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2012-11-08 21:54:17 +00:00
|
|
|
#ifndef ANIMVPX_STANDALONE
|
2019-03-01 08:51:50 +00:00
|
|
|
#include "vfs.h"
|
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
extern const char *animvpx_read_ivf_header_errmsg[7];
|
2019-03-01 08:51:50 +00:00
|
|
|
int32_t animvpx_read_ivf_header(buildvfs_kfd inhandle, animvpx_ivf_header_t *hdr);
|
2011-07-18 19:06:29 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *errmsg; // non-NULL if codec error? better always check...
|
|
|
|
const char *errmsg_detail; // may be NULL even if codec error
|
|
|
|
|
|
|
|
uint16_t width, height;
|
|
|
|
uint8_t *pic; // lines of [Y U V 0], calloc'ed on init
|
|
|
|
|
|
|
|
// VVV everything that follows should be considered private! VVV
|
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
buildvfs_kfd inhandle; // the kread() file handle
|
2011-07-18 19:06:29 +00:00
|
|
|
|
|
|
|
// state of this struct:
|
|
|
|
// 0: uninited (either not yet or already)
|
|
|
|
// 1: codec init OK
|
|
|
|
// -1: error while initing
|
|
|
|
// -2: error while uniniting
|
|
|
|
int32_t initstate;
|
|
|
|
|
|
|
|
// decoder state:
|
|
|
|
// 0: first time / begin
|
|
|
|
// 1: have more frames
|
|
|
|
// 2: reached EOF
|
|
|
|
// -1: unspecified error
|
|
|
|
// -2: decoder error
|
|
|
|
int32_t decstate;
|
|
|
|
|
|
|
|
uint32_t compbuflen;
|
|
|
|
uint32_t compbufallocsiz;
|
|
|
|
uint8_t *compbuf; // compressed data buffer (one IVF/VP8 frame)
|
|
|
|
|
|
|
|
vpx_codec_ctx_t codec;
|
|
|
|
vpx_codec_iter_t iter;
|
2012-07-13 18:20:55 +00:00
|
|
|
|
|
|
|
// statistics
|
|
|
|
int32_t numframes;
|
|
|
|
int32_t sumtimes[3];
|
|
|
|
int32_t maxtimes[3];
|
2011-07-18 19:06:29 +00:00
|
|
|
} animvpx_codec_ctx;
|
|
|
|
|
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
int32_t animvpx_init_codec(const animvpx_ivf_header_t *info, buildvfs_kfd inhandle, animvpx_codec_ctx *codec);
|
2011-07-18 19:06:29 +00:00
|
|
|
int32_t animvpx_uninit_codec(animvpx_codec_ctx *codec);
|
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
extern const char *animvpx_nextpic_errmsg[8];
|
2011-07-18 19:06:29 +00:00
|
|
|
int32_t animvpx_nextpic(animvpx_codec_ctx *codec, uint8_t **pic);
|
|
|
|
|
2017-12-12 05:13:38 +00:00
|
|
|
void animvpx_setup_glstate(int32_t animvpx_flags);
|
2011-07-18 19:06:29 +00:00
|
|
|
void animvpx_restore_glstate(void);
|
2017-12-12 05:13:32 +00:00
|
|
|
int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect);
|
2012-07-13 18:20:55 +00:00
|
|
|
|
|
|
|
void animvpx_print_stats(const animvpx_codec_ctx *codec);
|
2012-11-08 21:54:17 +00:00
|
|
|
#endif
|
2011-07-18 19:06:29 +00:00
|
|
|
|
2012-11-08 20:17:23 +00:00
|
|
|
static inline int32_t animvpx_check_header(const animvpx_ivf_header_t *hdr)
|
|
|
|
{
|
|
|
|
if (Bmemcmp(hdr->magic,"DKIF",4))
|
|
|
|
return 2; // "not an IVF file"
|
|
|
|
|
|
|
|
if (hdr->version != 0)
|
|
|
|
return 3; // "unrecognized IVF version"
|
|
|
|
|
|
|
|
// fourcc is left as-is
|
|
|
|
if (Bmemcmp(hdr->fourcc, "VP80", 4))
|
|
|
|
return 4; // "only VP8 supported"
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-07-18 19:06:29 +00:00
|
|
|
|
|
|
|
#endif // !defined ANIM_VPX_H
|