raze-gles/polymer/eduke32/source/animvpx.h
hendricks266 fcf9beae6a Work-in-progress adjustment to the C code to compile under C++. It builds for me without errors using Win32 MinGW-GCC, but it still generates warning soup. No guarantees about MSVC or anything using SDL. Enable C++ by building with CPLUSPLUS=1. C remains the default and should compile with no change in setup.
Credit to Plagman for the idea and doing the work on the game side, which is included in this commit.

(Building as C++ will give us features with which we can make improvements and optimizations on the multiplayer code and Polymer.)

git-svn-id: https://svn.eduke32.com/eduke32@3116 1a8010ca-5511-0410-912e-c29ae57300e0
2012-11-05 02:49:08 +00:00

90 lines
2.2 KiB
C

#ifndef USE_OPENGL
# error "VP8 support requires OpenGL"
#endif
#ifndef ANIM_VPX_H
#define ANIM_VPX_H
#define VPX_CODEC_DISABLE_COMPAT 1
#include <vpx/vpx_decoder.h>
//#include <vpx/vp8dx.h>
// 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)
extern const char *animvpx_read_ivf_header_errmsg[7];
int32_t animvpx_read_ivf_header(int32_t inhandle, animvpx_ivf_header_t *hdr);
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
int32_t inhandle; // the kread() file handle
// 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;
// statistics
int32_t numframes;
int32_t sumtimes[3];
int32_t maxtimes[3];
} animvpx_codec_ctx;
int32_t animvpx_init_codec(const animvpx_ivf_header_t *info, int32_t inhandle, animvpx_codec_ctx *codec);
int32_t animvpx_uninit_codec(animvpx_codec_ctx *codec);
extern const char *animvpx_nextpic_errmsg[8];
int32_t animvpx_nextpic(animvpx_codec_ctx *codec, uint8_t **pic);
void animvpx_setup_glstate(void);
void animvpx_restore_glstate(void);
int32_t animvpx_render_frame(animvpx_codec_ctx *codec);
void animvpx_print_stats(const animvpx_codec_ctx *codec);
#endif // !defined ANIM_VPX_H