text:
import Base.zero

export
    SampleFormat,
    SAMPLE_FMT_NONE,
    SAMPLE_FMT_U8,
    SAMPLE_FMT_S16,
    SAMPLE_FMT_S32,
    SAMPLE_FMT_FLT,
    SAMPLE_FMT_DBL,
    SAMPLE_FMT_NB,
    CH_FRONT_LEFT,
    CH_FRONT_RIGHT,
    CH_FRONT_CENTER,
    CH_LOW_FREQUENCY,
    CH_BACK_LEFT,
    CH_BACK_RIGHT,
    CH_FRONT_LEFT_OF_CENTER,
    CH_FRONT_RIGHT_OF_CENTER,
    CH_BACK_CENTER,
    CH_SIDE_LEFT,
    CH_SIDE_RIGHT,
    CH_TOP_CENTER,
    CH_TOP_FRONT_LEFT,
    CH_TOP_FRONT_CENTER,
    CH_TOP_FRONT_RIGHT,
    CH_TOP_BACK_LEFT,
    CH_TOP_BACK_CENTER,
    CH_TOP_BACK_RIGHT,
    CH_STEREO_LEFT,
    CH_STEREO_RIGHT,
    CH_LAYOUT_NATIVE,
    CH_LAYOUT_MONO,
    CH_LAYOUT_STEREO,
    CH_LAYOUT_2_1,
    CH_LAYOUT_SURROUND,
    CH_LAYOUT_4POINT0,
    CH_LAYOUT_2_2,
    CH_LAYOUT_QUAD,
    CH_LAYOUT_5POINT0,
    CH_LAYOUT_5POINT1,
    CH_LAYOUT_5POINT0_BACK,
    CH_LAYOUT_5POINT1_BACK,
    CH_LAYOUT_7POINT0,
    CH_LAYOUT_7POINT1,
    CH_LAYOUT_7POINT1_WIDE,
    CH_LAYOUT_STEREO_DOWNMIX,
    AVCODEC_MAX_AUDIO_FRAME_SIZE,
    CODEC_FLAG_QSCALE,
    CODEC_FLAG_4MV,
    CODEC_FLAG_QPEL,
    CODEC_FLAG_GMC,
    CODEC_FLAG_MV0,
    CODEC_FLAG_INPUT_PRESERVED,
    CODEC_FLAG_PASS1,
    CODEC_FLAG_PASS2,
    CODEC_FLAG_GRAY,
    CODEC_FLAG_EMU_EDGE,
    CODEC_FLAG_PSNR,
    CODEC_FLAG_TRUNCATED,
    CODEC_FLAG_NORMALIZE_AQP,
    CODEC_FLAG_INTERLACED_DCT,
    CODEC_FLAG_LOW_DELAY,
    CODEC_FLAG_GLOBAL_HEADER,
    CODEC_FLAG_BITEXACT,
    CODEC_FLAG_AC_PRED,
    CODEC_FLAG_CBP_RD,
    CODEC_FLAG_QP_RD,
    CODEC_FLAG_LOOP_FILTER,
    CODEC_FLAG_INTERLACED_ME,
    CODEC_FLAG_CLOSED_GOP,
    CODEC_FLAG2_FAST,
    CODEC_FLAG2_STRICT_GOP,
    CODEC_FLAG2_NO_OUTPUT,
    CODEC_FLAG2_LOCAL_HEADER,
    CODEC_FLAG2_SKIP_RD,
    CODEC_FLAG2_CHUNKS,
    CODEC_FLAG_OBMC,
    CODEC_FLAG_H263P_AIV,
    CODEC_FLAG_PART,
    CODEC_FLAG_ALT_SCAN,
    CODEC_FLAG_H263P_UMV,
    CODEC_FLAG_H263P_SLICE_STRUCT,
    CODEC_FLAG_SVCD_SCAN_OFFSET,
    CODEC_FLAG2_INTRA_VLC,
    CODEC_FLAG2_DROP_FRAME_TIMECODE,
    CODEC_FLAG2_NON_LINEAR_QUANT,
    CODEC_FLAG_EXTERN_HUFF,
    CODEC_FLAG2_BPYRAMID,
    CODEC_FLAG2_WPRED,
    CODEC_FLAG2_MIXED_REFS,
    CODEC_FLAG2_8X8DCT,
    CODEC_FLAG2_FASTPSKIP,
    CODEC_FLAG2_AUD,
    CODEC_FLAG2_BRDO,
    CODEC_FLAG2_MBTREE,
    CODEC_FLAG2_PSY,
    CODEC_FLAG2_SSIM,
    CODEC_FLAG2_INTRA_REFRESH,
    CODEC_FLAG2_MEMC_ONLY,
    CODEC_FLAG2_BIT_RESERVOIR,
    CODEC_CAP_DRAW_HORIZ_BAND,
    CODEC_CAP_DR1,
    CODEC_CAP_PARSE_ONLY,
    CODEC_CAP_TRUNCATED,
    CODEC_CAP_HWACCEL,
    CODEC_CAP_DELAY,
    CODEC_CAP_SMALL_LAST_FRAME,
    CODEC_CAP_HWACCEL_VDPAU,
    CODEC_CAP_SUBFRAMES,
    CODEC_CAP_EXPERIMENTAL,
    CODEC_CAP_CHANNEL_CONF,
    CODEC_CAP_NEG_LINESIZES,
    CODEC_CAP_FRAME_THREADS,
    CODEC_CAP_SLICE_THREADS,
    CODEC_CAP_PARAM_CHANGE,
    CODEC_CAP_AUTO_THREADS,
    CODEC_CAP_VARIABLE_FRAME_SIZE,
    MB_TYPE_INTRA4x4,
    MB_TYPE_INTRA16x16,
    MB_TYPE_INTRA_PCM,
    MB_TYPE_16x16,
    MB_TYPE_16x8,
    MB_TYPE_8x16,
    MB_TYPE_8x8,
    MB_TYPE_INTERLACED,
    MB_TYPE_DIRECT2,
    MB_TYPE_ACPRED,
    MB_TYPE_GMC,
    MB_TYPE_SKIP,
    MB_TYPE_P0L0,
    MB_TYPE_P1L0,
    MB_TYPE_P0L1,
    MB_TYPE_P1L1,
    MB_TYPE_L0,
    MB_TYPE_L1,
    MB_TYPE_L0L1,
    MB_TYPE_QUANT,
    MB_TYPE_CBP,
    AV_PKT_FLAG_KEY,
    AV_PKT_FLAG_CORRUPT,
    AV_NUM_DATA_POINTERS,
    SLICE_FLAG_CODED_ORDER,
    SLICE_FLAG_ALLOW_FIELD,
    SLICE_FLAG_ALLOW_PLANE,
    X264_PART_I4X4,
    X264_PART_I8X8,
    X264_PART_P8X8,
    X264_PART_P4X4,
    X264_PART_B8X8,
    AV_EF_CRCCHECK,
    AV_EF_BITSTREAM,
    AV_EF_BUFFER,
    AV_EF_EXPLODE,
    AVPALETTE_SIZE,
    AVPALETTE_COUNT,
    AV_PARSER_PTS_NB,
    PARSER_FLAG_COMPLETE_FRAMES,
    PARSER_FLAG_ONCE,
    PARSER_FLAG_FETCHED_OFFSET,
    CodecID,
    CODEC_ID_NONE,
    CODEC_ID_MPEG1VIDEO,
    CODEC_ID_MPEG2VIDEO,
    CODEC_ID_MPEG2VIDEO_XVMC,
    CODEC_ID_H261,
    CODEC_ID_H263,
    CODEC_ID_RV10,
    CODEC_ID_RV20,
    CODEC_ID_MJPEG,
    CODEC_ID_MJPEGB,
    CODEC_ID_LJPEG,
    CODEC_ID_SP5X,
    CODEC_ID_JPEGLS,
    CODEC_ID_MPEG4,
    CODEC_ID_RAWVIDEO,
    CODEC_ID_MSMPEG4V1,
    CODEC_ID_MSMPEG4V2,
    CODEC_ID_MSMPEG4V3,
    CODEC_ID_WMV1,
    CODEC_ID_WMV2,
    CODEC_ID_H263P,
    CODEC_ID_H263I,
    CODEC_ID_FLV1,
    CODEC_ID_SVQ1,
    CODEC_ID_SVQ3,
    CODEC_ID_DVVIDEO,
    CODEC_ID_HUFFYUV,
    CODEC_ID_CYUV,
    CODEC_ID_H264,
    CODEC_ID_INDEO3,
    CODEC_ID_VP3,
    CODEC_ID_THEORA,
    CODEC_ID_ASV1,
    CODEC_ID_ASV2,
    CODEC_ID_FFV1,
    CODEC_ID_4XM,
    CODEC_ID_VCR1,
    CODEC_ID_CLJR,
    CODEC_ID_MDEC,
    CODEC_ID_ROQ,
    CODEC_ID_INTERPLAY_VIDEO,
    CODEC_ID_XAN_WC3,
    CODEC_ID_XAN_WC4,
    CODEC_ID_RPZA,
    CODEC_ID_CINEPAK,
    CODEC_ID_WS_VQA,
    CODEC_ID_MSRLE,
    CODEC_ID_MSVIDEO1,
    CODEC_ID_IDCIN,
    CODEC_ID_8BPS,
    CODEC_ID_SMC,
    CODEC_ID_FLIC,
    CODEC_ID_TRUEMOTION1,
    CODEC_ID_VMDVIDEO,
    CODEC_ID_MSZH,
    CODEC_ID_ZLIB,
    CODEC_ID_QTRLE,
    CODEC_ID_SNOW,
    CODEC_ID_TSCC,
    CODEC_ID_ULTI,
    CODEC_ID_QDRAW,
    CODEC_ID_VIXL,
    CODEC_ID_QPEG,
    CODEC_ID_PNG,
    CODEC_ID_PPM,
    CODEC_ID_PBM,
    CODEC_ID_PGM,
    CODEC_ID_PGMYUV,
    CODEC_ID_PAM,
    CODEC_ID_FFVHUFF,
    CODEC_ID_RV30,
    CODEC_ID_RV40,
    CODEC_ID_VC1,
    CODEC_ID_WMV3,
    CODEC_ID_LOCO,
    CODEC_ID_WNV1,
    CODEC_ID_AASC,
    CODEC_ID_INDEO2,
    CODEC_ID_FRAPS,
    CODEC_ID_TRUEMOTION2,
    CODEC_ID_BMP,
    CODEC_ID_CSCD,
    CODEC_ID_MMVIDEO,
    CODEC_ID_ZMBV,
    CODEC_ID_AVS,
    CODEC_ID_SMACKVIDEO,
    CODEC_ID_NUV,
    CODEC_ID_KMVC,
    CODEC_ID_FLASHSV,
    CODEC_ID_CAVS,
    CODEC_ID_JPEG2000,
    CODEC_ID_VMNC,
    CODEC_ID_VP5,
    CODEC_ID_VP6,
    CODEC_ID_VP6F,
    CODEC_ID_TARGA,
    CODEC_ID_DSICINVIDEO,
    CODEC_ID_TIERTEXSEQVIDEO,
    CODEC_ID_TIFF,
    CODEC_ID_GIF,
    CODEC_ID_FFH264,
    CODEC_ID_DXA,
    CODEC_ID_DNXHD,
    CODEC_ID_THP,
    CODEC_ID_SGI,
    CODEC_ID_C93,
    CODEC_ID_BETHSOFTVID,
    CODEC_ID_PTX,
    CODEC_ID_TXD,
    CODEC_ID_VP6A,
    CODEC_ID_AMV,
    CODEC_ID_VB,
    CODEC_ID_PCX,
    CODEC_ID_SUNRAST,
    CODEC_ID_INDEO4,
    CODEC_ID_INDEO5,
    CODEC_ID_MIMIC,
    CODEC_ID_RL2,
    CODEC_ID_8SVX_EXP,
    CODEC_ID_8SVX_FIB,
    CODEC_ID_ESCAPE124,
    CODEC_ID_DIRAC,
    CODEC_ID_BFI,
    CODEC_ID_CMV,
    CODEC_ID_MOTIONPIXELS,
    CODEC_ID_TGV,
    CODEC_ID_TGQ,
    CODEC_ID_TQI,
    CODEC_ID_AURA,
    CODEC_ID_AURA2,
    CODEC_ID_V210X,
    CODEC_ID_TMV,
    CODEC_ID_V210,
    CODEC_ID_DPX,
    CODEC_ID_MAD,
    CODEC_ID_FRWU,
    CODEC_ID_FLASHSV2,
    CODEC_ID_CDGRAPHICS,
    CODEC_ID_R210,
    CODEC_ID_ANM,
    CODEC_ID_BINKVIDEO,
    CODEC_ID_IFF_ILBM,
    CODEC_ID_IFF_BYTERUN1,
    CODEC_ID_KGV1,
    CODEC_ID_YOP,
    CODEC_ID_VP8,
    CODEC_ID_PICTOR,
    CODEC_ID_ANSI,
    CODEC_ID_A64_MULTI,
    CODEC_ID_A64_MULTI5,
    CODEC_ID_R10K,
    CODEC_ID_MXPEG,
    CODEC_ID_LAGARITH,
    CODEC_ID_PRORES,
    CODEC_ID_JV,
    CODEC_ID_DFA,
    CODEC_ID_WMV3IMAGE,
    CODEC_ID_VC1IMAGE,
    CODEC_ID_G723_1,
    CODEC_ID_G729,
    CODEC_ID_UTVIDEO,
    CODEC_ID_BMV_VIDEO,
    CODEC_ID_VBLE,
    CODEC_ID_DXTORY,
    CODEC_ID_V410,
    CODEC_ID_FIRST_AUDIO,
    CODEC_ID_PCM_S16LE,
    CODEC_ID_PCM_S16BE,
    CODEC_ID_PCM_U16LE,
    CODEC_ID_PCM_U16BE,
    CODEC_ID_PCM_S8,
    CODEC_ID_PCM_U8,
    CODEC_ID_PCM_MULAW,
    CODEC_ID_PCM_ALAW,
    CODEC_ID_PCM_S32LE,
    CODEC_ID_PCM_S32BE,
    CODEC_ID_PCM_U32LE,
    CODEC_ID_PCM_U32BE,
    CODEC_ID_PCM_S24LE,
    CODEC_ID_PCM_S24BE,
    CODEC_ID_PCM_U24LE,
    CODEC_ID_PCM_U24BE,
    CODEC_ID_PCM_S24DAUD,
    CODEC_ID_PCM_ZORK,
    CODEC_ID_PCM_S16LE_PLANAR,
    CODEC_ID_PCM_DVD,
    CODEC_ID_PCM_F32BE,
    CODEC_ID_PCM_F32LE,
    CODEC_ID_PCM_F64BE,
    CODEC_ID_PCM_F64LE,
    CODEC_ID_PCM_BLURAY,
    CODEC_ID_PCM_LXF,
    CODEC_ID_S302M,
    CODEC_ID_PCM_S8_PLANAR,
    CODEC_ID_ADPCM_IMA_QT,
    CODEC_ID_ADPCM_IMA_WAV,
    CODEC_ID_ADPCM_IMA_DK3,
    CODEC_ID_ADPCM_IMA_DK4,
    CODEC_ID_ADPCM_IMA_WS,
    CODEC_ID_ADPCM_IMA_SMJPEG,
    CODEC_ID_ADPCM_MS,
    CODEC_ID_ADPCM_4XM,
    CODEC_ID_ADPCM_XA,
    CODEC_ID_ADPCM_ADX,
    CODEC_ID_ADPCM_EA,
    CODEC_ID_ADPCM_G726,
    CODEC_ID_ADPCM_CT,
    CODEC_ID_ADPCM_SWF,
    CODEC_ID_ADPCM_YAMAHA,
    CODEC_ID_ADPCM_SBPRO_4,
    CODEC_ID_ADPCM_SBPRO_3,
    CODEC_ID_ADPCM_SBPRO_2,
    CODEC_ID_ADPCM_THP,
    CODEC_ID_ADPCM_IMA_AMV,
    CODEC_ID_ADPCM_EA_R1,
    CODEC_ID_ADPCM_EA_R3,
    CODEC_ID_ADPCM_EA_R2,
    CODEC_ID_ADPCM_IMA_EA_SEAD,
    CODEC_ID_ADPCM_IMA_EA_EACS,
    CODEC_ID_ADPCM_EA_XAS,
    CODEC_ID_ADPCM_EA_MAXIS_XA,
    CODEC_ID_ADPCM_IMA_ISS,
    CODEC_ID_ADPCM_G722,
    CODEC_ID_AMR_NB,
    CODEC_ID_AMR_WB,
    CODEC_ID_RA_144,
    CODEC_ID_RA_288,
    CODEC_ID_ROQ_DPCM,
    CODEC_ID_INTERPLAY_DPCM,
    CODEC_ID_XAN_DPCM,
    CODEC_ID_SOL_DPCM,
    CODEC_ID_MP2,
    CODEC_ID_MP3,
    CODEC_ID_AAC,
    CODEC_ID_AC3,
    CODEC_ID_DTS,
    CODEC_ID_VORBIS,
    CODEC_ID_DVAUDIO,
    CODEC_ID_WMAV1,
    CODEC_ID_WMAV2,
    CODEC_ID_MACE3,
    CODEC_ID_MACE6,
    CODEC_ID_VMDAUDIO,
    CODEC_ID_SONIC,
    CODEC_ID_SONIC_LS,
    CODEC_ID_FLAC,
    CODEC_ID_MP3ADU,
    CODEC_ID_MP3ON4,
    CODEC_ID_SHORTEN,
    CODEC_ID_ALAC,
    CODEC_ID_WESTWOOD_SND1,
    CODEC_ID_GSM,
    CODEC_ID_QDM2,
    CODEC_ID_COOK,
    CODEC_ID_TRUESPEECH,
    CODEC_ID_TTA,
    CODEC_ID_SMACKAUDIO,
    CODEC_ID_QCELP,
    CODEC_ID_WAVPACK,
    CODEC_ID_DSICINAUDIO,
    CODEC_ID_IMC,
    CODEC_ID_MUSEPACK7,
    CODEC_ID_MLP,
    CODEC_ID_GSM_MS,
    CODEC_ID_ATRAC3,
    CODEC_ID_VOXWARE,
    CODEC_ID_APE,
    CODEC_ID_NELLYMOSER,
    CODEC_ID_MUSEPACK8,
    CODEC_ID_SPEEX,
    CODEC_ID_WMAVOICE,
    CODEC_ID_WMAPRO,
    CODEC_ID_WMALOSSLESS,
    CODEC_ID_ATRAC3P,
    CODEC_ID_EAC3,
    CODEC_ID_SIPR,
    CODEC_ID_MP1,
    CODEC_ID_TWINVQ,
    CODEC_ID_TRUEHD,
    CODEC_ID_MP4ALS,
    CODEC_ID_ATRAC1,
    CODEC_ID_BINKAUDIO_RDFT,
    CODEC_ID_BINKAUDIO_DCT,
    CODEC_ID_AAC_LATM,
    CODEC_ID_QDMC,
    CODEC_ID_CELT,
    CODEC_ID_BMV_AUDIO,
    CODEC_ID_FIRST_SUBTITLE,
    CODEC_ID_DVD_SUBTITLE,
    CODEC_ID_DVB_SUBTITLE,
    CODEC_ID_TEXT,
    CODEC_ID_XSUB,
    CODEC_ID_SSA,
    CODEC_ID_MOV_TEXT,
    CODEC_ID_HDMV_PGS_SUBTITLE,
    CODEC_ID_DVB_TELETEXT,
    CODEC_ID_SRT,
    CODEC_ID_FIRST_UNKNOWN,
    CODEC_ID_TTF,
    CODEC_ID_PROBE,
    CODEC_ID_MPEG2TS,
    CODEC_ID_MPEG4SYSTEMS,
    CODEC_ID_FFMETADATA,
    Motion_Est_ID,
    ME_ZERO,
    ME_FULL,
    ME_LOG,
    ME_PHODS,
    ME_EPZS,
    ME_X1,
    ME_HEX,
    ME_UMH,
    ME_ITER,
    ME_TESA,
    AVDiscard,
    AVDISCARD_NONE,
    AVDISCARD_DEFAULT,
    AVDISCARD_NONREF,
    AVDISCARD_BIDIR,
    AVDISCARD_NONKEY,
    AVDISCARD_ALL,
    AVColorPrimaries,
    AVCOL_PRI_BT709,
    AVCOL_PRI_UNSPECIFIED,
    AVCOL_PRI_BT470M,
    AVCOL_PRI_BT470BG,
    AVCOL_PRI_SMPTE170M,
    AVCOL_PRI_SMPTE240M,
    AVCOL_PRI_FILM,
    AVCOL_PRI_NB,
    AVColorTransferCharacteristic,
    AVCOL_TRC_BT709,
    AVCOL_TRC_UNSPECIFIED,
    AVCOL_TRC_GAMMA22,
    AVCOL_TRC_GAMMA28,
    AVCOL_TRC_NB,
    AVColorSpace,
    AVCOL_SPC_RGB,
    AVCOL_SPC_BT709,
    AVCOL_SPC_UNSPECIFIED,
    AVCOL_SPC_FCC,
    AVCOL_SPC_BT470BG,
    AVCOL_SPC_SMPTE170M,
    AVCOL_SPC_SMPTE240M,
    AVCOL_SPC_NB,
    AVColorRange,
    AVCOL_RANGE_UNSPECIFIED,
    AVCOL_RANGE_MPEG,
    AVCOL_RANGE_JPEG,
    AVCOL_RANGE_NB,
    AVChromaLocation,
    AVCHROMA_LOC_UNSPECIFIED,
    AVCHROMA_LOC_LEFT,
    AVCHROMA_LOC_CENTER,
    AVCHROMA_LOC_TOPLEFT,
    AVCHROMA_LOC_TOP,
    AVCHROMA_LOC_BOTTOMLEFT,
    AVCHROMA_LOC_BOTTOM,
    AVCHROMA_LOC_NB,
    AVLPCType,
    AV_LPC_TYPE_DEFAULT,
    AV_LPC_TYPE_NONE,
    AV_LPC_TYPE_FIXED,
    AV_LPC_TYPE_LEVINSON,
    AV_LPC_TYPE_CHOLESKY,
    AV_LPC_TYPE_NB,
    AVAudioServiceType,
    AV_AUDIO_SERVICE_TYPE_MAIN,
    AV_AUDIO_SERVICE_TYPE_EFFECTS,
    AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED,
    AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED,
    AV_AUDIO_SERVICE_TYPE_DIALOGUE,
    AV_AUDIO_SERVICE_TYPE_COMMENTARY,
    AV_AUDIO_SERVICE_TYPE_EMERGENCY,
    AV_AUDIO_SERVICE_TYPE_VOICE_OVER,
    AV_AUDIO_SERVICE_TYPE_KARAOKE,
    AV_AUDIO_SERVICE_TYPE_NB,
    RcOverride,
    Array_2_Int16,
    Array_3_Array_2_Int16,
    AVPanScan,
    AVPacketSideDataType,
    AV_PKT_DATA_PALETTE,
    AV_PKT_DATA_NEW_EXTRADATA,
    AV_PKT_DATA_PARAM_CHANGE,
    AVPacket,
    AVSideDataParamChangeFlags,
    AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT,
    AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT,
    AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE,
    AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS,
    Array_4_Ptr,
    Array_4_Cint,
    Array_2_Ptr,
    Array_4_Uint64,
    AVProfile,
    AVCodecDefault,
    AVCodec,
    Array_32_Uint8,
    Array_256_Uint32,
    AVPaletteControl,
    AVHWAccel,
    AVCodecInternal,
    AVFieldOrder,
    AV_FIELD_UNKNOWN,
    AV_FIELD_PROGRESSIVE,
    AV_FIELD_TT,
    AV_FIELD_BB,
    AV_FIELD_TB,
    AV_FIELD_BT,
    AVCodecContext,
    AVFrame,
    AVPicture,
    AVSubtitleType,
    SUBTITLE_NONE,
    SUBTITLE_BITMAP,
    SUBTITLE_TEXT,
    SUBTITLE_ASS,
    AVSubtitleRect,
    AVSubtitle,
    ReSampleContext,
    AVResampleContext,
    Array_4_Int64,
    Array_5_Cint,
    AVCodecParser,
    AVCodecParserContext,
    AVBitStreamFilter,
    AVBitStreamFilterContext,
    AVLockOp,
    AV_LOCK_CREATE,
    AV_LOCK_OBTAIN,
    AV_LOCK_RELEASE,
    AV_LOCK_DESTROY,
    LIBAVCODEC_VERSION_MAJOR,
    LIBAVCODEC_VERSION_MINOR,
    LIBAVCODEC_VERSION_MICRO,
    LIBAVCODEC_BUILD,
    vaapi_context,
    vdpau_render_state,
    AV_XVMC_ID,
    xvmc_pix_fmt

