mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +00:00
- added all the prerequisites for the cutscene system from Raze:
* libvpx library * libsmackerdec * playmve * MoviePlayer class. * ScreenJob engine core.
This commit is contained in:
parent
339419240c
commit
69a7715a02
39 changed files with 9900 additions and 23 deletions
148
bin/windows/vpx/include/vpx/vp8.h
Normal file
148
bin/windows/vpx/include/vpx/vp8.h
Normal file
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8 VP8
|
||||
* \ingroup codecs
|
||||
* VP8 is vpx's newest video compression algorithm that uses motion
|
||||
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
|
||||
* prediction error signal and context dependent entropy coding techniques
|
||||
* based on arithmetic principles. It features:
|
||||
* - YUV 4:2:0 image format
|
||||
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
|
||||
* - 1/4 (1/8) pixel accuracy motion compensated prediction
|
||||
* - 4x4 DCT transform
|
||||
* - 128 level linear quantizer
|
||||
* - In loop deblocking filter
|
||||
* - Context-based entropy coding
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides controls common to both the VP8 encoder and decoder.
|
||||
*/
|
||||
#ifndef VPX_VP8_H_
|
||||
#define VPX_VP8_H_
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Control functions
|
||||
*
|
||||
* The set of macros define the control functions of VP8 interface
|
||||
*/
|
||||
enum vp8_com_control_id {
|
||||
VP8_SET_REFERENCE = 1, /**< pass in an external frame into decoder to be used as reference frame */
|
||||
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
|
||||
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
|
||||
VP8_SET_DBG_COLOR_REF_FRAME = 4, /**< set the reference frames to color for each macroblock */
|
||||
VP8_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */
|
||||
VP8_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */
|
||||
VP8_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */
|
||||
|
||||
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
|
||||
* for its control ids. These should be migrated to something like the
|
||||
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
|
||||
*/
|
||||
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
|
||||
VP8_COMMON_CTRL_ID_MAX,
|
||||
VP8_DECODER_CTRL_ID_START = 256
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* The set of macros define VP8 decoder post processing flags
|
||||
*/
|
||||
enum vp8_postproc_level {
|
||||
VP8_NOFILTERING = 0,
|
||||
VP8_DEBLOCK = 1 << 0,
|
||||
VP8_DEMACROBLOCK = 1 << 1,
|
||||
VP8_ADDNOISE = 1 << 2,
|
||||
VP8_DEBUG_TXT_FRAME_INFO = 1 << 3, /**< print frame information */
|
||||
VP8_DEBUG_TXT_MBLK_MODES = 1 << 4, /**< print macro block modes over each macro block */
|
||||
VP8_DEBUG_TXT_DC_DIFF = 1 << 5, /**< print dc diff for each macro block */
|
||||
VP8_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */
|
||||
VP8_MFQE = 1 << 10
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* This define a structure that describe the post processing settings. For
|
||||
* the best objective measure (using the PSNR metric) set post_proc_flag
|
||||
* to VP8_DEBLOCK and deblocking_level to 1.
|
||||
*/
|
||||
|
||||
typedef struct vp8_postproc_cfg {
|
||||
int post_proc_flag; /**< the types of post processing to be done, should be combination of "vp8_postproc_level" */
|
||||
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
|
||||
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
|
||||
} vp8_postproc_cfg_t;
|
||||
|
||||
/*!\brief reference frame type
|
||||
*
|
||||
* The set of macros define the type of VP8 reference frames
|
||||
*/
|
||||
typedef enum vpx_ref_frame_type {
|
||||
VP8_LAST_FRAME = 1,
|
||||
VP8_GOLD_FRAME = 2,
|
||||
VP8_ALTR_FRAME = 4
|
||||
} vpx_ref_frame_type_t;
|
||||
|
||||
/*!\brief reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp8 reference frames.
|
||||
*/
|
||||
typedef struct vpx_ref_frame {
|
||||
vpx_ref_frame_type_t frame_type; /**< which reference frame */
|
||||
vpx_image_t img; /**< reference frame data in image format */
|
||||
} vpx_ref_frame_t;
|
||||
|
||||
/*!\brief VP9 specific reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp9 reference frames.
|
||||
*/
|
||||
typedef struct vp9_ref_frame {
|
||||
int idx; /**< frame index to get (input) */
|
||||
vpx_image_t img; /**< img structure to populate (output) */
|
||||
} vp9_ref_frame_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief vp8 decoder control function parameter type
|
||||
*
|
||||
* defines the data type for each of VP8 decoder control function requires
|
||||
*/
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_SET_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_COPY_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
|
||||
#define VPX_CTRL_VP8_SET_POSTPROC
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_DBG_COLOR_REF_FRAME, int)
|
||||
#define VPX_CTRL_VP8_SET_DBG_COLOR_REF_FRAME
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_DBG_COLOR_MB_MODES, int)
|
||||
#define VPX_CTRL_VP8_SET_DBG_COLOR_MB_MODES
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_DBG_COLOR_B_MODES, int)
|
||||
#define VPX_CTRL_VP8_SET_DBG_COLOR_B_MODES
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_DBG_DISPLAY_MV, int)
|
||||
#define VPX_CTRL_VP8_SET_DBG_DISPLAY_MV
|
||||
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
|
||||
#define VPX_CTRL_VP9_GET_REFERENCE
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VP8_H_
|
176
bin/windows/vpx/include/vpx/vp8dx.h
Normal file
176
bin/windows/vpx/include/vpx/vp8dx.h
Normal file
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
|
||||
* \ingroup vp8
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
|
||||
* interface.
|
||||
*/
|
||||
#ifndef VPX_VP8DX_H_
|
||||
#define VPX_VP8DX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include controls common to both the encoder and decoder */
|
||||
#include "./vp8.h"
|
||||
|
||||
/*!\name Algorithm interface for VP8
|
||||
*
|
||||
* This interface provides the capability to decode VP8 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\name Algorithm interface for VP9
|
||||
*
|
||||
* This interface provides the capability to decode VP9 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\enum vp8_dec_control_id
|
||||
* \brief VP8 decoder control functions
|
||||
*
|
||||
* This set of macros define the control functions available for the VP8
|
||||
* decoder interface.
|
||||
*
|
||||
* \sa #vpx_codec_control
|
||||
*/
|
||||
enum vp8_dec_control_id {
|
||||
/** control function to get info on which reference frames were updated
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
|
||||
|
||||
/** check if the indicated frame is corrupted */
|
||||
VP8D_GET_FRAME_CORRUPTED,
|
||||
|
||||
/** control function to get info on which reference frames were used
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_USED,
|
||||
|
||||
/** decryption function to decrypt encoded buffer data immediately
|
||||
* before decoding. Takes a vpx_decrypt_init, which contains
|
||||
* a callback function and opaque context pointer.
|
||||
*/
|
||||
VPXD_SET_DECRYPTOR,
|
||||
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
|
||||
|
||||
/** control function to get the dimensions that the current frame is decoded
|
||||
* at. This may be different to the intended display size for the frame as
|
||||
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
|
||||
VP9D_GET_FRAME_SIZE,
|
||||
|
||||
/** control function to get the current frame's intended display dimensions
|
||||
* (as specified in the wrapper or frame header). This may be different to
|
||||
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
|
||||
VP9D_GET_DISPLAY_SIZE,
|
||||
|
||||
/** control function to get the bit depth of the stream. */
|
||||
VP9D_GET_BIT_DEPTH,
|
||||
|
||||
/** control function to set the byte alignment of the planes in the reference
|
||||
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
|
||||
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
|
||||
* follows Y plane, and V plane directly follows U plane. Default value is 0.
|
||||
*/
|
||||
VP9_SET_BYTE_ALIGNMENT,
|
||||
|
||||
/** control function to invert the decoding order to from right to left. The
|
||||
* function is used in a test to confirm the decoding independence of tile
|
||||
* columns. The function may be used in application where this order
|
||||
* of decoding is desired.
|
||||
*
|
||||
* TODO(yaowu): Rework the unit test that uses this control, and in a future
|
||||
* release, this test-only control shall be removed.
|
||||
*/
|
||||
VP9_INVERT_TILE_DECODE_ORDER,
|
||||
|
||||
/** control function to set the skip loop filter flag. Valid values are
|
||||
* integers. The decoder will skip the loop filter when its value is set to
|
||||
* nonzero. If the loop filter is skipped the decoder may accumulate decode
|
||||
* artifacts. The default value is 0.
|
||||
*/
|
||||
VP9_SET_SKIP_LOOP_FILTER,
|
||||
|
||||
VP8_DECODER_CTRL_ID_MAX
|
||||
};
|
||||
|
||||
/** Decrypt n bytes of data from input -> output, using the decrypt_state
|
||||
* passed in VPXD_SET_DECRYPTOR.
|
||||
*/
|
||||
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
|
||||
unsigned char *output, int count);
|
||||
|
||||
/*!\brief Structure to hold decryption state
|
||||
*
|
||||
* Defines a structure to hold the decryption state and access function.
|
||||
*/
|
||||
typedef struct vpx_decrypt_init {
|
||||
/*! Decrypt callback. */
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
|
||||
/*! Decryption state. */
|
||||
void *decrypt_state;
|
||||
} vpx_decrypt_init;
|
||||
|
||||
/*!\brief A deprecated alias for vpx_decrypt_init.
|
||||
*/
|
||||
typedef vpx_decrypt_init vp8_decrypt_init;
|
||||
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief VP8 decoder control function parameter type
|
||||
*
|
||||
* Defines the data types that VP8D control functions take. Note that
|
||||
* additional common controls are defined in vp8.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
|
||||
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VPXD_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VP8D_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
|
||||
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
|
||||
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8_decoder */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VP8DX_H_
|
479
bin/windows/vpx/include/vpx/vpx_codec.h
Normal file
479
bin/windows/vpx/include/vpx/vpx_codec.h
Normal file
|
@ -0,0 +1,479 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/*!\defgroup codec Common Algorithm Interface
|
||||
* This abstraction allows applications to easily support multiple video
|
||||
* formats with minimal code duplication. This section describes the interface
|
||||
* common to all codecs (both encoders and decoders).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the codec algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video codec algorithm.
|
||||
*
|
||||
* An application instantiates a specific codec instance by using
|
||||
* vpx_codec_init() and a pointer to the algorithm's interface structure:
|
||||
* <pre>
|
||||
* my_app.c:
|
||||
* extern vpx_codec_iface_t my_codec;
|
||||
* {
|
||||
* vpx_codec_ctx_t algo;
|
||||
* res = vpx_codec_init(&algo, &my_codec);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Once initialized, the instance is manged using other functions from
|
||||
* the vpx_codec_* family.
|
||||
*/
|
||||
#ifndef VPX_VPX_CODEC_H_
|
||||
#define VPX_VPX_CODEC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_integer.h"
|
||||
#include "./vpx_image.h"
|
||||
|
||||
/*!\brief Decorator indicating a function is deprecated */
|
||||
#ifndef DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define DEPRECATED __attribute__ ((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define DEPRECATED
|
||||
#else
|
||||
#define DEPRECATED
|
||||
#endif
|
||||
#endif /* DEPRECATED */
|
||||
|
||||
#ifndef DECLSPEC_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLSPEC_DEPRECATED __declspec(deprecated) /**< \copydoc #DEPRECATED */
|
||||
#else
|
||||
#define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */
|
||||
#endif
|
||||
#endif /* DECLSPEC_DEPRECATED */
|
||||
|
||||
/*!\brief Decorator indicating a function is potentially unused */
|
||||
#ifdef UNUSED
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define UNUSED __attribute__ ((unused))
|
||||
#else
|
||||
#define UNUSED
|
||||
#endif
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_CODEC_ABI_VERSION (3 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Algorithm return codes */
|
||||
typedef enum {
|
||||
/*!\brief Operation completed without error */
|
||||
VPX_CODEC_OK,
|
||||
|
||||
/*!\brief Unspecified error */
|
||||
VPX_CODEC_ERROR,
|
||||
|
||||
/*!\brief Memory operation failed */
|
||||
VPX_CODEC_MEM_ERROR,
|
||||
|
||||
/*!\brief ABI version mismatch */
|
||||
VPX_CODEC_ABI_MISMATCH,
|
||||
|
||||
/*!\brief Algorithm does not have required capability */
|
||||
VPX_CODEC_INCAPABLE,
|
||||
|
||||
/*!\brief The given bitstream is not supported.
|
||||
*
|
||||
* The bitstream was unable to be parsed at the highest level. The decoder
|
||||
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
|
||||
* stream. */
|
||||
VPX_CODEC_UNSUP_BITSTREAM,
|
||||
|
||||
/*!\brief Encoded bitstream uses an unsupported feature
|
||||
*
|
||||
* The decoder does not implement a feature required by the encoder. This
|
||||
* return code should only be used for features that prevent future
|
||||
* pictures from being properly decoded. This error \ref MAY be treated as
|
||||
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
|
||||
*/
|
||||
VPX_CODEC_UNSUP_FEATURE,
|
||||
|
||||
/*!\brief The coded data for this stream is corrupt or incomplete
|
||||
*
|
||||
* There was a problem decoding the current frame. This return code
|
||||
* should only be used for failures that prevent future pictures from
|
||||
* being properly decoded. This error \ref MAY be treated as fatal to the
|
||||
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
|
||||
* is continued for the current GOP, artifacts may be present.
|
||||
*/
|
||||
VPX_CODEC_CORRUPT_FRAME,
|
||||
|
||||
/*!\brief An application-supplied parameter is not valid.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_INVALID_PARAM,
|
||||
|
||||
/*!\brief An iterator reached the end of list.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_LIST_END
|
||||
|
||||
}
|
||||
vpx_codec_err_t;
|
||||
|
||||
|
||||
/*! \brief Codec capabilities bitfield
|
||||
*
|
||||
* Each codec advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_caps_t;
|
||||
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
|
||||
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
|
||||
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_flags_t;
|
||||
|
||||
|
||||
/*!\brief Codec interface structure.
|
||||
*
|
||||
* Contains function pointers and other data private to the codec
|
||||
* implementation. This structure is opaque to the application.
|
||||
*/
|
||||
typedef const struct vpx_codec_iface vpx_codec_iface_t;
|
||||
|
||||
|
||||
/*!\brief Codec private data structure.
|
||||
*
|
||||
* Contains data private to the codec implementation. This structure is opaque
|
||||
* to the application.
|
||||
*/
|
||||
typedef struct vpx_codec_priv vpx_codec_priv_t;
|
||||
|
||||
|
||||
/*!\brief Iterator
|
||||
*
|
||||
* Opaque storage used for iterating over lists.
|
||||
*/
|
||||
typedef const void *vpx_codec_iter_t;
|
||||
|
||||
|
||||
/*!\brief Codec context structure
|
||||
*
|
||||
* All codecs \ref MUST support this context structure fully. In general,
|
||||
* this data should be considered private to the codec algorithm, and
|
||||
* not be manipulated or examined by the calling application. Applications
|
||||
* may reference the 'name' member to get a printable description of the
|
||||
* algorithm.
|
||||
*/
|
||||
typedef struct vpx_codec_ctx {
|
||||
const char *name; /**< Printable interface name */
|
||||
vpx_codec_iface_t *iface; /**< Interface pointers */
|
||||
vpx_codec_err_t err; /**< Last returned error */
|
||||
const char *err_detail; /**< Detailed info, if available */
|
||||
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
|
||||
union {
|
||||
/**< Decoder Configuration Pointer */
|
||||
const struct vpx_codec_dec_cfg *dec;
|
||||
/**< Encoder Configuration Pointer */
|
||||
const struct vpx_codec_enc_cfg *enc;
|
||||
const void *raw;
|
||||
} config; /**< Configuration pointer aliasing union */
|
||||
vpx_codec_priv_t *priv; /**< Algorithm private storage */
|
||||
} vpx_codec_ctx_t;
|
||||
|
||||
/*!\brief Bit depth for codec
|
||||
* *
|
||||
* This enumeration determines the bit depth of the codec.
|
||||
*/
|
||||
typedef enum vpx_bit_depth {
|
||||
VPX_BITS_8 = 8, /**< 8 bits */
|
||||
VPX_BITS_10 = 10, /**< 10 bits */
|
||||
VPX_BITS_12 = 12, /**< 12 bits */
|
||||
} vpx_bit_depth_t;
|
||||
|
||||
/*
|
||||
* Library Version Number Interface
|
||||
*
|
||||
* For example, see the following sample return values:
|
||||
* vpx_codec_version() (1<<16 | 2<<8 | 3)
|
||||
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
|
||||
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
|
||||
*/
|
||||
|
||||
/*!\brief Return the version information (as an integer)
|
||||
*
|
||||
* Returns a packed encoding of the library version number. This will only include
|
||||
* the major.minor.patch component of the version number. Note that this encoded
|
||||
* value should be accessed through the macros provided, as the encoding may change
|
||||
* in the future.
|
||||
*
|
||||
*/
|
||||
int vpx_codec_version(void);
|
||||
#define VPX_VERSION_MAJOR(v) ((v>>16)&0xff) /**< extract major from packed version */
|
||||
#define VPX_VERSION_MINOR(v) ((v>>8)&0xff) /**< extract minor from packed version */
|
||||
#define VPX_VERSION_PATCH(v) ((v>>0)&0xff) /**< extract patch from packed version */
|
||||
|
||||
/*!\brief Return the version major number */
|
||||
#define vpx_codec_version_major() ((vpx_codec_version()>>16)&0xff)
|
||||
|
||||
/*!\brief Return the version minor number */
|
||||
#define vpx_codec_version_minor() ((vpx_codec_version()>>8)&0xff)
|
||||
|
||||
/*!\brief Return the version patch number */
|
||||
#define vpx_codec_version_patch() ((vpx_codec_version()>>0)&0xff)
|
||||
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable string containing the full library version number. This may
|
||||
* contain additional text following the three digit version number, as to indicate
|
||||
* release candidates, prerelease versions, etc.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_str(void);
|
||||
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable "extra string". This is the component of the string returned
|
||||
* by vpx_codec_version_str() following the three digit version number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_extra_str(void);
|
||||
|
||||
|
||||
/*!\brief Return the build configuration
|
||||
*
|
||||
* Returns a printable string containing an encoded version of the build
|
||||
* configuration. This may be useful to vpx support.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_build_config(void);
|
||||
|
||||
|
||||
/*!\brief Return the name for a given interface
|
||||
*
|
||||
* Returns a human readable string for name of the given codec interface.
|
||||
*
|
||||
* \param[in] iface Interface pointer
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
|
||||
|
||||
|
||||
/*!\brief Convert error number to printable string
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] err Error number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
|
||||
|
||||
|
||||
/*!\brief Retrieve error synopsis for codec context
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
|
||||
|
||||
|
||||
/*!\brief Retrieve detailed error information for codec context
|
||||
*
|
||||
* Returns a human readable string providing detailed information about
|
||||
* the last error.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
* \retval NULL
|
||||
* No detailed information is available.
|
||||
*/
|
||||
const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
|
||||
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all codecs.
|
||||
* They represent the base case functionality expected of all codecs.
|
||||
*/
|
||||
|
||||
/*!\brief Destroy a codec instance
|
||||
*
|
||||
* Destroys a codec context, freeing any associated memory buffers.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The codec algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
|
||||
|
||||
|
||||
/*!\brief Get the capabilities of an algorithm.
|
||||
*
|
||||
* Retrieves the capabilities bitfield from the algorithm's interface.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
*
|
||||
*/
|
||||
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
|
||||
|
||||
|
||||
/*!\brief Control algorithm
|
||||
*
|
||||
* This function is used to exchange algorithm specific data with the codec
|
||||
* instance. This can be used to implement features specific to a particular
|
||||
* algorithm.
|
||||
*
|
||||
* This wrapper function dispatches the request to the helper function
|
||||
* associated with the given ctrl_id. It tries to call this function
|
||||
* transparently, but will return #VPX_CODEC_ERROR if the request could not
|
||||
* be dispatched.
|
||||
*
|
||||
* Note that this function should not be used directly. Call the
|
||||
* #vpx_codec_control wrapper macro instead.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] ctrl_id Algorithm specific control identifier
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The control request was processed.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* The control request was not processed.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* The data was not valid.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx,
|
||||
int ctrl_id,
|
||||
...);
|
||||
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
|
||||
# define vpx_codec_control(ctx,id,data) vpx_codec_control_(ctx,id,data)
|
||||
# define VPX_CTRL_USE_TYPE(id, typ)
|
||||
# define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
|
||||
# define VPX_CTRL_VOID(id, typ)
|
||||
|
||||
#else
|
||||
/*!\brief vpx_codec_control wrapper macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_().
|
||||
*
|
||||
* \internal
|
||||
* It works by dispatching the call to the control function through a wrapper
|
||||
* function named with the id parameter.
|
||||
*/
|
||||
# define vpx_codec_control(ctx,id,data) vpx_codec_control_##id(ctx,id,data)\
|
||||
/**<\hideinitializer*/
|
||||
|
||||
|
||||
/*!\brief vpx_codec_control type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It defines the type of the argument for a given
|
||||
* control identifier.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with
|
||||
* the correctly typed arguments as a wrapper to the type-unsafe internal
|
||||
* function.
|
||||
*/
|
||||
# define VPX_CTRL_USE_TYPE(id, typ) \
|
||||
static vpx_codec_err_t \
|
||||
vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) UNUSED;\
|
||||
\
|
||||
static vpx_codec_err_t \
|
||||
vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
|
||||
return vpx_codec_control_(ctx, ctrl_id, data);\
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
|
||||
/*!\brief vpx_codec_control deprecated type definition macro
|
||||
*
|
||||
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
|
||||
* deprecated and should not be used. Consult the documentation for your
|
||||
* codec for more information.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with the correctly typed arguments as a
|
||||
* wrapper to the type-unsafe internal function.
|
||||
*/
|
||||
# define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
|
||||
DECLSPEC_DEPRECATED static vpx_codec_err_t \
|
||||
vpx_codec_control_##id(vpx_codec_ctx_t*, int, typ) DEPRECATED UNUSED;\
|
||||
\
|
||||
DECLSPEC_DEPRECATED static vpx_codec_err_t \
|
||||
vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id, typ data) {\
|
||||
return vpx_codec_control_(ctx, ctrl_id, data);\
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
|
||||
/*!\brief vpx_codec_control void type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It indicates that a given control identifier takes
|
||||
* no argument.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function without a data argument as a wrapper to the
|
||||
* type-unsafe internal function.
|
||||
*/
|
||||
# define VPX_CTRL_VOID(id) \
|
||||
static vpx_codec_err_t \
|
||||
vpx_codec_control_##id(vpx_codec_ctx_t*, int) UNUSED;\
|
||||
\
|
||||
static vpx_codec_err_t \
|
||||
vpx_codec_control_##id(vpx_codec_ctx_t *ctx, int ctrl_id) {\
|
||||
return vpx_codec_control_(ctx, ctrl_id);\
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*!@} - end defgroup codec*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_CODEC_H_
|
||||
|
378
bin/windows/vpx/include/vpx/vpx_decoder.h
Normal file
378
bin/windows/vpx/include/vpx/vpx_decoder.h
Normal file
|
@ -0,0 +1,378 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_DECODER_H_
|
||||
#define VPX_VPX_DECODER_H_
|
||||
|
||||
/*!\defgroup decoder Decoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this decoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all decoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video decoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_frame_buffer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_DECODER_ABI_VERSION (3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Decoder capabilities bitfield
|
||||
*
|
||||
* Each decoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported by a decoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
|
||||
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
|
||||
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
|
||||
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000 /**< Can conceal errors due to
|
||||
packet loss */
|
||||
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000 /**< Can receive encoded frames
|
||||
one fragment at a time */
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000 /**< Can support frame-based
|
||||
multi-threading */
|
||||
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000 /**< Can support external
|
||||
frame buffers */
|
||||
|
||||
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
|
||||
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded
|
||||
frames */
|
||||
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000 /**< The input frame should be
|
||||
passed to the decoder one
|
||||
fragment at a time */
|
||||
#define VPX_CODEC_USE_FRAME_THREADING 0x80000 /**< Enable frame-based
|
||||
multi-threading */
|
||||
|
||||
/*!\brief Stream properties
|
||||
*
|
||||
* This structure is used to query or set properties of the decoded
|
||||
* stream. Algorithms may extend this structure with data specific
|
||||
* to their bitstream by setting the sz member appropriately.
|
||||
*/
|
||||
typedef struct vpx_codec_stream_info {
|
||||
unsigned int sz; /**< Size of this structure */
|
||||
unsigned int w; /**< Width (or 0 for unknown/default) */
|
||||
unsigned int h; /**< Height (or 0 for unknown/default) */
|
||||
unsigned int is_kf; /**< Current frame is a keyframe */
|
||||
} vpx_codec_stream_info_t;
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders.
|
||||
* They represent the base case functionality expected of all decoders.
|
||||
*/
|
||||
|
||||
|
||||
/*!\brief Initialization Configurations
|
||||
*
|
||||
* This structure is used to pass init time configuration options to the
|
||||
* decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_dec_cfg {
|
||||
unsigned int threads; /**< Maximum number of threads to use, default 1 */
|
||||
unsigned int w; /**< Width */
|
||||
unsigned int h; /**< Height */
|
||||
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
|
||||
|
||||
|
||||
/*!\brief Initialize a decoder instance
|
||||
*
|
||||
* Initializes a decoder context using the given interface. Applications
|
||||
* should call the vpx_codec_dec_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_DECODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_dec_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags,
|
||||
int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
|
||||
|
||||
|
||||
/*!\brief Parse stream info from a buffer
|
||||
*
|
||||
* Performs high level parsing of the bitstream. Construction of a decoder
|
||||
* context is not necessary. Can be used to determine if the bitstream is
|
||||
* of the proper format, and to extract information from the stream.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
* \param[in] data Pointer to a block of data to parse
|
||||
* \param[in] data_sz Size of the data buffer
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
|
||||
const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
|
||||
/*!\brief Return information about the current stream.
|
||||
*
|
||||
* Returns information about the stream that has been parsed during decoding.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
|
||||
/*!\brief Decode data
|
||||
*
|
||||
* Processes a buffer of coded data. If the processing results in a new
|
||||
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
|
||||
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
|
||||
* time stamp) order. Frames produced will always be in PTS (presentation
|
||||
* time stamp) order.
|
||||
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
|
||||
* data and data_sz can contain a fragment of the encoded frame. Fragment
|
||||
* \#n must contain at least partition \#n, but can also contain subsequent
|
||||
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
|
||||
* be empty. When no more data is available, this function should be called
|
||||
* with NULL as data and 0 as data_sz. The memory passed to this function
|
||||
* must be available until the frame has been decoded.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] data Pointer to this block of new coded data. If
|
||||
* NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
|
||||
* for the previously decoded frame.
|
||||
* \param[in] data_sz Size of the coded data, in bytes.
|
||||
* \param[in] user_priv Application specific data to associate with
|
||||
* this frame.
|
||||
* \param[in] deadline Soft deadline the decoder should attempt to meet,
|
||||
* in us. Set to zero for unlimited.
|
||||
*
|
||||
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
|
||||
* and future pictures can be decoded without error. Otherwise,
|
||||
* see the descriptions of the other error codes in ::vpx_codec_err_t
|
||||
* for recoverability capabilities.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx,
|
||||
const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
void *user_priv,
|
||||
long deadline);
|
||||
|
||||
|
||||
/*!\brief Decoded frames iterator
|
||||
*
|
||||
* Iterates over a list of the frames available for display. The iterator
|
||||
* storage should be initialized to NULL to start the iteration. Iteration is
|
||||
* complete when this function returns NULL.
|
||||
*
|
||||
* The list of available frames becomes valid upon completion of the
|
||||
* vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an image, if one is ready for display. Frames
|
||||
* produced will always be in PTS (presentation time stamp) order.
|
||||
*/
|
||||
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iter_t *iter);
|
||||
|
||||
|
||||
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put frame callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of decoded image data.
|
||||
*/
|
||||
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img);
|
||||
|
||||
|
||||
/*!\brief Register for notification of frame completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded frame is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_frame_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
|
||||
/*!@} - end defgroup cap_put_frame */
|
||||
|
||||
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put slice callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of partially decoded image data. The
|
||||
*/
|
||||
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img,
|
||||
const vpx_image_rect_t *valid,
|
||||
const vpx_image_rect_t *update);
|
||||
|
||||
|
||||
/*!\brief Register for notification of slice completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded slice is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_slice_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
|
||||
/*!@} - end defgroup cap_put_slice*/
|
||||
|
||||
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
|
||||
*
|
||||
* The following section is required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
|
||||
* Calling this function for codecs that don't advertise this capability
|
||||
* will result in an error code being returned, usually VPX_CODEC_ERROR.
|
||||
*
|
||||
* \note
|
||||
* Currently this only works with VP9.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief Pass in external frame buffers for the decoder to use.
|
||||
*
|
||||
* Registers functions to be called when libvpx needs a frame buffer
|
||||
* to decode the current frame and a function to be called when libvpx does
|
||||
* not internally reference the frame buffer. This set function must
|
||||
* be called before the first call to decode or libvpx will assume the
|
||||
* default behavior of allocating frame buffers internally.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb_get Pointer to the get callback function
|
||||
* \param[in] cb_release Pointer to the release callback function
|
||||
* \param[in] cb_priv Callback's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* External frame buffers will be used by libvpx.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* One or more of the callbacks were NULL.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* using external frame buffers.
|
||||
*
|
||||
* \note
|
||||
* When decoding VP9, the application may be required to pass in at least
|
||||
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
|
||||
* buffers.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
|
||||
vpx_codec_ctx_t *ctx,
|
||||
vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
|
||||
|
||||
/*!@} - end defgroup cap_external_frame_buffer */
|
||||
|
||||
/*!@} - end defgroup decoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_DECODER_H_
|
||||
|
83
bin/windows/vpx/include/vpx/vpx_frame_buffer.h
Normal file
83
bin/windows/vpx/include/vpx/vpx_frame_buffer.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_FRAME_BUFFER_H_
|
||||
#define VPX_VPX_FRAME_BUFFER_H_
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder external frame buffer interface.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief The maximum number of work buffers used by libvpx.
|
||||
* Support maximum 4 threads to decode video in parallel.
|
||||
* Each thread will use one work buffer.
|
||||
* TODO(hkuang): Add support to set number of worker threads dynamically.
|
||||
*/
|
||||
#define VPX_MAXIMUM_WORK_BUFFERS 8
|
||||
|
||||
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
|
||||
*/
|
||||
#define VP9_MAXIMUM_REF_BUFFERS 8
|
||||
|
||||
/*!\brief External frame buffer
|
||||
*
|
||||
* This structure holds allocated frame buffers used by the decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_frame_buffer {
|
||||
uint8_t *data; /**< Pointer to the data buffer */
|
||||
size_t size; /**< Size of data in bytes */
|
||||
void *priv; /**< Frame's private data */
|
||||
} vpx_codec_frame_buffer_t;
|
||||
|
||||
/*!\brief get frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to retrieve data for the frame
|
||||
* buffer in order for the decode call to complete. The callback must
|
||||
* allocate at least min_size in bytes and assign it to fb->data. The callback
|
||||
* must zero out all the data allocated. Then the callback must set fb->size
|
||||
* to the allocated size. The application does not need to align the allocated
|
||||
* data. The callback is triggered when the decoder needs a frame buffer to
|
||||
* decode a compressed image into. This function may be called more than once
|
||||
* for every call to vpx_codec_decode. The application may set fb->priv to
|
||||
* some data which will be passed back in the ximage and the release function
|
||||
* call. |fb| is guaranteed to not be NULL. On success the callback must
|
||||
* return 0. Any failure the callback must return a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] new_size Size in bytes needed by the buffer
|
||||
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_get_frame_buffer_cb_fn_t)(
|
||||
void *priv, size_t min_size, vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
/*!\brief release frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder when the frame buffer is not
|
||||
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
|
||||
* success the callback must return 0. Any failure the callback must return
|
||||
* a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_release_frame_buffer_cb_fn_t)(
|
||||
void *priv, vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_FRAME_BUFFER_H_
|
235
bin/windows/vpx/include/vpx/vpx_image.h
Normal file
235
bin/windows/vpx/include/vpx/vpx_image.h
Normal file
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the vpx image descriptor and associated operations
|
||||
*
|
||||
*/
|
||||
#ifndef VPX_VPX_IMAGE_H_
|
||||
#define VPX_VPX_IMAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_IMAGE_ABI_VERSION (4) /**<\hideinitializer*/
|
||||
|
||||
|
||||
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
||||
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
||||
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
|
||||
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
||||
|
||||
/*!\brief List of supported image formats */
|
||||
typedef enum vpx_img_fmt {
|
||||
VPX_IMG_FMT_NONE,
|
||||
VPX_IMG_FMT_RGB24, /**< 24 bit per pixel packed RGB */
|
||||
VPX_IMG_FMT_RGB32, /**< 32 bit per pixel packed 0RGB */
|
||||
VPX_IMG_FMT_RGB565, /**< 16 bit per pixel, 565 */
|
||||
VPX_IMG_FMT_RGB555, /**< 16 bit per pixel, 555 */
|
||||
VPX_IMG_FMT_UYVY, /**< UYVY packed YUV */
|
||||
VPX_IMG_FMT_YUY2, /**< YUYV packed YUV */
|
||||
VPX_IMG_FMT_YVYU, /**< YVYU packed YUV */
|
||||
VPX_IMG_FMT_BGR24, /**< 24 bit per pixel packed BGR */
|
||||
VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
|
||||
VPX_IMG_FMT_ARGB, /**< 32 bit packed ARGB, alpha=255 */
|
||||
VPX_IMG_FMT_ARGB_LE, /**< 32 bit packed BGRA, alpha=255 */
|
||||
VPX_IMG_FMT_RGB565_LE, /**< 16 bit per pixel, gggbbbbb rrrrrggg */
|
||||
VPX_IMG_FMT_RGB555_LE, /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
|
||||
VPX_IMG_FMT_YV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
||||
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
|
||||
VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
|
||||
VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4,
|
||||
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
|
||||
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
|
||||
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
|
||||
VPX_IMG_FMT_444A = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_HAS_ALPHA | 6,
|
||||
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
|
||||
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
|
||||
|
||||
/*!\brief List of supported color spaces */
|
||||
typedef enum vpx_color_space {
|
||||
VPX_CS_UNKNOWN = 0, /**< Unknown */
|
||||
VPX_CS_BT_601 = 1, /**< BT.601 */
|
||||
VPX_CS_BT_709 = 2, /**< BT.709 */
|
||||
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
|
||||
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
|
||||
VPX_CS_BT_2020 = 5, /**< BT.2020 */
|
||||
VPX_CS_RESERVED = 6, /**< Reserved */
|
||||
VPX_CS_SRGB = 7 /**< sRGB */
|
||||
} vpx_color_space_t; /**< alias for enum vpx_color_space */
|
||||
|
||||
/*!\brief List of supported color range */
|
||||
typedef enum vpx_color_range {
|
||||
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
|
||||
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
|
||||
} vpx_color_range_t; /**< alias for enum vpx_color_range */
|
||||
|
||||
/**\brief Image Descriptor */
|
||||
typedef struct vpx_image {
|
||||
vpx_img_fmt_t fmt; /**< Image Format */
|
||||
vpx_color_space_t cs; /**< Color Space */
|
||||
vpx_color_range_t range; /**< Color Range */
|
||||
|
||||
/* Image storage dimensions */
|
||||
unsigned int w; /**< Stored image width */
|
||||
unsigned int h; /**< Stored image height */
|
||||
unsigned int bit_depth; /**< Stored image bit-depth */
|
||||
|
||||
/* Image display dimensions */
|
||||
unsigned int d_w; /**< Displayed image width */
|
||||
unsigned int d_h; /**< Displayed image height */
|
||||
|
||||
/* Image intended rendering dimensions */
|
||||
unsigned int r_w; /**< Intended rendering image width */
|
||||
unsigned int r_h; /**< Intended rendering image height */
|
||||
|
||||
/* Chroma subsampling info */
|
||||
unsigned int x_chroma_shift; /**< subsampling order, X */
|
||||
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
||||
|
||||
/* Image data pointers. */
|
||||
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
|
||||
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
|
||||
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
|
||||
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
|
||||
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
|
||||
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
|
||||
int stride[4]; /**< stride between rows for each plane */
|
||||
|
||||
int bps; /**< bits per sample (for packed formats) */
|
||||
|
||||
/* The following member may be set by the application to associate data
|
||||
* with this image.
|
||||
*/
|
||||
void *user_priv; /**< may be set by the application to associate data
|
||||
* with this image. */
|
||||
|
||||
/* The following members should be treated as private. */
|
||||
unsigned char *img_data; /**< private */
|
||||
int img_data_owner; /**< private */
|
||||
int self_allocd; /**< private */
|
||||
|
||||
void *fb_priv; /**< Frame buffer data associated with the image. */
|
||||
} vpx_image_t; /**< alias for struct vpx_image */
|
||||
|
||||
/**\brief Representation of a rectangle on a surface */
|
||||
typedef struct vpx_image_rect {
|
||||
unsigned int x; /**< leftmost column */
|
||||
unsigned int y; /**< topmost row */
|
||||
unsigned int w; /**< width */
|
||||
unsigned int h; /**< height */
|
||||
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the descriptor is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image(stride).
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_alloc(vpx_image_t *img,
|
||||
vpx_img_fmt_t fmt,
|
||||
unsigned int d_w,
|
||||
unsigned int d_h,
|
||||
unsigned int align);
|
||||
|
||||
/*!\brief Open a descriptor, using existing storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for descriptor has been allocated elsewhere, and a descriptor is
|
||||
* desired to "wrap" that storage.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of each row in the image.
|
||||
* \param[in] img_data Storage to use for the image
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_wrap(vpx_image_t *img,
|
||||
vpx_img_fmt_t fmt,
|
||||
unsigned int d_w,
|
||||
unsigned int d_h,
|
||||
unsigned int align,
|
||||
unsigned char *img_data);
|
||||
|
||||
|
||||
/*!\brief Set the rectangle identifying the displayed portion of the image
|
||||
*
|
||||
* Updates the displayed rectangle (aka viewport) on the image surface to
|
||||
* match the specified coordinates and size.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] x leftmost column
|
||||
* \param[in] y topmost row
|
||||
* \param[in] w width
|
||||
* \param[in] h height
|
||||
*
|
||||
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
||||
*/
|
||||
int vpx_img_set_rect(vpx_image_t *img,
|
||||
unsigned int x,
|
||||
unsigned int y,
|
||||
unsigned int w,
|
||||
unsigned int h);
|
||||
|
||||
|
||||
/*!\brief Flip the image vertically (top for bottom)
|
||||
*
|
||||
* Adjusts the image descriptor's pointers and strides to make the image
|
||||
* be referenced upside-down.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_flip(vpx_image_t *img);
|
||||
|
||||
/*!\brief Close an image descriptor
|
||||
*
|
||||
* Frees all allocated storage associated with an image descriptor.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_free(vpx_image_t *img);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_IMAGE_H_
|
74
bin/windows/vpx/include/vpx/vpx_integer.h
Normal file
74
bin/windows/vpx/include/vpx/vpx_integer.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VPX_VPX_INTEGER_H_
|
||||
#define VPX_VPX_INTEGER_H_
|
||||
|
||||
/* get ptrdiff_t, size_t, wchar_t, NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define VPX_FORCE_INLINE __forceinline
|
||||
#define VPX_INLINE __inline
|
||||
#else
|
||||
#define VPX_FORCE_INLINE __inline__ __attribute__(always_inline)
|
||||
// TODO(jbb): Allow a way to force inline off for older compilers.
|
||||
#define VPX_INLINE inline
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER < 1600)) || defined(VPX_EMULATE_INTTYPES)
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER < 1600))
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT32_MIN _I32_MIN
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT16_MIN _I16_MIN
|
||||
#endif
|
||||
|
||||
#ifndef _UINTPTR_T_DEFINED
|
||||
typedef size_t uintptr_t;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/* Most platforms have the C99 standard integer types. */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
# if !defined(__STDC_FORMAT_MACROS)
|
||||
# define __STDC_FORMAT_MACROS
|
||||
# endif
|
||||
# if !defined(__STDC_LIMIT_MACROS)
|
||||
# define __STDC_LIMIT_MACROS
|
||||
# endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#endif
|
||||
|
||||
/* VS2010 defines stdint.h, but not inttypes.h */
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
#define PRId64 "I64d"
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_INTEGER_H_
|
BIN
bin/windows/vpx/lib/32/libcompat-to-msvc.lib
Normal file
BIN
bin/windows/vpx/lib/32/libcompat-to-msvc.lib
Normal file
Binary file not shown.
BIN
bin/windows/vpx/lib/32/libvpx.lib
Normal file
BIN
bin/windows/vpx/lib/32/libvpx.lib
Normal file
Binary file not shown.
BIN
bin/windows/vpx/lib/64/libcompat-to-msvc.lib
Normal file
BIN
bin/windows/vpx/lib/64/libcompat-to-msvc.lib
Normal file
Binary file not shown.
BIN
bin/windows/vpx/lib/64/libvpx.lib
Normal file
BIN
bin/windows/vpx/lib/64/libvpx.lib
Normal file
Binary file not shown.
44
bin/windows/vpx/lib/instructions.txt
Normal file
44
bin/windows/vpx/lib/instructions.txt
Normal file
|
@ -0,0 +1,44 @@
|
|||
Instructions for Building EDuke32's Library Dependencies Targeting Win32 and Win64
|
||||
==================================================================================
|
||||
|
||||
First, follow these instructions: http://wiki.eduke32.com/wiki/Building_EDuke32_on_Windows
|
||||
|
||||
Download the latest sources from the link provided.
|
||||
|
||||
The build output listed as "Desired Results" is what EDuke32 needs to function.
|
||||
|
||||
The desired results for each library in some cases may need to be installed to the compiler. "x depends on the results of y to compile" means that the build output of x must be added to the compiler in this way. Copy files listed in each category to the appropriate destinations. Unless otherwise noted, do NOT copy the ".dll.a" file or else the final product may depend on external DLLs (which you may actually want).
|
||||
|
||||
For MinGW (MinGW32):
|
||||
from the compiler root (ex. C:/MinGW/)
|
||||
* headers: include/
|
||||
* libraries: lib/
|
||||
|
||||
For MinGW-w64:
|
||||
from the compiler root (ex. C:/MinGW-w64/mingw32-dw2/)
|
||||
* headers: <target>-w64-mingw32/include/
|
||||
* libraries: <target>-w64-mingw32/lib/
|
||||
|
||||
Binaries (if mentioned) need to be present with the finished EDuke32 executables. They are not needed during compilation.
|
||||
|
||||
NB: Text formatted as code blocks are commands to be pasted into the Windows command prompt.
|
||||
http://wiki.eduke32.com/wiki/Working_with_the_Windows_Command_Prompt
|
||||
|
||||
[//]: # (Plain text readers: This refers to lines beginning with exactly four spaces.)
|
||||
|
||||
|
||||
libvpx
|
||||
------
|
||||
### Prerequisites ###
|
||||
Download the binary of yasm (http://yasm.tortall.net/) for your host system architecture. Both builds target both architectures.
|
||||
The build environment needs pr.exe (https://mingw-lib.googlecode.com/files/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2).
|
||||
### Download ###
|
||||
* Instructions: http://www.webmproject.org/code/
|
||||
* Stable: http://downloads.webmproject.org/releases/webm/
|
||||
* Git: https://chromium.googlesource.com/webm/libvpx
|
||||
### Build ###
|
||||
sh ./configure --disable-vp8-encoder --disable-vp9-encoder --disable-multithread --disable-spatial-resampling --as=yasm && make libvpx.a
|
||||
### Desired Results ###
|
||||
* headers: vpx/vp8.h vpx/vp8dx.h vpx/vpx_codec.h vpx/vpx_decoder.h vpx/vpx_frame_buffer.h vpx/vpx_image.h vpx/vpx_integer.h
|
||||
* libraries: libvpx.a
|
||||
|
55
bin/windows/vpx/src/_dbg_LOAD_IMAGE.h
Normal file
55
bin/windows/vpx/src/_dbg_LOAD_IMAGE.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#ifndef _dbg_LOAD_IMAGE_h
|
||||
#define _dbg_LOAD_IMAGE_h
|
||||
|
||||
#ifndef WINAPI
|
||||
#define WINAPI __stdcall
|
||||
#endif
|
||||
|
||||
#define IMAGEAPI DECLSPEC_IMPORT WINAPI
|
||||
#define DBHLP_DEPRECIATED __declspec(deprecated)
|
||||
|
||||
#define DBHLPAPI IMAGEAPI
|
||||
|
||||
#ifndef EBACKTRACE_MINGW32
|
||||
|
||||
#define IMAGE_SEPARATION (64*1024)
|
||||
|
||||
typedef struct _LOADED_IMAGE {
|
||||
PSTR ModuleName;
|
||||
HANDLE hFile;
|
||||
PUCHAR MappedAddress;
|
||||
#ifdef _IMAGEHLP64
|
||||
PIMAGE_NT_HEADERS64 FileHeader;
|
||||
#else
|
||||
PIMAGE_NT_HEADERS32 FileHeader;
|
||||
#endif
|
||||
PIMAGE_SECTION_HEADER LastRvaSection;
|
||||
ULONG NumberOfSections;
|
||||
PIMAGE_SECTION_HEADER Sections;
|
||||
ULONG Characteristics;
|
||||
BOOLEAN fSystemImage;
|
||||
BOOLEAN fDOSImage;
|
||||
BOOLEAN fReadOnly;
|
||||
UCHAR Version;
|
||||
LIST_ENTRY Links;
|
||||
ULONG SizeOfImage;
|
||||
} LOADED_IMAGE,*PLOADED_IMAGE;
|
||||
|
||||
#endif
|
||||
|
||||
#define MAX_SYM_NAME 2000
|
||||
|
||||
typedef struct _MODLOAD_DATA {
|
||||
DWORD ssize;
|
||||
DWORD ssig;
|
||||
PVOID data;
|
||||
DWORD size;
|
||||
DWORD flags;
|
||||
} MODLOAD_DATA,*PMODLOAD_DATA;
|
||||
|
||||
#endif
|
2051
bin/windows/vpx/src/_dbg_common.h
Normal file
2051
bin/windows/vpx/src/_dbg_common.h
Normal file
File diff suppressed because it is too large
Load diff
702
bin/windows/vpx/src/backtrace.c
Normal file
702
bin/windows/vpx/src/backtrace.c
Normal file
|
@ -0,0 +1,702 @@
|
|||
/*
|
||||
Copyright (c) 2010 ,
|
||||
Cloud Wu . All rights reserved.
|
||||
|
||||
http://www.codingnow.com
|
||||
|
||||
Use, modification and distribution are subject to the "New BSD License"
|
||||
as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
|
||||
|
||||
filename: backtrace.c
|
||||
|
||||
build command: gcc -O2 -shared -Wall -o backtrace.dll backtrace.c -lbfd -liberty -limagehlp
|
||||
|
||||
how to use: Call LoadLibraryA("backtrace.dll"); at beginning of your program .
|
||||
|
||||
*/
|
||||
|
||||
/* modified from original for EDuke32 */
|
||||
|
||||
// warnings cleaned up, ported to 64-bit, and heavily extended by Hendricks266
|
||||
|
||||
#include <windows.h>
|
||||
#include <excpt.h>
|
||||
#include <imagehlp.h>
|
||||
|
||||
// Tenuous: MinGW provides _IMAGEHLP_H while MinGW-w64 defines _IMAGEHLP_.
|
||||
#ifdef _IMAGEHLP_H
|
||||
# define EBACKTRACE_MINGW32
|
||||
#endif
|
||||
#ifdef _IMAGEHLP_
|
||||
# define EBACKTRACE_MINGW_W64
|
||||
#endif
|
||||
#if defined(EBACKTRACE_MINGW32) && !defined(EBACKTRACE_MINGW_W64)
|
||||
# include "_dbg_common.h"
|
||||
#endif
|
||||
|
||||
#ifndef PACKAGE
|
||||
# define PACKAGE EBACKTRACE1
|
||||
#endif
|
||||
#ifndef PACKAGE_VERSION
|
||||
# define PACKAGE_VERSION 1
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) || defined(_WIN64)
|
||||
# define EBACKTRACE64
|
||||
#endif
|
||||
|
||||
#include <bfd.h>
|
||||
#include <psapi.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef DBG_PRINTEXCEPTION_C
|
||||
# define DBG_PRINTEXCEPTION_C (0x40010006)
|
||||
#endif
|
||||
#ifndef MS_VC_EXCEPTION
|
||||
# define MS_VC_EXCEPTION 1080890248
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
# define ATTRIBUTE(attrlist) __attribute__(attrlist)
|
||||
#else
|
||||
# define ATTRIBUTE(attrlist)
|
||||
#endif
|
||||
|
||||
#define BUFFER_MAX (16*1024)
|
||||
|
||||
struct bfd_ctx {
|
||||
bfd * handle;
|
||||
asymbol ** symbol;
|
||||
};
|
||||
|
||||
struct bfd_set {
|
||||
char * name;
|
||||
struct bfd_ctx * bc;
|
||||
struct bfd_set *next;
|
||||
};
|
||||
|
||||
struct find_info {
|
||||
asymbol **symbol;
|
||||
bfd_vma counter;
|
||||
const char *file;
|
||||
const char *func;
|
||||
unsigned line;
|
||||
};
|
||||
|
||||
struct output_buffer {
|
||||
char * buf;
|
||||
size_t sz;
|
||||
size_t ptr;
|
||||
};
|
||||
|
||||
static void
|
||||
output_init(struct output_buffer *ob, char * buf, size_t sz)
|
||||
{
|
||||
ob->buf = buf;
|
||||
ob->sz = sz;
|
||||
ob->ptr = 0;
|
||||
ob->buf[0] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
output_print(struct output_buffer *ob, const char * format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (ob->sz == ob->ptr)
|
||||
return;
|
||||
ob->buf[ob->ptr] = '\0';
|
||||
va_start(ap,format);
|
||||
vsnprintf(ob->buf + ob->ptr , ob->sz - ob->ptr , format, ap);
|
||||
va_end(ap);
|
||||
|
||||
ob->ptr = strlen(ob->buf + ob->ptr) + ob->ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
lookup_section(bfd *abfd, asection *sec, void *opaque_data)
|
||||
{
|
||||
struct find_info *data = opaque_data;
|
||||
bfd_vma vma;
|
||||
|
||||
if (data->func)
|
||||
return;
|
||||
|
||||
if (!(bfd_get_section_flags(abfd, sec) & SEC_ALLOC))
|
||||
return;
|
||||
|
||||
vma = bfd_get_section_vma(abfd, sec);
|
||||
if (data->counter < vma || vma + bfd_get_section_size(sec) <= data->counter)
|
||||
return;
|
||||
|
||||
bfd_find_nearest_line(abfd, sec, data->symbol, data->counter - vma, &(data->file), &(data->func), &(data->line));
|
||||
}
|
||||
|
||||
static void
|
||||
find(struct bfd_ctx * b, DWORD offset, const char **file, const char **func, unsigned *line)
|
||||
{
|
||||
struct find_info data;
|
||||
data.func = NULL;
|
||||
data.symbol = b->symbol;
|
||||
data.counter = offset;
|
||||
data.file = NULL;
|
||||
data.func = NULL;
|
||||
data.line = 0;
|
||||
|
||||
bfd_map_over_sections(b->handle, &lookup_section, &data);
|
||||
if (file) {
|
||||
*file = data.file;
|
||||
}
|
||||
if (func) {
|
||||
*func = data.func;
|
||||
}
|
||||
if (line) {
|
||||
*line = data.line;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
init_bfd_ctx(struct bfd_ctx *bc, const char * procname, struct output_buffer *ob)
|
||||
{
|
||||
int r1, r2, r3;
|
||||
bfd *b;
|
||||
void *symbol_table;
|
||||
unsigned dummy = 0;
|
||||
bc->handle = NULL;
|
||||
bc->symbol = NULL;
|
||||
|
||||
b = bfd_openr(procname, 0);
|
||||
if (!b) {
|
||||
output_print(ob,"Failed to open bfd from (%s)\n" , procname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
r1 = bfd_check_format(b, bfd_object);
|
||||
r2 = bfd_check_format_matches(b, bfd_object, NULL);
|
||||
r3 = bfd_get_file_flags(b) & HAS_SYMS;
|
||||
|
||||
if (!(r1 && r2 && r3)) {
|
||||
bfd_close(b);
|
||||
if (!(r1 && r2))
|
||||
output_print(ob,"Failed to init bfd from (%s): %d %d %d\n", procname, r1, r2, r3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bfd_read_minisymbols(b, FALSE, &symbol_table, &dummy) == 0) {
|
||||
if (bfd_read_minisymbols(b, TRUE, &symbol_table, &dummy) < 0) {
|
||||
free(symbol_table);
|
||||
bfd_close(b);
|
||||
output_print(ob,"Failed to read symbols from (%s)\n", procname);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
bc->handle = b;
|
||||
bc->symbol = symbol_table;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
close_bfd_ctx(struct bfd_ctx *bc)
|
||||
{
|
||||
if (bc) {
|
||||
if (bc->symbol) {
|
||||
free(bc->symbol);
|
||||
}
|
||||
if (bc->handle) {
|
||||
bfd_close(bc->handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct bfd_ctx *
|
||||
get_bc(struct output_buffer *ob , struct bfd_set *set , const char *procname)
|
||||
{
|
||||
struct bfd_ctx bc;
|
||||
while(set->name) {
|
||||
if (strcmp(set->name , procname) == 0) {
|
||||
return set->bc;
|
||||
}
|
||||
set = set->next;
|
||||
}
|
||||
if (init_bfd_ctx(&bc, procname , ob)) {
|
||||
return NULL;
|
||||
}
|
||||
set->next = calloc(1, sizeof(*set));
|
||||
set->bc = malloc(sizeof(struct bfd_ctx));
|
||||
memcpy(set->bc, &bc, sizeof(bc));
|
||||
set->name = strdup(procname);
|
||||
|
||||
return set->bc;
|
||||
}
|
||||
|
||||
static void
|
||||
release_set(struct bfd_set *set)
|
||||
{
|
||||
while(set) {
|
||||
struct bfd_set * temp = set->next;
|
||||
if (set->name)
|
||||
free(set->name);
|
||||
close_bfd_ctx(set->bc);
|
||||
free(set);
|
||||
set = temp;
|
||||
}
|
||||
}
|
||||
|
||||
static char procname[MAX_PATH];
|
||||
|
||||
#ifdef EBACKTRACE64
|
||||
# define MachineType IMAGE_FILE_MACHINE_AMD64
|
||||
# define MAYBE64(x) x ## 64
|
||||
#else
|
||||
# define MachineType IMAGE_FILE_MACHINE_I386
|
||||
# define MAYBE64(x) x
|
||||
#endif
|
||||
|
||||
static void
|
||||
_backtrace(struct output_buffer *ob, struct bfd_set *set, int depth , LPCONTEXT context)
|
||||
{
|
||||
MAYBE64(STACKFRAME) frame;
|
||||
HANDLE process, thread;
|
||||
char symbol_buffer[sizeof(MAYBE64(IMAGEHLP_SYMBOL)) + 255];
|
||||
char module_name_raw[MAX_PATH];
|
||||
struct bfd_ctx *bc = NULL;
|
||||
|
||||
GetModuleFileNameA(NULL, procname, sizeof procname);
|
||||
|
||||
memset(&frame,0,sizeof(frame));
|
||||
|
||||
#ifdef EBACKTRACE64
|
||||
frame.AddrPC.Offset = context->Rip;
|
||||
frame.AddrStack.Offset = context->Rsp;
|
||||
frame.AddrFrame.Offset = context->Rbp;
|
||||
#else
|
||||
frame.AddrPC.Offset = context->Eip;
|
||||
frame.AddrStack.Offset = context->Esp;
|
||||
frame.AddrFrame.Offset = context->Ebp;
|
||||
#endif
|
||||
|
||||
frame.AddrPC.Mode = AddrModeFlat;
|
||||
frame.AddrStack.Mode = AddrModeFlat;
|
||||
frame.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
process = GetCurrentProcess();
|
||||
thread = GetCurrentThread();
|
||||
|
||||
while(MAYBE64(StackWalk)(MachineType,
|
||||
process,
|
||||
thread,
|
||||
&frame,
|
||||
context,
|
||||
NULL,
|
||||
MAYBE64(SymFunctionTableAccess),
|
||||
MAYBE64(SymGetModuleBase), NULL)) {
|
||||
MAYBE64(IMAGEHLP_SYMBOL) *symbol;
|
||||
MAYBE64(DWORD) module_base;
|
||||
const char * module_name = "[unknown module]";
|
||||
|
||||
const char * file = NULL;
|
||||
const char * func = NULL;
|
||||
unsigned line = 0;
|
||||
|
||||
--depth;
|
||||
if (depth < 0)
|
||||
break;
|
||||
|
||||
symbol = (MAYBE64(IMAGEHLP_SYMBOL) *)symbol_buffer;
|
||||
symbol->SizeOfStruct = (sizeof *symbol) + 255;
|
||||
symbol->MaxNameLength = 254;
|
||||
|
||||
module_base = MAYBE64(SymGetModuleBase)(process, frame.AddrPC.Offset);
|
||||
|
||||
if (module_base &&
|
||||
GetModuleFileNameA((HINSTANCE)(intptr_t)module_base, module_name_raw, MAX_PATH)) {
|
||||
module_name = module_name_raw;
|
||||
bc = get_bc(ob, set, module_name);
|
||||
}
|
||||
|
||||
if (bc) {
|
||||
find(bc,frame.AddrPC.Offset,&file,&func,&line);
|
||||
}
|
||||
|
||||
if (file == NULL) {
|
||||
MAYBE64(DWORD) dummy = 0;
|
||||
if (MAYBE64(SymGetSymFromAddr)(process, frame.AddrPC.Offset, &dummy, symbol)) {
|
||||
file = symbol->Name;
|
||||
}
|
||||
else {
|
||||
file = "[unknown file]";
|
||||
}
|
||||
}
|
||||
|
||||
output_print(ob,"0x%p : %s : %s", frame.AddrPC.Offset, module_name, file);
|
||||
if (func != NULL)
|
||||
output_print(ob, " (%d) : in function (%s)", line, func);
|
||||
output_print(ob, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
static LPTSTR FormatErrorMessage(DWORD dwMessageId)
|
||||
{
|
||||
LPTSTR lpBuffer = NULL;
|
||||
|
||||
// adapted from http://stackoverflow.com/a/455533
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM
|
||||
|FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
dwMessageId,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
|
||||
(LPTSTR)&lpBuffer,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
return lpBuffer; // must be LocalFree()'d by caller
|
||||
}
|
||||
|
||||
static LPTSTR FormatExceptionCodeMessage(DWORD dwMessageId)
|
||||
{
|
||||
LPTSTR lpBuffer = NULL;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_HMODULE
|
||||
|FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
GetModuleHandleA("ntdll.dll"),
|
||||
dwMessageId,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
|
||||
(LPTSTR)&lpBuffer,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
return lpBuffer; // must be LocalFree()'d by caller
|
||||
}
|
||||
|
||||
|
||||
// adapted from http://www.catch22.net/tuts/custom-messagebox
|
||||
static HHOOK hMsgBoxHook;
|
||||
|
||||
LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (nCode < 0)
|
||||
return CallNextHookEx(hMsgBoxHook, nCode, wParam, lParam);
|
||||
|
||||
switch (nCode)
|
||||
{
|
||||
case HCBT_ACTIVATE:
|
||||
{
|
||||
// Get handle to the message box!
|
||||
HWND hwnd = (HWND)wParam;
|
||||
|
||||
// Do customization!
|
||||
SetWindowTextA(GetDlgItem(hwnd, IDYES), "Quit");
|
||||
SetWindowTextA(GetDlgItem(hwnd, IDNO), "Continue");
|
||||
SetWindowTextA(GetDlgItem(hwnd, IDCANCEL), "Ignore");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Call the next hook, if there is one
|
||||
return CallNextHookEx(hMsgBoxHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
int ExceptionMessage(TCHAR *szText, TCHAR *szCaption)
|
||||
{
|
||||
int retval;
|
||||
|
||||
// Install a window hook, so we can intercept the message-box
|
||||
// creation, and customize it
|
||||
hMsgBoxHook = SetWindowsHookEx(
|
||||
WH_CBT,
|
||||
CBTProc,
|
||||
NULL,
|
||||
GetCurrentThreadId() // Only install for THIS thread!!!
|
||||
);
|
||||
|
||||
// Display a standard message box
|
||||
retval = MessageBoxA(NULL, szText, szCaption, MB_YESNOCANCEL|MB_ICONERROR|MB_TASKMODAL);
|
||||
|
||||
// remove the window hook
|
||||
UnhookWindowsHookEx(hMsgBoxHook);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char crashlogfilename[MAX_PATH] = "crash.log";
|
||||
static char propername[MAX_PATH] = "this application";
|
||||
|
||||
__declspec(dllexport) void SetTechnicalName(const char* input)
|
||||
{
|
||||
snprintf(crashlogfilename, MAX_PATH, "%s.crash.log", input);
|
||||
}
|
||||
__declspec(dllexport) void SetProperName(const char* input)
|
||||
{
|
||||
strncpy(propername, input, MAX_PATH);
|
||||
}
|
||||
|
||||
static char * g_output = NULL;
|
||||
static PVOID g_prev = NULL;
|
||||
|
||||
static LONG WINAPI
|
||||
exception_filter(LPEXCEPTION_POINTERS info)
|
||||
{
|
||||
struct output_buffer ob;
|
||||
int logfd, written, msgboxID;
|
||||
PEXCEPTION_RECORD exception;
|
||||
BOOL initialized = FALSE;
|
||||
char *ExceptionPrinted;
|
||||
|
||||
for (exception = info->ExceptionRecord; exception != NULL; exception = exception->ExceptionRecord)
|
||||
{
|
||||
#if 0
|
||||
if (exception->ExceptionFlags & EXCEPTION_NONCONTINUABLE)
|
||||
continuable = FALSE;
|
||||
#endif
|
||||
|
||||
switch (exception->ExceptionCode)
|
||||
{
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
case EXCEPTION_SINGLE_STEP:
|
||||
case DBG_CONTROL_C:
|
||||
case DBG_PRINTEXCEPTION_C:
|
||||
case MS_VC_EXCEPTION:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
LPTSTR ExceptionCodeMsg = FormatExceptionCodeMessage(exception->ExceptionCode);
|
||||
// The message for this exception code is broken.
|
||||
LPTSTR ExceptionText = exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ? "Access violation." : ExceptionCodeMsg;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
output_init(&ob, g_output, BUFFER_MAX);
|
||||
initialized = TRUE;
|
||||
}
|
||||
|
||||
output_print(&ob, "Caught exception 0x%08X at 0x%p: %s\n", exception->ExceptionCode, exception->ExceptionAddress, ExceptionText);
|
||||
|
||||
LocalFree(ExceptionCodeMsg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!initialized)
|
||||
return EXCEPTION_CONTINUE_SEARCH; // EXCEPTION_CONTINUE_EXECUTION
|
||||
|
||||
ExceptionPrinted = (char*)calloc(strlen(g_output) + 37 + 2*MAX_PATH, sizeof(char));
|
||||
strcpy(ExceptionPrinted, g_output);
|
||||
strcat(ExceptionPrinted, "\nPlease send ");
|
||||
strcat(ExceptionPrinted, crashlogfilename);
|
||||
strcat(ExceptionPrinted, " to the maintainers of ");
|
||||
strcat(ExceptionPrinted, propername);
|
||||
strcat(ExceptionPrinted, ".");
|
||||
|
||||
{
|
||||
DWORD error = 0;
|
||||
BOOL SymInitialized = SymInitialize(GetCurrentProcess(), NULL, TRUE);
|
||||
|
||||
if (!SymInitialized)
|
||||
{
|
||||
LPTSTR errorText;
|
||||
|
||||
error = GetLastError();
|
||||
errorText = FormatErrorMessage(error);
|
||||
output_print(&ob, "SymInitialize() failed with error %d: %s\n", error, errorText);
|
||||
LocalFree(errorText);
|
||||
}
|
||||
|
||||
if (SymInitialized || error == 87)
|
||||
{
|
||||
struct bfd_set *set = calloc(1,sizeof(*set));
|
||||
bfd_init();
|
||||
_backtrace(&ob , set , 128 , info->ContextRecord);
|
||||
release_set(set);
|
||||
|
||||
SymCleanup(GetCurrentProcess());
|
||||
}
|
||||
}
|
||||
|
||||
logfd = open(crashlogfilename, O_APPEND | O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
|
||||
if (logfd) {
|
||||
time_t curtime;
|
||||
struct tm *curltime;
|
||||
const char *theasctime;
|
||||
const char *finistr = "---------------\n";
|
||||
|
||||
while ((written = write(logfd, g_output, strlen(g_output)))) {
|
||||
g_output += written;
|
||||
}
|
||||
|
||||
curtime = time(NULL);
|
||||
curltime = localtime(&curtime);
|
||||
theasctime = curltime ? asctime(curltime) : NULL;
|
||||
|
||||
if (theasctime)
|
||||
write(logfd, theasctime, strlen(theasctime));
|
||||
write(logfd, finistr, strlen(finistr));
|
||||
close(logfd);
|
||||
}
|
||||
|
||||
//fputs(g_output, stderr);
|
||||
|
||||
msgboxID = ExceptionMessage(ExceptionPrinted, propername);
|
||||
|
||||
free(ExceptionPrinted);
|
||||
|
||||
switch (msgboxID)
|
||||
{
|
||||
case IDYES:
|
||||
exit(0xBAC);
|
||||
break;
|
||||
case IDNO:
|
||||
break;
|
||||
case IDCANCEL:
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
break;
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
static void
|
||||
backtrace_register(void)
|
||||
{
|
||||
if (g_output == NULL) {
|
||||
g_output = malloc(BUFFER_MAX);
|
||||
g_prev = AddVectoredExceptionHandler(1, exception_filter);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
backtrace_unregister(void)
|
||||
{
|
||||
if (g_output) {
|
||||
free(g_output);
|
||||
RemoveVectoredExceptionHandler(g_prev);
|
||||
g_prev = NULL;
|
||||
g_output = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain(HINSTANCE hinstDLL ATTRIBUTE((unused)), DWORD dwReason, LPVOID lpvReserved ATTRIBUTE((unused)))
|
||||
{
|
||||
switch (dwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
backtrace_register();
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
backtrace_unregister();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* cut dependence on libintl... libbfd needs this */
|
||||
char *libintl_dgettext (const char *domain_name ATTRIBUTE((unused)), const char *msgid ATTRIBUTE((unused)))
|
||||
{
|
||||
static char buf[1024] = "XXX placeholder XXX";
|
||||
return buf;
|
||||
}
|
||||
|
||||
int __printf__ ( const char * format, ... );
|
||||
int libintl_fprintf ( FILE * stream, const char * format, ... );
|
||||
int libintl_sprintf ( char * str, const char * format, ... );
|
||||
int libintl_snprintf ( char *buffer, int buf_size, const char *format, ... );
|
||||
int libintl_vprintf ( const char * format, va_list arg );
|
||||
int libintl_vfprintf ( FILE * stream, const char * format, va_list arg );
|
||||
int libintl_vsprintf ( char * str, const char * format, va_list arg );
|
||||
|
||||
int __printf__ ( const char * format, ... )
|
||||
{
|
||||
int value;
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
value = vprintf ( format, arg );
|
||||
va_end(arg);
|
||||
return value;
|
||||
}
|
||||
|
||||
int libintl_fprintf ( FILE * stream, const char * format, ... )
|
||||
{
|
||||
int value;
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
value = vfprintf ( stream, format, arg );
|
||||
va_end(arg);
|
||||
return value;
|
||||
}
|
||||
int libintl_sprintf ( char * str, const char * format, ... )
|
||||
{
|
||||
int value;
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
value = vsprintf ( str, format, arg );
|
||||
va_end(arg);
|
||||
return value;
|
||||
}
|
||||
int libintl_snprintf ( char *buffer, int buf_size, const char *format, ... )
|
||||
{
|
||||
int value;
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
value = vsnprintf ( buffer, buf_size, format, arg );
|
||||
va_end(arg);
|
||||
return value;
|
||||
}
|
||||
int libintl_vprintf ( const char * format, va_list arg )
|
||||
{
|
||||
return vprintf ( format, arg );
|
||||
}
|
||||
int libintl_vfprintf ( FILE * stream, const char * format, va_list arg )
|
||||
{
|
||||
return vfprintf ( stream, format, arg );
|
||||
}
|
||||
int libintl_vsprintf ( char * str, const char * format, va_list arg )
|
||||
{
|
||||
return vsprintf ( str, format, arg );
|
||||
}
|
||||
|
||||
/* cut dependence on zlib... libbfd needs this */
|
||||
|
||||
int compress (unsigned char *dest ATTRIBUTE((unused)), unsigned long destLen ATTRIBUTE((unused)), const unsigned char source ATTRIBUTE((unused)), unsigned long sourceLen ATTRIBUTE((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
unsigned long compressBound (unsigned long sourceLen)
|
||||
{
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13;
|
||||
}
|
||||
int inflateEnd(void *strm ATTRIBUTE((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int inflateInit_(void *strm ATTRIBUTE((unused)), const char *version ATTRIBUTE((unused)), int stream_size ATTRIBUTE((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int inflateReset(void *strm ATTRIBUTE((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int inflate(void *strm ATTRIBUTE((unused)), int flush ATTRIBUTE((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
22
bin/windows/vpx/src/compat-to-msvc/Makefile
Normal file
22
bin/windows/vpx/src/compat-to-msvc/Makefile
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
o=o
|
||||
|
||||
NAME:=libcompat-to-msvc
|
||||
|
||||
|
||||
%.$o: %.c
|
||||
gcc -Wall -Wextra -O3 -c $< -o $@
|
||||
|
||||
%.$o: %.S
|
||||
gcc -c $< -o $@
|
||||
|
||||
OBJS=dll_math.$o io_math.$o dll_dependency.$o vsnprintf.$o
|
||||
|
||||
.INTERMEDIATE: $(OBJS)
|
||||
|
||||
$(NAME).a: $(OBJS)
|
||||
ar rc $@ $^
|
||||
ranlib $@
|
||||
|
||||
clean:
|
||||
-rm -f *.a *.o
|
88
bin/windows/vpx/src/compat-to-msvc/dll_dependency.S
Normal file
88
bin/windows/vpx/src/compat-to-msvc/dll_dependency.S
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* Implementation for gcc's internal stack-allocation routines. */
|
||||
.global ___chkstk
|
||||
.global __alloca
|
||||
|
||||
.global ___chkstk_ms
|
||||
___chkstk_ms:
|
||||
#ifdef _WIN64
|
||||
pushq %rax
|
||||
pushq %rcx
|
||||
cmpq $0x1000, %rax
|
||||
leaq 24(%rsp), %rcx
|
||||
jb .Lchkstk_ms_end
|
||||
.Lchkstk_ms_loop:
|
||||
subq $0x1000, %rcx
|
||||
subq $0x1000, %rax
|
||||
orq $0x0, (%rcx)
|
||||
cmpq $0x1000, %rax
|
||||
ja .Lchkstk_ms_loop
|
||||
.Lchkstk_ms_end:
|
||||
subq %rax, %rcx
|
||||
orq $0x0, (%rcx)
|
||||
popq %rcx
|
||||
popq %rax
|
||||
ret
|
||||
#else
|
||||
pushl %eax
|
||||
pushl %ecx
|
||||
cmpl $0x1000, %eax
|
||||
leal 12(%esp), %ecx
|
||||
jb chkstk_ms_end
|
||||
chkstk_ms_loop:
|
||||
subl $0x1000, %ecx
|
||||
subl $0x1000, %eax
|
||||
orl $0x0, (%ecx)
|
||||
cmpl $0x1000, %eax
|
||||
ja chkstk_ms_loop
|
||||
chkstk_ms_end:
|
||||
subl %eax, %ecx
|
||||
orl $0x0, (%ecx)
|
||||
popl %ecx
|
||||
popl %eax
|
||||
ret
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
__alloca:
|
||||
movq %rcx, %rax
|
||||
.align 4
|
||||
___chkstk:
|
||||
popq %r11
|
||||
movq %rsp, %r10
|
||||
cmpq $0x1000, %rax
|
||||
jb .Lchkstk_end
|
||||
.Lchkstk_loop:
|
||||
subq $0x1000, %r10
|
||||
subq $0x1000, %rax
|
||||
orl $0x0, (%r10)
|
||||
cmpq $0x1000, %rax
|
||||
ja .Lchkstk_loop
|
||||
.Lchkstk_end:
|
||||
subq %rax, %r10
|
||||
movq %rsp, %rax
|
||||
orl $0x0, (%r10)
|
||||
movq %r10, %rsp
|
||||
pushq %r11
|
||||
ret
|
||||
#else
|
||||
___chkstk:
|
||||
__alloca:
|
||||
pushl %ecx
|
||||
leal 8(%esp), %ecx
|
||||
cmpl $0x1000, %eax /* > 4k ?*/
|
||||
jb chkstk_end
|
||||
chkstk_loop:
|
||||
subl $0x1000, %ecx
|
||||
subl $0x1000, %eax
|
||||
orl $0x0, (%ecx)
|
||||
cmpl $0x1000, %eax
|
||||
ja chkstk_loop
|
||||
chkstk_end:
|
||||
subl %eax, %ecx
|
||||
orl $0x0, (%ecx)
|
||||
movl %esp, %eax
|
||||
movl %ecx, %esp
|
||||
movl (%eax), %ecx
|
||||
pushl 4(%eax)
|
||||
ret
|
||||
#endif
|
572
bin/windows/vpx/src/compat-to-msvc/dll_math.c
Normal file
572
bin/windows/vpx/src/compat-to-msvc/dll_math.c
Normal file
|
@ -0,0 +1,572 @@
|
|||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LIBKERN_QUAD_H_
|
||||
#define _LIBKERN_QUAD_H_
|
||||
|
||||
/*
|
||||
* Quad arithmetic.
|
||||
*
|
||||
* This library makes the following assumptions:
|
||||
*
|
||||
* - The type long long (aka quad_t) exists.
|
||||
*
|
||||
* - A quad variable is exactly twice as long as `long'.
|
||||
*
|
||||
* - The machine's arithmetic is two's complement.
|
||||
*
|
||||
* This library can provide 128-bit arithmetic on a machine with 128-bit
|
||||
* quads and 64-bit longs, for instance, or 96-bit arithmetic on machines
|
||||
* with 48-bit longs.
|
||||
*/
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/syslimits.h>
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
typedef long long quad_t;
|
||||
typedef unsigned long long u_quad_t;
|
||||
typedef unsigned long u_long;
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT __CHAR_BIT__
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define the order of 32-bit words in 64-bit words.
|
||||
* For little endian only.
|
||||
*/
|
||||
#define _QUAD_HIGHWORD 1
|
||||
#define _QUAD_LOWWORD 0
|
||||
|
||||
/*
|
||||
* Depending on the desired operation, we view a `long long' (aka quad_t) in
|
||||
* one or more of the following formats.
|
||||
*/
|
||||
union uu {
|
||||
quad_t q; /* as a (signed) quad */
|
||||
quad_t uq; /* as an unsigned quad */
|
||||
long sl[2]; /* as two signed longs */
|
||||
u_long ul[2]; /* as two unsigned longs */
|
||||
};
|
||||
|
||||
/*
|
||||
* Define high and low longwords.
|
||||
*/
|
||||
#define H _QUAD_HIGHWORD
|
||||
#define L _QUAD_LOWWORD
|
||||
|
||||
/*
|
||||
* Total number of bits in a quad_t and in the pieces that make it up.
|
||||
* These are used for shifting, and also below for halfword extraction
|
||||
* and assembly.
|
||||
*/
|
||||
#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT)
|
||||
#define LONG_BITS (sizeof(long) * CHAR_BIT)
|
||||
#define HALF_BITS (sizeof(long) * CHAR_BIT / 2)
|
||||
|
||||
/*
|
||||
* Extract high and low shortwords from longword, and move low shortword of
|
||||
* longword to upper half of long, i.e., produce the upper longword of
|
||||
* ((quad_t)(x) << (number_of_bits_in_long/2)). (`x' must actually be u_long.)
|
||||
*
|
||||
* These are used in the multiply code, to split a longword into upper
|
||||
* and lower halves, and to reassemble a product as a quad_t, shifted left
|
||||
* (sizeof(long)*CHAR_BIT/2).
|
||||
*/
|
||||
#define HHALF(x) ((x) >> HALF_BITS)
|
||||
#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1))
|
||||
#define LHUP(x) ((x) << HALF_BITS)
|
||||
|
||||
typedef unsigned int qshift_t;
|
||||
|
||||
quad_t __ashldi3(quad_t, qshift_t);
|
||||
quad_t __ashrdi3(quad_t, qshift_t);
|
||||
int __cmpdi2(quad_t a, quad_t b);
|
||||
quad_t __divdi3(quad_t a, quad_t b);
|
||||
quad_t __lshrdi3(quad_t, qshift_t);
|
||||
quad_t __moddi3(quad_t a, quad_t b);
|
||||
u_quad_t __qdivrem(u_quad_t u, u_quad_t v, u_quad_t *rem);
|
||||
u_quad_t __udivdi3(u_quad_t a, u_quad_t b);
|
||||
u_quad_t __umoddi3(u_quad_t a, u_quad_t b);
|
||||
int __ucmpdi2(u_quad_t a, u_quad_t b);
|
||||
|
||||
#endif /* !_LIBKERN_QUAD_H_ */
|
||||
|
||||
#if defined (_X86_) && !defined (__x86_64__)
|
||||
/*
|
||||
* Shift a (signed) quad value left (arithmetic shift left).
|
||||
* This is the same as logical shift left!
|
||||
*/
|
||||
quad_t
|
||||
__ashldi3(a, shift)
|
||||
quad_t a;
|
||||
qshift_t shift;
|
||||
{
|
||||
union uu aa;
|
||||
|
||||
aa.q = a;
|
||||
if (shift >= LONG_BITS) {
|
||||
aa.ul[H] = shift >= QUAD_BITS ? 0 :
|
||||
aa.ul[L] << (shift - LONG_BITS);
|
||||
aa.ul[L] = 0;
|
||||
} else if (shift > 0) {
|
||||
aa.ul[H] = (aa.ul[H] << shift) |
|
||||
(aa.ul[L] >> (LONG_BITS - shift));
|
||||
aa.ul[L] <<= shift;
|
||||
}
|
||||
return (aa.q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shift a (signed) quad value right (arithmetic shift right).
|
||||
*/
|
||||
quad_t
|
||||
__ashrdi3(a, shift)
|
||||
quad_t a;
|
||||
qshift_t shift;
|
||||
{
|
||||
union uu aa;
|
||||
|
||||
aa.q = a;
|
||||
if (shift >= LONG_BITS) {
|
||||
long s;
|
||||
|
||||
/*
|
||||
* Smear bits rightward using the machine's right-shift
|
||||
* method, whether that is sign extension or zero fill,
|
||||
* to get the `sign word' s. Note that shifting by
|
||||
* LONG_BITS is undefined, so we shift (LONG_BITS-1),
|
||||
* then 1 more, to get our answer.
|
||||
*/
|
||||
s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1;
|
||||
aa.ul[L] = shift >= QUAD_BITS ? s :
|
||||
aa.sl[H] >> (shift - LONG_BITS);
|
||||
aa.ul[H] = s;
|
||||
} else if (shift > 0) {
|
||||
aa.ul[L] = (aa.ul[L] >> shift) |
|
||||
(aa.ul[H] << (LONG_BITS - shift));
|
||||
aa.sl[H] >>= shift;
|
||||
}
|
||||
return (aa.q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 0, 1, or 2 as a <, =, > b respectively.
|
||||
* Both a and b are considered signed---which means only the high word is
|
||||
* signed.
|
||||
*/
|
||||
int
|
||||
__cmpdi2(a, b)
|
||||
quad_t a, b;
|
||||
{
|
||||
union uu aa, bb;
|
||||
|
||||
aa.q = a;
|
||||
bb.q = b;
|
||||
return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 :
|
||||
aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Divide two signed quads.
|
||||
* ??? if -1/2 should produce -1 on this machine, this code is wrong
|
||||
*/
|
||||
quad_t
|
||||
__divdi3(a, b)
|
||||
quad_t a, b;
|
||||
{
|
||||
u_quad_t ua, ub, uq;
|
||||
int neg;
|
||||
|
||||
if (a < 0)
|
||||
ua = -(u_quad_t)a, neg = 1;
|
||||
else
|
||||
ua = a, neg = 0;
|
||||
if (b < 0)
|
||||
ub = -(u_quad_t)b, neg ^= 1;
|
||||
else
|
||||
ub = b;
|
||||
uq = __qdivrem(ua, ub, (u_quad_t *)0);
|
||||
return (neg ? -uq : uq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shift an (unsigned) quad value right (logical shift right).
|
||||
*/
|
||||
quad_t
|
||||
__lshrdi3(a, shift)
|
||||
quad_t a;
|
||||
qshift_t shift;
|
||||
{
|
||||
union uu aa;
|
||||
|
||||
aa.q = a;
|
||||
if (shift >= LONG_BITS) {
|
||||
aa.ul[L] = shift >= QUAD_BITS ? 0 :
|
||||
aa.ul[H] >> (shift - LONG_BITS);
|
||||
aa.ul[H] = 0;
|
||||
} else if (shift > 0) {
|
||||
aa.ul[L] = (aa.ul[L] >> shift) |
|
||||
(aa.ul[H] << (LONG_BITS - shift));
|
||||
aa.ul[H] >>= shift;
|
||||
}
|
||||
return (aa.q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return remainder after dividing two signed quads.
|
||||
*
|
||||
* XXX
|
||||
* If -1/2 should produce -1 on this machine, this code is wrong.
|
||||
*/
|
||||
quad_t
|
||||
__moddi3(a, b)
|
||||
quad_t a, b;
|
||||
{
|
||||
u_quad_t ua, ub, ur;
|
||||
int neg;
|
||||
|
||||
if (a < 0)
|
||||
ua = -(u_quad_t)a, neg = 1;
|
||||
else
|
||||
ua = a, neg = 0;
|
||||
if (b < 0)
|
||||
ub = -(u_quad_t)b;
|
||||
else
|
||||
ub = b;
|
||||
(void)__qdivrem(ua, ub, &ur);
|
||||
return (neg ? -ur : ur);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed),
|
||||
* section 4.3.1, pp. 257--259.
|
||||
*/
|
||||
|
||||
#define B (1 << HALF_BITS) /* digit base */
|
||||
|
||||
/* Combine two `digits' to make a single two-digit number. */
|
||||
#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b))
|
||||
|
||||
/* select a type for digits in base B: use unsigned short if they fit */
|
||||
#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff
|
||||
typedef unsigned short digit;
|
||||
#else
|
||||
typedef u_long digit;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Shift p[0]..p[len] left `sh' bits, ignoring any bits that
|
||||
* `fall out' the left (there never will be any such anyway).
|
||||
* We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS.
|
||||
*/
|
||||
static void
|
||||
__shl(register digit *p, register int len, register int sh)
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh));
|
||||
p[i] = LHALF(p[i] << sh);
|
||||
}
|
||||
|
||||
/*
|
||||
* __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
|
||||
*
|
||||
* We do this in base 2-sup-HALF_BITS, so that all intermediate products
|
||||
* fit within u_long. As a consequence, the maximum length dividend and
|
||||
* divisor are 4 `digits' in this base (they are shorter if they have
|
||||
* leading zeros).
|
||||
*/
|
||||
u_quad_t
|
||||
__qdivrem(uq, vq, arq)
|
||||
u_quad_t uq, vq, *arq;
|
||||
{
|
||||
union uu tmp;
|
||||
digit *u, *v, *q;
|
||||
register digit v1, v2;
|
||||
u_long qhat, rhat, t;
|
||||
int m, n, d, j, i;
|
||||
digit uspace[5], vspace[5], qspace[5];
|
||||
|
||||
/*
|
||||
* Take care of special cases: divide by zero, and u < v.
|
||||
*/
|
||||
if (vq == 0) {
|
||||
/* divide by zero. */
|
||||
static volatile const unsigned int zero = 0;
|
||||
|
||||
tmp.ul[H] = tmp.ul[L] = 1 / zero;
|
||||
if (arq)
|
||||
*arq = uq;
|
||||
return (tmp.q);
|
||||
}
|
||||
if (uq < vq) {
|
||||
if (arq)
|
||||
*arq = uq;
|
||||
return (0);
|
||||
}
|
||||
u = &uspace[0];
|
||||
v = &vspace[0];
|
||||
q = &qspace[0];
|
||||
|
||||
/*
|
||||
* Break dividend and divisor into digits in base B, then
|
||||
* count leading zeros to determine m and n. When done, we
|
||||
* will have:
|
||||
* u = (u[1]u[2]...u[m+n]) sub B
|
||||
* v = (v[1]v[2]...v[n]) sub B
|
||||
* v[1] != 0
|
||||
* 1 < n <= 4 (if n = 1, we use a different division algorithm)
|
||||
* m >= 0 (otherwise u < v, which we already checked)
|
||||
* m + n = 4
|
||||
* and thus
|
||||
* m = 4 - n <= 2
|
||||
*/
|
||||
tmp.uq = uq;
|
||||
u[0] = 0;
|
||||
u[1] = HHALF(tmp.ul[H]);
|
||||
u[2] = LHALF(tmp.ul[H]);
|
||||
u[3] = HHALF(tmp.ul[L]);
|
||||
u[4] = LHALF(tmp.ul[L]);
|
||||
tmp.uq = vq;
|
||||
v[1] = HHALF(tmp.ul[H]);
|
||||
v[2] = LHALF(tmp.ul[H]);
|
||||
v[3] = HHALF(tmp.ul[L]);
|
||||
v[4] = LHALF(tmp.ul[L]);
|
||||
for (n = 4; v[1] == 0; v++) {
|
||||
if (--n == 1) {
|
||||
u_long rbj; /* r*B+u[j] (not root boy jim) */
|
||||
digit q1, q2, q3, q4;
|
||||
|
||||
/*
|
||||
* Change of plan, per exercise 16.
|
||||
* r = 0;
|
||||
* for j = 1..4:
|
||||
* q[j] = floor((r*B + u[j]) / v),
|
||||
* r = (r*B + u[j]) % v;
|
||||
* We unroll this completely here.
|
||||
*/
|
||||
t = v[2]; /* nonzero, by definition */
|
||||
q1 = u[1] / t;
|
||||
rbj = COMBINE(u[1] % t, u[2]);
|
||||
q2 = rbj / t;
|
||||
rbj = COMBINE(rbj % t, u[3]);
|
||||
q3 = rbj / t;
|
||||
rbj = COMBINE(rbj % t, u[4]);
|
||||
q4 = rbj / t;
|
||||
if (arq)
|
||||
*arq = rbj % t;
|
||||
tmp.ul[H] = COMBINE(q1, q2);
|
||||
tmp.ul[L] = COMBINE(q3, q4);
|
||||
return (tmp.q);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* By adjusting q once we determine m, we can guarantee that
|
||||
* there is a complete four-digit quotient at &qspace[1] when
|
||||
* we finally stop.
|
||||
*/
|
||||
for (m = 4 - n; u[1] == 0; u++)
|
||||
m--;
|
||||
for (i = 4 - m; --i >= 0;)
|
||||
q[i] = 0;
|
||||
q += 4 - m;
|
||||
|
||||
/*
|
||||
* Here we run Program D, translated from MIX to C and acquiring
|
||||
* a few minor changes.
|
||||
*
|
||||
* D1: choose multiplier 1 << d to ensure v[1] >= B/2.
|
||||
*/
|
||||
d = 0;
|
||||
for (t = v[1]; t < B / 2; t <<= 1)
|
||||
d++;
|
||||
if (d > 0) {
|
||||
__shl(&u[0], m + n, d); /* u <<= d */
|
||||
__shl(&v[1], n - 1, d); /* v <<= d */
|
||||
}
|
||||
/*
|
||||
* D2: j = 0.
|
||||
*/
|
||||
j = 0;
|
||||
v1 = v[1]; /* for D3 -- note that v[1..n] are constant */
|
||||
v2 = v[2]; /* for D3 */
|
||||
do {
|
||||
register digit uj0, uj1, uj2;
|
||||
|
||||
/*
|
||||
* D3: Calculate qhat (\^q, in TeX notation).
|
||||
* Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and
|
||||
* let rhat = (u[j]*B + u[j+1]) mod v[1].
|
||||
* While rhat < B and v[2]*qhat > rhat*B+u[j+2],
|
||||
* decrement qhat and increase rhat correspondingly.
|
||||
* Note that if rhat >= B, v[2]*qhat < rhat*B.
|
||||
*/
|
||||
uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */
|
||||
uj1 = u[j + 1]; /* for D3 only */
|
||||
uj2 = u[j + 2]; /* for D3 only */
|
||||
if (uj0 == v1) {
|
||||
qhat = B;
|
||||
rhat = uj1;
|
||||
goto qhat_too_big;
|
||||
} else {
|
||||
u_long nn = COMBINE(uj0, uj1);
|
||||
qhat = nn / v1;
|
||||
rhat = nn % v1;
|
||||
}
|
||||
while (v2 * qhat > COMBINE(rhat, uj2)) {
|
||||
qhat_too_big:
|
||||
qhat--;
|
||||
if ((rhat += v1) >= B)
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* D4: Multiply and subtract.
|
||||
* The variable `t' holds any borrows across the loop.
|
||||
* We split this up so that we do not require v[0] = 0,
|
||||
* and to eliminate a final special case.
|
||||
*/
|
||||
for (t = 0, i = n; i > 0; i--) {
|
||||
t = u[i + j] - v[i] * qhat - t;
|
||||
u[i + j] = LHALF(t);
|
||||
t = (B - HHALF(t)) & (B - 1);
|
||||
}
|
||||
t = u[j] - t;
|
||||
u[j] = LHALF(t);
|
||||
/*
|
||||
* D5: test remainder.
|
||||
* There is a borrow if and only if HHALF(t) is nonzero;
|
||||
* in that (rare) case, qhat was too large (by exactly 1).
|
||||
* Fix it by adding v[1..n] to u[j..j+n].
|
||||
*/
|
||||
if (HHALF(t)) {
|
||||
qhat--;
|
||||
for (t = 0, i = n; i > 0; i--) { /* D6: add back. */
|
||||
t += u[i + j] + v[i];
|
||||
u[i + j] = LHALF(t);
|
||||
t = HHALF(t);
|
||||
}
|
||||
u[j] = LHALF(u[j] + t);
|
||||
}
|
||||
q[j] = qhat;
|
||||
} while (++j <= m); /* D7: loop on j. */
|
||||
|
||||
/*
|
||||
* If caller wants the remainder, we have to calculate it as
|
||||
* u[m..m+n] >> d (this is at most n digits and thus fits in
|
||||
* u[m+1..m+n], but we may need more source digits).
|
||||
*/
|
||||
if (arq) {
|
||||
if (d) {
|
||||
for (i = m + n; i > m; --i)
|
||||
u[i] = (u[i] >> d) |
|
||||
LHALF(u[i - 1] << (HALF_BITS - d));
|
||||
u[i] = 0;
|
||||
}
|
||||
tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
|
||||
tmp.ul[L] = COMBINE(uspace[3], uspace[4]);
|
||||
*arq = tmp.q;
|
||||
}
|
||||
|
||||
tmp.ul[H] = COMBINE(qspace[1], qspace[2]);
|
||||
tmp.ul[L] = COMBINE(qspace[3], qspace[4]);
|
||||
return (tmp.q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 0, 1, or 2 as a <, =, > b respectively.
|
||||
* Neither a nor b are considered signed.
|
||||
*/
|
||||
int
|
||||
__ucmpdi2(a, b)
|
||||
u_quad_t a, b;
|
||||
{
|
||||
union uu aa, bb;
|
||||
|
||||
aa.uq = a;
|
||||
bb.uq = b;
|
||||
return (aa.ul[H] < bb.ul[H] ? 0 : aa.ul[H] > bb.ul[H] ? 2 :
|
||||
aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Divide two unsigned quads.
|
||||
*/
|
||||
u_quad_t
|
||||
__udivdi3(a, b)
|
||||
u_quad_t a, b;
|
||||
{
|
||||
|
||||
return (__qdivrem(a, b, (u_quad_t *)0));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return remainder after dividing two unsigned quads.
|
||||
*/
|
||||
u_quad_t
|
||||
__umoddi3(a, b)
|
||||
u_quad_t a, b;
|
||||
{
|
||||
u_quad_t r;
|
||||
|
||||
(void)__qdivrem(a, b, &r);
|
||||
return (r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Divide two unsigned quads.
|
||||
* This function is new in GCC 7.
|
||||
*/
|
||||
u_quad_t
|
||||
__udivmoddi4(a, b, rem)
|
||||
u_quad_t a, b, *rem;
|
||||
{
|
||||
u_quad_t ua, ub, uq, ur;
|
||||
|
||||
ua = a;
|
||||
ub = b;
|
||||
uq = __qdivrem(ua, ub, &ur);
|
||||
if (rem)
|
||||
*rem = ur;
|
||||
return uq;
|
||||
}
|
||||
#else
|
||||
static int __attribute__((unused)) dummy;
|
||||
#endif /* defined (_X86_) && !defined (__x86_64__) */
|
||||
|
39
bin/windows/vpx/src/compat-to-msvc/io_math.c
Normal file
39
bin/windows/vpx/src/compat-to-msvc/io_math.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Some libraries expect these functions, for which Visual Studio (pre-2013) falls down on the job.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# include <stdint.h>
|
||||
int64_t _ftelli64(
|
||||
FILE *stream
|
||||
);
|
||||
int _fseeki64(
|
||||
FILE *stream,
|
||||
int64_t offset,
|
||||
int origin
|
||||
);
|
||||
#endif
|
||||
|
||||
int fseeko(FILE *fp, off_t offset, int whence)
|
||||
{
|
||||
return _fseeki64(fp, (int64_t)offset, whence);
|
||||
}
|
||||
int fseeko64(FILE *fp, off64_t offset, int whence)
|
||||
{
|
||||
return _fseeki64(fp, (int64_t)offset, whence);
|
||||
}
|
||||
|
||||
off_t ftello(FILE *stream)
|
||||
{
|
||||
return (off_t)_ftelli64(stream);
|
||||
}
|
||||
off64_t ftello64(FILE *stream)
|
||||
{
|
||||
return (off64_t)_ftelli64(stream);
|
||||
}
|
||||
|
||||
long lround(double d)
|
||||
{
|
||||
return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
|
||||
}
|
19
bin/windows/vpx/src/compat-to-msvc/vsnprintf.c
Normal file
19
bin/windows/vpx/src/compat-to-msvc/vsnprintf.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#define __CRT__NO_INLINE
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int __cdecl _vsnprintf(char * __restrict__, size_t, const char * __restrict__, va_list);
|
||||
|
||||
int __cdecl __ms_vsnprintf (char * __restrict__ s, size_t n, const char * __restrict__ format, va_list arg)
|
||||
{
|
||||
return _vsnprintf(s, n, format, arg);
|
||||
}
|
||||
int __cdecl __mingw_vsnprintf (char * __restrict__ s, size_t n, const char * __restrict__ format, va_list arg)
|
||||
{
|
||||
return _vsnprintf(s, n, format, arg);
|
||||
}
|
|
@ -406,6 +406,29 @@ set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_L
|
|||
if (HAVE_VULKAN)
|
||||
set( ZDOOM_LIBS ${ZDOOM_LIBS} "glslang" "SPIRV" "OGLCompiler")
|
||||
endif()
|
||||
# VPX
|
||||
|
||||
if( MSVC AND NOT VPX_FOUND )
|
||||
# Use prebuilt library
|
||||
set( VPX_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../bin/Windows/vpx" )
|
||||
set( VPX_INCLUDE_DIR ${VPX_ROOT_PATH}/include )
|
||||
set( VPX_LIBRARIES libvpx libcompat-to-msvc )
|
||||
if( ARM64 )
|
||||
link_directories( ${VPX_ROOT_PATH}/lib/arm64 )
|
||||
else()
|
||||
link_directories( ${VPX_ROOT_PATH}/lib/64 )
|
||||
endif()
|
||||
set( VPX_FOUND TRUE )
|
||||
endif()
|
||||
|
||||
if( VPX_FOUND )
|
||||
add_definitions( "-DUSE_LIBVPX=1" )
|
||||
include_directories( "${VPX_INCLUDE_DIR}" )
|
||||
set( ZDOOM_LIBS ${ZDOOM_LIBS} ${VPX_LIBRARIES} )
|
||||
else()
|
||||
message( SEND_ERROR "Could not find libvpx" )
|
||||
endif()
|
||||
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${DRPC_INCLUDE_DIR}")
|
||||
|
||||
if( ${HAVE_VM_JIT} )
|
||||
|
@ -587,6 +610,7 @@ file( GLOB HEADER_FILES
|
|||
common/audio/music/*.h*
|
||||
common/2d/*.h
|
||||
common/console/*.h
|
||||
common/cutscenes/*.h
|
||||
common/utility/*.h
|
||||
common/engine/*.h
|
||||
common/menu/*.h
|
||||
|
@ -605,6 +629,7 @@ file( GLOB HEADER_FILES
|
|||
common/thirdparty/*.h
|
||||
common/thirdparty/rapidjson/*.h
|
||||
common/thirdparty/math/*h
|
||||
common/thirdparty/libsmackerdec/include/*.h
|
||||
common/rendering/*.h
|
||||
common/rendering/gl_load/*.h
|
||||
common/rendering/gles/*.h
|
||||
|
@ -624,6 +649,7 @@ file( GLOB HEADER_FILES
|
|||
common/scripting/interface/*.h
|
||||
common/scripting/backend/*.h
|
||||
common/scripting/frontend/*.h
|
||||
|
||||
utility/*.h
|
||||
scripting/*.h
|
||||
scripting/backend/*.h
|
||||
|
@ -1077,6 +1103,9 @@ set (PCH_SOURCES
|
|||
common/console/c_notifybufferbase.cpp
|
||||
common/console/c_tabcomplete.cpp
|
||||
common/console/c_expr.cpp
|
||||
common/cutscenes/playmve.cpp
|
||||
common/cutscenes/movieplayer.cpp
|
||||
common/cutscenes/screenjob.cpp
|
||||
common/utility/engineerrors.cpp
|
||||
common/utility/i_module.cpp
|
||||
common/utility/m_alloc.cpp
|
||||
|
@ -1096,6 +1125,11 @@ set (PCH_SOURCES
|
|||
common/thirdparty/base64.cpp
|
||||
common/thirdparty/md5.cpp
|
||||
common/thirdparty/superfasthash.cpp
|
||||
common/thirdparty/libsmackerdec/src/BitReader.cpp
|
||||
common/thirdparty/libsmackerdec/src/FileStream.cpp
|
||||
common/thirdparty/libsmackerdec/src/HuffmanVLC.cpp
|
||||
common/thirdparty/libsmackerdec/src/LogError.cpp
|
||||
common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp
|
||||
common/filesystem/filesystem.cpp
|
||||
common/filesystem/ancientzip.cpp
|
||||
common/filesystem/file_7z.cpp
|
||||
|
@ -1262,6 +1296,8 @@ include_directories( .
|
|||
common/audio/sound
|
||||
common/audio/music
|
||||
common/2d
|
||||
common/cutscenes
|
||||
common/thirdparty/libsmackerdec/include
|
||||
common/thirdparty
|
||||
common/textures
|
||||
common/textures/formats
|
||||
|
|
828
src/common/cutscenes/movieplayer.cpp
Normal file
828
src/common/cutscenes/movieplayer.cpp
Normal file
|
@ -0,0 +1,828 @@
|
|||
/*
|
||||
** movieplayer.cpp
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2020 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
#include "screenjob.h"
|
||||
#include "i_time.h"
|
||||
#include "v_2ddrawer.h"
|
||||
#include "animlib.h"
|
||||
#include "v_draw.h"
|
||||
#include "s_soundinternal.h"
|
||||
#include "animtexture.h"
|
||||
#include "gamestate.h"
|
||||
#include "SmackerDecoder.h"
|
||||
#include "playmve.h"
|
||||
#include <vpx/vpx_decoder.h>
|
||||
#include <vpx/vp8dx.h>
|
||||
#include "filesystem.h"
|
||||
#include "vm.h"
|
||||
#include "printf.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma comment(lib, "legacy_stdio_definitions.lib")
|
||||
#endif
|
||||
|
||||
class MoviePlayer
|
||||
{
|
||||
protected:
|
||||
enum EMovieFlags
|
||||
{
|
||||
NOSOUNDCUTOFF = 1,
|
||||
FIXEDVIEWPORT = 2, // Forces fixed 640x480 screen size like for Blood's intros.
|
||||
};
|
||||
|
||||
int flags;
|
||||
public:
|
||||
virtual void Start() {}
|
||||
virtual bool Frame(uint64_t clock) = 0;
|
||||
virtual void Stop() {}
|
||||
virtual ~MoviePlayer() = default;
|
||||
virtual FTextureID GetTexture() = 0;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class AnmPlayer : public MoviePlayer
|
||||
{
|
||||
// This doesn't need its own class type
|
||||
anim_t anim;
|
||||
TArray<uint8_t> buffer;
|
||||
int numframes = 0;
|
||||
int curframe = 1;
|
||||
int frametime = 0;
|
||||
int nextframetime = 0;
|
||||
AnimTextures animtex;
|
||||
const TArray<int> animSnd;
|
||||
int frameTicks[3];
|
||||
|
||||
public:
|
||||
bool isvalid() { return numframes > 0; }
|
||||
|
||||
AnmPlayer(FileReader& fr, TArray<int>& ans, const int *frameticks, int flags_)
|
||||
: animSnd(std::move(ans))
|
||||
{
|
||||
memcpy(frameTicks, frameticks, 3 * sizeof(int));
|
||||
flags = flags_;
|
||||
buffer = fr.ReadPadded(1);
|
||||
fr.Close();
|
||||
|
||||
if (ANIM_LoadAnim(&anim, buffer.Data(), buffer.Size() - 1) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
numframes = ANIM_NumFrames(&anim);
|
||||
animtex.SetSize(AnimTexture::Paletted, 320, 200);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool Frame(uint64_t clock) override
|
||||
{
|
||||
int currentclock = int(clock * 120 / 1'000'000'000);
|
||||
|
||||
if (currentclock < nextframetime - 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
animtex.SetFrame(ANIM_GetPalette(&anim), ANIM_DrawFrame(&anim, curframe));
|
||||
frametime = currentclock;
|
||||
|
||||
int delay = 20;
|
||||
if (frameTicks)
|
||||
{
|
||||
if (curframe == 1) delay = frameTicks[0];
|
||||
else if (curframe < numframes - 2) delay = frameTicks[1];
|
||||
else delay = frameTicks[2];
|
||||
}
|
||||
nextframetime += delay;
|
||||
|
||||
bool nostopsound = (flags & NOSOUNDCUTOFF);
|
||||
for (unsigned i = 0; i < animSnd.Size(); i+=2)
|
||||
{
|
||||
if (animSnd[i] == curframe)
|
||||
{
|
||||
int sound = animSnd[i+1];
|
||||
if (sound == -1)
|
||||
soundEngine->StopAllChannels();
|
||||
else
|
||||
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
if (!nostopsound && curframe == numframes && soundEngine->GetSoundPlayingInfo(SOURCE_None, nullptr, -1)) return true;
|
||||
curframe++;
|
||||
return curframe < numframes;
|
||||
}
|
||||
|
||||
void Stop() override
|
||||
{
|
||||
bool nostopsound = (flags & NOSOUNDCUTOFF);
|
||||
if (!nostopsound) soundEngine->StopAllChannels();
|
||||
}
|
||||
|
||||
|
||||
~AnmPlayer()
|
||||
{
|
||||
buffer.Reset();
|
||||
animtex.Clean();
|
||||
}
|
||||
|
||||
FTextureID GetTexture() override
|
||||
{
|
||||
return animtex.GetFrameID();
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class MvePlayer : public MoviePlayer
|
||||
{
|
||||
InterplayDecoder decoder;
|
||||
bool failed = false;
|
||||
|
||||
public:
|
||||
bool isvalid() { return !failed; }
|
||||
|
||||
MvePlayer(FileReader& fr) : decoder(SoundEnabled())
|
||||
{
|
||||
failed = !decoder.Open(fr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool Frame(uint64_t clock) override
|
||||
{
|
||||
if (failed) return false;
|
||||
bool playon = decoder.RunFrame(clock);
|
||||
return playon;
|
||||
}
|
||||
|
||||
~MvePlayer()
|
||||
{
|
||||
decoder.Close();
|
||||
}
|
||||
|
||||
FTextureID GetTexture() override
|
||||
{
|
||||
return decoder.animTex().GetFrameID();
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class VpxPlayer : public MoviePlayer
|
||||
{
|
||||
bool failed = false;
|
||||
FileReader fr;
|
||||
AnimTextures animtex;
|
||||
const TArray<int> animSnd;
|
||||
|
||||
unsigned width, height;
|
||||
TArray<uint8_t> Pic;
|
||||
TArray<uint8_t> readBuf;
|
||||
vpx_codec_ctx_t codec{};
|
||||
vpx_codec_iter_t iter = nullptr;
|
||||
|
||||
uint32_t convnumer;
|
||||
uint32_t convdenom;
|
||||
|
||||
uint64_t nsecsperframe;
|
||||
uint64_t nextframetime;
|
||||
|
||||
int decstate = 0;
|
||||
int framenum = 0;
|
||||
int numframes;
|
||||
int lastsoundframe = -1;
|
||||
public:
|
||||
int soundtrack = -1;
|
||||
|
||||
|
||||
public:
|
||||
bool isvalid() { return !failed; }
|
||||
|
||||
VpxPlayer(FileReader& fr_, TArray<int>& animSnd_, int flags_, int origframedelay, FString& error) : animSnd(std::move(animSnd_))
|
||||
{
|
||||
fr = std::move(fr_);
|
||||
flags = flags_;
|
||||
|
||||
if (!ReadIVFHeader(origframedelay))
|
||||
{
|
||||
// We should never get here, because any file failing this has been eliminated before this constructor got called.
|
||||
error.Format("Failed reading IVF header\n");
|
||||
failed = true;
|
||||
}
|
||||
|
||||
Pic.Resize(width * height * 4);
|
||||
|
||||
|
||||
// Todo: Support VP9 as well?
|
||||
vpx_codec_dec_cfg_t cfg = { 1, width, height };
|
||||
if (vpx_codec_dec_init(&codec, &vpx_codec_vp8_dx_algo, &cfg, 0))
|
||||
{
|
||||
error.Format("Error initializing VPX codec.\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool ReadIVFHeader(int origframedelay)
|
||||
{
|
||||
// IVF format: http://wiki.multimedia.cx/index.php?title=IVF
|
||||
uint32_t magic; fr.Read(&magic, 4); // do not byte swap!
|
||||
if (magic != MAKE_ID('D', 'K', 'I', 'F')) return false;
|
||||
uint16_t version = fr.ReadUInt16();
|
||||
if (version != 0) return false;
|
||||
uint16_t length = fr.ReadUInt16();
|
||||
if (length != 32) return false;
|
||||
fr.Read(&magic, 4);
|
||||
if (magic != MAKE_ID('V', 'P', '8', '0')) return false;
|
||||
|
||||
width = fr.ReadUInt16();
|
||||
height = fr.ReadUInt16();
|
||||
uint32_t fpsdenominator = fr.ReadUInt32();
|
||||
uint32_t fpsnumerator = fr.ReadUInt32();
|
||||
numframes = fr.ReadUInt32();
|
||||
if (numframes == 0) return false;
|
||||
fr.Seek(4, FileReader::SeekCur);
|
||||
|
||||
if (fpsdenominator > 1000 || fpsnumerator == 0 || fpsdenominator == 0)
|
||||
{
|
||||
// default to 30 fps if the header does not provide useful info.
|
||||
fpsdenominator = 30;
|
||||
fpsnumerator = 1;
|
||||
}
|
||||
|
||||
convnumer = 120 * fpsnumerator;
|
||||
convdenom = fpsdenominator * origframedelay;
|
||||
|
||||
nsecsperframe = int64_t(fpsnumerator) * 1'000'000'000 / fpsdenominator;
|
||||
nextframetime = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool ReadFrame()
|
||||
{
|
||||
int corrupted = 0;
|
||||
int framesize = fr.ReadInt32();
|
||||
fr.Seek(8, FileReader::SeekCur);
|
||||
if (framesize == 0) return false;
|
||||
|
||||
readBuf.Resize(framesize);
|
||||
if (fr.Read(readBuf.Data(), framesize) != framesize) return false;
|
||||
if (vpx_codec_decode(&codec, readBuf.Data(), readBuf.Size(), NULL, 0) != VPX_CODEC_OK) return false;
|
||||
if (vpx_codec_control(&codec, VP8D_GET_FRAME_CORRUPTED, &corrupted) != VPX_CODEC_OK) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
vpx_image_t *GetFrameData()
|
||||
{
|
||||
vpx_image_t *img;
|
||||
do
|
||||
{
|
||||
if (decstate == 0) // first time / begin
|
||||
{
|
||||
if (!ReadFrame()) return nullptr;
|
||||
decstate = 1;
|
||||
}
|
||||
|
||||
img = vpx_codec_get_frame(&codec, &iter);
|
||||
if (img == nullptr)
|
||||
{
|
||||
decstate = 0;
|
||||
iter = nullptr;
|
||||
}
|
||||
} while (img == nullptr);
|
||||
|
||||
return img->d_w == width && img->d_h == height? img : nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SetPixel(uint8_t* dest, uint8_t y, uint8_t u, uint8_t v)
|
||||
{
|
||||
dest[0] = y;
|
||||
dest[1] = u;
|
||||
dest[2] = v;
|
||||
}
|
||||
|
||||
bool CreateNextFrame()
|
||||
{
|
||||
auto img = GetFrameData();
|
||||
if (!img) return false;
|
||||
uint8_t const* const yplane = img->planes[VPX_PLANE_Y];
|
||||
uint8_t const* const uplane = img->planes[VPX_PLANE_U];
|
||||
uint8_t const* const vplane = img->planes[VPX_PLANE_V];
|
||||
|
||||
const int ystride = img->stride[VPX_PLANE_Y];
|
||||
const int ustride = img->stride[VPX_PLANE_U];
|
||||
const int vstride = img->stride[VPX_PLANE_V];
|
||||
|
||||
for (unsigned int y = 0; y < height; y += 2)
|
||||
{
|
||||
unsigned int y1 = y + 1;
|
||||
unsigned int wy = width * y;
|
||||
unsigned int wy1 = width * y1;
|
||||
|
||||
for (unsigned int x = 0; x < width; x += 2)
|
||||
{
|
||||
uint8_t u = uplane[ustride * (y >> 1) + (x >> 1)];
|
||||
uint8_t v = vplane[vstride * (y >> 1) + (x >> 1)];
|
||||
|
||||
SetPixel(&Pic[(wy + x) << 2], yplane[ystride * y + x], u, v);
|
||||
SetPixel(&Pic[(wy + x + 1) << 2], yplane[ystride * y + x + 1], u, v);
|
||||
SetPixel(&Pic[(wy1 + x) << 2], yplane[ystride * y1 + x], u, v);
|
||||
SetPixel(&Pic[(wy1 + x + 1) << 2], yplane[ystride * y1 + x + 1], u, v);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Start() override
|
||||
{
|
||||
if (soundtrack > 0)
|
||||
{
|
||||
S_ChangeMusic(fileSystem.GetFileFullName(soundtrack, false), 0, false);
|
||||
}
|
||||
animtex.SetSize(AnimTexture::YUV, width, height);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool Frame(uint64_t clock) override
|
||||
{
|
||||
bool stop = false;
|
||||
if (clock > nextframetime)
|
||||
{
|
||||
nextframetime += nsecsperframe;
|
||||
|
||||
if (!CreateNextFrame())
|
||||
{
|
||||
Printf(PRINT_BOLD, "Failed reading next frame\n");
|
||||
stop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
animtex.SetFrame(nullptr, Pic.Data());
|
||||
}
|
||||
framenum++;
|
||||
if (framenum >= numframes) stop = true;
|
||||
|
||||
bool nostopsound = (flags & NOSOUNDCUTOFF);
|
||||
int soundframe = convdenom ? Scale(framenum, convnumer, convdenom) : framenum;
|
||||
if (soundframe > lastsoundframe)
|
||||
{
|
||||
if (soundtrack == -1)
|
||||
{
|
||||
for (unsigned i = 0; i < animSnd.Size(); i += 2)
|
||||
{
|
||||
if (animSnd[i] == soundframe)
|
||||
{
|
||||
int sound = animSnd[i + 1];
|
||||
if (sound == -1)
|
||||
soundEngine->StopAllChannels();
|
||||
else
|
||||
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound ? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastsoundframe = soundframe;
|
||||
}
|
||||
}
|
||||
return !stop;
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
S_StopMusic(true);
|
||||
bool nostopsound = (flags & NOSOUNDCUTOFF);
|
||||
if (!nostopsound) soundEngine->StopAllChannels();
|
||||
}
|
||||
|
||||
~VpxPlayer()
|
||||
{
|
||||
vpx_codec_destroy(&codec);
|
||||
animtex.Clean();
|
||||
}
|
||||
|
||||
FTextureID GetTexture() override
|
||||
{
|
||||
return animtex.GetFrameID();
|
||||
}
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct AudioData
|
||||
{
|
||||
int hFx;
|
||||
SmackerAudioInfo inf;
|
||||
|
||||
int16_t samples[6000 * 20]; // must be a multiple of the stream buffer size and larger than the initial chunk of audio
|
||||
|
||||
int nWrite;
|
||||
int nRead;
|
||||
};
|
||||
|
||||
class SmkPlayer : public MoviePlayer
|
||||
{
|
||||
SmackerHandle hSMK{};
|
||||
int numAudioTracks;
|
||||
AudioData adata;
|
||||
uint32_t nWidth, nHeight;
|
||||
uint8_t palette[768];
|
||||
AnimTextures animtex;
|
||||
TArray<uint8_t> pFrame;
|
||||
TArray<uint8_t> audioBuffer;
|
||||
int nFrames;
|
||||
bool fullscreenScale;
|
||||
uint64_t nFrameNs;
|
||||
int nFrame = 0;
|
||||
const TArray<int> animSnd;
|
||||
FString filename;
|
||||
SoundStream* stream = nullptr;
|
||||
bool hassound = false;
|
||||
|
||||
public:
|
||||
bool isvalid() { return hSMK.isValid; }
|
||||
|
||||
static bool StreamCallbackFunc(SoundStream* stream, void* buff, int len, void* userdata)
|
||||
{
|
||||
SmkPlayer* pId = (SmkPlayer*)userdata;
|
||||
memcpy(buff, &pId->adata.samples[pId->adata.nRead], len);
|
||||
pId->adata.nRead += len / 2;
|
||||
if (pId->adata.nRead >= countof(pId->adata.samples)) pId->adata.nRead = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void copy8bitSamples(unsigned count)
|
||||
{
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
adata.samples[adata.nWrite] = (audioBuffer[i] - 128) << 8;
|
||||
if (++adata.nWrite >= countof(adata.samples)) adata.nWrite = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void copy16bitSamples(unsigned count)
|
||||
{
|
||||
auto ptr = (uint16_t*)audioBuffer.Data();
|
||||
for (unsigned i = 0; i < count/2; i++)
|
||||
{
|
||||
adata.samples[adata.nWrite] = *ptr++;
|
||||
if (++adata.nWrite >= countof(adata.samples)) adata.nWrite = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SmkPlayer(const char *fn, TArray<int>& ans, int flags_) : animSnd(std::move(ans))
|
||||
{
|
||||
hSMK = Smacker_Open(fn);
|
||||
if (!hSMK.isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
flags = flags_;
|
||||
Smacker_GetFrameSize(hSMK, nWidth, nHeight);
|
||||
pFrame.Resize(nWidth * nHeight + std::max(nWidth, nHeight));
|
||||
float frameRate = Smacker_GetFrameRate(hSMK);
|
||||
nFrameNs = uint64_t(1'000'000'000 / frameRate);
|
||||
nFrames = Smacker_GetNumFrames(hSMK);
|
||||
Smacker_GetPalette(hSMK, palette);
|
||||
|
||||
numAudioTracks = Smacker_GetNumAudioTracks(hSMK);
|
||||
if (numAudioTracks)
|
||||
{
|
||||
adata.nWrite = 0;
|
||||
adata.nRead = 0;
|
||||
adata.inf = Smacker_GetAudioTrackDetails(hSMK, 0);
|
||||
if (adata.inf.idealBufferSize > 0)
|
||||
{
|
||||
audioBuffer.Resize(adata.inf.idealBufferSize);
|
||||
auto read = Smacker_GetAudioData(hSMK, 0, (int16_t*)audioBuffer.Data());
|
||||
if (adata.inf.bitsPerSample == 8) copy8bitSamples(read);
|
||||
else copy16bitSamples(read);
|
||||
hassound = true;
|
||||
}
|
||||
}
|
||||
if (!hassound)
|
||||
{
|
||||
adata.inf = {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Start() override
|
||||
{
|
||||
animtex.SetSize(AnimTexture::Paletted, nWidth, nHeight);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool Frame(uint64_t clock) override
|
||||
{
|
||||
int frame = int(clock / nFrameNs);
|
||||
|
||||
twod->ClearScreen();
|
||||
if (frame > nFrame)
|
||||
{
|
||||
Smacker_GetPalette(hSMK, palette);
|
||||
Smacker_GetFrame(hSMK, pFrame.Data());
|
||||
animtex.SetFrame(palette, pFrame.Data());
|
||||
if (numAudioTracks && SoundEnabled())
|
||||
{
|
||||
auto read = Smacker_GetAudioData(hSMK, 0, (int16_t*)audioBuffer.Data());
|
||||
if (adata.inf.bitsPerSample == 8) copy8bitSamples(read);
|
||||
else copy16bitSamples(read);
|
||||
if (!stream && read) // the sound may not start in the first frame, but the stream cannot start without any sound data present.
|
||||
stream = S_CreateCustomStream(6000, adata.inf.sampleRate, adata.inf.nChannels, StreamCallbackFunc, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (frame > nFrame)
|
||||
{
|
||||
nFrame++;
|
||||
Smacker_GetNextFrame(hSMK);
|
||||
bool nostopsound = (flags & NOSOUNDCUTOFF);
|
||||
if (!hassound) for (unsigned i = 0; i < animSnd.Size(); i += 2)
|
||||
{
|
||||
if (animSnd[i] == nFrame)
|
||||
{
|
||||
int sound = animSnd[i + 1];
|
||||
if (sound == -1)
|
||||
soundEngine->StopAllChannels();
|
||||
else
|
||||
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, CHAN_AUTO, nostopsound ? CHANF_UI : CHANF_NONE, sound, 1.f, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nFrame < nFrames;
|
||||
}
|
||||
|
||||
void Stop() override
|
||||
{
|
||||
if (stream) S_StopCustomStream(stream);
|
||||
bool nostopsound = (flags & NOSOUNDCUTOFF);
|
||||
if (!nostopsound && !hassound) soundEngine->StopAllChannels();
|
||||
}
|
||||
|
||||
~SmkPlayer()
|
||||
{
|
||||
Smacker_Close(hSMK);
|
||||
animtex.Clean();
|
||||
}
|
||||
|
||||
FTextureID GetTexture() override
|
||||
{
|
||||
return animtex.GetFrameID();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
MoviePlayer* OpenMovie(const char* filename, TArray<int>& ans, const int* frameticks, int flags, FString& error)
|
||||
{
|
||||
FileReader fr;
|
||||
// first try as .ivf - but only if sounds are provided - the decoder is video only.
|
||||
if (ans.Size())
|
||||
{
|
||||
auto fn = StripExtension(filename);
|
||||
DefaultExtension(fn, ".ivf");
|
||||
fr = fileSystem.OpenFileReader(fn);
|
||||
}
|
||||
|
||||
if (!fr.isOpen()) fr = fileSystem.OpenFileReader(filename);
|
||||
if (!fr.isOpen())
|
||||
{
|
||||
size_t nLen = strlen(filename);
|
||||
// Strip the drive letter and retry.
|
||||
if (nLen >= 3 && isalpha(filename[0]) && filename[1] == ':' && filename[2] == '/')
|
||||
{
|
||||
filename += 3;
|
||||
fr = fileSystem.OpenFileReader(filename);
|
||||
}
|
||||
if (!fr.isOpen())
|
||||
{
|
||||
error.Format("%s: Unable to open video\n", filename);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
char id[20] = {};
|
||||
|
||||
fr.Read(&id, 20);
|
||||
fr.Seek(-20, FileReader::SeekCur);
|
||||
|
||||
if (!memcmp(id, "LPF ", 4))
|
||||
{
|
||||
auto anm = new AnmPlayer(fr, ans, frameticks, flags);
|
||||
if (!anm->isvalid())
|
||||
{
|
||||
error.Format("%s: invalid ANM file.\n", filename);
|
||||
delete anm;
|
||||
return nullptr;
|
||||
}
|
||||
return anm;
|
||||
}
|
||||
else if (!memcmp(id, "SMK2", 4))
|
||||
{
|
||||
fr.Close();
|
||||
auto anm = new SmkPlayer(filename, ans, flags);
|
||||
if (!anm->isvalid())
|
||||
{
|
||||
error.Format("%s: invalid SMK file.\n", filename);
|
||||
delete anm;
|
||||
return nullptr;
|
||||
}
|
||||
return anm;
|
||||
}
|
||||
else if (!memcmp(id, "Interplay MVE File", 18))
|
||||
{
|
||||
auto anm = new MvePlayer(fr);
|
||||
if (!anm->isvalid())
|
||||
{
|
||||
delete anm;
|
||||
return nullptr;
|
||||
}
|
||||
return anm;
|
||||
}
|
||||
else if (!memcmp(id, "DKIF\0\0 \0VP80", 12))
|
||||
{
|
||||
auto anm = new VpxPlayer(fr, ans, frameticks ? frameticks[1] : 0, flags, error);
|
||||
if (!anm->isvalid())
|
||||
{
|
||||
delete anm;
|
||||
return nullptr;
|
||||
}
|
||||
// VPX files have no sound track, so look for a same-named sound file with a known extension as the soundtrack to be played.
|
||||
static const char* knownSoundExts[] = { "OGG", "FLAC", "MP3", "OPUS", "WAV" };
|
||||
FString name = StripExtension(filename);
|
||||
anm->soundtrack = fileSystem.FindFileWithExtensions(name, knownSoundExts, countof(knownSoundExts));
|
||||
return anm;
|
||||
}
|
||||
// add more formats here.
|
||||
else
|
||||
{
|
||||
error.Format("%s: Unknown video format\n", filename);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Create)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_STRING(filename);
|
||||
PARAM_POINTER(sndinf, TArray<int>);
|
||||
PARAM_INT(flags);
|
||||
PARAM_INT(frametime);
|
||||
PARAM_INT(firstframetime);
|
||||
PARAM_INT(lastframetime);
|
||||
|
||||
FString error;
|
||||
if (firstframetime == -1) firstframetime = frametime;
|
||||
if (lastframetime == -1) lastframetime = frametime;
|
||||
int frametimes[] = { firstframetime, frametime, lastframetime };
|
||||
auto movie = OpenMovie(filename, *sndinf, frametime == -1? nullptr : frametimes, flags, error);
|
||||
if (!movie)
|
||||
{
|
||||
Printf(TEXTCOLOR_YELLOW, "%s", error.GetChars());
|
||||
}
|
||||
ACTION_RETURN_POINTER(movie);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Start)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
self->Start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Frame)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
PARAM_FLOAT(clock);
|
||||
ACTION_RETURN_INT(self->Frame(int64_t(clock)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, Destroy)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
self->Stop();
|
||||
delete self;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_MoviePlayer, GetTexture)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
|
||||
ACTION_RETURN_INT(self->GetTexture().GetIndex());
|
||||
}
|
1008
src/common/cutscenes/playmve.cpp
Normal file
1008
src/common/cutscenes/playmve.cpp
Normal file
File diff suppressed because it is too large
Load diff
179
src/common/cutscenes/playmve.h
Normal file
179
src/common/cutscenes/playmve.h
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* InterplayDecoder
|
||||
* Copyright (C) 2020 sirlemonhead
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* This code is based on interplayvideo.c, dpcm.c and ipmovie.c from the FFmpeg project which can be obtained
|
||||
* from http://www.ffmpeg.org/. Below is the license from interplayvideo.c
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Interplay MVE Video Decoder
|
||||
* Copyright (C) 2003 The FFmpeg project
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "files.h"
|
||||
#include "animtexture.h"
|
||||
#include "s_music.h"
|
||||
|
||||
#ifndef playmve_h_
|
||||
#define playmve_h_
|
||||
|
||||
class InterplayDecoder
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
CHUNK_PREAMBLE_SIZE = 4,
|
||||
OPCODE_PREAMBLE_SIZE = 4,
|
||||
|
||||
CHUNK_INIT_AUDIO = 0x0000,
|
||||
CHUNK_AUDIO_ONLY = 0x0001,
|
||||
CHUNK_INIT_VIDEO = 0x0002,
|
||||
CHUNK_VIDEO = 0x0003,
|
||||
CHUNK_SHUTDOWN = 0x0004,
|
||||
CHUNK_END = 0x0005,
|
||||
/* these last types are used internally */
|
||||
CHUNK_DONE = 0xFFFC,
|
||||
CHUNK_NOMEM = 0xFFFD,
|
||||
CHUNK_EOF = 0xFFFE,
|
||||
CHUNK_BAD = 0xFFFF,
|
||||
|
||||
OPCODE_END_OF_STREAM = 0x00,
|
||||
OPCODE_END_OF_CHUNK = 0x01,
|
||||
OPCODE_CREATE_TIMER = 0x02,
|
||||
OPCODE_INIT_AUDIO_BUFFERS = 0x03,
|
||||
OPCODE_START_STOP_AUDIO = 0x04,
|
||||
OPCODE_INIT_VIDEO_BUFFERS = 0x05,
|
||||
OPCODE_UNKNOWN_06 = 0x06,
|
||||
OPCODE_SEND_BUFFER = 0x07,
|
||||
OPCODE_AUDIO_FRAME = 0x08,
|
||||
OPCODE_SILENCE_FRAME = 0x09,
|
||||
OPCODE_INIT_VIDEO_MODE = 0x0A,
|
||||
OPCODE_CREATE_GRADIENT = 0x0B,
|
||||
OPCODE_SET_PALETTE = 0x0C,
|
||||
OPCODE_SET_PALETTE_COMPRESSED = 0x0D,
|
||||
OPCODE_UNKNOWN_0E = 0x0E,
|
||||
OPCODE_SET_DECODING_MAP = 0x0F,
|
||||
OPCODE_UNKNOWN_10 = 0x10,
|
||||
OPCODE_VIDEO_DATA = 0x11,
|
||||
OPCODE_UNKNOWN_12 = 0x12,
|
||||
OPCODE_UNKNOWN_13 = 0x13,
|
||||
OPCODE_UNKNOWN_14 = 0x14,
|
||||
OPCODE_UNKNOWN_15 = 0x15,
|
||||
|
||||
PALETTE_COUNT = 256,
|
||||
kAudioBlocks = 20 // alloc a lot of blocks - need to store lots of audio data before video frames start.
|
||||
};
|
||||
|
||||
InterplayDecoder(bool soundenabled);
|
||||
~InterplayDecoder();
|
||||
|
||||
bool Open(FileReader &fr);
|
||||
void Close();
|
||||
bool RunFrame(uint64_t clock);
|
||||
|
||||
struct AudioData
|
||||
{
|
||||
int hFx;
|
||||
int nChannels;
|
||||
uint16_t nSampleRate;
|
||||
uint8_t nBitDepth;
|
||||
|
||||
int16_t samples[6000 * kAudioBlocks]; // must be a multiple of the stream buffer size
|
||||
int nWrite;
|
||||
int nRead;
|
||||
};
|
||||
|
||||
AudioData audio;
|
||||
AnimTextures animtex;
|
||||
|
||||
AnimTextures& animTex() { return animtex; }
|
||||
|
||||
private:
|
||||
struct DecodeMap
|
||||
{
|
||||
uint8_t* pData;
|
||||
uint32_t nSize;
|
||||
};
|
||||
|
||||
struct Palette
|
||||
{
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
uint8_t* GetCurrentFrame();
|
||||
uint8_t* GetPreviousFrame();
|
||||
void SwapFrames();
|
||||
void CopyBlock(uint8_t* pDest, uint8_t* pSrc);
|
||||
void DecodeBlock0(int32_t offset);
|
||||
void DecodeBlock1(int32_t offset);
|
||||
void DecodeBlock2(int32_t offset);
|
||||
void DecodeBlock3(int32_t offset);
|
||||
void DecodeBlock4(int32_t offset);
|
||||
void DecodeBlock5(int32_t offset);
|
||||
void DecodeBlock7(int32_t offset);
|
||||
void DecodeBlock8(int32_t offset);
|
||||
void DecodeBlock9(int32_t offset);
|
||||
void DecodeBlock10(int32_t offset);
|
||||
void DecodeBlock11(int32_t offset);
|
||||
void DecodeBlock12(int32_t offset);
|
||||
void DecodeBlock13(int32_t offset);
|
||||
void DecodeBlock14(int32_t offset);
|
||||
void DecodeBlock15(int32_t offset);
|
||||
|
||||
FileReader fr;
|
||||
|
||||
bool bIsPlaying, bAudioStarted;
|
||||
|
||||
uint32_t nTimerRate, nTimerDiv;
|
||||
uint32_t nWidth, nHeight, nFrame;
|
||||
double nFps;
|
||||
uint64_t nFrameDuration;
|
||||
|
||||
uint8_t* pVideoBuffers[2];
|
||||
uint32_t nCurrentVideoBuffer, nPreviousVideoBuffer;
|
||||
int32_t videoStride;
|
||||
|
||||
DecodeMap decodeMap;
|
||||
|
||||
Palette palette[256];
|
||||
uint64_t nNextFrameTime = 0;
|
||||
SoundStream* stream = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
364
src/common/cutscenes/screenjob.cpp
Normal file
364
src/common/cutscenes/screenjob.cpp
Normal file
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
** screenjob.cpp
|
||||
**
|
||||
** Generic cutscene display
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2020 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
#include "screenjob.h"
|
||||
#include "i_time.h"
|
||||
#include "v_2ddrawer.h"
|
||||
#include "animlib.h"
|
||||
#include "v_draw.h"
|
||||
#include "s_soundinternal.h"
|
||||
#include "animtexture.h"
|
||||
#include "gamestate.h"
|
||||
#include "vm.h"
|
||||
#include "c_bind.h"
|
||||
#include "c_console.h"
|
||||
#include "gamestate.h"
|
||||
#include "printf.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "s_music.h"
|
||||
#include "m_argv.h"
|
||||
|
||||
static DObject* runner;
|
||||
static PClass* runnerclass;
|
||||
static PType* runnerclasstype;
|
||||
static CompletionFunc completion;
|
||||
static int ticks;
|
||||
int intermissiondelay;
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void Job_Init()
|
||||
{
|
||||
static bool done = false;
|
||||
if (!done)
|
||||
{
|
||||
done = true;
|
||||
GC::AddMarkerFunc([] { GC::Mark(runner); });
|
||||
}
|
||||
runnerclass = PClass::FindClass("ScreenJobRunner");
|
||||
if (!runnerclass) I_FatalError("ScreenJobRunner not defined");
|
||||
runnerclasstype = NewPointer(runnerclass);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
static VMFunction* LookupFunction(const char* qname, bool validate = true)
|
||||
{
|
||||
size_t p = strcspn(qname, ".");
|
||||
if (p == 0) I_Error("Call to undefined function %s", qname);
|
||||
FString clsname(qname, p);
|
||||
FString funcname = qname + p + 1;
|
||||
|
||||
auto func = PClass::FindFunction(clsname, funcname);
|
||||
if (func == nullptr) I_Error("Call to undefined function %s", qname);
|
||||
if (validate)
|
||||
{
|
||||
// these conditions must be met by all functions for this interface.
|
||||
if (func->Proto->ReturnTypes.Size() != 0) I_Error("Bad cutscene function %s. Return value not allowed", qname);
|
||||
if (func->ImplicitArgs != 0) I_Error("Bad cutscene function %s. Must be static", qname);
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void CallCreateFunction(const char* qname, DObject* runner)
|
||||
{
|
||||
auto func = LookupFunction(qname);
|
||||
if (func->Proto->ArgumentTypes.Size() != 1) I_Error("Bad cutscene function %s. Must receive precisely one argument.", qname);
|
||||
if (func->Proto->ArgumentTypes[0] != runnerclasstype) I_Error("Bad cutscene function %s. Must receive ScreenJobRunner reference.", qname);
|
||||
VMValue val = runner;
|
||||
VMCall(func, &val, 1, nullptr, 0);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
DObject* CreateRunner(bool clearbefore = true)
|
||||
{
|
||||
auto obj = runnerclass->CreateNew();
|
||||
auto func = LookupFunction("ScreenJobRunner.Init", false);
|
||||
VMValue val[3] = { obj, clearbefore, false };
|
||||
VMCall(func, val, 3, nullptr, 0);
|
||||
return obj;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps)
|
||||
{
|
||||
auto obj = runnerclass->CreateNew();
|
||||
auto func = LookupFunction("ScreenJobRunner.AddGenericVideo", false);
|
||||
VMValue val[] = { runner, &fn, soundid, fps };
|
||||
VMCall(func, val, 4, nullptr, 0);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
int CutsceneDef::GetSound()
|
||||
{
|
||||
int id;
|
||||
if (soundName.IsNotEmpty()) id = soundEngine->FindSound(soundName);
|
||||
if (id <= 0) id = soundEngine->FindSoundByResID(soundID);
|
||||
return id;
|
||||
}
|
||||
|
||||
void CutsceneDef::Create(DObject* runner)
|
||||
{
|
||||
if (function.IsNotEmpty())
|
||||
{
|
||||
CallCreateFunction(function, runner);
|
||||
}
|
||||
else if (video.IsNotEmpty())
|
||||
{
|
||||
AddGenericVideo(runner, video, GetSound(), framespersec);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void DeleteScreenJob()
|
||||
{
|
||||
if (runner) runner->Destroy();
|
||||
runner = nullptr;
|
||||
}
|
||||
|
||||
void EndScreenJob()
|
||||
{
|
||||
DeleteScreenJob();
|
||||
if (completion) completion(false);
|
||||
completion = nullptr;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
bool ScreenJobResponder(event_t* ev)
|
||||
{
|
||||
if (ev->type == EV_KeyDown)
|
||||
{
|
||||
// We never reach the key binding checks in G_Responder, so for the console we have to check for ourselves here.
|
||||
auto binding = Bindings.GetBinding(ev->data1);
|
||||
if (binding.CompareNoCase("toggleconsole") == 0)
|
||||
{
|
||||
C_ToggleConsole();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
FInputEvent evt = ev;
|
||||
if (runner)
|
||||
{
|
||||
IFVIRTUALPTRNAME(runner, NAME_ScreenJobRunner, OnEvent)
|
||||
{
|
||||
int result = 0;
|
||||
VMValue parm[] = { runner, &evt };
|
||||
VMReturn ret(&result);
|
||||
VMCall(func, parm, 2, &ret, 1);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
bool ScreenJobTick()
|
||||
{
|
||||
ticks++;
|
||||
if (runner)
|
||||
{
|
||||
IFVIRTUALPTRNAME(runner, NAME_ScreenJobRunner, OnTick)
|
||||
{
|
||||
int result = 0;
|
||||
VMValue parm[] = { runner };
|
||||
VMReturn ret(&result);
|
||||
VMCall(func, parm, 1, &ret, 1);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void ScreenJobDraw()
|
||||
{
|
||||
double smoothratio = I_GetTimeFrac();
|
||||
|
||||
if (runner)
|
||||
{
|
||||
twod->ClearScreen();
|
||||
IFVIRTUALPTRNAME(runner, NAME_ScreenJobRunner, RunFrame)
|
||||
{
|
||||
VMValue parm[] = { runner, smoothratio };
|
||||
VMCall(func, parm, 2, nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
bool ScreenJobValidate()
|
||||
{
|
||||
if (runner)
|
||||
{
|
||||
IFVIRTUALPTRNAME(runner, NAME_ScreenJobRunner, Validate)
|
||||
{
|
||||
int res;
|
||||
VMValue parm[] = { runner };
|
||||
VMReturn ret(&res);
|
||||
VMCall(func, parm, 1, &ret, 1);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
bool StartCutscene(CutsceneDef& cs, int flags, const CompletionFunc& completion_)
|
||||
{
|
||||
if ((cs.function.IsNotEmpty() || cs.video.IsNotEmpty()) && cs.function.CompareNoCase("none") != 0)
|
||||
{
|
||||
completion = completion_;
|
||||
runner = CreateRunner();
|
||||
GC::WriteBarrier(runner);
|
||||
try
|
||||
{
|
||||
cs.Create(runner);
|
||||
if (!ScreenJobValidate())
|
||||
{
|
||||
runner->Destroy();
|
||||
runner = nullptr;
|
||||
return false;
|
||||
}
|
||||
if (flags & SJ_DELAY) intermissiondelay = 10; // need to wait a bit at the start to let the timer catch up.
|
||||
else intermissiondelay = 0;
|
||||
gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (runner) runner->Destroy();
|
||||
runner = nullptr;
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StartCutscene(const char* s, int flags, const CompletionFunc& completion)
|
||||
{
|
||||
CutsceneDef def;
|
||||
def.function = s;
|
||||
return StartCutscene(def, 0, completion);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
CCMD(testcutscene)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("Usage: testcutscene <buildfunction>\n");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (StartCutscene(argv[1], 0, [](bool) {}))
|
||||
{
|
||||
C_HideConsole();
|
||||
}
|
||||
}
|
||||
catch (const CRecoverableError& err)
|
||||
{
|
||||
Printf(TEXTCOLOR_RED "Unable to play cutscene: %s\n", err.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
43
src/common/cutscenes/screenjob.h
Normal file
43
src/common/cutscenes/screenjob.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
#include "dobject.h"
|
||||
#include "v_2ddrawer.h"
|
||||
#include "d_eventbase.h"
|
||||
#include "s_soundinternal.h"
|
||||
#include "gamestate.h"
|
||||
#include "zstring.h"
|
||||
|
||||
using CompletionFunc = std::function<void(bool)>;
|
||||
|
||||
void Job_Init();
|
||||
|
||||
enum
|
||||
{
|
||||
SJ_BLOCKUI = 1,
|
||||
SJ_DELAY = 2,
|
||||
};
|
||||
|
||||
struct CutsceneDef
|
||||
{
|
||||
FString video;
|
||||
FString function;
|
||||
FString soundName;
|
||||
int soundID = -1; // ResID not SoundID!
|
||||
int framespersec = 0; // only relevant for ANM.
|
||||
bool transitiononly = false; // only play when transitioning between maps, but not when starting on a map or ending a game.
|
||||
|
||||
void Create(DObject* runner);
|
||||
bool isdefined() { return video.IsNotEmpty() || function.IsNotEmpty(); }
|
||||
int GetSound();
|
||||
};
|
||||
|
||||
void EndScreenJob();
|
||||
void DeleteScreenJob();
|
||||
bool ScreenJobResponder(event_t* ev);
|
||||
bool ScreenJobTick();
|
||||
void ScreenJobDraw();
|
||||
|
||||
struct CutsceneDef;
|
||||
bool StartCutscene(const char* s, int flags, const CompletionFunc& completion);
|
||||
|
||||
extern int intermissiondelay;
|
504
src/common/thirdparty/libsmackerdec/COPYING
vendored
Normal file
504
src/common/thirdparty/libsmackerdec/COPYING
vendored
Normal file
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
55
src/common/thirdparty/libsmackerdec/include/BitReader.h
vendored
Normal file
55
src/common/thirdparty/libsmackerdec/include/BitReader.h
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _SmackerBitReader_h_
|
||||
#define _SmackerBitReader_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "FileStream.h"
|
||||
#include "tarray.h"
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
class BitReader
|
||||
{
|
||||
public:
|
||||
BitReader(SmackerCommon::FileStream &file, uint32_t size);
|
||||
~BitReader();
|
||||
uint32_t GetBit();
|
||||
uint32_t GetBits(uint32_t n);
|
||||
void SkipBits(uint32_t n);
|
||||
|
||||
uint32_t GetSize();
|
||||
uint32_t GetPosition();
|
||||
|
||||
private:
|
||||
uint32_t totalSize;
|
||||
uint32_t currentOffset;
|
||||
uint32_t bytesRead;
|
||||
|
||||
SmackerCommon::FileStream *file;
|
||||
|
||||
TArray<uint8_t> Cache;
|
||||
|
||||
void FillCache();
|
||||
};
|
||||
|
||||
} // close namespace SmackerCommon
|
||||
|
||||
#endif
|
63
src/common/thirdparty/libsmackerdec/include/FileStream.h
vendored
Normal file
63
src/common/thirdparty/libsmackerdec/include/FileStream.h
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _SmackerFileStream_h_
|
||||
#define _SmackerFileStream_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "files.h"
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
class FileStream
|
||||
{
|
||||
public:
|
||||
|
||||
bool Open(const char *fileName);
|
||||
bool Is_Open() { return file.isOpen(); }
|
||||
void Close() { file.Close(); }
|
||||
|
||||
int32_t ReadBytes(uint8_t *data, uint32_t nBytes)
|
||||
{
|
||||
return (uint32_t)file.Read(data, static_cast<int32_t>(nBytes));
|
||||
}
|
||||
|
||||
uint64_t ReadUint64LE() { return file.ReadUInt64(); }
|
||||
uint32_t ReadUint32LE() { return file.ReadUInt32(); }
|
||||
uint16_t ReadUint16LE() { return file.ReadUInt16(); }
|
||||
uint8_t ReadByte() { return file.ReadInt8(); }
|
||||
|
||||
|
||||
enum SeekDirection{
|
||||
kSeekCurrent = SEEK_CUR,
|
||||
kSeekStart = SEEK_SET,
|
||||
kSeekEnd = SEEK_END
|
||||
};
|
||||
|
||||
int32_t Seek(int32_t offset, SeekDirection dir = kSeekStart) { return (int)file.Seek(offset, (FileReader::ESeek) dir); }
|
||||
int32_t Skip(int32_t offset) { return (int)Seek(offset, kSeekCurrent); }
|
||||
int32_t GetPosition() { return (int)file.Tell(); }
|
||||
|
||||
private:
|
||||
FileReader file;
|
||||
};
|
||||
|
||||
} // close namespace SmackerCommon
|
||||
|
||||
#endif
|
43
src/common/thirdparty/libsmackerdec/include/HuffmanVLC.h
vendored
Normal file
43
src/common/thirdparty/libsmackerdec/include/HuffmanVLC.h
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _SmackerHuffmanVLC_h_
|
||||
#define _SmackerHuffmanVLC_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "BitReader.h"
|
||||
#include <vector>
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
struct VLC
|
||||
{
|
||||
uint32_t symbol;
|
||||
uint32_t code;
|
||||
};
|
||||
|
||||
typedef std::vector< std::vector<VLC> > VLCtable;
|
||||
|
||||
uint16_t VLC_GetCodeBits(BitReader &bits, VLCtable &table);
|
||||
void VLC_InitTable (VLCtable &table, uint32_t maxLength, uint32_t size, int *lengths, uint32_t *bits);
|
||||
uint32_t VLC_GetSize (VLCtable &table);
|
||||
|
||||
} // close namespace SmackerCommon
|
||||
|
||||
#endif
|
31
src/common/thirdparty/libsmackerdec/include/LogError.h
vendored
Normal file
31
src/common/thirdparty/libsmackerdec/include/LogError.h
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _SmackerLogError_h_
|
||||
#define _SmackerLogError_h_
|
||||
|
||||
//#include <string>
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
//void LogError(const std::string &error);
|
||||
|
||||
} // close namespace SmackerCommon
|
||||
|
||||
#endif
|
168
src/common/thirdparty/libsmackerdec/include/SmackerDecoder.h
vendored
Normal file
168
src/common/thirdparty/libsmackerdec/include/SmackerDecoder.h
vendored
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* This code is based on smacker.c from the FFmpeg project which can be obtained from http://www.ffmpeg.org/
|
||||
* below is the license from smacker.c
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Smacker decoder
|
||||
* Copyright (c) 2006 Konstantin Shishkov
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _SmackerDecoder_h_
|
||||
#define _SmackerDecoder_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "FileStream.h"
|
||||
#include "BitReader.h"
|
||||
#include <vector>
|
||||
|
||||
// exportable interface
|
||||
struct SmackerHandle
|
||||
{
|
||||
bool isValid;
|
||||
int instanceIndex;
|
||||
};
|
||||
|
||||
struct SmackerAudioInfo
|
||||
{
|
||||
uint32_t sampleRate;
|
||||
uint8_t nChannels;
|
||||
uint8_t bitsPerSample;
|
||||
|
||||
uint32_t idealBufferSize;
|
||||
};
|
||||
|
||||
SmackerHandle Smacker_Open (const char *fileName);
|
||||
void Smacker_Close (SmackerHandle &handle);
|
||||
uint32_t Smacker_GetNumAudioTracks (SmackerHandle &handle);
|
||||
SmackerAudioInfo Smacker_GetAudioTrackDetails (SmackerHandle &handle, uint32_t trackIndex);
|
||||
uint32_t Smacker_GetAudioData (SmackerHandle &handle, uint32_t trackIndex, int16_t *data);
|
||||
uint32_t Smacker_GetNumFrames (SmackerHandle &handle);
|
||||
void Smacker_GetFrameSize (SmackerHandle &handle, uint32_t &width, uint32_t &height);
|
||||
uint32_t Smacker_GetCurrentFrameNum (SmackerHandle &handle);
|
||||
uint32_t Smacker_GetNextFrame (SmackerHandle &handle);
|
||||
float Smacker_GetFrameRate (SmackerHandle &handle);
|
||||
void Smacker_GetPalette (SmackerHandle &handle, uint8_t *palette);
|
||||
void Smacker_GetFrame (SmackerHandle &handle, uint8_t *frame);
|
||||
void Smacker_GotoFrame (SmackerHandle &handle, uint32_t frameNum);
|
||||
|
||||
const int kMaxAudioTracks = 7;
|
||||
|
||||
// forward declare
|
||||
struct HuffContext;
|
||||
struct DBCtx;
|
||||
|
||||
struct SmackerAudioTrack
|
||||
{
|
||||
uint32_t sizeInBytes;
|
||||
uint32_t flags;
|
||||
uint32_t sampleRate;
|
||||
uint8_t nChannels;
|
||||
uint8_t bitsPerSample;
|
||||
// int compressionType;
|
||||
|
||||
uint8_t *buffer;
|
||||
uint32_t bufferSize;
|
||||
|
||||
uint32_t bytesReadThisFrame;
|
||||
};
|
||||
|
||||
class SmackerDecoder
|
||||
{
|
||||
public:
|
||||
uint32_t frameWidth;
|
||||
uint32_t frameHeight;
|
||||
|
||||
SmackerDecoder();
|
||||
~SmackerDecoder();
|
||||
|
||||
bool Open(const char *fileName);
|
||||
void GetPalette(uint8_t *palette);
|
||||
void GetFrame(uint8_t *frame);
|
||||
|
||||
SmackerAudioInfo GetAudioTrackDetails(uint32_t trackIndex);
|
||||
uint32_t GetAudioData(uint32_t trackIndex, int16_t *audioBuffer);
|
||||
uint32_t GetNumFrames();
|
||||
uint32_t GetCurrentFrameNum();
|
||||
float GetFrameRate();
|
||||
void GetNextFrame();
|
||||
void GotoFrame(uint32_t frameNum);
|
||||
|
||||
private:
|
||||
SmackerCommon::FileStream file;
|
||||
char signature[4];
|
||||
|
||||
// video related members
|
||||
uint32_t nFrames;
|
||||
uint32_t fps; // frames per second
|
||||
|
||||
uint8_t palette[768];
|
||||
uint8_t *picture;
|
||||
|
||||
bool isVer4;
|
||||
|
||||
SmackerAudioTrack audioTracks[kMaxAudioTracks];
|
||||
|
||||
uint32_t treeSize;
|
||||
uint32_t mMapSize, MClrSize, fullSize, typeSize;
|
||||
|
||||
std::vector<int> mmap_tbl;
|
||||
std::vector<int> mclr_tbl;
|
||||
std::vector<int> full_tbl;
|
||||
std::vector<int> type_tbl;
|
||||
|
||||
int mmap_last[3], mclr_last[3], full_last[3], type_last[3];
|
||||
|
||||
std::vector<uint32_t> frameSizes;
|
||||
std::vector<uint8_t> frameFlags;
|
||||
|
||||
uint32_t currentFrame;
|
||||
int32_t nextPos;
|
||||
int32_t firstFrameFilePos;
|
||||
|
||||
bool DecodeHeaderTrees();
|
||||
int DecodeHeaderTree(SmackerCommon::BitReader &bits, std::vector<int> &recodes, int *last, int size);
|
||||
int DecodeTree(SmackerCommon::BitReader &bits, HuffContext *hc, uint32_t prefix, int length);
|
||||
int DecodeBigTree(SmackerCommon::BitReader &bits, HuffContext *hc, DBCtx *ctx);
|
||||
int GetCode(SmackerCommon::BitReader &bits, std::vector<int> &recode, int *last);
|
||||
int ReadPacket();
|
||||
int DecodeFrame(uint32_t frameSize);
|
||||
void GetFrameSize(uint32_t &width, uint32_t &height);
|
||||
int DecodeAudio(uint32_t size, SmackerAudioTrack &track);
|
||||
};
|
||||
|
||||
#endif
|
90
src/common/thirdparty/libsmackerdec/src/BitReader.cpp
vendored
Normal file
90
src/common/thirdparty/libsmackerdec/src/BitReader.cpp
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "BitReader.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
BitReader::BitReader(SmackerCommon::FileStream &file, uint32_t size)
|
||||
{
|
||||
this->file = &file;
|
||||
this->totalSize = size;
|
||||
this->currentOffset = 0;
|
||||
this->bytesRead = 0;
|
||||
|
||||
this->Cache.Resize(size);
|
||||
file.ReadBytes(this->Cache.Data(), size);
|
||||
}
|
||||
|
||||
BitReader::~BitReader()
|
||||
{
|
||||
}
|
||||
|
||||
void BitReader::FillCache()
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t BitReader::GetSize()
|
||||
{
|
||||
return totalSize * 8;
|
||||
}
|
||||
|
||||
uint32_t BitReader::GetPosition()
|
||||
{
|
||||
return currentOffset;
|
||||
}
|
||||
|
||||
uint32_t BitReader::GetBit()
|
||||
{
|
||||
uint32_t ret = (Cache[currentOffset>>3]>>(currentOffset&7))&1;
|
||||
currentOffset++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t BitReader::GetBits(uint32_t n)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
int bitsTodo = n;
|
||||
|
||||
uint32_t theShift = 0;
|
||||
|
||||
while (bitsTodo)
|
||||
{
|
||||
uint32_t bit = GetBit();
|
||||
bit <<= theShift;
|
||||
|
||||
theShift++;
|
||||
|
||||
ret |= bit;
|
||||
|
||||
bitsTodo--;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BitReader::SkipBits(uint32_t n)
|
||||
{
|
||||
GetBits(n);
|
||||
}
|
||||
|
||||
} // close namespace SmackerCommon
|
||||
|
40
src/common/thirdparty/libsmackerdec/src/FileStream.cpp
vendored
Normal file
40
src/common/thirdparty/libsmackerdec/src/FileStream.cpp
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "FileStream.h"
|
||||
#include "filesystem.h"
|
||||
#include <stdlib.h>
|
||||
#include "cmdlib.h"
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
bool FileStream::Open(const char *fileName)
|
||||
{
|
||||
FString fixedname = fileName;
|
||||
FixPathSeperator(fixedname);
|
||||
file = fileSystem.OpenFileReader(fixedname);
|
||||
if (!file.isOpen())
|
||||
{
|
||||
// log error
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // close namespace SmackerCommon
|
71
src/common/thirdparty/libsmackerdec/src/HuffmanVLC.cpp
vendored
Normal file
71
src/common/thirdparty/libsmackerdec/src/HuffmanVLC.cpp
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <HuffmanVLC.h>
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
uint16_t VLC_GetCodeBits(BitReader &bits, VLCtable &table)
|
||||
{
|
||||
uint32_t codeBits = 0;
|
||||
|
||||
// search each length array
|
||||
for (uint32_t i = 0; i < table.size(); i++)
|
||||
{
|
||||
// get and add a new bit to codeBits
|
||||
uint32_t theBit = bits.GetBit() << i;
|
||||
codeBits |= theBit;
|
||||
|
||||
// search for a code match
|
||||
for (uint32_t j = 0; j < table[i].size(); j++)
|
||||
{
|
||||
if (codeBits == table[i][j].code)
|
||||
{
|
||||
return table[i][j].symbol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// shouldn't get here..
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VLC_InitTable(VLCtable &table, uint32_t maxLength, uint32_t size, int *lengths, uint32_t *bits)
|
||||
{
|
||||
table.resize(maxLength);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++)
|
||||
{
|
||||
VLC newCode;
|
||||
newCode.symbol = i;
|
||||
newCode.code = bits[i];
|
||||
|
||||
uint32_t codeLength = lengths[i];
|
||||
|
||||
if (codeLength)
|
||||
table[codeLength - 1].push_back(newCode);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t VLC_GetSize(VLCtable &table)
|
||||
{
|
||||
return uint32_t(table.size());
|
||||
}
|
||||
|
||||
} // close namespace SmackerCommon
|
33
src/common/thirdparty/libsmackerdec/src/LogError.cpp
vendored
Normal file
33
src/common/thirdparty/libsmackerdec/src/LogError.cpp
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* libsmackerdec - Smacker video decoder
|
||||
* Copyright (C) 2011 Barry Duncan
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "LogError.h"
|
||||
|
||||
namespace SmackerCommon {
|
||||
|
||||
#if 0
|
||||
static std::string LastError;
|
||||
|
||||
void LogError(const std::string &error)
|
||||
{
|
||||
LastError = error;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // close namespace SmackerCommon
|
1151
src/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp
vendored
Normal file
1151
src/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -27,31 +27,9 @@
|
|||
#include "basics.h"
|
||||
#include <functional>
|
||||
#include "d_eventbase.h"
|
||||
|
||||
#include "gamestate.h"
|
||||
|
||||
|
||||
enum gameaction_t : int
|
||||
{
|
||||
ga_nothing,
|
||||
ga_loadlevel, // not used.
|
||||
ga_newgame,
|
||||
ga_newgame2,
|
||||
ga_recordgame,
|
||||
ga_loadgame,
|
||||
ga_loadgamehidecon,
|
||||
ga_loadgameplaydemo,
|
||||
ga_autoloadgame,
|
||||
ga_savegame,
|
||||
ga_autosave,
|
||||
ga_playdemo,
|
||||
ga_completed,
|
||||
ga_slideshow,
|
||||
ga_worlddone,
|
||||
ga_screenshot,
|
||||
ga_togglemap,
|
||||
ga_fullconsole,
|
||||
ga_resumeconversation,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,3 +23,30 @@ enum gamestate_t : int
|
|||
};
|
||||
|
||||
extern gamestate_t gamestate;
|
||||
|
||||
enum gameaction_t : int
|
||||
{
|
||||
ga_nothing,
|
||||
ga_loadlevel, // not used.
|
||||
ga_newgame,
|
||||
ga_newgame2,
|
||||
ga_recordgame,
|
||||
ga_loadgame,
|
||||
ga_loadgamehidecon,
|
||||
ga_loadgameplaydemo,
|
||||
ga_autoloadgame,
|
||||
ga_savegame,
|
||||
ga_autosave,
|
||||
ga_playdemo,
|
||||
ga_completed,
|
||||
ga_slideshow,
|
||||
ga_worlddone,
|
||||
ga_screenshot,
|
||||
ga_togglemap,
|
||||
ga_fullconsole,
|
||||
ga_resumeconversation,
|
||||
ga_intro,
|
||||
ga_intermission,
|
||||
};
|
||||
|
||||
extern gameaction_t gameaction;
|
||||
|
|
Loading…
Reference in a new issue