亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mtype.cpp

?? 用DirectX制作高級(jí)動(dòng)畫-[Advanced.Animation.with.DirectX]
?? CPP
字號(hào):
//------------------------------------------------------------------------------
// File: MType.cpp
//
// Desc: DirectShow base classes - implements a class that holds and 
//       manages media type information.
//
// Copyright (c) 1992-2002 Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------------------------


// helper class that derived pin objects can use to compare media
// types etc. Has same data members as the struct AM_MEDIA_TYPE defined
// in the streams IDL file, but also has (non-virtual) functions

#include <streams.h>
#include <mmreg.h>

CMediaType::~CMediaType(){
    FreeMediaType(*this);
}


CMediaType::CMediaType()
{
    InitMediaType();
}


CMediaType::CMediaType(const GUID * type)
{
    InitMediaType();
    majortype = *type;
}


// copy constructor does a deep copy of the format block

CMediaType::CMediaType(const AM_MEDIA_TYPE& rt, HRESULT* phr)
{
    HRESULT hr = CopyMediaType(this, &rt);
    if (FAILED(hr) && (NULL != phr)) {
        *phr = hr;
    }
}


CMediaType::CMediaType(const CMediaType& rt, HRESULT* phr)
{
    HRESULT hr = CopyMediaType(this, &rt);
    if (FAILED(hr) && (NULL != phr)) {
        *phr = hr;
    }
}


// this class inherits publicly from AM_MEDIA_TYPE so the compiler could generate
// the following assignment operator itself, however it could introduce some
// memory conflicts and leaks in the process because the structure contains
// a dynamically allocated block (pbFormat) which it will not copy correctly

CMediaType&
CMediaType::operator=(const AM_MEDIA_TYPE& rt)
{
    Set(rt);
    return *this;
}

CMediaType&
CMediaType::operator=(const CMediaType& rt)
{
    *this = (AM_MEDIA_TYPE &) rt;
    return *this;
}

BOOL
CMediaType::operator == (const CMediaType& rt) const
{
    // I don't believe we need to check sample size or
    // temporal compression flags, since I think these must
    // be represented in the type, subtype and format somehow. They
    // are pulled out as separate flags so that people who don't understand
    // the particular format representation can still see them, but
    // they should duplicate information in the format block.

    return ((IsEqualGUID(majortype,rt.majortype) == TRUE) &&
        (IsEqualGUID(subtype,rt.subtype) == TRUE) &&
        (IsEqualGUID(formattype,rt.formattype) == TRUE) &&
        (cbFormat == rt.cbFormat) &&
        ( (cbFormat == 0) ||
          (memcmp(pbFormat, rt.pbFormat, cbFormat) == 0)));
}


BOOL
CMediaType::operator != (const CMediaType& rt) const
{
    /* Check to see if they are equal */

    if (*this == rt) {
        return FALSE;
    }
    return TRUE;
}


HRESULT
CMediaType::Set(const CMediaType& rt)
{
    return Set((AM_MEDIA_TYPE &) rt);
}


HRESULT
CMediaType::Set(const AM_MEDIA_TYPE& rt)
{
    if (&rt != this) {
        FreeMediaType(*this);
        HRESULT hr = CopyMediaType(this, &rt);
        if (FAILED(hr)) {
            return E_OUTOFMEMORY;
        }
    }

    return S_OK;    
}


BOOL
CMediaType::IsValid() const
{
    return (!IsEqualGUID(majortype,GUID_NULL));
}


void
CMediaType::SetType(const GUID* ptype)
{
    majortype = *ptype;
}


void
CMediaType::SetSubtype(const GUID* ptype)
{
    subtype = *ptype;
}


ULONG
CMediaType::GetSampleSize() const {
    if (IsFixedSize()) {
        return lSampleSize;
    } else {
        return 0;
    }
}


void
CMediaType::SetSampleSize(ULONG sz) {
    if (sz == 0) {
        SetVariableSize();
    } else {
        bFixedSizeSamples = TRUE;
        lSampleSize = sz;
    }
}


void
CMediaType::SetVariableSize() {
    bFixedSizeSamples = FALSE;
}


void
CMediaType::SetTemporalCompression(BOOL bCompressed) {
    bTemporalCompression = bCompressed;
}

BOOL
CMediaType::SetFormat(BYTE * pformat, ULONG cb)
{
    if (NULL == AllocFormatBuffer(cb))
	return(FALSE);

    ASSERT(pbFormat);
    memcpy(pbFormat, pformat, cb);
    return(TRUE);
}


// set the type of the media type format block, this type defines what you
// will actually find in the format pointer. For example FORMAT_VideoInfo or
// FORMAT_WaveFormatEx. In the future this may be an interface pointer to a
// property set. Before sending out media types this should be filled in.

void
CMediaType::SetFormatType(const GUID *pformattype)
{
    formattype = *pformattype;
}