const SampleFormat = AVSampleFormat
const SAMPLE_FMT_NONE = AV_SAMPLE_FMT_NONE
const SAMPLE_FMT_U8 = AV_SAMPLE_FMT_U8
const SAMPLE_FMT_S16 = AV_SAMPLE_FMT_S16
const SAMPLE_FMT_S32 = AV_SAMPLE_FMT_S32
const SAMPLE_FMT_FLT = AV_SAMPLE_FMT_FLT
const SAMPLE_FMT_DBL = AV_SAMPLE_FMT_DBL
const SAMPLE_FMT_NB = AV_SAMPLE_FMT_NB
const CH_FRONT_LEFT = AV_CH_FRONT_LEFT
const CH_FRONT_RIGHT = AV_CH_FRONT_RIGHT
const CH_FRONT_CENTER = AV_CH_FRONT_CENTER
const CH_LOW_FREQUENCY = AV_CH_LOW_FREQUENCY
const CH_BACK_LEFT = AV_CH_BACK_LEFT
const CH_BACK_RIGHT = AV_CH_BACK_RIGHT
const CH_FRONT_LEFT_OF_CENTER = AV_CH_FRONT_LEFT_OF_CENTER
const CH_FRONT_RIGHT_OF_CENTER = AV_CH_FRONT_RIGHT_OF_CENTER
const CH_BACK_CENTER = AV_CH_BACK_CENTER
const CH_SIDE_LEFT = AV_CH_SIDE_LEFT
const CH_SIDE_RIGHT = AV_CH_SIDE_RIGHT
const CH_TOP_CENTER = AV_CH_TOP_CENTER
const CH_TOP_FRONT_LEFT = AV_CH_TOP_FRONT_LEFT
const CH_TOP_FRONT_CENTER = AV_CH_TOP_FRONT_CENTER
const CH_TOP_FRONT_RIGHT = AV_CH_TOP_FRONT_RIGHT
const CH_TOP_BACK_LEFT = AV_CH_TOP_BACK_LEFT
const CH_TOP_BACK_CENTER = AV_CH_TOP_BACK_CENTER
const CH_TOP_BACK_RIGHT = AV_CH_TOP_BACK_RIGHT
const CH_STEREO_LEFT = AV_CH_STEREO_LEFT
const CH_STEREO_RIGHT = AV_CH_STEREO_RIGHT
const CH_LAYOUT_NATIVE = AV_CH_LAYOUT_NATIVE
const CH_LAYOUT_MONO = AV_CH_LAYOUT_MONO
const CH_LAYOUT_STEREO = AV_CH_LAYOUT_STEREO
const CH_LAYOUT_2_1 = AV_CH_LAYOUT_2_1
const CH_LAYOUT_SURROUND = AV_CH_LAYOUT_SURROUND
const CH_LAYOUT_4POINT0 = AV_CH_LAYOUT_4POINT0
const CH_LAYOUT_2_2 = AV_CH_LAYOUT_2_2
const CH_LAYOUT_QUAD = AV_CH_LAYOUT_QUAD
const CH_LAYOUT_5POINT0 = AV_CH_LAYOUT_5POINT0
const CH_LAYOUT_5POINT1 = AV_CH_LAYOUT_5POINT1
const CH_LAYOUT_5POINT0_BACK = AV_CH_LAYOUT_5POINT0_BACK
const CH_LAYOUT_5POINT1_BACK = AV_CH_LAYOUT_5POINT1_BACK
const CH_LAYOUT_7POINT0 = AV_CH_LAYOUT_7POINT0
const CH_LAYOUT_7POINT1 = AV_CH_LAYOUT_7POINT1
const CH_LAYOUT_7POINT1_WIDE = AV_CH_LAYOUT_7POINT1_WIDE
const CH_LAYOUT_STEREO_DOWNMIX = AV_CH_LAYOUT_STEREO_DOWNMIX
const AVCODEC_MAX_AUDIO_FRAME_SIZE = 192000
const FF_INPUT_BUFFER_PADDING_SIZE = 8
const FF_MIN_BUFFER_SIZE = 16384
const FF_MAX_B_FRAMES = 16
const CODEC_FLAG_QSCALE = 0x0002
const CODEC_FLAG_4MV = 0x0004
const CODEC_FLAG_QPEL = 0x0010
const CODEC_FLAG_GMC = 0x0020
const CODEC_FLAG_MV0 = 0x0040
const CODEC_FLAG_INPUT_PRESERVED = 0x0100
const CODEC_FLAG_PASS1 = 0x0200
const CODEC_FLAG_PASS2 = 0x0400
const CODEC_FLAG_GRAY = 0x2000
const CODEC_FLAG_EMU_EDGE = 0x4000
const CODEC_FLAG_PSNR = 0x8000
const CODEC_FLAG_TRUNCATED = 0x00010000
const CODEC_FLAG_NORMALIZE_AQP = 0x00020000
const CODEC_FLAG_INTERLACED_DCT = 0x00040000
const CODEC_FLAG_LOW_DELAY = 0x00080000
const CODEC_FLAG_GLOBAL_HEADER = 0x00400000
const CODEC_FLAG_BITEXACT = 0x00800000
const CODEC_FLAG_AC_PRED = 0x01000000
const CODEC_FLAG_CBP_RD = 0x04000000
const CODEC_FLAG_QP_RD = 0x08000000
const CODEC_FLAG_LOOP_FILTER = 0x00000800
const CODEC_FLAG_INTERLACED_ME = 0x20000000
const CODEC_FLAG_CLOSED_GOP = 0x80000000
const CODEC_FLAG2_FAST = 0x00000001
const CODEC_FLAG2_STRICT_GOP = 0x00000002
const CODEC_FLAG2_NO_OUTPUT = 0x00000004
const CODEC_FLAG2_LOCAL_HEADER = 0x00000008
const CODEC_FLAG2_SKIP_RD = 0x00004000
const CODEC_FLAG2_CHUNKS = 0x00008000
const CODEC_FLAG_OBMC = 0x00000001
const CODEC_FLAG_H263P_AIV = 0x00000008
const CODEC_FLAG_PART = 0x0080
const CODEC_FLAG_ALT_SCAN = 0x00100000
const CODEC_FLAG_H263P_UMV = 0x02000000
const CODEC_FLAG_H263P_SLICE_STRUCT = 0x10000000
const CODEC_FLAG_SVCD_SCAN_OFFSET = 0x40000000
const CODEC_FLAG2_INTRA_VLC = 0x00000800
const CODEC_FLAG2_DROP_FRAME_TIMECODE = 0x00002000
const CODEC_FLAG2_NON_LINEAR_QUANT = 0x00010000
const CODEC_FLAG_EXTERN_HUFF = 0x1000
const CODEC_FLAG2_BPYRAMID = 0x00000010
const CODEC_FLAG2_WPRED = 0x00000020
const CODEC_FLAG2_MIXED_REFS = 0x00000040
const CODEC_FLAG2_8X8DCT = 0x00000080
const CODEC_FLAG2_FASTPSKIP = 0x00000100
const CODEC_FLAG2_AUD = 0x00000200
const CODEC_FLAG2_BRDO = 0x00000400
const CODEC_FLAG2_MBTREE = 0x00040000
const CODEC_FLAG2_PSY = 0x00080000
const CODEC_FLAG2_SSIM = 0x00100000
const CODEC_FLAG2_INTRA_REFRESH = 0x00200000
const CODEC_FLAG2_MEMC_ONLY = 0x00001000
const CODEC_FLAG2_BIT_RESERVOIR = 0x00020000
const CODEC_CAP_DRAW_HORIZ_BAND = 0x0001
const CODEC_CAP_DR1 = 0x0002
const CODEC_CAP_PARSE_ONLY = 0x0004
const CODEC_CAP_TRUNCATED = 0x0008
const CODEC_CAP_HWACCEL = 0x0010
const CODEC_CAP_DELAY = 0x0020
const CODEC_CAP_SMALL_LAST_FRAME = 0x0040
const CODEC_CAP_HWACCEL_VDPAU = 0x0080
const CODEC_CAP_SUBFRAMES = 0x0100
const CODEC_CAP_EXPERIMENTAL = 0x0200
const CODEC_CAP_CHANNEL_CONF = 0x0400
const CODEC_CAP_NEG_LINESIZES = 0x0800
const CODEC_CAP_FRAME_THREADS = 0x1000
const CODEC_CAP_SLICE_THREADS = 0x2000
const CODEC_CAP_PARAM_CHANGE = 0x4000
const CODEC_CAP_AUTO_THREADS = 0x8000
const CODEC_CAP_VARIABLE_FRAME_SIZE = 0x00010000
const MB_TYPE_INTRA4x4 = 0x0001
const MB_TYPE_INTRA16x16 = 0x0002
const MB_TYPE_INTRA_PCM = 0x0004
const MB_TYPE_16x16 = 0x0008
const MB_TYPE_16x8 = 0x0010
const MB_TYPE_8x16 = 0x0020
const MB_TYPE_8x8 = 0x0040
const MB_TYPE_INTERLACED = 0x0080
const MB_TYPE_DIRECT2 = 0x0100
const MB_TYPE_ACPRED = 0x0200
const MB_TYPE_GMC = 0x0400
const MB_TYPE_SKIP = 0x0800
const MB_TYPE_P0L0 = 0x1000
const MB_TYPE_P1L0 = 0x2000
const MB_TYPE_P0L1 = 0x4000
const MB_TYPE_P1L1 = 0x8000
const MB_TYPE_L0 = MB_TYPE_P0L0 | MB_TYPE_P1L0
const MB_TYPE_L1 = MB_TYPE_P0L1 | MB_TYPE_P1L1
const MB_TYPE_L0L1 = MB_TYPE_L0 | MB_TYPE_L1
const MB_TYPE_QUANT = 0x00010000
const MB_TYPE_CBP = 0x00020000
const FF_QSCALE_TYPE_MPEG1 = 0
const FF_QSCALE_TYPE_MPEG2 = 1
const FF_QSCALE_TYPE_H264 = 2
const FF_QSCALE_TYPE_VP56 = 3
const FF_BUFFER_TYPE_INTERNAL = 1
const FF_BUFFER_TYPE_USER = 2
const FF_BUFFER_TYPE_SHARED = 4
const FF_BUFFER_TYPE_COPY = 8
const FF_I_TYPE = AV_PICTURE_TYPE_I
const FF_P_TYPE = AV_PICTURE_TYPE_P
const FF_B_TYPE = AV_PICTURE_TYPE_B
const FF_S_TYPE = AV_PICTURE_TYPE_S
const FF_SI_TYPE = AV_PICTURE_TYPE_SI
const FF_SP_TYPE = AV_PICTURE_TYPE_SP
const FF_BI_TYPE = AV_PICTURE_TYPE_BI
const FF_BUFFER_HINTS_VALID = 0x01
const FF_BUFFER_HINTS_READABLE = 0x02
const FF_BUFFER_HINTS_PRESERVE = 0x04
const FF_BUFFER_HINTS_REUSABLE = 0x08
const AV_PKT_FLAG_KEY = 0x0001
const AV_PKT_FLAG_CORRUPT = 0x0002
const AV_NUM_DATA_POINTERS = 4
const FF_ASPECT_EXTENDED = 15
const FF_RC_STRATEGY_XVID = 1
const FF_BUG_AUTODETECT = 1
const FF_BUG_OLD_MSMPEG4 = 2
const FF_BUG_XVID_ILACE = 4
const FF_BUG_UMP4 = 8
const FF_BUG_NO_PADDING = 16
const FF_BUG_AMV = 32
const FF_BUG_AC_VLC = 0
const FF_BUG_QPEL_CHROMA = 64
const FF_BUG_STD_QPEL = 128
const FF_BUG_QPEL_CHROMA2 = 256
const FF_BUG_DIRECT_BLOCKSIZE = 512
const FF_BUG_EDGE = 1024
const FF_BUG_HPEL_CHROMA = 2048
const FF_BUG_DC_CLIP = 4096
const FF_BUG_MS = 8192
const FF_BUG_TRUNCATED = 16384
const FF_COMPLIANCE_VERY_STRICT = 2
const FF_COMPLIANCE_STRICT = 1
const FF_COMPLIANCE_NORMAL = 0
const FF_COMPLIANCE_UNOFFICIAL = -1
const FF_COMPLIANCE_EXPERIMENTAL = -2
const FF_ER_CAREFUL = 1
const FF_ER_COMPLIANT = 2
const FF_ER_AGGRESSIVE = 3
const FF_ER_VERY_AGGRESSIVE = 4
const FF_ER_EXPLODE = 5
const FF_DCT_AUTO = 0
const FF_DCT_FASTINT = 1
const FF_DCT_INT = 2
const FF_DCT_MMX = 3
const FF_DCT_MLIB = 4
const FF_DCT_ALTIVEC = 5
const FF_DCT_FAAN = 6
const FF_IDCT_AUTO = 0
const FF_IDCT_INT = 1
const FF_IDCT_SIMPLE = 2
const FF_IDCT_SIMPLEMMX = 3
const FF_IDCT_LIBMPEG2MMX = 4
const FF_IDCT_PS2 = 5
const FF_IDCT_MLIB = 6
const FF_IDCT_ARM = 7
const FF_IDCT_ALTIVEC = 8
const FF_IDCT_SH4 = 9
const FF_IDCT_SIMPLEARM = 10
const FF_IDCT_H264 = 11
const FF_IDCT_VP3 = 12
const FF_IDCT_IPP = 13
const FF_IDCT_XVIDMMX = 14
const FF_IDCT_CAVS = 15
const FF_IDCT_SIMPLEARMV5TE = 16
const FF_IDCT_SIMPLEARMV6 = 17
const FF_IDCT_SIMPLEVIS = 18
const FF_IDCT_WMV2 = 19
const FF_IDCT_FAAN = 20
const FF_IDCT_EA = 21
const FF_IDCT_SIMPLENEON = 22
const FF_IDCT_SIMPLEALPHA = 23
const FF_IDCT_BINK = 24
const FF_EC_GUESS_MVS = 1
const FF_EC_DEBLOCK = 2
const FF_PRED_LEFT = 0
const FF_PRED_PLANE = 1
const FF_PRED_MEDIAN = 2
const FF_DEBUG_PICT_INFO = 1
const FF_DEBUG_RC = 2
const FF_DEBUG_BITSTREAM = 4
const FF_DEBUG_MB_TYPE = 8
const FF_DEBUG_QP = 16
const FF_DEBUG_MV = 32
const FF_DEBUG_DCT_COEFF = 0x00000040
const FF_DEBUG_SKIP = 0x00000080
const FF_DEBUG_STARTCODE = 0x00000100
const FF_DEBUG_PTS = 0x00000200
const FF_DEBUG_ER = 0x00000400
const FF_DEBUG_MMCO = 0x00000800
const FF_DEBUG_BUGS = 0x00001000
const FF_DEBUG_VIS_QP = 0x00002000
const FF_DEBUG_VIS_MB_TYPE = 0x00004000
const FF_DEBUG_BUFFERS = 0x00008000
const FF_DEBUG_THREADS = 0x00010000
const FF_DEBUG_VIS_MV_P_FOR = 0x00000001
const FF_DEBUG_VIS_MV_B_FOR = 0x00000002
const FF_DEBUG_VIS_MV_B_BACK = 0x00000004
const FF_CMP_SAD = 0
const FF_CMP_SSE = 1
const FF_CMP_SATD = 2
const FF_CMP_DCT = 3
const FF_CMP_PSNR = 4
const FF_CMP_BIT = 5
const FF_CMP_RD = 6
const FF_CMP_ZERO = 7
const FF_CMP_VSAD = 8
const FF_CMP_VSSE = 9
const FF_CMP_NSSE = 10
const FF_CMP_W53 = 11
const FF_CMP_W97 = 12
const FF_CMP_DCTMAX = 13
const FF_CMP_DCT264 = 14
const FF_CMP_CHROMA = 256
const FF_DTG_AFD_SAME = 8
const FF_DTG_AFD_4_3 = 9
const FF_DTG_AFD_16_9 = 10
const FF_DTG_AFD_14_9 = 11
const FF_DTG_AFD_4_3_SP_14_9 = 13
const FF_DTG_AFD_16_9_SP_14_9 = 14
const FF_DTG_AFD_SP_4_3 = 15
const FF_DEFAULT_QUANT_BIAS = 999999
const FF_CODER_TYPE_VLC = 0
const FF_CODER_TYPE_AC = 1
const FF_CODER_TYPE_RAW = 2
const FF_CODER_TYPE_RLE = 3
const FF_CODER_TYPE_DEFLATE = 4
const SLICE_FLAG_CODED_ORDER = 0x0001
const SLICE_FLAG_ALLOW_FIELD = 0x0002
const SLICE_FLAG_ALLOW_PLANE = 0x0004
const FF_MB_DECISION_SIMPLE = 0
const FF_MB_DECISION_BITS = 1
const FF_MB_DECISION_RD = 2
const FF_AA_AUTO = 0
const FF_AA_FASTINT = 1
const FF_AA_INT = 2
const FF_AA_FLOAT = 3
const FF_PROFILE_UNKNOWN = -99
const FF_PROFILE_RESERVED = -100
const FF_PROFILE_AAC_MAIN = 0
const FF_PROFILE_AAC_LOW = 1
const FF_PROFILE_AAC_SSR = 2
const FF_PROFILE_AAC_LTP = 3
const FF_PROFILE_DTS = 20
const FF_PROFILE_DTS_ES = 30
const FF_PROFILE_DTS_96_24 = 40
const FF_PROFILE_DTS_HD_HRA = 50
const FF_PROFILE_DTS_HD_MA = 60
const FF_PROFILE_MPEG2_422 = 0
const FF_PROFILE_MPEG2_HIGH = 1
const FF_PROFILE_MPEG2_SS = 2
const FF_PROFILE_MPEG2_SNR_SCALABLE = 3
const FF_PROFILE_MPEG2_MAIN = 4
const FF_PROFILE_MPEG2_SIMPLE = 5
const FF_PROFILE_H264_CONSTRAINED = 1 << 9
const FF_PROFILE_H264_INTRA = 1 << 11
const FF_PROFILE_H264_BASELINE = 66
const FF_PROFILE_H264_CONSTRAINED_BASELINE = 66 | FF_PROFILE_H264_CONSTRAINED
const FF_PROFILE_H264_MAIN = 77
const FF_PROFILE_H264_EXTENDED = 88
const FF_PROFILE_H264_HIGH = 100
const FF_PROFILE_H264_HIGH_10 = 110
const FF_PROFILE_H264_HIGH_10_INTRA = 110 | FF_PROFILE_H264_INTRA
const FF_PROFILE_H264_HIGH_422 = 122
const FF_PROFILE_H264_HIGH_422_INTRA = 122 | FF_PROFILE_H264_INTRA
const FF_PROFILE_H264_HIGH_444 = 144
const FF_PROFILE_H264_HIGH_444_PREDICTIVE = 244
const FF_PROFILE_H264_HIGH_444_INTRA = 244 | FF_PROFILE_H264_INTRA
const FF_PROFILE_H264_CAVLC_444 = 44
const FF_PROFILE_VC1_SIMPLE = 0
const FF_PROFILE_VC1_MAIN = 1
const FF_PROFILE_VC1_COMPLEX = 2
const FF_PROFILE_VC1_ADVANCED = 3
const FF_PROFILE_MPEG4_SIMPLE = 0
const FF_PROFILE_MPEG4_SIMPLE_SCALABLE = 1
const FF_PROFILE_MPEG4_CORE = 2
const FF_PROFILE_MPEG4_MAIN = 3
const FF_PROFILE_MPEG4_N_BIT = 4
const FF_PROFILE_MPEG4_SCALABLE_TEXTURE = 5
const FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION = 6
const FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE = 7
const FF_PROFILE_MPEG4_HYBRID = 8
const FF_PROFILE_MPEG4_ADVANCED_REAL_TIME = 9
const FF_PROFILE_MPEG4_CORE_SCALABLE = 10
const FF_PROFILE_MPEG4_ADVANCED_CODING = 11
const FF_PROFILE_MPEG4_ADVANCED_CORE = 12
const FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE = 13
const FF_PROFILE_MPEG4_SIMPLE_STUDIO = 14
const FF_PROFILE_MPEG4_ADVANCED_SIMPLE = 15
const FF_LEVEL_UNKNOWN = -99
const X264_PART_I4X4 = 0x0001
const X264_PART_I8X8 = 0x0002
const X264_PART_P8X8 = 0x0010
const X264_PART_P4X4 = 0x0020
const X264_PART_B8X8 = 0x0100
const FF_COMPRESSION_DEFAULT = -1
const FF_THREAD_FRAME = 1
const FF_THREAD_SLICE = 2
const AV_EF_CRCCHECK = 1 << 0
const AV_EF_BITSTREAM = 1 << 1
const AV_EF_BUFFER = 1 << 2
const AV_EF_EXPLODE = 1 << 3
const AVPALETTE_SIZE = 1024
const AVPALETTE_COUNT = 256
const FF_LOSS_RESOLUTION = 0x0001
const FF_LOSS_DEPTH = 0x0002
const FF_LOSS_COLORSPACE = 0x0004
const FF_LOSS_ALPHA = 0x0008
const FF_LOSS_COLORQUANT = 0x0010
const FF_LOSS_CHROMA = 0x0020
const FF_ALPHA_TRANSP = 0x0001
const FF_ALPHA_SEMI_TRANSP = 0x0002
const AV_PARSER_PTS_NB = 4
const PARSER_FLAG_COMPLETE_FRAMES = 0x0001
const PARSER_FLAG_ONCE = 0x0002
const PARSER_FLAG_FETCHED_OFFSET = 0x0004

