1 #ifndef MY_VPX_DEFS_H_ 2 #define MY_VPX_DEFS_H_ 3 4 5 #define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */ 6 #define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */ 7 #define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */ 8 #define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */ 9 10 typedef unsigned char uint8_t; 11 12 enum class RenderMode { 13 RENDER_BY_HOST_GPU = 1, 14 RENDER_BY_GUEST_CPU = 2, 15 }; 16 17 enum vpx_img_fmt_t { 18 VPX_IMG_FMT_NONE, 19 VPX_IMG_FMT_YV12 = 20 VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */ 21 VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2, 22 VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5, 23 VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6, 24 VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7, 25 VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH, 26 VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH, 27 VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH, 28 VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH 29 }; 30 31 struct vpx_image_t { 32 vpx_img_fmt_t fmt; /**< Image Format */ 33 unsigned int d_w; /**< Displayed image width */ 34 unsigned int d_h; /**< Displayed image height */ 35 void *user_priv; 36 }; 37 38 #define VPX_CODEC_OK 0 39 40 struct vpx_codec_ctx_t { 41 int vpversion; //8: vp8 or 9: vp9 42 int version; // 100: return decoded frame to guest; 200: render on host 43 int hostColorBufferId; 44 uint64_t id; // >= 1, unique 45 int memory_slot; 46 uint64_t address_offset = 0; 47 size_t outputBufferWidth; 48 size_t outputBufferHeight; 49 size_t width; 50 size_t height; 51 size_t bpp; 52 uint8_t *data; 53 uint8_t *dst; 54 vpx_image_t myImg; 55 }; 56 57 int vpx_codec_destroy(vpx_codec_ctx_t*); 58 int vpx_codec_dec_init(vpx_codec_ctx_t*); 59 vpx_image_t* vpx_codec_get_frame(vpx_codec_ctx_t*, int hostColorBufferId = -1); 60 int vpx_codec_flush(vpx_codec_ctx_t *ctx); 61 int vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data, 62 unsigned int data_sz, void *user_priv, 63 long deadline); 64 65 #endif // MY_VPX_DEFS_H_ 66