// reset the format buffer

void CMediaType::ResetFormatBuffer()
{
    if (cbFormat) {
        CoTaskMemFree((PVOID)pbFormat);
    }
    cbFormat = 0;
    pbFormat = NULL;
}


// allocate length bytes for the format and return a read/write pointer
// If we cannot allocate the new block of memory we return NULL leaving
// the original block of memory untouched (as does ReallocFormatBuffer)

BYTE*
CMediaType::AllocFormatBuffer(ULONG length)
{
    ASSERT(length);

    // do the types have the same buffer size

    if (cbFormat == length) {
        return pbFormat;
    }

    // allocate the new format buffer

    BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);
    if (pNewFormat == NULL) {
        if (length <= cbFormat) return pbFormat; //reuse the old block anyway.
        return NULL;
    }

    // delete the old format

    if (cbFormat != 0) {
        ASSERT(pbFormat);
        CoTaskMemFree((PVOID)pbFormat);
    }

    cbFormat = length;
    pbFormat = pNewFormat;
    return pbFormat;
}


// reallocate length bytes for the format and return a read/write pointer
// to it. We keep as much information as we can given the new buffer size
// if this fails the original format buffer is left untouched. The caller
// is responsible for ensuring the size of memory required is non zero

BYTE*
CMediaType::ReallocFormatBuffer(ULONG length)
{
    ASSERT(length);

    // do the types have the same buffer size

    if (cbFormat == length) {
        return pbFormat;
    }

    // allocate the new format buffer

    BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);
    if (pNewFormat == NULL) {
        if (length <= cbFormat) return pbFormat; //reuse the old block anyway.
        return NULL;
    }

    // copy any previous format (or part of if new is smaller)
    // delete the old format and replace with the new one

    if (cbFormat != 0) {
        ASSERT(pbFormat);
        memcpy(pNewFormat,pbFormat,min(length,cbFormat));
        CoTaskMemFree((PVOID)pbFormat);
    }

    cbFormat = length;
    pbFormat = pNewFormat;
    return pNewFormat;
}

// initialise a media type structure

void CMediaType::InitMediaType()
{
    ZeroMemory((PVOID)this, sizeof(*this));
    lSampleSize = 1;
    bFixedSizeSamples = TRUE;
}


// a partially specified media type can be passed to IPin::Connect
// as a constraint on the media type used in the connection.
// the type, subtype or format type can be null.
BOOL
CMediaType::IsPartiallySpecified(void) const
{
    if ((majortype == GUID_NULL) ||
        (formattype == GUID_NULL)) {
            return TRUE;
    } else {
        return FALSE;
    }
}

BOOL
CMediaType::MatchesPartial(const CMediaType* ppartial) const
{
    if ((ppartial->majortype != GUID_NULL) &&
        (majortype != ppartial->majortype)) {
            return FALSE;
    }
    if ((ppartial->subtype != GUID_NULL) &&
        (subtype != ppartial->subtype)) {
            return FALSE;
    }

    if (ppartial->formattype != GUID_NULL) {
        // if the format block is specified then it must match exactly
        if (formattype != ppartial->formattype) {
            return FALSE;
        }
        if (cbFormat != ppartial->cbFormat) {
            return FALSE;
        }
        if ((cbFormat != 0) &&
            (memcmp(pbFormat, ppartial->pbFormat, cbFormat) != 0)) {
                return FALSE;
        }
    }

    return TRUE;

}



// general purpose function to delete a heap allocated AM_MEDIA_TYPE structure
// which is useful when calling IEnumMediaTypes::Next as the interface
// implementation allocates the structures which you must later delete
// the format block may also be a pointer to an interface to release

void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pmt)
{
    // allow NULL pointers for coding simplicity

    if (pmt == NULL) {
        return;
    }

    FreeMediaType(*pmt);
    CoTaskMemFree((PVOID)pmt);
}


// this also comes in useful when using the IEnumMediaTypes interface so
// that you can copy a media type, you can do nearly the same by creating
// a CMediaType object but as soon as it goes out of scope the destructor
// will delete the memory it allocated (this takes a copy of the memory)

AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc)
{
    ASSERT(pSrc);

    // Allocate a block of memory for the media type

    AM_MEDIA_TYPE *pMediaType =
        (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));

    if (pMediaType == NULL) {
        return NULL;
    }
    // Copy the variable length format block

    HRESULT hr = CopyMediaType(pMediaType,pSrc);
    if (FAILED(hr)) {
        CoTaskMemFree((PVOID)pMediaType);
        return NULL;
    }

    return pMediaType;
}


//  Copy 1 media type to another

HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource)
{
    //  We'll leak if we copy onto one that already exists - there's one
    //  case we can check like that - copying to itself.
    ASSERT(pmtSource != pmtTarget);
    *pmtTarget = *pmtSource;
    if (pmtSource->cbFormat != 0) {
        ASSERT(pmtSource->pbFormat != NULL);
        pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc(pmtSource->cbFormat);
        if (pmtTarget->pbFormat == NULL) {
            pmtTarget->cbFormat = 0;
            return E_OUTOFMEMORY;
        } else {
            CopyMemory((PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat,
                       pmtTarget->cbFormat);
        }
    }
    if (pmtTarget->pUnk != NULL) {
        pmtTarget->pUnk->AddRef();
    }

    return S_OK;
}

//  Free an existing media type (ie free resources it holds)

void WINAPI FreeMediaType(AM_MEDIA_TYPE& mt)
{
    if (mt.cbFormat != 0) {
        CoTaskMemFree((PVOID)mt.pbFormat);

        // Strictly unnecessary but tidier
        mt.cbFormat = 0;
        mt.pbFormat = NULL;
    }
    if (mt.pUnk != NULL) {
        mt.pUnk->Release();
        mt.pUnk = NULL;
    }
}

//  Initialize a media type from a WAVEFORMATEX

STDAPI CreateAudioMediaType(
    const WAVEFORMATEX *pwfx,
    AM_MEDIA_TYPE *pmt,
    BOOL bSetFormat
)
{
    pmt->majortype            = MEDIATYPE_Audio;
    if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
        pmt->subtype = ((PWAVEFORMATEXTENSIBLE)pwfx)->SubFormat;
    } else {
        pmt->subtype              = FOURCCMap(pwfx->wFormatTag);
    }
    pmt->formattype           = FORMAT_WaveFormatEx;
    pmt->bFixedSizeSamples    = TRUE;
    pmt->bTemporalCompression = FALSE;
    pmt->lSampleSize          = pwfx->nBlockAlign;
    pmt->pUnk                 = NULL;
    if (bSetFormat) {
        if (pwfx->wFormatTag == WAVE_FORMAT_PCM) {
            pmt->cbFormat         = sizeof(WAVEFORMATEX);
        } else {
            pmt->cbFormat         = sizeof(WAVEFORMATEX) + pwfx->cbSize;
        }
        pmt->pbFormat             = (PBYTE)CoTaskMemAlloc(pmt->cbFormat);
        if (pmt->pbFormat == NULL) {
            return E_OUTOFMEMORY;
        }
        if (pwfx->wFormatTag == WAVE_FORMAT_PCM) {
            CopyMemory(pmt->pbFormat, pwfx, sizeof(PCMWAVEFORMAT));
            ((WAVEFORMATEX *)pmt->pbFormat)->cbSize = 0;
        } else {
            CopyMemory(pmt->pbFormat, pwfx, pmt->cbFormat);
        }
    }
    return S_OK;
}