# begin enum CodecID
typealias CodecID UInt32
const CODEC_ID_NONE = UInt32(0)
const CODEC_ID_MPEG1VIDEO = UInt32(1)
const CODEC_ID_MPEG2VIDEO = UInt32(2)
const CODEC_ID_MPEG2VIDEO_XVMC = UInt32(3)
const CODEC_ID_H261 = UInt32(4)
const CODEC_ID_H263 = UInt32(5)
const CODEC_ID_RV10 = UInt32(6)
const CODEC_ID_RV20 = UInt32(7)
const CODEC_ID_MJPEG = UInt32(8)
const CODEC_ID_MJPEGB = UInt32(9)
const CODEC_ID_LJPEG = UInt32(10)
const CODEC_ID_SP5X = UInt32(11)
const CODEC_ID_JPEGLS = UInt32(12)
const CODEC_ID_MPEG4 = UInt32(13)
const CODEC_ID_RAWVIDEO = UInt32(14)
const CODEC_ID_MSMPEG4V1 = UInt32(15)
const CODEC_ID_MSMPEG4V2 = UInt32(16)
const CODEC_ID_MSMPEG4V3 = UInt32(17)
const CODEC_ID_WMV1 = UInt32(18)
const CODEC_ID_WMV2 = UInt32(19)
const CODEC_ID_H263P = UInt32(20)
const CODEC_ID_H263I = UInt32(21)
const CODEC_ID_FLV1 = UInt32(22)
const CODEC_ID_SVQ1 = UInt32(23)
const CODEC_ID_SVQ3 = UInt32(24)
const CODEC_ID_DVVIDEO = UInt32(25)
const CODEC_ID_HUFFYUV = UInt32(26)
const CODEC_ID_CYUV = UInt32(27)
const CODEC_ID_H264 = UInt32(28)
const CODEC_ID_INDEO3 = UInt32(29)
const CODEC_ID_VP3 = UInt32(30)
const CODEC_ID_THEORA = UInt32(31)
const CODEC_ID_ASV1 = UInt32(32)
const CODEC_ID_ASV2 = UInt32(33)
const CODEC_ID_FFV1 = UInt32(34)
const CODEC_ID_4XM = UInt32(35)
const CODEC_ID_VCR1 = UInt32(36)
const CODEC_ID_CLJR = UInt32(37)
const CODEC_ID_MDEC = UInt32(38)
const CODEC_ID_ROQ = UInt32(39)
const CODEC_ID_INTERPLAY_VIDEO = UInt32(40)
const CODEC_ID_XAN_WC3 = UInt32(41)
const CODEC_ID_XAN_WC4 = UInt32(42)
const CODEC_ID_RPZA = UInt32(43)
const CODEC_ID_CINEPAK = UInt32(44)
const CODEC_ID_WS_VQA = UInt32(45)
const CODEC_ID_MSRLE = UInt32(46)
const CODEC_ID_MSVIDEO1 = UInt32(47)
const CODEC_ID_IDCIN = UInt32(48)
const CODEC_ID_8BPS = UInt32(49)
const CODEC_ID_SMC = UInt32(50)
const CODEC_ID_FLIC = UInt32(51)
const CODEC_ID_TRUEMOTION1 = UInt32(52)
const CODEC_ID_VMDVIDEO = UInt32(53)
const CODEC_ID_MSZH = UInt32(54)
const CODEC_ID_ZLIB = UInt32(55)
const CODEC_ID_QTRLE = UInt32(56)
const CODEC_ID_SNOW = UInt32(57)
const CODEC_ID_TSCC = UInt32(58)
const CODEC_ID_ULTI = UInt32(59)
const CODEC_ID_QDRAW = UInt32(60)
const CODEC_ID_VIXL = UInt32(61)
const CODEC_ID_QPEG = UInt32(62)
const CODEC_ID_PNG = UInt32(63)
const CODEC_ID_PPM = UInt32(64)
const CODEC_ID_PBM = UInt32(65)
const CODEC_ID_PGM = UInt32(66)
const CODEC_ID_PGMYUV = UInt32(67)
const CODEC_ID_PAM = UInt32(68)
const CODEC_ID_FFVHUFF = UInt32(69)
const CODEC_ID_RV30 = UInt32(70)
const CODEC_ID_RV40 = UInt32(71)
const CODEC_ID_VC1 = UInt32(72)
const CODEC_ID_WMV3 = UInt32(73)
const CODEC_ID_LOCO = UInt32(74)
const CODEC_ID_WNV1 = UInt32(75)
const CODEC_ID_AASC = UInt32(76)
const CODEC_ID_INDEO2 = UInt32(77)
const CODEC_ID_FRAPS = UInt32(78)
const CODEC_ID_TRUEMOTION2 = UInt32(79)
const CODEC_ID_BMP = UInt32(80)
const CODEC_ID_CSCD = UInt32(81)
const CODEC_ID_MMVIDEO = UInt32(82)
const CODEC_ID_ZMBV = UInt32(83)
const CODEC_ID_AVS = UInt32(84)
const CODEC_ID_SMACKVIDEO = UInt32(85)
const CODEC_ID_NUV = UInt32(86)
const CODEC_ID_KMVC = UInt32(87)
const CODEC_ID_FLASHSV = UInt32(88)
const CODEC_ID_CAVS = UInt32(89)
const CODEC_ID_JPEG2000 = UInt32(90)
const CODEC_ID_VMNC = UInt32(91)
const CODEC_ID_VP5 = UInt32(92)
const CODEC_ID_VP6 = UInt32(93)
const CODEC_ID_VP6F = UInt32(94)
const CODEC_ID_TARGA = UInt32(95)
const CODEC_ID_DSICINVIDEO = UInt32(96)
const CODEC_ID_TIERTEXSEQVIDEO = UInt32(97)
const CODEC_ID_TIFF = UInt32(98)
const CODEC_ID_GIF = UInt32(99)
const CODEC_ID_FFH264 = UInt32(100)
const CODEC_ID_DXA = UInt32(101)
const CODEC_ID_DNXHD = UInt32(102)
const CODEC_ID_THP = UInt32(103)
const CODEC_ID_SGI = UInt32(104)
const CODEC_ID_C93 = UInt32(105)
const CODEC_ID_BETHSOFTVID = UInt32(106)
const CODEC_ID_PTX = UInt32(107)
const CODEC_ID_TXD = UInt32(108)
const CODEC_ID_VP6A = UInt32(109)
const CODEC_ID_AMV = UInt32(110)
const CODEC_ID_VB = UInt32(111)
const CODEC_ID_PCX = UInt32(112)
const CODEC_ID_SUNRAST = UInt32(113)
const CODEC_ID_INDEO4 = UInt32(114)
const CODEC_ID_INDEO5 = UInt32(115)
const CODEC_ID_MIMIC = UInt32(116)
const CODEC_ID_RL2 = UInt32(117)
const CODEC_ID_8SVX_EXP = UInt32(118)
const CODEC_ID_8SVX_FIB = UInt32(119)
const CODEC_ID_ESCAPE124 = UInt32(120)
const CODEC_ID_DIRAC = UInt32(121)
const CODEC_ID_BFI = UInt32(122)
const CODEC_ID_CMV = UInt32(123)
const CODEC_ID_MOTIONPIXELS = UInt32(124)
const CODEC_ID_TGV = UInt32(125)
const CODEC_ID_TGQ = UInt32(126)
const CODEC_ID_TQI = UInt32(127)
const CODEC_ID_AURA = UInt32(128)
const CODEC_ID_AURA2 = UInt32(129)
const CODEC_ID_V210X = UInt32(130)
const CODEC_ID_TMV = UInt32(131)
const CODEC_ID_V210 = UInt32(132)
const CODEC_ID_DPX = UInt32(133)
const CODEC_ID_MAD = UInt32(134)
const CODEC_ID_FRWU = UInt32(135)
const CODEC_ID_FLASHSV2 = UInt32(136)
const CODEC_ID_CDGRAPHICS = UInt32(137)
const CODEC_ID_R210 = UInt32(138)
const CODEC_ID_ANM = UInt32(139)
const CODEC_ID_BINKVIDEO = UInt32(140)
const CODEC_ID_IFF_ILBM = UInt32(141)
const CODEC_ID_IFF_BYTERUN1 = UInt32(142)
const CODEC_ID_KGV1 = UInt32(143)
const CODEC_ID_YOP = UInt32(144)
const CODEC_ID_VP8 = UInt32(145)
const CODEC_ID_PICTOR = UInt32(146)
const CODEC_ID_ANSI = UInt32(147)
const CODEC_ID_A64_MULTI = UInt32(148)
const CODEC_ID_A64_MULTI5 = UInt32(149)
const CODEC_ID_R10K = UInt32(150)
const CODEC_ID_MXPEG = UInt32(151)
const CODEC_ID_LAGARITH = UInt32(152)
const CODEC_ID_PRORES = UInt32(153)
const CODEC_ID_JV = UInt32(154)
const CODEC_ID_DFA = UInt32(155)
const CODEC_ID_WMV3IMAGE = UInt32(156)
const CODEC_ID_VC1IMAGE = UInt32(157)
const CODEC_ID_G723_1 = UInt32(158)
const CODEC_ID_G729 = UInt32(159)
const CODEC_ID_UTVIDEO = UInt32(160)
const CODEC_ID_BMV_VIDEO = UInt32(161)
const CODEC_ID_VBLE = UInt32(162)
const CODEC_ID_DXTORY = UInt32(163)
const CODEC_ID_V410 = UInt32(164)
const CODEC_ID_FIRST_AUDIO = UInt32(65536)
const CODEC_ID_PCM_S16LE = UInt32(65536)
const CODEC_ID_PCM_S16BE = UInt32(65537)
const CODEC_ID_PCM_U16LE = UInt32(65538)
const CODEC_ID_PCM_U16BE = UInt32(65539)
const CODEC_ID_PCM_S8 = UInt32(65540)
const CODEC_ID_PCM_U8 = UInt32(65541)
const CODEC_ID_PCM_MULAW = UInt32(65542)
const CODEC_ID_PCM_ALAW = UInt32(65543)
const CODEC_ID_PCM_S32LE = UInt32(65544)
const CODEC_ID_PCM_S32BE = UInt32(65545)
const CODEC_ID_PCM_U32LE = UInt32(65546)
const CODEC_ID_PCM_U32BE = UInt32(65547)
const CODEC_ID_PCM_S24LE = UInt32(65548)
const CODEC_ID_PCM_S24BE = UInt32(65549)
const CODEC_ID_PCM_U24LE = UInt32(65550)
const CODEC_ID_PCM_U24BE = UInt32(65551)
const CODEC_ID_PCM_S24DAUD = UInt32(65552)
const CODEC_ID_PCM_ZORK = UInt32(65553)
const CODEC_ID_PCM_S16LE_PLANAR = UInt32(65554)
const CODEC_ID_PCM_DVD = UInt32(65555)
const CODEC_ID_PCM_F32BE = UInt32(65556)
const CODEC_ID_PCM_F32LE = UInt32(65557)
const CODEC_ID_PCM_F64BE = UInt32(65558)
const CODEC_ID_PCM_F64LE = UInt32(65559)
const CODEC_ID_PCM_BLURAY = UInt32(65560)
const CODEC_ID_PCM_LXF = UInt32(65561)
const CODEC_ID_S302M = UInt32(65562)
const CODEC_ID_PCM_S8_PLANAR = UInt32(65563)
const CODEC_ID_ADPCM_IMA_QT = UInt32(69632)
const CODEC_ID_ADPCM_IMA_WAV = UInt32(69633)
const CODEC_ID_ADPCM_IMA_DK3 = UInt32(69634)
const CODEC_ID_ADPCM_IMA_DK4 = UInt32(69635)
const CODEC_ID_ADPCM_IMA_WS = UInt32(69636)
const CODEC_ID_ADPCM_IMA_SMJPEG = UInt32(69637)
const CODEC_ID_ADPCM_MS = UInt32(69638)
const CODEC_ID_ADPCM_4XM = UInt32(69639)
const CODEC_ID_ADPCM_XA = UInt32(69640)
const CODEC_ID_ADPCM_ADX = UInt32(69641)
const CODEC_ID_ADPCM_EA = UInt32(69642)
const CODEC_ID_ADPCM_G726 = UInt32(69643)
const CODEC_ID_ADPCM_CT = UInt32(69644)
const CODEC_ID_ADPCM_SWF = UInt32(69645)
const CODEC_ID_ADPCM_YAMAHA = UInt32(69646)
const CODEC_ID_ADPCM_SBPRO_4 = UInt32(69647)
const CODEC_ID_ADPCM_SBPRO_3 = UInt32(69648)
const CODEC_ID_ADPCM_SBPRO_2 = UInt32(69649)
const CODEC_ID_ADPCM_THP = UInt32(69650)
const CODEC_ID_ADPCM_IMA_AMV = UInt32(69651)
const CODEC_ID_ADPCM_EA_R1 = UInt32(69652)
const CODEC_ID_ADPCM_EA_R3 = UInt32(69653)
const CODEC_ID_ADPCM_EA_R2 = UInt32(69654)
const CODEC_ID_ADPCM_IMA_EA_SEAD = UInt32(69655)
const CODEC_ID_ADPCM_IMA_EA_EACS = UInt32(69656)
const CODEC_ID_ADPCM_EA_XAS = UInt32(69657)
const CODEC_ID_ADPCM_EA_MAXIS_XA = UInt32(69658)
const CODEC_ID_ADPCM_IMA_ISS = UInt32(69659)
const CODEC_ID_ADPCM_G722 = UInt32(69660)
const CODEC_ID_AMR_NB = UInt32(73728)
const CODEC_ID_AMR_WB = UInt32(73729)
const CODEC_ID_RA_144 = UInt32(77824)
const CODEC_ID_RA_288 = UInt32(77825)
const CODEC_ID_ROQ_DPCM = UInt32(81920)
const CODEC_ID_INTERPLAY_DPCM = UInt32(81921)
const CODEC_ID_XAN_DPCM = UInt32(81922)
const CODEC_ID_SOL_DPCM = UInt32(81923)
const CODEC_ID_MP2 = UInt32(86016)
const CODEC_ID_MP3 = UInt32(86017)
const CODEC_ID_AAC = UInt32(86018)
const CODEC_ID_AC3 = UInt32(86019)
const CODEC_ID_DTS = UInt32(86020)
const CODEC_ID_VORBIS = UInt32(86021)
const CODEC_ID_DVAUDIO = UInt32(86022)
const CODEC_ID_WMAV1 = UInt32(86023)
const CODEC_ID_WMAV2 = UInt32(86024)
const CODEC_ID_MACE3 = UInt32(86025)
const CODEC_ID_MACE6 = UInt32(86026)
const CODEC_ID_VMDAUDIO = UInt32(86027)
const CODEC_ID_SONIC = UInt32(86028)
const CODEC_ID_SONIC_LS = UInt32(86029)
const CODEC_ID_FLAC = UInt32(86030)
const CODEC_ID_MP3ADU = UInt32(86031)
const CODEC_ID_MP3ON4 = UInt32(86032)
const CODEC_ID_SHORTEN = UInt32(86033)
const CODEC_ID_ALAC = UInt32(86034)
const CODEC_ID_WESTWOOD_SND1 = UInt32(86035)
const CODEC_ID_GSM = UInt32(86036)
const CODEC_ID_QDM2 = UInt32(86037)
const CODEC_ID_COOK = UInt32(86038)
const CODEC_ID_TRUESPEECH = UInt32(86039)
const CODEC_ID_TTA = UInt32(86040)
const CODEC_ID_SMACKAUDIO = UInt32(86041)
const CODEC_ID_QCELP = UInt32(86042)
const CODEC_ID_WAVPACK = UInt32(86043)
const CODEC_ID_DSICINAUDIO = UInt32(86044)
const CODEC_ID_IMC = UInt32(86045)
const CODEC_ID_MUSEPACK7 = UInt32(86046)
const CODEC_ID_MLP = UInt32(86047)
const CODEC_ID_GSM_MS = UInt32(86048)
const CODEC_ID_ATRAC3 = UInt32(86049)
const CODEC_ID_VOXWARE = UInt32(86050)
const CODEC_ID_APE = UInt32(86051)
const CODEC_ID_NELLYMOSER = UInt32(86052)
const CODEC_ID_MUSEPACK8 = UInt32(86053)
const CODEC_ID_SPEEX = UInt32(86054)
const CODEC_ID_WMAVOICE = UInt32(86055)
const CODEC_ID_WMAPRO = UInt32(86056)
const CODEC_ID_WMALOSSLESS = UInt32(86057)
const CODEC_ID_ATRAC3P = UInt32(86058)
const CODEC_ID_EAC3 = UInt32(86059)
const CODEC_ID_SIPR = UInt32(86060)
const CODEC_ID_MP1 = UInt32(86061)
const CODEC_ID_TWINVQ = UInt32(86062)
const CODEC_ID_TRUEHD = UInt32(86063)
const CODEC_ID_MP4ALS = UInt32(86064)
const CODEC_ID_ATRAC1 = UInt32(86065)
const CODEC_ID_BINKAUDIO_RDFT = UInt32(86066)
const CODEC_ID_BINKAUDIO_DCT = UInt32(86067)
const CODEC_ID_AAC_LATM = UInt32(86068)
const CODEC_ID_QDMC = UInt32(86069)
const CODEC_ID_CELT = UInt32(86070)
const CODEC_ID_BMV_AUDIO = UInt32(86071)
const CODEC_ID_FIRST_SUBTITLE = UInt32(94208)
const CODEC_ID_DVD_SUBTITLE = UInt32(94208)
const CODEC_ID_DVB_SUBTITLE = UInt32(94209)
const CODEC_ID_TEXT = UInt32(94210)
const CODEC_ID_XSUB = UInt32(94211)
const CODEC_ID_SSA = UInt32(94212)
const CODEC_ID_MOV_TEXT = UInt32(94213)
const CODEC_ID_HDMV_PGS_SUBTITLE = UInt32(94214)
const CODEC_ID_DVB_TELETEXT = UInt32(94215)
const CODEC_ID_SRT = UInt32(94216)
const CODEC_ID_FIRST_UNKNOWN = UInt32(98304)
const CODEC_ID_TTF = UInt32(98304)
const CODEC_ID_PROBE = UInt32(102400)
const CODEC_ID_MPEG2TS = UInt32(131072)
const CODEC_ID_MPEG4SYSTEMS = UInt32(131073)
const CODEC_ID_FFMETADATA = UInt32(135168)
# end enum CodecID

# begin enum Motion_Est_ID
typealias Motion_Est_ID UInt32
const ME_ZERO = UInt32(1)
const ME_FULL = UInt32(2)
const ME_LOG = UInt32(3)
const ME_PHODS = UInt32(4)
const ME_EPZS = UInt32(5)
const ME_X1 = UInt32(6)
const ME_HEX = UInt32(7)
const ME_UMH = UInt32(8)
const ME_ITER = UInt32(9)
const ME_TESA = UInt32(10)
# end enum Motion_Est_ID

# begin enum AVDiscard
typealias AVDiscard Cint
const AVDISCARD_NONE = Int32(-16)
const AVDISCARD_DEFAULT = Int32(0)
const AVDISCARD_NONREF = Int32(8)
const AVDISCARD_BIDIR = Int32(16)
const AVDISCARD_NONKEY = Int32(32)
const AVDISCARD_ALL = Int32(48)
# end enum AVDiscard

# begin enum AVColorPrimaries
typealias AVColorPrimaries UInt32
const AVCOL_PRI_BT709 = UInt32(1)
const AVCOL_PRI_UNSPECIFIED = UInt32(2)
const AVCOL_PRI_BT470M = UInt32(4)
const AVCOL_PRI_BT470BG = UInt32(5)
const AVCOL_PRI_SMPTE170M = UInt32(6)
const AVCOL_PRI_SMPTE240M = UInt32(7)
const AVCOL_PRI_FILM = UInt32(8)
const AVCOL_PRI_NB = UInt32(9)
# end enum AVColorPrimaries

# begin enum AVColorTransferCharacteristic
typealias AVColorTransferCharacteristic UInt32
const AVCOL_TRC_BT709 = UInt32(1)
const AVCOL_TRC_UNSPECIFIED = UInt32(2)
const AVCOL_TRC_GAMMA22 = UInt32(4)
const AVCOL_TRC_GAMMA28 = UInt32(5)
const AVCOL_TRC_NB = UInt32(6)
# end enum AVColorTransferCharacteristic

# begin enum AVColorSpace
typealias AVColorSpace UInt32
const AVCOL_SPC_RGB = UInt32(0)
const AVCOL_SPC_BT709 = UInt32(1)
const AVCOL_SPC_UNSPECIFIED = UInt32(2)
const AVCOL_SPC_FCC = UInt32(4)
const AVCOL_SPC_BT470BG = UInt32(5)
const AVCOL_SPC_SMPTE170M = UInt32(6)
const AVCOL_SPC_SMPTE240M = UInt32(7)
const AVCOL_SPC_NB = UInt32(8)
# end enum AVColorSpace

# begin enum AVColorRange
typealias AVColorRange UInt32
const AVCOL_RANGE_UNSPECIFIED = UInt32(0)
const AVCOL_RANGE_MPEG = UInt32(1)
const AVCOL_RANGE_JPEG = UInt32(2)
const AVCOL_RANGE_NB = UInt32(3)
# end enum AVColorRange

# begin enum AVChromaLocation
typealias AVChromaLocation UInt32
const AVCHROMA_LOC_UNSPECIFIED = UInt32(0)
const AVCHROMA_LOC_LEFT = UInt32(1)
const AVCHROMA_LOC_CENTER = UInt32(2)
const AVCHROMA_LOC_TOPLEFT = UInt32(3)
const AVCHROMA_LOC_TOP = UInt32(4)
const AVCHROMA_LOC_BOTTOMLEFT = UInt32(5)
const AVCHROMA_LOC_BOTTOM = UInt32(6)
const AVCHROMA_LOC_NB = UInt32(7)
# end enum AVChromaLocation