// eliminate very many spurious warnings from MS compiler
#pragma warning(disable:4514)

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产乱码| 色菇凉天天综合网| 欧美r级在线观看| 久久精品国产亚洲a| 欧美精品一区二区三区在线播放 | 不卡一区二区中文字幕| 国产精品素人视频| 99久久精品国产导航| 一区二区三区四区激情| 欧美日韩和欧美的一区二区| 男人操女人的视频在线观看欧美| 欧美刺激脚交jootjob| 国产超碰在线一区| 亚洲靠逼com| 91麻豆精品国产无毒不卡在线观看 | 国产一区二区h| 国产精品三级av| 在线欧美一区二区| 日韩不卡在线观看日韩不卡视频| 亚洲精品一区二区三区精华液| 成人国产精品免费网站| 亚洲国产精品一区二区www在线 | 一本久久a久久免费精品不卡| 亚洲综合精品久久| 欧美不卡123| 精品国产麻豆免费人成网站| 成人免费高清视频| 亚洲成a人v欧美综合天堂下载| 日韩欧美高清dvd碟片| eeuss鲁一区二区三区| 三级在线观看一区二区| 久久精品夜夜夜夜久久| 欧美性猛片xxxx免费看久爱| 国产毛片精品一区| 亚洲最新在线观看| 国产偷v国产偷v亚洲高清| 在线免费观看日本欧美| 国内精品嫩模私拍在线| 夜夜嗨av一区二区三区网页 | 岛国精品在线观看| 视频在线观看91| 中文字幕在线播放不卡一区| 日韩一区二区在线观看视频| 99视频精品在线| 国模冰冰炮一区二区| 亚洲电影中文字幕在线观看| 国产精品进线69影院| 日韩美女在线视频 | 欧美日韩国产美女| 成人av一区二区三区| 毛片av中文字幕一区二区| 亚洲免费观看高清完整版在线观看熊| 日韩精品一区国产麻豆| 欧美日本韩国一区二区三区视频| av在线不卡免费看| 国产成人免费网站| 激情亚洲综合在线| 免费人成在线不卡| 五月婷婷色综合| 亚洲自拍偷拍av| 中文字幕一区二区三区在线不卡| 久久久99精品免费观看不卡| 欧美大片在线观看一区二区| 欧美精品九九99久久| 欧美亚洲禁片免费| 97se狠狠狠综合亚洲狠狠| 成人视屏免费看| 国产成人精品影视| 国产精品一区二区三区乱码| 免费人成精品欧美精品| 午夜久久久久久电影| 亚洲午夜电影网| 亚洲夂夂婷婷色拍ww47| 亚洲美女电影在线| 亚洲乱码日产精品bd| 中文字幕一区二区三区精华液| 国产精品伦理在线| 国产精品高潮呻吟| 亚洲色图视频免费播放| 亚洲三级电影网站| 夜夜精品浪潮av一区二区三区| 国产99久久久国产精品潘金 | 国产精品午夜久久| 中文字幕不卡三区| 18涩涩午夜精品.www| 亚洲男人的天堂av| 亚洲午夜在线视频| 日韩**一区毛片| 韩国精品久久久| 国产99精品国产| 91色九色蝌蚪| 欧美午夜一区二区| 欧美一区二区在线观看| 精品剧情在线观看| 国产精品人成在线观看免费| 日韩毛片高清在线播放| 亚洲国产一区视频| 麻豆成人久久精品二区三区小说| 国模一区二区三区白浆| 丁香啪啪综合成人亚洲小说| 91蝌蚪porny| 91精品国产91热久久久做人人| 日韩欧美中文字幕公布| 久久蜜桃香蕉精品一区二区三区| 国产精品麻豆一区二区| 亚洲一区二区三区在线看| 日韩成人一级片| 国产成人午夜高潮毛片| 色一区在线观看| 欧美一区二区三区免费| 久久久av毛片精品| 亚洲黄色av一区| 久久国产精品72免费观看| 91精品久久久久久久99蜜桃| 久久婷婷一区二区三区| 亚洲乱码国产乱码精品精小说 | 亚洲精品国产无天堂网2021| 日本中文字幕不卡| 丰满白嫩尤物一区二区| 欧洲一区二区av| 久久一区二区三区四区| 亚洲免费观看高清完整版在线观看 | 亚洲天堂2016| 美女www一区二区| 97久久超碰国产精品电影| 欧美精品99久久久**| 国产精品久久网站| 日韩经典中文字幕一区| www.久久久久久久久| 欧美大片日本大片免费观看| 日韩美女视频19| 国产一区999| 91麻豆精品国产91久久久久 | 91论坛在线播放| 久久精品一区蜜桃臀影院| 亚洲高清免费在线| 成人免费av资源| 日韩你懂的在线播放| 亚洲成精国产精品女| 成人国产精品免费网站| 久久久久久亚洲综合| 日韩和欧美一区二区| 91福利国产精品| 亚洲欧美自拍偷拍色图| 国产精品一区二区无线| 91精品国产欧美一区二区18| 亚洲最大的成人av| 成人小视频在线| 精品国产免费久久| 日本欧美在线观看| 欧美日韩国产色站一区二区三区| 亚洲婷婷综合久久一本伊一区| 国产成人久久精品77777最新版本| 欧美一级黄色大片| 日韩精彩视频在线观看| 欧美三级午夜理伦三级中视频| 亚洲三级久久久| 色综合咪咪久久| 国产精品―色哟哟| 风间由美一区二区三区在线观看 | 亚洲欧美乱综合| 不卡一区二区在线| 国产精品动漫网站| 成人sese在线| 国产精品嫩草影院av蜜臀| 成人永久看片免费视频天堂| 精品国产99国产精品| 精品一区二区日韩| 久久免费的精品国产v∧| 国产真实乱对白精彩久久| 精品国产伦一区二区三区观看方式| 免费在线欧美视频| 欧美精品一区二区三区在线播放| 久久精品二区亚洲w码| 欧美大白屁股肥臀xxxxxx| 精品一区二区三区免费观看| 欧美精品一区二区三区蜜臀| 国产精品一品视频| 久久精品一二三| 91亚洲精品久久久蜜桃网站| 亚洲伦理在线免费看| 欧美日韩国产精品成人| 日本成人在线不卡视频| 精品国产91久久久久久久妲己| 国产精品18久久久| 国产精品不卡在线| 欧洲一区二区三区免费视频| 日韩国产欧美在线播放| www国产成人| 91丝袜美女网| 日韩中文字幕区一区有砖一区| 欧美成人性战久久| 不卡的av在线播放| 亚洲国产精品久久人人爱| 日韩欧美在线不卡| aaa国产一区| 石原莉奈在线亚洲二区| 国产午夜精品久久久久久久| 色综合久久中文综合久久牛| 日韩电影在线看|