# begin enum AVLPCType
typealias AVLPCType Cint
const AV_LPC_TYPE_DEFAULT = Int32(-1)
const AV_LPC_TYPE_NONE = Int32(0)
const AV_LPC_TYPE_FIXED = Int32(1)
const AV_LPC_TYPE_LEVINSON = Int32(2)
const AV_LPC_TYPE_CHOLESKY = Int32(3)
const AV_LPC_TYPE_NB = Int32(4)
# end enum AVLPCType

# begin enum AVAudioServiceType
typealias AVAudioServiceType UInt32
const AV_AUDIO_SERVICE_TYPE_MAIN = UInt32(0)
const AV_AUDIO_SERVICE_TYPE_EFFECTS = UInt32(1)
const AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = UInt32(2)
const AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = UInt32(3)
const AV_AUDIO_SERVICE_TYPE_DIALOGUE = UInt32(4)
const AV_AUDIO_SERVICE_TYPE_COMMENTARY = UInt32(5)
const AV_AUDIO_SERVICE_TYPE_EMERGENCY = UInt32(6)
const AV_AUDIO_SERVICE_TYPE_VOICE_OVER = UInt32(7)
const AV_AUDIO_SERVICE_TYPE_KARAOKE = UInt32(8)
const AV_AUDIO_SERVICE_TYPE_NB = UInt32(9)
# end enum AVAudioServiceType

immutable RcOverride
    start_frame::Cint
    end_frame::Cint
    qscale::Cint
    quality_factor::Cfloat
end

immutable Array_2_Int16
    d1::Int16
    d2::Int16
end

zero(::Type{Array_2_Int16}) = Array_2_Int16(fill(zero(Int16),2)...)

immutable Array_3_Array_2_Int16
    d1::Array_2_Int16
    d2::Array_2_Int16
    d3::Array_2_Int16
end

zero(::Type{Array_3_Array_2_Int16}) = Array_3_Array_2_Int16(fill(zero(Array_2_Int16),3)...)

immutable AVPanScan
    id::Cint
    width::Cint
    height::Cint
    position::Array_3_Array_2_Int16
end

# begin enum AVPacketSideDataType
typealias AVPacketSideDataType UInt32
const AV_PKT_DATA_PALETTE = UInt32(0)
const AV_PKT_DATA_NEW_EXTRADATA = UInt32(1)
const AV_PKT_DATA_PARAM_CHANGE = UInt32(2)
# end enum AVPacketSideDataType

immutable AVPacket
    pts::Int64
    dts::Int64
    data::Ptr{UInt8}
    size::Cint
    stream_index::Cint
    flags::Cint
    side_data::Ptr{Void}
    side_data_elems::Cint
    duration::Cint
    destruct::Ptr{Void}
    priv::Ptr{Void}
    pos::Int64
    convergence_duration::Int64
end

# begin enum AVSideDataParamChangeFlags
typealias AVSideDataParamChangeFlags UInt32
const AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = UInt32(1)
const AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = UInt32(2)
const AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = UInt32(4)
const AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = UInt32(8)
# end enum AVSideDataParamChangeFlags

immutable Array_4_Ptr
    d1::Ptr{UInt8}
    d2::Ptr{UInt8}
    d3::Ptr{UInt8}
    d4::Ptr{UInt8}
end

zero(::Type{Array_4_Ptr}) = Array_4_Ptr(fill(C_NULL,4)...)

immutable Array_4_Cint
    d1::Cint
    d2::Cint
    d3::Cint
    d4::Cint
end

zero(::Type{Array_4_Cint}) = Array_4_Cint(fill(zero(Cint),4)...)

immutable Array_2_Ptr
    d1::Ptr{Void}
    d2::Ptr{Void}
end

zero(::Type{Array_2_Ptr}) = Array_2_Ptr(fill(C_NULL,2)...)

immutable Array_4_Uint64
    d1::UInt64
    d2::UInt64
    d3::UInt64
    d4::UInt64
end

zero(::Type{Array_4_Uint64}) = Array_4_Uint64(fill(zero(UInt64),4)...)

immutable AVProfile
    profile::Cint
    name::Ptr{UInt8}
end

typealias AVCodecDefault Void

immutable AVCodec
    name::Ptr{UInt8}
    _type::AVMediaType
    id::CodecID
    priv_data_size::Cint
    init::Ptr{Void}
    encode::Ptr{Void}
    close::Ptr{Void}
    decode::Ptr{Void}
    capabilities::Cint
    next::Ptr{AVCodec}
    flush::Ptr{Void}
    supported_framerates::Ptr{AVRational}
    pix_fmts::Ptr{PixelFormat}
    long_name::Ptr{UInt8}
    supported_samplerates::Ptr{Cint}
    sample_fmts::Ptr{AVSampleFormat}
    channel_layouts::Ptr{UInt64}
    max_lowres::UInt8
    priv_class::Ptr{AVClass}
    profiles::Ptr{AVProfile}
    init_thread_copy::Ptr{Void}
    update_thread_context::Ptr{Void}
    defaults::Ptr{AVCodecDefault}
    init_static_data::Ptr{Void}
    encode2::Ptr{Void}
end

immutable Array_32_Uint8
    d1::UInt8
    d2::UInt8
    d3::UInt8
    d4::UInt8
    d5::UInt8
    d6::UInt8
    d7::UInt8
    d8::UInt8
    d9::UInt8
    d10::UInt8
    d11::UInt8
    d12::UInt8
    d13::UInt8
    d14::UInt8
    d15::UInt8
    d16::UInt8
    d17::UInt8
    d18::UInt8
    d19::UInt8
    d20::UInt8
    d21::UInt8
    d22::UInt8
    d23::UInt8
    d24::UInt8
    d25::UInt8
    d26::UInt8
    d27::UInt8
    d28::UInt8
    d29::UInt8
    d30::UInt8
    d31::UInt8
    d32::UInt8
end

zero(::Type{Array_32_Uint8}) = Array_32_Uint8(fill(zero(UInt8),32)...)

immutable Array_256_Uint32
    d1::UInt32
    d2::UInt32
    d3::UInt32
    d4::UInt32
    d5::UInt32
    d6::UInt32
    d7::UInt32
    d8::UInt32
    d9::UInt32
    d10::UInt32
    d11::UInt32
    d12::UInt32
    d13::UInt32
    d14::UInt32
    d15::UInt32
    d16::UInt32
    d17::UInt32
    d18::UInt32
    d19::UInt32
    d20::UInt32
    d21::UInt32
    d22::UInt32
    d23::UInt32
    d24::UInt32
    d25::UInt32
    d26::UInt32
    d27::UInt32
    d28::UInt32
    d29::UInt32
    d30::UInt32
    d31::UInt32
    d32::UInt32
    d33::UInt32
    d34::UInt32
    d35::UInt32
    d36::UInt32
    d37::UInt32
    d38::UInt32
    d39::UInt32
    d40::UInt32
    d41::UInt32
    d42::UInt32
    d43::UInt32
    d44::UInt32
    d45::UInt32
    d46::UInt32
    d47::UInt32
    d48::UInt32
    d49::UInt32
    d50::UInt32
    d51::UInt32
    d52::UInt32
    d53::UInt32
    d54::UInt32
    d55::UInt32
    d56::UInt32
    d57::UInt32
    d58::UInt32
    d59::UInt32
    d60::UInt32
    d61::UInt32
    d62::UInt32
    d63::UInt32
    d64::UInt32
    d65::UInt32
    d66::UInt32
    d67::UInt32
    d68::UInt32
    d69::UInt32
    d70::UInt32
    d71::UInt32
    d72::UInt32
    d73::UInt32
    d74::UInt32
    d75::UInt32
    d76::UInt32
    d77::UInt32
    d78::UInt32
    d79::UInt32
    d80::UInt32
    d81::UInt32
    d82::UInt32
    d83::UInt32
    d84::UInt32
    d85::UInt32
    d86::UInt32
    d87::UInt32
    d88::UInt32
    d89::UInt32
    d90::UInt32
    d91::UInt32
    d92::UInt32
    d93::UInt32
    d94::UInt32
    d95::UInt32
    d96::UInt32
    d97::UInt32
    d98::UInt32
    d99::UInt32
    d100::UInt32
    d101::UInt32
    d102::UInt32
    d103::UInt32
    d104::UInt32
    d105::UInt32
    d106::UInt32
    d107::UInt32
    d108::UInt32
    d109::UInt32
    d110::UInt32
    d111::UInt32
    d112::UInt32
    d113::UInt32
    d114::UInt32
    d115::UInt32
    d116::UInt32
    d117::UInt32
    d118::UInt32
    d119::UInt32
    d120::UInt32
    d121::UInt32
    d122::UInt32
    d123::UInt32
    d124::UInt32
    d125::UInt32
    d126::UInt32
    d127::UInt32
    d128::UInt32
    d129::UInt32
    d130::UInt32
    d131::UInt32
    d132::UInt32
    d133::UInt32
    d134::UInt32
    d135::UInt32
    d136::UInt32
    d137::UInt32
    d138::UInt32
    d139::UInt32
    d140::UInt32
    d141::UInt32
    d142::UInt32
    d143::UInt32
    d144::UInt32
    d145::UInt32
    d146::UInt32
    d147::UInt32
    d148::UInt32
    d149::UInt32
    d150::UInt32
    d151::UInt32
    d152::UInt32
    d153::UInt32
    d154::UInt32
    d155::UInt32
    d156::UInt32
    d157::UInt32
    d158::UInt32
    d159::UInt32
    d160::UInt32
    d161::UInt32
    d162::UInt32
    d163::UInt32
    d164::UInt32
    d165::UInt32
    d166::UInt32
    d167::UInt32
    d168::UInt32
    d169::UInt32
    d170::UInt32
    d171::UInt32
    d172::UInt32
    d173::UInt32
    d174::UInt32
    d175::UInt32
    d176::UInt32
    d177::UInt32
    d178::UInt32
    d179::UInt32
    d180::UInt32
    d181::UInt32
    d182::UInt32
    d183::UInt32
    d184::UInt32
    d185::UInt32
    d186::UInt32
    d187::UInt32
    d188::UInt32
    d189::UInt32
    d190::UInt32
    d191::UInt32
    d192::UInt32
    d193::UInt32
    d194::UInt32
    d195::UInt32
    d196::UInt32
    d197::UInt32
    d198::UInt32
    d199::UInt32
    d200::UInt32
    d201::UInt32
    d202::UInt32
    d203::UInt32
    d204::UInt32
    d205::UInt32
    d206::UInt32
    d207::UInt32
    d208::UInt32
    d209::UInt32
    d210::UInt32
    d211::UInt32
    d212::UInt32
    d213::UInt32
    d214::UInt32
    d215::UInt32
    d216::UInt32
    d217::UInt32
    d218::UInt32
    d219::UInt32
    d220::UInt32
    d221::UInt32
    d222::UInt32
    d223::UInt32
    d224::UInt32
    d225::UInt32
    d226::UInt32
    d227::UInt32
    d228::UInt32
    d229::UInt32
    d230::UInt32
    d231::UInt32
    d232::UInt32
    d233::UInt32
    d234::UInt32
    d235::UInt32
    d236::UInt32
    d237::UInt32
    d238::UInt32
    d239::UInt32
    d240::UInt32
    d241::UInt32
    d242::UInt32
    d243::UInt32
    d244::UInt32
    d245::UInt32
    d246::UInt32
    d247::UInt32
    d248::UInt32
    d249::UInt32
    d250::UInt32
    d251::UInt32
    d252::UInt32
    d253::UInt32
    d254::UInt32
    d255::UInt32
    d256::UInt32
end

zero(::Type{Array_256_Uint32}) = Array_256_Uint32(fill(zero(UInt32),256)...)

immutable AVPaletteControl
    palette_changed::Cint
    palette::Array_256_Uint32
end

immutable AVHWAccel
    name::Ptr{UInt8}
    _type::AVMediaType
    id::CodecID
    pix_fmt::PixelFormat
    capabilities::Cint
    next::Ptr{AVHWAccel}
    start_frame::Ptr{Void}
    decode_slice::Ptr{Void}
    end_frame::Ptr{Void}
    priv_data_size::Cint
end

typealias AVCodecInternal Void

# begin enum AVFieldOrder
typealias AVFieldOrder UInt32
const AV_FIELD_UNKNOWN = UInt32(0)
const AV_FIELD_PROGRESSIVE = UInt32(1)
const AV_FIELD_TT = UInt32(2)
const AV_FIELD_BB = UInt32(3)
const AV_FIELD_TB = UInt32(4)
const AV_FIELD_BT = UInt32(5)
# end enum AVFieldOrder

immutable AVCodecContext
    av_class::Ptr{AVClass}
    bit_rate::Cint
    bit_rate_tolerance::Cint
    flags::Cint
    sub_id::Cint
    me_method::Cint
    extradata::Ptr{UInt8}
    extradata_size::Cint
    time_base::AVRational
    width::Cint
    height::Cint
    gop_size::Cint
    pix_fmt::PixelFormat
    draw_horiz_band::Ptr{Void}
    sample_rate::Cint
    channels::Cint
    sample_fmt::AVSampleFormat
    frame_size::Cint
    frame_number::Cint
    delay::Cint
    qcompress::Cfloat
    qblur::Cfloat
    qmin::Cint
    qmax::Cint
    max_qdiff::Cint
    max_b_frames::Cint
    b_quant_factor::Cfloat
    rc_strategy::Cint
    b_frame_strategy::Cint
    codec::Ptr{AVCodec}
    priv_data::Ptr{Void}
    rtp_payload_size::Cint
    rtp_callback::Ptr{Void}
    mv_bits::Cint
    header_bits::Cint
    i_tex_bits::Cint
    p_tex_bits::Cint
    i_count::Cint
    p_count::Cint
    skip_count::Cint
    misc_bits::Cint
    frame_bits::Cint
    opaque::Ptr{Void}
    codec_name::Array_32_Uint8
    codec_type::AVMediaType
    codec_id::CodecID
    codec_tag::UInt32
    workaround_bugs::Cint
    luma_elim_threshold::Cint
    chroma_elim_threshold::Cint
    strict_std_compliance::Cint
    b_quant_offset::Cfloat
    error_recognition::Cint
    get_buffer::Ptr{Void}
    release_buffer::Ptr{Void}
    has_b_frames::Cint
    block_align::Cint
    parse_only::Cint
    mpeg_quant::Cint
    stats_out::Ptr{UInt8}
    stats_in::Ptr{UInt8}
    rc_qsquish::Cfloat
    rc_qmod_amp::Cfloat
    rc_qmod_freq::Cint
    rc_override::Ptr{RcOverride}
    rc_override_count::Cint
    rc_eq::Ptr{UInt8}
    rc_max_rate::Cint
    rc_min_rate::Cint
    rc_buffer_size::Cint
    rc_buffer_aggressivity::Cfloat
    i_quant_factor::Cfloat
    i_quant_offset::Cfloat
    rc_initial_cplx::Cfloat
    dct_algo::Cint
    lumi_masking::Cfloat
    temporal_cplx_masking::Cfloat
    spatial_cplx_masking::Cfloat
    p_masking::Cfloat
    dark_masking::Cfloat
    idct_algo::Cint
    slice_count::Cint
    slice_offset::Ptr{Cint}
    error_concealment::Cint
    dsp_mask::UInt32
    bits_per_coded_sample::Cint
    prediction_method::Cint
    sample_aspect_ratio::AVRational
    coded_frame::Ptr{AVFrame}
    debug::Cint
    debug_mv::Cint
    error::Array_4_Uint64
    me_cmp::Cint
    me_sub_cmp::Cint
    mb_cmp::Cint
    ildct_cmp::Cint
    dia_size::Cint
    last_predictor_count::Cint
    pre_me::Cint
    me_pre_cmp::Cint
    pre_dia_size::Cint
    me_subpel_quality::Cint
    get_format::Ptr{Void}
    dtg_active_format::Cint
    me_range::Cint
    intra_quant_bias::Cint
    inter_quant_bias::Cint
    color_table_id::Cint
    internal_buffer_count::Cint
    internal_buffer::Ptr{Void}
    global_quality::Cint
    coder_type::Cint
    context_model::Cint
    slice_flags::Cint
    xvmc_acceleration::Cint
    mb_decision::Cint
    intra_matrix::Ptr{UInt16}
    inter_matrix::Ptr{UInt16}
    stream_codec_tag::UInt32
    scenechange_threshold::Cint
    lmin::Cint
    lmax::Cint
    palctrl::Ptr{AVPaletteControl}
    noise_reduction::Cint
    reget_buffer::Ptr{Void}
    rc_initial_buffer_occupancy::Cint
    inter_threshold::Cint
    flags2::Cint
    error_rate::Cint
    antialias_algo::Cint
    quantizer_noise_shaping::Cint
    thread_count::Cint
    execute::Ptr{Void}
    thread_opaque::Ptr{Void}
    me_threshold::Cint
    mb_threshold::Cint
    intra_dc_precision::Cint
    nsse_weight::Cint
    skip_top::Cint
    skip_bottom::Cint
    profile::Cint
    level::Cint
    lowres::Cint
    coded_width::Cint
    coded_height::Cint
    frame_skip_threshold::Cint
    frame_skip_factor::Cint
    frame_skip_exp::Cint
    frame_skip_cmp::Cint
    border_masking::Cfloat
    mb_lmin::Cint
    mb_lmax::Cint
    me_penalty_compensation::Cint
    skip_loop_filter::AVDiscard
    skip_idct::AVDiscard
    skip_frame::AVDiscard
    bidir_refine::Cint
    brd_scale::Cint
    crf::Cfloat
    cqp::Cint
    keyint_min::Cint
    refs::Cint
    chromaoffset::Cint
    bframebias::Cint
    trellis::Cint
    complexityblur::Cfloat
    deblockalpha::Cint
    deblockbeta::Cint
    partitions::Cint
    directpred::Cint
    cutoff::Cint
    scenechange_factor::Cint
    mv0_threshold::Cint
    b_sensitivity::Cint
    compression_level::Cint
    min_prediction_order::Cint
    max_prediction_order::Cint
    lpc_coeff_precision::Cint
    prediction_order_method::Cint
    min_partition_order::Cint
    max_partition_order::Cint
    timecode_frame_start::Int64
    request_channels::Cint
    drc_scale::Cfloat
    reordered_opaque::Int64
    bits_per_raw_sample::Cint
    channel_layout::UInt64
    request_channel_layout::UInt64
    rc_max_available_vbv_use::Cfloat
    rc_min_vbv_overflow_use::Cfloat
    hwaccel::Ptr{AVHWAccel}
    ticks_per_frame::Cint
    hwaccel_context::Ptr{Void}
    color_primaries::AVColorPrimaries
    color_trc::AVColorTransferCharacteristic
    colorspace::AVColorSpace
    color_range::AVColorRange
    chroma_sample_location::AVChromaLocation
    execute2::Ptr{Void}
    weighted_p_pred::Cint
    aq_mode::Cint
    aq_strength::Cfloat
    psy_rd::Cfloat
    psy_trellis::Cfloat
    rc_lookahead::Cint
    crf_max::Cfloat
    log_level_offset::Cint
    lpc_type::AVLPCType
    lpc_passes::Cint
    slices::Cint
    subtitle_header::Ptr{UInt8}
    subtitle_header_size::Cint
    pkt::Ptr{AVPacket}
    is_copy::Cint
    thread_type::Cint
    active_thread_type::Cint
    thread_safe_callbacks::Cint
    vbv_delay::UInt64
    audio_service_type::AVAudioServiceType
    request_sample_fmt::AVSampleFormat
    err_recognition::Cint
    internal::Ptr{AVCodecInternal}
    field_order::AVFieldOrder
end

immutable AVFrame
    data::Array_4_Ptr
    linesize::Array_4_Cint
    base::Array_4_Ptr
    key_frame::Cint
    pict_type::AVPictureType
    pts::Int64
    coded_picture_number::Cint
    display_picture_number::Cint
    quality::Cint
    age::Cint
    reference::Cint
    qscale_table::Ptr{Int8}
    qstride::Cint
    mbskip_table::Ptr{UInt8}
    motion_val::Array_2_Ptr
    mb_type::Ptr{UInt32}
    motion_subsample_log2::UInt8
    opaque::Ptr{Void}
    error::Array_4_Uint64
    _type::Cint
    repeat_pict::Cint
    qscale_type::Cint
    interlaced_frame::Cint
    top_field_first::Cint
    pan_scan::Ptr{AVPanScan}
    palette_has_changed::Cint
    buffer_hints::Cint
    dct_coeff::Ptr{Int16}
    ref_index::Array_2_Ptr
    reordered_opaque::Int64
    hwaccel_picture_private::Ptr{Void}
    pkt_pts::Int64
    pkt_dts::Int64
    owner::Ptr{AVCodecContext}
    thread_opaque::Ptr{Void}
    nb_samples::Cint
    extended_data::Ptr{Ptr{UInt8}}
    sample_aspect_ratio::AVRational
    width::Cint
    height::Cint
    format::Cint
end

immutable AVPicture
    data::Array_4_Ptr
    linesize::Array_4_Cint
end

# begin enum AVSubtitleType
typealias AVSubtitleType UInt32
const SUBTITLE_NONE = UInt32(0)
const SUBTITLE_BITMAP = UInt32(1)
const SUBTITLE_TEXT = UInt32(2)
const SUBTITLE_ASS = UInt32(3)
# end enum AVSubtitleType

immutable AVSubtitleRect
    x::Cint
    y::Cint
    w::Cint
    h::Cint
    nb_colors::Cint
    pict::AVPicture
    _type::AVSubtitleType
    text::Ptr{UInt8}
    ass::Ptr{UInt8}
end

immutable AVSubtitle
    format::UInt16
    start_display_time::UInt32
    end_display_time::UInt32
    num_rects::UInt32
    rects::Ptr{Ptr{AVSubtitleRect}}
    pts::Int64
end

typealias ReSampleContext Void
typealias AVResampleContext Void

immutable Array_4_Int64
    d1::Int64
    d2::Int64
    d3::Int64
    d4::Int64
end

zero(::Type{Array_4_Int64}) = Array_4_Int64(fill(zero(Int64),4)...)

immutable Array_5_Cint
    d1::Cint
    d2::Cint
    d3::Cint
    d4::Cint
    d5::Cint
end

zero(::Type{Array_5_Cint}) = Array_5_Cint(fill(zero(Cint),5)...)

immutable AVCodecParser
    codec_ids::Array_5_Cint
    priv_data_size::Cint
    parser_init::Ptr{Void}
    parser_parse::Ptr{Void}
    parser_close::Ptr{Void}
    split::Ptr{Void}
    next::Ptr{AVCodecParser}
end

immutable AVCodecParserContext
    priv_data::Ptr{Void}
    parser::Ptr{AVCodecParser}
    frame_offset::Int64
    cur_offset::Int64
    next_frame_offset::Int64
    pict_type::Cint
    repeat_pict::Cint
    pts::Int64
    dts::Int64
    last_pts::Int64
    last_dts::Int64
    fetch_timestamp::Cint
    cur_frame_start_index::Cint
    cur_frame_offset::Array_4_Int64
    cur_frame_pts::Array_4_Int64
    cur_frame_dts::Array_4_Int64
    flags::Cint
    offset::Int64
    cur_frame_end::Array_4_Int64
    key_frame::Cint
    convergence_duration::Int64
    dts_sync_point::Cint
    dts_ref_dts_delta::Cint
    pts_dts_delta::Cint
    cur_frame_pos::Array_4_Int64
    pos::Int64
    last_pos::Int64
end

immutable AVBitStreamFilter
    name::Ptr{UInt8}
    priv_data_size::Cint
    filter::Ptr{Void}
    close::Ptr{Void}
    next::Ptr{AVBitStreamFilter}
end

immutable AVBitStreamFilterContext
    priv_data::Ptr{Void}
    filter::Ptr{AVBitStreamFilter}
    parser::Ptr{AVCodecParserContext}
    next::Ptr{AVBitStreamFilterContext}
end

# begin enum AVLockOp
typealias AVLockOp UInt32
const AV_LOCK_CREATE = UInt32(0)
const AV_LOCK_OBTAIN = UInt32(1)
const AV_LOCK_RELEASE = UInt32(2)
const AV_LOCK_DESTROY = UInt32(3)
# end enum AVLockOp

const LIBAVCODEC_VERSION_MAJOR = 53
const LIBAVCODEC_VERSION_MINOR = 35
const LIBAVCODEC_VERSION_MICRO = 0

# Skipping MacroDefinition: LIBAVCODEC_VERSION_INT AV_VERSION_INT ( LIBAVCODEC_VERSION_MAJOR , LIBAVCODEC_VERSION_MINOR , LIBAVCODEC_VERSION_MICRO )
# Skipping MacroDefinition: LIBAVCODEC_VERSION AV_VERSION ( LIBAVCODEC_VERSION_MAJOR , LIBAVCODEC_VERSION_MINOR , LIBAVCODEC_VERSION_MICRO )

const LIBAVCODEC_BUILD = LIBAVCODEC_VERSION_INT

# Skipping MacroDefinition: LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY ( LIBAVCODEC_VERSION )
# Skipping MacroDefinition: FF_API_PALETTE_CONTROL ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_OLD_SAMPLE_FMT ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_OLD_AUDIOCONVERT ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_ANTIALIAS_ALGO ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_REQUEST_CHANNELS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_OPT_H ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_THREAD_INIT ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_OLD_FF_PICT_TYPES ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_FLAC_GLOBAL_OPTS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_GET_PIX_FMT_NAME ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_ALLOC_CONTEXT ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_AVCODEC_OPEN ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_DRC_SCALE ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_ER ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_AVCODEC_INIT ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_X264_GLOBAL_OPTS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_MPEGVIDEO_GLOBAL_OPTS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_LAME_GLOBAL_OPTS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_SNOW_GLOBAL_OPTS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_MJPEG_GLOBAL_OPTS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_GET_ALPHA_INFO ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_PARSE_FRAME ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_INTERNAL_CONTEXT ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_TIFFENC_COMPLEVEL ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_DATA_POINTERS ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_OLD_DECODE_AUDIO ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_AVFRAME_AGE ( LIBAVCODEC_VERSION_MAJOR < 54 )
# Skipping MacroDefinition: FF_API_OLD_ENCODE_AUDIO ( LIBAVCODEC_VERSION_MAJOR < 54 )

immutable vaapi_context
    display::Ptr{Void}
    config_id::UInt32
    context_id::UInt32
    pic_param_buf_id::UInt32
    iq_matrix_buf_id::UInt32
    bitplane_buf_id::UInt32
    slice_buf_ids::Ptr{UInt32}
    n_slice_buf_ids::UInt32
    slice_buf_ids_alloc::UInt32
    slice_params::Ptr{Void}
    slice_param_size::UInt32
    slice_params_alloc::UInt32
    slice_count::UInt32
    slice_data::Ptr{UInt8}
    slice_data_size::UInt32
end

const FF_VDPAU_STATE_USED_FOR_RENDER = 1
const FF_VDPAU_STATE_USED_FOR_REFERENCE = 2

immutable vdpau_render_state
    surface::VdpVideoSurface
    state::Cint
    info::VdpPictureInfo
    bitstream_buffers_allocated::Cint
    bitstream_buffers_used::Cint
    bitstream_buffers::Ptr{VdpBitstreamBuffer}
end

const AV_XVMC_ID = 0x1dc711c0

immutable xvmc_pix_fmt
    xvmc_id::Cint
    data_blocks::Ptr{Int16}
    mv_blocks::Ptr{XvMCMacroBlock}
    allocated_mv_blocks::Cint
    allocated_data_blocks::Cint
    idct::Cint
    unsigned_intra::Cint
    p_surface::Ptr{XvMCSurface}
    p_past_surface::Ptr{XvMCSurface}
    p_future_surface::Ptr{XvMCSurface}
    picture_structure::UInt32
    flags::UInt32
    start_mv_blocks_num::Cint
    filled_mv_blocks_num::Cint
    next_free_data_block_num::Cint
end


text:
# Implements Candid Covariance-Free Incremental PCA algorithm of Weng et al:
# Weng, Juyang, Yilu Zhang, and Wey-Shiuan Hwang. "Candid covariance-free
# incremental principal component analysis." IEEE Transactions on Pattern
# Analysis and Machine Intelligence 25.8 (2003): 1034-1040.
#
# A comparison of online PCA algorithms in 2018 showed it to be a good
# trade-off in that it is fast and has low reconstruction error:
# H. Cardot and D. Degras, "Online Principal Component Analysis in
# High Dimension: Which Algorithm to Choose?", Int. Statistical Review, 2018-

"""
    CCIPCA(outdim::Int, indim; l::Int)

Online PCA with the CCIPCA (Candid Covariance-free Incremental PCA) algorithm,
where indim is the length of incoming vectors, outdim is the number of
dimension to project to, and l is the level of amnesia. Give values of l in
the range 2-4 if you want old vectors to be gradually less important, i.e.
latest vectors added get more weight.

If no indim is specified it will be set later, on first call to fit. After
that it is fixed and cannot change.

The CCIPCA is a very fast, simple, and online approximation of PCA. It can be used
for Dimensionality Reduction to project high-dimensional vectors into a
low-dimensional (typically 2D or 3D) space. This algorithm has shown very
good properties in comparative studies; it is both fast and give a good
approximation to (batch) PCA.

# Example

    o = CCIPCA(2, 10)                # Project 10-dimensional vectors into 2D
    u1 = rand(10)
    fit!(o, u1)                      # Fit to u1
    u2 = rand(10)
    fit!(o, u2)                      # Fit to u2
    u3 = rand(10)
    OnlineStats.transform(o, u3)     # Project u3 into PCA space fitted to u1 and u2 but don't change the projection
    u4 = rand(10)
    OnlineStats.fittransform!(o, u4) # Fit u4 and then project u4 into the space
    sort!(o)                         # Sort from high to low eigenvalues
    o[1]                             # Get primary (1st) eigenvector
    OnlineStats.variation(o)         # Get the variation (explained) "by" each eigenvector
"""
mutable struct CCIPCA <: OnlineStat{AbstractVector{<:Real}}
    lambda::Vector{Float64} # Eigenvalues, one per outdim
    U::Matrix{Float64}      # Eigenvectors, one row per indim, one column per outdim
    center::Vector{Float64} # Center/mean, one per indim
    xi::Vector{Float64}     # temp var used in calc, saved here for speed
    v::Vector{Float64}      # temp var used in calc, saved here for speed
    l::Int
    n::Int
    indimdet::Bool          # True iff indim has been determined (if not it is set on first fit)
end
function CCIPCA(outdim::Int, indim::Union{Nothing,Int} = nothing; l::Int=0)
    if isnothing(indim)
        indim = 1 # Dummy value, since we will update on first _fit
        indimdet = false
    elseif indim > 0
        @assert outdim < indim "indim ($indim) must be larger than outdim ($outdim)"
        indimdet = true
    else
        error("indim cannot take a value below 1, was set to $indim")
    end
    @assert l >= 0
    CCIPCA(setup_internal_vars(outdim, indim)..., l, 0, indimdet)
end
function setup_internal_vars(outdim::Int, indim::Int)
    lambda = zeros(Float64, outdim)
    U      = zeros(Float64, indim, outdim)
    center = zeros(Float64, indim)
    xi     = zeros(Float64, indim)
    v      = zeros(Float64, indim)
    return (lambda, U, center, xi, v)
end
Base.length(o::CCIPCA) = outdim(o) # Number of eigen-vectors
Base.getindex(o::CCIPCA, i) = o.U[:, i]
Base.lastindex(o::CCIPCA) = outdim(o)
Base.size(o::CCIPCA) = (indim(o), outdim(o))
@inline outdim(o::CCIPCA) = length(o.lambda)
@inline indim(o::CCIPCA) = length(o.center)
function _fit!(o::CCIPCA, x::Vector{Float64})
    if o.indimdet == false
        # Now indim is known so we set up accordingly
        idim = length(x)
        o.indimdet = true
        odim = size(o.U, 2)
        @assert odim < idim "indim ($idim) must be larger than outdim ($odim)"
        o.lambda, o.U, o.center, o.xi, o.v = setup_internal_vars(odim, idim)
    else
        @assert length(x) == OnlineStats.indim(o)
    end
    n = o.n + 1
    # update center with new observation:
    #o.center = (o.n * o.center .+ x)/n
    o.center += (x .- o.center) ./ n
    # center the new observation, unless this is the first observation:
    o.xi = (o.n > 0) ? (x .- o.center) : deepcopy(x)
    # Now recalc eigen-values and -vectors given the new observation:
    f = (1.0+o.l)/n
    @inbounds for i in 1:outdim(o)
        if i == n
            o.lambda[i] = norm(o.xi)
            o.U[:, i] = o.xi / o.lambda[i]
            break
        end
        o.v = (1-f) * o.lambda[i] * o.U[:, i] + f * dot(o.U[:, i], o.xi) * o.xi
        o.lambda[i] = norm(o.v)
        o.U[:, i] = o.v/o.lambda[i]
        o.xi = o.xi .- (dot(o.U[:, i], o.xi) * o.U[:, i])
    end
    o.n = n
end
"""
    transform(o::CCIPCA, u::AbstractArray{Float64})

Transform (i.e. project) the vector `u` into the PCA space
represented by `o`.
"""
function transform(o::CCIPCA, u::AbstractArray{Float64})
    @assert indim(o) == length(u)
    (u .- o.center)' * o.U
end
# We can also call the CCIPCA object itself to transform:
(o::CCIPCA)(u::AbstractArray{Float64}) = transform(o, u)
"""
    reconstruct(o::CCIPCA, uproj::AbstractArray{Float64})

Reconstruct the (projected) vector `uproj` back to the original
space from which `o` has been fitted.
"""
function reconstruct(o::CCIPCA, uproj::AbstractArray{Float64})
    @assert outdim(o) == length(uproj)
    o.center .+ (o.U * uproj')
end
"""
    fittransform!(o::CCIPCA, u::Vector{Float64})

First `fit!` and then `transform` the vector `u` into the PCA
space represented by `o`.
"""
function fittransform!(o::CCIPCA, u::Vector{Float64})
    _fit!(o, u)
    transform(o, u)
end
"""
    eigenvalue(o::CCIPCA, i::Int)

Get the `i`th eigenvalue of `o`. Also called principal variance
for PCA.
"""
function eigenvalue(o::CCIPCA, i::Int)
    @assert 1 <= i <= outdim(o) "This CCIPCA has $(outdim(o)) eigenvalues, cannot return eigenvalue $(i)!"
    o.lambda[i]
end
"""
    eigenvalue(o::CCIPCA, i::Int)

Get the `i`th eigenvalue of `o`. Also called principal variance
for PCA.
"""
principalvar(o::CCIPCA, i::Int) = eigenvalue(o, i)
"""
    eigenvector(o::CCIPCA, i::Int)

Get the `i`th eigenvector of `o`.
"""
function eigenvector(o::CCIPCA, i::Int)
    @assert 1 <= i <= outdim(o) "This CCIPCA has $(outdim(o)) eigenvectors, cannot return eigenvector $(i)!"
    o.U[:, i]
end
eigenvalues(o::CCIPCA) = Float64[eigenvalue(o, i) for i in 1:outdim(o)]
principalvars(o::CCIPCA) = eigenvalues(o)
"""
    relativevariances(o::CCIPCA)

Get the relative variance (explained) in the direction of each
eigenvector. Returns a vector of zeros if no vectors have yet been fitted.
Note that this does not inclue the residual variance that is not captured
in the eigenvectors.
"""
function relativevariances(o::CCIPCA)
    if o.n == 0
        return zeros(Float64, outdim(o))
    else
        return o.lambda ./ sum(o.lambda)
    end
end
"""
    sort!(o::CCIPCA)

Sort eigenvalues and their eigenvectors of `o` so highest ones come first.
Useful before visualising since it ensures most variation is on the
first (X) axis.
"""
function Base.sort!(o::CCIPCA)
    perm = sortperm(o.lambda, rev=true)
    o.lambda = o.lambda[perm]
    o.U = o.U[:, perm]
end

ext: jl


text:
# Accept either Symbol or String keys, but allways convert to Symbol
const Key = Union{Symbol,AbstractString}

"""
    AbstractRasterStack

Abstract supertype for objects that hold multiple [`AbstractRaster`](@ref)
that share spatial dimensions.

They are `NamedTuple`-like structures that may either contain `NamedTuple`
of [`AbstractRaster`](@ref), string paths that will load [`AbstractRaster`](@ref),
or a single path that points to as a file itself containing multiple layers, like
NetCDF or HDF5. Use and syntax is similar or identical for all cases.

`AbstractRasterStack` can hold layers that share some or all of their dimensions.
They cannot have the same dimension with t different length or spatial extent as
another layer.

`getindex` on a `AbstractRasterStack` generally returns a memory backed standard
[`Raster`](@ref). `geoarray[:somelayer] |> plot` plots the layers array,
while `geoarray[:somelayer, X(1:100), Band(2)] |> plot` will plot the
subset without loading the whole array.

`getindex` on a `AbstractRasterStack` with a key returns another stack with
getindex applied to all the arrays in the stack.
"""
abstract type AbstractRasterStack{L} <: AbstractDimStack{L} end

missingval(stack::AbstractRasterStack) = stack.missingval
filename(stack::AbstractRasterStack) = filename(parent(stack))
missingval(s::AbstractRasterStack, key::Symbol) = _singlemissingval(missingval(s), key)

isdisk(A::AbstractRasterStack) = isdisk(first(A))

setcrs(x::AbstractRasterStack, crs) = set(x, setcrs(dims(x), crs)...)
setmappedcrs(x::AbstractRasterStack, mappedcrs) = set(x, setmappedcrs(dims(x), mappedcrs)...)

"""
    subset(s::AbstractRasterStack, keys)

Subset a stack to hold only the layers in `keys`, where `keys` is a `Tuple`
or `Array` of `String` or `Symbol`, or a `Tuple` or `Array` of `Int`
"""
subset(s::AbstractRasterStack, keys) = subset(s, Tuple(keys))
function subset(s::AbstractRasterStack, keys::NTuple{<:Any,<:Key})
    RasterStack(map(k -> s[k], Tuple(keys)))
end
function subset(s::AbstractRasterStack, I::NTuple{<:Any,Int})
    subset(s, map(i -> keys(s)[i], I))
end

_singlemissingval(mvs::NamedTuple, key) = mvs[key]
_singlemissingval(mv, key) = mv

# DimensionalData methods ######################################################

# Always read a stack before loading it as a table.
DD.DimTable(stack::AbstractRasterStack) = invoke(DD.DimTable, Tuple{AbstractDimStack}, read(stack))

function DD.layers(s::AbstractRasterStack{<:FileStack{<:Any,Keys}}) where Keys
    NamedTuple{Keys}(map(K -> s[K], Keys))
end
function DD.layers(s::AbstractRasterStack{<:OpenStack{<:Any,Keys}}) where Keys
    NamedTuple{Keys}(map(K -> s[K], Keys))
end

function DD.rebuild(
    s::AbstractRasterStack, data, dims=dims(s), refdims=refdims(s),
    layerdims=DD.layerdims(s), metadata=metadata(s), layermetadata=DD.layermetadata(s),
    missingval=missingval(s),
)
    DD.basetypeof(s)(data, dims, refdims, layerdims, metadata, layermetadata, missingval)
end
function DD.rebuild(s::AbstractRasterStack;
    data=parent(s), dims=dims(s), refdims=refdims(s), layerdims=DD.layerdims(s),
    metadata=metadata(s), layermetadata=DD.layermetadata(s),
    missingval=missingval(s),
)
    DD.basetypeof(s)(
        data, dims, refdims, layerdims, metadata, layermetadata, missingval
    )
end

function DD.rebuild_from_arrays(
    s::AbstractRasterStack, das::NamedTuple{<:Any,<:Tuple{Vararg{<:AbstractDimArray}}};
    refdims=DD.refdims(s),
    metadata=DD.metadata(s),
    data=map(parent, das),
    dims=DD.combinedims(das...),
    layerdims=map(DD.basedims, das),
    layermetadata=map(DD.metadata, das),
    missingval=map(missingval, das),
)
    rebuild(s; data, dims, refdims, layerdims, metadata, layermetadata, missingval)
end

# Base methods #################################################################

Base.names(s::AbstractRasterStack) = keys(s)
Base.copy(stack::AbstractRasterStack) = map(copy, stack)

#### Stack getindex ####
# Different to DimensionalData as we construct a Raster
Base.getindex(s::AbstractRasterStack, key::AbstractString) = s[Symbol(key)]
function Base.getindex(s::AbstractRasterStack, key::Symbol)
    data_ = parent(s)[key]
    dims_ = dims(s, DD.layerdims(s, key))
    metadata = DD.layermetadata(s, key)
    Raster(data_, dims_, refdims(s), key, metadata, missingval(s, key))
end
# Key + Index
@propagate_inbounds @inline function Base.getindex(s::AbstractRasterStack, key::Symbol, i1, I...)
    A = s[key][i1, I...]
end

# Concrete AbstrackRasterStack implementation #################################################

"""
    RasterStack <: AbstrackRasterStack

    RasterStack(data...; name, kw...)
    RasterStack(data::Union{Vector,Tuple}; name, kw...)
    RasterStack(data::NamedTuple; kw...))
    RasterStack(s::AbstractRasterStack; kw...)
    RasterStack(s::AbstractRaster; layersfrom=Band, kw...)

Load a file path or a `NamedTuple` of paths as a `RasterStack`, or convert arguments, a
`Vector` or `NamedTuple` of `Raster` to `RasterStack`.

# Arguments

- `data`: A `NamedTuple` of [`Raster`](@ref), or a `Vector`, `Tuple` or splatted arguments
    of [`Raster`](@ref). The latter options must pass a `name` keyword argument.

# Keywords

- `name`: Used as stack layer names when a `Tuple`, `Vector` or splat of `Raster` is passed in.
- `metadata`: A `Dict` or `DimensionalData.Metadata` object.
- `refdims`: `Tuple` of `Dimension` that the stack was sliced from.
- `layersfrom`: `Dimension` to source stack layers from if the file is not already multi-layered.
    `nothing` is default, so that a single `RasterStack(raster)` is a single layered stack.
    `RasterStack(raster; layersfrom=Band)` will use the bands as layers.

```julia
files = (:temp="temp.tif", :pressure="pressure.tif", :relhum="relhum.tif")
stack = RasterStack(files; mappedcrs=EPSG(4326))
stack[:relhum][Lat(Contains(-37), Lon(Contains(144))
```
"""
struct RasterStack{L<:Union{FileStack,OpenStack,NamedTuple},D<:Tuple,R<:Tuple,LD<:NamedTuple,M,LM,MV} <: AbstractRasterStack{L}
    data::L
    dims::D
    refdims::R
    layerdims::LD
    metadata::M
    layermetadata::LM
    missingval::MV
end
# Multi-file stack from strings
function RasterStack(
    filenames::Union{AbstractArray{<:AbstractString},Tuple{<:AbstractString,Vararg}};
    name=map(filekey, filenames), keys=name, kw...
)
    RasterStack(NamedTuple{Tuple(keys)}(Tuple(filenames)); kw...)
end
function RasterStack(filenames::NamedTuple{K,<:Tuple{<:AbstractString,Vararg}};
    crs=nothing, mappedcrs=nothing, source=nothing, lazy=true, kw...
) where K
    layers = map(keys(filenames), values(filenames)) do key, fn
        source = source isa Nothing ? _sourcetype(fn) : source
        crs = defaultcrs(source, crs)
        mappedcrs = defaultmappedcrs(source, mappedcrs)
        _open(source, fn; key) do ds
            data = if lazy
                FileArray(ds, fn; key)
            else
                _open(Array, source, ds; key)
            end
            dims = DD.dims(ds, crs, mappedcrs)
            md = metadata(ds)
            mv = missingval(ds)
            Raster(data, dims; name=key, metadata=md, missingval=mv)
        end
    end
    RasterStack(NamedTuple{K}(layers); kw...)
end
# Multi Raster stack from Tuple of AbstractArray
function RasterStack(data::Tuple{Vararg{<:AbstractArray}}, dims::Tuple; name=nothing, keys=name, kw...)
    return RasterStack(NamedTuple{cleankeys(keys)}(data), dims; kw...)
end
# Multi Raster stack from NamedTuple of AbstractArray
function RasterStack(data::NamedTuple{<:Any,<:Tuple{Vararg{<:AbstractArray}}}, dims::Tuple; kw...)
    # TODO: make this more sophisticated an match dimension length to axes?
    layers = map(data) do A
        Raster(A, dims[1:ndims(A)])
    end
    return RasterStack(layers; kw...)
end
# Multi Raster stack from AbstractDimArray splat
RasterStack(layers::AbstractDimArray...; kw...) = RasterStack(layers; kw...)
# Multi Raster stack from tuple with `keys` keyword
function RasterStack(layers::Tuple{Vararg{<:AbstractRaster}};
    name=map(name, layers), keys=name, kw...
)
    RasterStack(NamedTuple{cleankeys(keys)}(layers); kw...)
end
# Multi Raster stack from NamedTuple
function RasterStack(layers::NamedTuple{<:Any,<:Tuple{Vararg{<:AbstractRaster}}};
    resize=nothing, refdims=(), metadata=NoMetadata(), kw...
)
    # resize if not matching sizes - resize can be `crop`, `resample` or `extend`
    layers = resize isa Nothing ? layers : resize(layers)
    # DD.comparedims(layers...)
    dims=DD.combinedims(layers...)
    data=map(parent, layers)
    layerdims=map(DD.basedims, layers)
    layermetadata=map(DD.metadata, layers)
    missingval=map(Rasters.missingval, layers)
    return RasterStack(
        data, dims, refdims, layerdims, metadata,
        layermetadata, missingval
    )
end
# Single-file stack from a string
function RasterStack(filename::AbstractString;
    dims=nothing, refdims=(), metadata=nothing, crs=nothing, mappedcrs=nothing,
    layerdims=nothing, layermetadata=nothing, missingval=nothing,
    source=_sourcetype(filename), name=nothing, keys=name, layersfrom=nothing,
    resize=nothing, lazy=true,
)
    st = if haslayers(_sourcetype(filename))
        crs = defaultcrs(source, crs)
        mappedcrs = defaultmappedcrs(source, mappedcrs)
        data, field_kw = _open(filename) do ds
            dims = dims isa Nothing ? DD.dims(ds, crs, mappedcrs) : dims
            refdims = refdims == () || refdims isa Nothing ? () : refdims
            layerdims = layerdims isa Nothing ? DD.layerdims(ds) : layerdims
            metadata = metadata isa Nothing ? DD.metadata(ds) : metadata
            layermetadata = layermetadata isa Nothing ? DD.layermetadata(ds) : layermetadata
            missingval = missingval isa Nothing ? Rasters.missingval(ds) : missingval
            data = FileStack{source}(ds, filename; keys)
            data, (; dims, refdims, layerdims, metadata, layermetadata, missingval)
        end
        if lazy
            RasterStack(data; field_kw...)
        else
            read(RasterStack(data; field_kw...))
        end
    else
        # Band dims acts as layers
        RasterStack(Raster(filename); layersfrom)
    end

    # Maybe split the stack into separate arrays to remove extra dims.
    if !(keys isa Nothing)
        return map(identity, st)
    else
        return st
    end
end
function RasterStack(A::Raster;
    layersfrom=nothing, name=nothing, keys=name, metadata=metadata(A), refdims=refdims(A), kw...
)

    keys = keys isa Union{AbstractString,Symbol,Name} ? (keys,) : keys
    layers = if isnothing(layersfrom)
        keys = if keys isa Nothing
            keys = DD.name(A) in (NoName(), Symbol(""), Name(Symbol(""))) ? ("layer1",) : DD.name(A)
        else
            keys
        end
        NamedTuple{cleankeys(keys)}((A,))
    else
        keys = keys isa Nothing ? _layerkeysfromdim(A, layersfrom) : keys
        slices = slice(A, layersfrom)
        NamedTuple{cleankeys(keys)}(Tuple(slices))
    end
    RasterStack(layers; refdims=refdims, metadata=metadata, kw...)
end
# Stack from stack, dims args
RasterStack(st::AbstractRasterStack, dims::Tuple; kw...) = RasterStack(st; dims, kw...)
# Stack from table, dims args
function RasterStack(table, dims::Tuple; name=_not_a_dimcol(table, dims), keys=name, kw...)
    # TODO use `name` everywhere, not keys
    if keys isa Symbol
        col = Tables.getcolumn(table, keys)
        layers = NamedTuple{(keys,)}((reshape(col, map(length, dims)),))
    else
        layers = map(keys) do k
            col = Tables.getcolumn(table, k)
            reshape(col, map(length, dims))
        end |> NamedTuple{keys}
    end
    RasterStack(layers, dims; kw...)
end

function DD.modify(f, s::AbstractDimStack{<:FileStack})
    open(s) do o
        map(a -> modify(f, a), o)
    end
end

function Base.open(f::Function, s::AbstractDimStack{<:FileStack})
    f(rebuild(s; data=OpenStack(parent(s))))
end

function _layerkeysfromdim(A, dim)
    map(index(A, dim)) do x
        if x isa Number
            Symbol(string(DD.dim2key(dim), "_", x))
        else
            Symbol(x)
        end
    end
end

# Rebuild from internals
function RasterStack(
    data::Union{FileStack,OpenStack,NamedTuple{<:Any,<:Tuple{Vararg{<:AbstractArray}}}};
    dims, refdims=(), layerdims, metadata=NoMetadata(), layermetadata, missingval)
    st = RasterStack(
        data, dims, refdims, layerdims, metadata, layermetadata, missingval
    )
end
# RasterStack from another stack
function RasterStack(s::AbstractDimStack; name=cleankeys(Base.keys(s)), keys=name,
    data=NamedTuple{keys}(s[key] for key in keys),
    dims=dims(s), refdims=refdims(s), layerdims=DD.layerdims(s),
    metadata=metadata(s), layermetadata=DD.layermetadata(s),
    missingval=missingval(s)
)
    st = RasterStack(
        data, DD.dims(s), refdims, layerdims, metadata, layermetadata, missingval
    )

    # TODO This is a bit of a hack, it should use `formatdims`.
    return set(st, dims...)
end

Base.convert(::Type{RasterStack}, src::AbstractDimStack) = RasterStack(src)

Raster(stack::RasterStack) = cat(values(stack)...; dims=Band([keys(stack)...]))

defaultcrs(T::Type, crs) = crs
defaultcrs(T::Type, ::Nothing) = defaultcrs(T)
defaultcrs(T::Type) = nothing
defaultmappedcrs(T::Type, crs) = crs
defaultmappedcrs(T::Type, ::Nothing) = defaultmappedcrs(T)
defaultmappedcrs(T::Type) = nothing

# Precompile
precompile(RasterStack, (String,))

@deprecate stack(args...; kw...) RasterStack(args...; kw...)


text:
module TestDescribe

using Base.Test
using RLEVectors

@testset begin

x = RLEVector([4,5,6],[3,6,9])

# nrun
@test nrun(x) == 3

# length
@test length(x) == 9

# size
@test size(x) == (9,)
@test size(x,1) == 9

# isempty
@test isempty(x) == false
@test isempty( RLEVector(Int[], Int[]) ) == true

# ==
@test x == x

# isequal
@test isequal(x,x)

end # testset

end # module


text:
using ViewerGL, LinearAlgebra
GL = ViewerGL
using LinearAlgebraicRepresentation
Lar = LinearAlgebraicRepresentation

#include("")
store = [];
scaling = 1.05;
V,(VV,EV,FV,CV) = Lar.cuboid([0.25,0.25,0.25],true,[-0.25,-0.25,-0.25]);
mybox = (V,CV,FV,EV);
for k=1:5
	size = rand()*scaling
	scale = Lar.s(size,size,size)
	transl = Lar.t(rand(3)...)
	alpha = 2*pi*rand()
	rx = Lar.r(alpha,0,0); ry = Lar.r(0,alpha,0); rz = Lar.r(0,0,alpha)
	rot = rx * ry * rz
	str = Lar.Struct([ transl, scale, rot, mybox ])
	obj = Lar.struct2lar(str)
	vs = obj[1]
	diag = LinearAlgebra.norm(vs[:,8]-vs[:,1])
	if diag > 1/5
		push!(store, obj)
	end
end

str = Lar.Struct(store);
V,CV,FV,EV = Lar.struct2lar(str);
# V = Plasm.normalize3D(V) TODO:  solve MethodError bug

open("/tmp/lar.txt", "w") do f
	write(f, "V = $V\n\n")
	write(f, "CV = $CV\n\n")
	write(f, "FV = $FV\n\n")
	write(f, "EV = $EV\n\n")
	close(f)
end
GL.VIEW([ GL.GLPol(V,CV, GL.COLORS[1]) ]);

# @show EV
# @show size(EV)
cop_EV = Lar.coboundary_0(EV::Lar.Cells);
# @show cop_EV
# @show size(cop_EV)

# @show size(V)
# @show size(FV)
# @show size(EV)
cop_FE = Lar.coboundary_1(V, FV::Lar.Cells, EV::Lar.Cells);
# @show cop_FE
# @show size(cop_FE)

W = convert(Lar.Points, V');#cobordo 1

V, copEV, copFE, copCF = Lar.Arrangement.spatial_arrangement(
	W::Lar.Points, cop_EV::Lar.ChainOp, cop_FE::Lar.ChainOp);
# println("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
# @show V
# @show copEV
# @show copFE
# @show copCF
# println("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
triangulated_faces = Lar.triangulate2D(V, [copEV, copFE]);
FVs = convert(Array{Lar.Cells}, triangulated_faces);
V = convert(Lar.Points, V');
#GL.VIEW( GL.GLExplode(V,FVs,1.5,1.5,1.5,99,1) );

EVs = Lar.FV2EVs(copEV, copFE); # polygonal face fragments
#GL.VIEW( GL.GLExplode(V,EVs,1.5,1.5,1.5,99,1) );


text:
@testset "Regression" begin

    rng = StableRNG(42)

    ## data
    m, n, n2 = 9, 6, 3
    X, A, E = randn(rng, m, n), randn(rng, n, n2), randn(rng, m, n2) * 0.1
    Y = X * A + E
    r = 0.1

    linear(w) = sum(abs2, Y .- X*w)
    ridge(w) = linear(w) + r*sum(abs2, w)
    ridgevec(w) = ridge(reshape(w,n,n2))

    # using vector individual
    opts = Evolutionary.Options(rng=rng)
    result = Evolutionary.optimize(ridgevec, randn(rng, n*n2), CMAES(μ=100, c_1=0.05), opts)
    @test sum(abs, inv(X'X + r * I)*X'*Y .- reshape(Evolutionary.minimizer(result), n, n2)) ≈ 0.001 atol=1e-3

    # using matrix individual
    res1 = Evolutionary.optimize(linear, randn(n,n2), CMAES(μ=100, c_1=0.05), opts)
    res2 = Evolutionary.optimize(ridge, randn(n,n2), CMAES(μ=100, c_1=0.05), opts)
    @test sum(abs, inv(X'X )*X'*Y .- Evolutionary.minimizer(res1)) ≈ 0.001 atol=1e-3
    @test sum(abs, inv(X'X + r * I)*X'*Y .- Evolutionary.minimizer(res2)) ≈ 0.001 atol=1e-3

end


text:
    """
    `-````````````````````````````````````````````````
    -ho```````````````````````````````````````````````
    `.sh:``````````````````````````````````````.``````
    ```:sho/::/+syhhys+:-..``.-://+osyhhhhso+ohdo.````
    ``````-/++//::-.:yhddddddhhhhhdddddddddddddddy-```
    ````````````````:ydddddddmdddddddddddddds++sh+.```
    ```````````.+/+sddddmmdysooo++ooohdmmmddhhho.`````
    ````````.-+dmmddmmmmy/```````````/oo+/::/+hmh:````
    ````.sdmdhhho/-----.``````````````````````````````
    ````.oy+oho.````.os-```````/y/```````:so-`````````
    ``.````````````/y+-:/-```:s/-:/:```-o+-.:/-```````
    `oyo///+.````:s/`````:o+o/`````-o+o+.`````-////yy-
    ``.`````/+-/o/```````-y/````````s+.````````````..`
    `````````.o/````````.:````````.:.`````````````````
    """


text:
module UnROOT

export ROOTFile, array

import Base: keys, get, getindex, show, length, iterate, position, ntoh
ntoh(b::Bool) = b

using CodecZlib, CodecLz4, CodecXz
using Mixers
using Parameters
using StaticArrays

include("constants.jl")
include("io.jl")
include("types.jl")
include("utils.jl")
include("streamers.jl")
include("bootstrap.jl")
include("root.jl")
include("custom.jl")

if VERSION < v"1.2"
    hasproperty(x, s::Symbol) = s in fieldnames(typeof(x))
end

end # module


text:
using Compat.Test

include("RotBasis.jl")

using Yao, Rot

# translation between polar angle and len-2 complex vector.
function u2polar(vec)
    ratio = slicedim(vec, 1, 2) ./ slicedim(vec, 1, 1)
    @. [atan(abs(ratio))'*2; angle(ratio)']
end

function polar2u(polar)
    theta, phi = slicedim(polar, 1, 1)', slicedim(polar, 1, 2)'
    @. [cos(theta/2) * exp(-im*phi/2); sin(theta/2) * exp(im*phi/2)]
end

# random polar basis, n-> number of basis
randpolar(n) = rand(2, n) * pi

polar = randpolar(10)
@test all(isapprox.(polar |> polar2u |> u2polar, polar))

rb = RotBasis(0.1, 0.3)
angles = randpolar(1)
psi = register(polar2u(angles))
dispatch!(rb, angles)
@test state(rb(psi)) ≈ [1, 0]

max_stars_repo_name: Roger-luo/QCBM

max_issues_repo_name: Roger-luo/QCBM

max_forks_repo_name: Roger-luo/QCBM


text:
# ---
# title: 981. Time Based Key-Value Store
# id: problem981
# author: Tian Jun
# date: 2020-10-31
# difficulty: Medium
# categories: Hash Table, Binary Search
# link: <https://leetcode.com/problems/time-based-key-value-store/description/>
# hidden: true
# ---
#
# Create a timebased key-value store class `TimeMap`, that supports two
# operations.
#
# 1\. `set(string key, string value, int timestamp)`
#
#   * Stores the `key` and `value`, along with the given `timestamp`.
#
# 2\. `get(string key, int timestamp)`
#
#   * Returns a value such that `set(key, value, timestamp_prev)` was called previously, with `timestamp_prev <= timestamp`.
#   * If there are multiple such values, it returns the one with the largest `timestamp_prev`.
#   * If there are no values, it returns the empty string (`""`).
#
#
#
# **Example 1:**
#
#
#
#     Input: inputs = ["TimeMap","set","get","get","set","get","get"], inputs = [[],["foo","bar",1],["foo",1],["foo",3],["foo","bar2",4],["foo",4],["foo",5]]
#     Output: [null,null,"bar","bar",null,"bar2","bar2"]
#     Explanation:
#     TimeMap kv;
#     kv.set("foo", "bar", 1); // store the key "foo" and value "bar" along with timestamp = 1
#     kv.get("foo", 1);  // output "bar"
#     kv.get("foo", 3); // output "bar" since there is no value corresponding to foo at timestamp 3 and timestamp 2, then the only value is at timestamp 1 ie "bar"
#     kv.set("foo", "bar2", 4);
#     kv.get("foo", 4); // output "bar2"
#     kv.get("foo", 5); //output "bar2"
#
#
#
# **Example 2:**
#
#
#
#     Input: inputs = ["TimeMap","set","set","get","get","get","get","get"], inputs = [[],["love","high",10],["love","low",20],["love",5],["love",10],["love",15],["love",20],["love",25]]
#     Output: [null,null,null,"","high","high","low","low"]
#
#
#
#
# **Note:**
#
#   1. All key/value strings are lowercase.
#   2. All key/value strings have length in the range `[1, 100]`
#   3. The `timestamps` for all `TimeMap.set` operations are strictly increasing.
#   4. `1 <= timestamp <= 10^7`
#   5. `TimeMap.set` and `TimeMap.get` functions will be called a total of `120000` times (combined) per test case.
#
#
## @lc code=start
using LeetCode

## add your code here:
## @lc code=end


text:
function bmult(x, y)
	if x==0 && !isnan(y)
		val = 0;
	else
		if y==0 && !isnan(x)
			val = 0;
		else
			val = x * y;
		end
	end
	return val
end

max_stars_repo_name: barzan/dbseer

max_issues_repo_name: barzan/dbseer

max_forks_repo_name: barzan/dbseer


text:
# Countdown timer in Julia

function run_timer()
    print("Enter the amount of seconds: ")
    seconds = parse(Int64, readline())

    println("Countdown starts now with $seconds seconds remaining.")
    current_seconds = seconds

    # While the countdown timer is not finished
    while current_seconds != 0

        # Print the current countdown
        if current_seconds != seconds
            println("Seconds left: $current_seconds")
        end

        # Wait for one second
        sleep(1)
        current_seconds = current_seconds - 1
    end
    println("The countdown is over!")
end

# Call the run_timer function in a loop until the user quits it
function countdown_timer()

    # While the user chooses to run the countdown timer
    while true
        print("Do you want set a countdown timer? (1=Yes/0=No): ")
        answer = parse(Int64, readline())
        # Convert the string value input to a number

        if answer == 1
            # Run the timer
            run_timer()
        elseif answer == 0
            println("Exiting...")
            break # Stop the countdown timer
        else
            println("Invalid input, please try again")
        end
    end

end

countdown_timer()


text:
@testset "5.longest-palindromic-substring.jl" begin
    @test longest_palindrome("babad") == "bab"
    @test longest_palindrome("cbbd") == "bb"
end


text:
""
function objective_min_fuel_cost(pm::AbstractPowerModel)
    model = PowerModels.check_cost_models(pm)
    if model == 1
        return objective_min_pwl_fuel_cost(pm)
    elseif model == 2
        return objective_min_polynomial_fuel_cost(pm)
    else
        error("Only cost models of types 1 and 2 are supported at this time, given cost model type of $(model)")
    end

end

""
function objective_min_polynomial_fuel_cost(pm::AbstractPowerModel)
    order = PowerModels.calc_max_cost_index(pm.data)-1

    if order == 1
        return _objective_min_polynomial_fuel_cost_linear(pm)
    elseif order == 2
        return _objective_min_polynomial_fuel_cost_quadratic(pm)
    else
        error("cost model order of $(order) is not supported")
    end
end

function _objective_min_polynomial_fuel_cost_linear(pm::AbstractPowerModel)
    from_idx = Dict()
    for (n, nw_ref) in nws(pm)
        from_idx[n] = Dict(arc[1] => arc for arc in nw_ref[:arcs_from_dc])
    end

    return @objective(pm.model, Min,
        sum(
            sum(   gen["cost"][1]*sum( var(pm, n, c, :pg, i) for c in conductor_ids(pm, n))+
                   gen["cost"][2] for (i,gen) in nw_ref[:gen])
        for (n, nw_ref) in nws(pm))
    )
end
""
function _objective_min_polynomial_fuel_cost_quadratic(pm::AbstractPowerModel)
    from_idx = Dict()
    for (n, nw_ref) in nws(pm)
        from_idx[n] = Dict(arc[1] => arc for arc in nw_ref[:arcs_from_dc])
    end

    return @objective(pm.model, Min,
        sum(
            sum(   gen["cost"][1]*sum( var(pm, n, c, :pg, i) for c in conductor_ids(pm, n))^2 +
                   gen["cost"][2]*sum( var(pm, n, c, :pg, i) for c in conductor_ids(pm, n))+
                   gen["cost"][3] for (i,gen) in nw_ref[:gen])
        for (n, nw_ref) in nws(pm))
    )
end
""
function objective_min_polynomial_fuel_cost(pm::AbstractConicModel)
    PowerModels.check_polynomial_cost_models(pm)
    pg_sqr = Dict()
    for (n, nw_ref) in PowerModels.nws(pm)
        for cnd in PowerModels.conductor_ids(pm, n)
            pg_sqr = PowerModels.var(pm, n, cnd)[:pg_sqr] = @variable(pm.model,
                [i in PowerModels.ids(pm, n, :gen)], base_name="$(n)_$(cnd)_pg_sqr",
                lower_bound = PowerModels.ref(pm, n, :gen, i, "pmin", cnd)^2,
                upper_bound = PowerModels.ref(pm, n, :gen, i, "pmax", cnd)^2
            )
            for (i, gen) in nw_ref[:gen]
                # @constraint(pm.model, norm([2*var(pm, n, cnd, :pg, i), pg_sqr[i]-1]) <= pg_sqr[i]+1)
                @constraint(pm.model, [pg_sqr[i], var(pm, n, cnd, :pg, i)/sqrt(2), var(pm, n, cnd, :pg, i)/sqrt(2)] in JuMP.SecondOrderCone())
            end

        end
    end
    print("pipi")
    return @objective(pm.model, Min,
        sum(
            sum( gen["cost"][1]*sum(PowerModels.var(pm, n, cnd, :pg_sqr, i) for cnd in PowerModels.conductor_ids(pm, n)) +
                 gen["cost"][2]*sum(PowerModels.var(pm, n, cnd, :pg, i) for cnd in PowerModels.conductor_ids(pm, n)) +
                 gen["cost"][3] for (i,gen) in nw_ref[:gen])
        for (n, nw_ref) in PowerModels.nws(pm))
    )
end
""
function objective_min_pwl_fuel_cost(pm::AbstractPowerModel)

    for (n, nw_ref) in PowerModels.nws(pm)
        pg_cost = PowerModels.var(pm, n)[:pg_cost] = @variable(pm.model,
            [i in PowerModels.ids(pm, n, :gen)], base_name="$(n)_pg_cost"
        )

        # pwl cost
        gen_lines = PowerModels.get_lines(nw_ref[:gen])
        for (i, gen) in nw_ref[:gen]
            for line in gen_lines[i]
                @constraint(pm.model, pg_cost[i] >= line["slope"]*sum(PowerModels.var(pm, n, cnd, :pg, i) for cnd in PowerModels.conductor_ids(pm, n)) + line["intercept"])
            end
        end

    end

    return @objective(pm.model, Min,
        sum(
            sum( PowerModels.var(pm, n,:pg_cost, i) for (i,gen) in nw_ref[:gen])
        for (n, nw_ref) in PowerModels.nws(pm))
        )
end


text:
function is_i18n_docstring(ex)
    ex.head === :macrocall && length(ex.args) == 3 && last(ex.args) isa String
end

function check_continous(line_string::LineNumberNode, content::String, line_binding::LineNumberNode)
    n = countlines(IOBuffer(content))
    line_string + n + 2 == line_binding
end

get_docstr(docstring) = Docs.docstr(last(docstring.args))

function ati18n(source::LineNumberNode, mod::Module, mex, def)
    def.head !== :block && error("Expect @i8n mod begin ... end")
    total = length(def.args)

    i18nex = Expr(:block)

    total <= 1 && return i18nex

    for i in 1:4:total
        nline_str, docstring, nline_binding, binding_ex = def.args[i], def.args[i+1], def.args[i+2], def.args[i+3]

        is_i18n_docstring(docstring) || error("This is not an i18n docstring")

        # functions
        b = @capture(binding_ex, f_(args__)|f_(args__; kwargs__)) ? f : binding_ex

        b = Symbol(b)
        mex = :($mex)
        ex = quote
            replace!($(esc(mex)), Docs.@var($(b)), $(get_docstr(docstring)), $(esc(Docs.signature(binding_ex))))
        end

        push!(i18nex.args, ex)
    end
    i18nex
end

macro i18n(x...)
   ati18n(__source__, __module__, x...)
end


text:
@testset "LPHRepresentation" begin
    @testset "with bad arguments" begin
        @test_throws DimensionMismatch LPHRepresentation(ones(2, 2), [1], [1], [1, 2], [1, 2])
        @test_throws DimensionMismatch LPHRepresentation(ones(2, 2), [1, 2], [1, 2], [1], [1])
    end
end