• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CODEC_THROW函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CODEC_THROW函数的典型用法代码示例。如果您正苦于以下问题:C++ CODEC_THROW函数的具体用法?C++ CODEC_THROW怎么用?C++ CODEC_THROW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CODEC_THROW函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CODEC_THROW

void ACFLACCodec::SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize)
{

	if(mIsInitialized)
	{
		CODEC_THROW(kAudioCodecStateError);
	}
	if(inMagicCookieDataByteSize > 256) // the largest cookie we can store
	{
		CODEC_THROW(kAudioCodecBadPropertySizeError);
	}
	else // store the cookie
	{
		memcpy (mMagicCookie, (const void *)(inMagicCookieData), inMagicCookieDataByteSize);
		mMagicCookieLength = inMagicCookieDataByteSize;
		mCookieSet = 1;
	}
	
	ParseMagicCookie(inMagicCookieData, inMagicCookieDataByteSize, &mStreamInfo);
	
	if (inMagicCookieDataByteSize > 0)
	{
		mCookieDefined = true;
	}
	else
	{
		mCookieDefined = false;
	}
}
开发者ID:fruitsamples,项目名称:AudioCodecs,代码行数:29,代码来源:ACFLACCodec.cpp


示例2: DebugMessage

void	ACAppleIMA4Encoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
	if(!mIsInitialized)
	{
		//	check to make sure the input format is legal
		if(	(inInputFormat.mFormatID != kAudioFormatLinearPCM) ||
			(inInputFormat.mFormatFlags != (kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked)) ||
			(inInputFormat.mBitsPerChannel != 16))
		{
	#if VERBOSE
			DebugMessage("ACAppleIMA4Encoder::SetCurrentInputFormat: only support 16 bit native endian signed integer for input");
	#endif
			CODEC_THROW(kAudioCodecUnsupportedFormatError);
		}
		
		// Do some basic sanity checking
		if(inInputFormat.mSampleRate < 0.0)
		{
	#if VERBOSE
			DebugMessage("ACAppleIMA4Encoder::SetCurrentInputFormat: input sample rates may not be negative");
	#endif
			CODEC_THROW(kAudioCodecUnsupportedFormatError);
		}
		
		if(inInputFormat.mChannelsPerFrame > kMaxIMA4Channels)
		{
	#if VERBOSE
			DebugMessage("ACAppleIMA4Encoder::SetCurrentInputFormat: only supports mono or stereo");
	#endif
			CODEC_THROW(kAudioCodecUnsupportedFormatError);
		}
		
		//	tell our base class about the new format
		ACAppleIMA4Codec::SetCurrentInputFormat(inInputFormat);
		// The encoder does no sample rate conversion nor channel manipulation
		if (inInputFormat.mChannelsPerFrame == 0)
		{
			mInputFormat.mChannelsPerFrame = mOutputFormat.mChannelsPerFrame;
		}
		else
		{
			mOutputFormat.mChannelsPerFrame = mInputFormat.mChannelsPerFrame;
		}
		if (inInputFormat.mSampleRate == 0.0)
		{
			mInputFormat.mSampleRate = mOutputFormat.mSampleRate;
		}
		else
		{
			mOutputFormat.mSampleRate = mInputFormat.mSampleRate;
		}
		// Fix derived values
		mInputFormat.mBytesPerFrame = mInputFormat.mBytesPerPacket = (mInputFormat.mBitsPerChannel >> 3) * mInputFormat.mChannelsPerFrame;
		mInputFormat.mFramesPerPacket = 1;
		
		// Zero out everything that has to be zero
		mInputFormat.mReserved = 0;
	}
	else
	{
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:60,代码来源:ACAppleIMA4Encoder.cpp


示例3: switch

void ACFLACCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
{
	switch(inPropertyID)
	{
        case kAudioCodecPropertyCurrentInputSampleRate:
			if(mIsInitialized)
			{
				CODEC_THROW(kAudioCodecIllegalOperationError);
			}
			if(inPropertyDataSize == sizeof(Float64))
			{
				mInputFormat.mSampleRate = *((Float64*)inPropertyData);
			}
			else
			{
				CODEC_THROW(kAudioCodecBadPropertySizeError);
			}
			break;

		case kAudioCodecPropertyFormatInfo:
		case kAudioCodecPropertyHasVariablePacketByteSizes:
		case kAudioCodecPropertyCurrentOutputSampleRate:
		case kAudioCodecPropertyAvailableInputChannelLayouts:
		case kAudioCodecPropertyAvailableOutputChannelLayouts:
		case kAudioCodecPropertyPacketFrameSize:
		case kAudioCodecPropertyMaximumPacketByteSize:
			CODEC_THROW(kAudioCodecIllegalOperationError);
			break;
		default:
			ACBaseCodec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
			break;            
	}
}
开发者ID:fruitsamples,项目名称:AudioCodecs,代码行数:33,代码来源:ACFLACCodec.cpp


示例4: GetUsedInputBufferByteSize

void	ACSimpleCodec::AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription)
{
	//	this buffer handling code doesn't care about such things as the packet descriptions
	if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
	
	//	this is a ring buffer we're dealing with, so we need to set up a few things
	UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
	UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;

	UInt32 theMaxAvailableInputBytes = ioInputDataByteSize; // we can't consume more than we get

	const Byte* theInputData = static_cast<const Byte*>(inInputData);
	
	// >>jamesmcc: added this because ioNumberPackets was not being updated if less was taken than given.
	// THIS ASSUMES CBR!
	UInt32 bytesPerPacketOfInput = mInputFormat.mBytesPerPacket;
	UInt32 theAvailablePacketSize = theAvailableByteSize / bytesPerPacketOfInput;
	
	UInt32 minPacketSize = ioNumberPackets < theAvailablePacketSize ? ioNumberPackets : theAvailablePacketSize;
	UInt32 minByteSize = minPacketSize * bytesPerPacketOfInput;
	
	//	we can copy only as much data as there is or up to how much space is availiable
	ioNumberPackets = minPacketSize;
	ioInputDataByteSize = minByteSize;
	
	// ioInputDataByteSize had better be <= to theMaxAvailableInputBytes or we're screwed
	if (ioInputDataByteSize > theMaxAvailableInputBytes)
	{
		CODEC_THROW(kAudioCodecStateError);
	}
	// <<jamesmcc 
	
	//	now we have to copy the data taking into account the wrap around and where the start is
	if(mInputBufferEnd + ioInputDataByteSize < mInputBufferByteSize)
	{
		//	no wrap around here
		memcpy(mInputBuffer + mInputBufferEnd, theInputData, ioInputDataByteSize);
		
		//	adjust the end point
		mInputBufferEnd += ioInputDataByteSize;
	}
	else
	{
		//	the copy will wrap
		
		//	copy the first part
		UInt32 theBeforeWrapByteSize = mInputBufferByteSize - mInputBufferEnd;
		memcpy(mInputBuffer + mInputBufferEnd, theInputData, theBeforeWrapByteSize);
		
		//	and the rest
		UInt32 theAfterWrapByteSize = ioInputDataByteSize - theBeforeWrapByteSize;
		memcpy(mInputBuffer, theInputData + theBeforeWrapByteSize, theAfterWrapByteSize);
		
		//	adjust the end point
		mInputBufferEnd = theAfterWrapByteSize;
	}
	
}
开发者ID:0xJoker,项目名称:apple-ios-samples,代码行数:58,代码来源:ACSimpleCodec.cpp


示例5: dbg_printf

void CAOggFLACDecoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
    if (!mIsInitialized) {
        if (inInputFormat.mFormatID != kAudioFormatXiphOggFramedFLAC) {
            dbg_printf("CAOggFLACDecoder::SetFormats: only support Xiph FLAC (Ogg-framed) for input\n");
            CODEC_THROW(kAudioCodecUnsupportedFormatError);
        }
        XCACodec::SetCurrentInputFormat(inInputFormat);
    } else {
        CODEC_THROW(kAudioCodecStateError);
    }
}
开发者ID:mecke,项目名称:xiph-qt,代码行数:12,代码来源:CAOggFLACDecoder.cpp


示例6: switch

void	ACShepA52Codec::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) {
    switch(inPropertyID) {
    case kAudioCodecPropertyManufacturerCFString:
    {
        if (ioPropertyDataSize != sizeof(CFStringRef)) {
            CODEC_THROW(kAudioCodecBadPropertySizeError);
        }

        CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Shepmaster Productions"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
        *(CFStringRef*)outPropertyData = name;
        break;
    }

    case kAudioCodecPropertyMaximumPacketByteSize:

        if(ioPropertyDataSize == sizeof(UInt32)) {
            *reinterpret_cast<UInt32*>(outPropertyData) = 3840; //Stolen from liba52 docs
        } else {
            CODEC_THROW(kAudioCodecBadPropertySizeError);
        }

        break;
    case kAudioCodecPropertyRequiresPacketDescription:

        if(ioPropertyDataSize == sizeof(UInt32)) {
            *reinterpret_cast<UInt32*>(outPropertyData) = 0;
        } else {
            CODEC_THROW(kAudioCodecBadPropertySizeError);
        }

        break;
    case kAudioCodecPropertyHasVariablePacketByteSizes:

        if(ioPropertyDataSize == sizeof(UInt32)) {
            *reinterpret_cast<UInt32*>(outPropertyData) = 1;
        } else {
            CODEC_THROW(kAudioCodecBadPropertySizeError);
        }

        break;
    case kAudioCodecPropertyPacketFrameSize:

        if(ioPropertyDataSize == sizeof(UInt32)) {
            *reinterpret_cast<UInt32*>(outPropertyData) = 6 * 256; // A frame has 6 blocks of 256 samples
        } else {
            CODEC_THROW(kAudioCodecBadPropertySizeError);
        }

        break;
    default:
        ACSimpleCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
    }
}
开发者ID:mackyle,项目名称:a52codec,代码行数:53,代码来源:ACShepA52Codec.cpp


示例7: dbg_printf

void CASpeexDecoder::SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
    dbg_printf(" >> [%08lx] CASpeexDecoder :: SetMagicCookie()\n", (UInt32) this);
    if (mIsInitialized)
        CODEC_THROW(kAudioCodecStateError);

    SetCookie(inMagicCookieData, inMagicCookieDataByteSize);

    InitializeCompressionSettings();

    if (!mCompressionInitialized)
        CODEC_THROW(kAudioCodecUnsupportedFormatError);
    dbg_printf("<.. [%08lx] CASpeexDecoder :: SetMagicCookie()\n", (UInt32) this);
}
开发者ID:JanX2,项目名称:XiphQT,代码行数:14,代码来源:CASpeexDecoder.cpp


示例8: GetInputBufferContiguousByteSize

void	ACSimpleCodec::ConsumeInputData(UInt32 inConsumedByteSize)
{
	//	this is a convenience routine to make maintaining the ring buffer state easy
	UInt32 theContiguousRange = GetInputBufferContiguousByteSize();
	
	if(inConsumedByteSize > GetUsedInputBufferByteSize()) CODEC_THROW(kAudioCodecUnspecifiedError);
	
	if(inConsumedByteSize <= theContiguousRange)
	{
		//	the region to consume doesn't wrap
		
		//	figure out how much to consume
		inConsumedByteSize = (theContiguousRange < inConsumedByteSize) ? theContiguousRange : inConsumedByteSize;
		
		//	clear the consumed bits
		memset(mInputBuffer + mInputBufferStart, 0, inConsumedByteSize);
		
		//	adjust the start
		mInputBufferStart += inConsumedByteSize;
	}
	else
	{
		//	the region to consume will wrap
		
		//	clear the bits to the end of the buffer
		memset(mInputBuffer + mInputBufferStart, 0, theContiguousRange);
		
		//	now clear the bits left from the start
		memset(mInputBuffer, 0, inConsumedByteSize - theContiguousRange);
		
		//	adjust the start
		mInputBufferStart = inConsumedByteSize - theContiguousRange;
	}
}
开发者ID:0xJoker,项目名称:apple-ios-samples,代码行数:34,代码来源:ACSimpleCodec.cpp


示例9: CODEC_THROW

void	ACBaseCodec::SetMagicCookie(const void* outMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
	if(mIsInitialized)
	{
		CODEC_THROW(kAudioCodecStateError);
	}
}
开发者ID:abscura,项目名称:audiounitjs,代码行数:7,代码来源:ACBaseCodec.cpp


示例10: SetCurrentInputFormat

void	ACShepA52Codec::Initialize(const AudioStreamBasicDescription* inInputFormat,
                                   const AudioStreamBasicDescription* inOutputFormat,
                                   const void* inMagicCookie, UInt32 inMagicCookieByteSize) {

    //	use the given arguments, if necessary
    if(inInputFormat != NULL)
    {
        SetCurrentInputFormat(*inInputFormat);
    }

    if(inOutputFormat != NULL)
    {
        SetCurrentOutputFormat(*inOutputFormat);
    }

    //	make sure the sample rate and number of channels match between the input format and the output format

    if( (mInputFormat.mSampleRate != mOutputFormat.mSampleRate))
    {
        CODEC_THROW(kAudioCodecUnsupportedFormatError);
    }


    ACSimpleCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
}
开发者ID:mackyle,项目名称:a52codec,代码行数:25,代码来源:ACShepA52Codec.cpp


示例11: SetCurrentInputFormat

void	ACFLACCodec::Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize)
{
	//	use the given arguments, if necessary
	if(inInputFormat != NULL)
	{
		SetCurrentInputFormat(*inInputFormat);
	}

	if(inOutputFormat != NULL)
	{
		SetCurrentOutputFormat(*inOutputFormat);
	}
	
	//	make sure the sample rate and number of channels match between the input format and the output format
	if( (mInputFormat.mSampleRate != mOutputFormat.mSampleRate) ||
		(mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame))
	{
#if VERBOSE	
		printf("The channels and sample rates don't match, mInputFormat.mSampleRate == %f, mOutputFormat.mSampleRate == %f, mInputFormat.mChannelsPerFrame == %lu, mOutputFormat.mChannelsPerFrame == %lu\n", 
				mInputFormat.mSampleRate, mOutputFormat.mSampleRate, mInputFormat.mChannelsPerFrame, mOutputFormat.mChannelsPerFrame);
#endif
		CODEC_THROW(kAudioCodecUnsupportedFormatError);
	}
	
	if(inMagicCookie != NULL)
	{
		SetMagicCookie(inMagicCookie, inMagicCookieByteSize);
	}
	ACBaseCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
}
开发者ID:fruitsamples,项目名称:AudioCodecs,代码行数:30,代码来源:ACFLACCodec.cpp


示例12: ReallocateInputBuffer

void	ACSimpleCodec::Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize)
{
	ReallocateInputBuffer(mInputBufferByteSize - kBufferPad);

	// By definition CBR has this greater than 0. We must avoid a div by 0 error in AppendInputData()
	// Note this will cause us to fail initialization which is intended
	if (mInputFormat.mBytesPerPacket == 0)
	{
		CODEC_THROW(kAudioCodecUnsupportedFormatError);
	}	
	
	ACBaseCodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
}
开发者ID:0xJoker,项目名称:apple-ios-samples,代码行数:13,代码来源:ACSimpleCodec.cpp


示例13: CODEC_THROW

void CAOggFLACDecoder::InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription)
{
    if (!mCompressionInitialized)
        CODEC_THROW(kAudioCodecUnspecifiedError);

    ogg_page op;

    if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize + inPacketDescription->mStartOffset, inPacketDescription->mStartOffset))
        CODEC_THROW(kAudioCodecUnspecifiedError);

    dbg_printf("[ oFD]   : [%08lx] InPacket() [%4.4s] %ld\n", (UInt32) this, (char *) (static_cast<const Byte*> (inInputData) + inPacketDescription->mStartOffset),
               ogg_page_pageno(&op));

    ogg_packet opk;
    SInt32 packet_count = 0;
    int oret;
    AudioStreamPacketDescription flac_packet_desc = {0, 0, 0};
    UInt32 page_packets = ogg_page_packets(&op);

    ogg_stream_pagein(&mO_st, &op);
    while ((oret = ogg_stream_packetout(&mO_st, &opk)) != 0) {
        if (oret < 0) {
            page_packets--;
            continue;
        }

        packet_count++;

        flac_packet_desc.mDataByteSize = opk.bytes;

        CAFLACDecoder::InPacket(opk.packet, &flac_packet_desc);
    }

    if (packet_count > 0)
        complete_pages += 1;

    mFramesBufferedList.push_back(OggPagePacket(packet_count, inPacketDescription->mVariableFramesInPacket));
}
开发者ID:mecke,项目名称:xiph-qt,代码行数:38,代码来源:CAOggFLACDecoder.cpp


示例14: switch

void ACAppleIMA4Encoder::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
{
	switch(inPropertyID)
	{
		case kAudioCodecPropertyAvailableInputSampleRates:
		case kAudioCodecPropertyAvailableOutputSampleRates:
		case kAudioCodecPropertyZeroFramesPadded:
		case kAudioCodecPropertyPrimeInfo:
			CODEC_THROW(kAudioCodecIllegalOperationError);
			break;
		default:
			ACAppleIMA4Codec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
			break;            
	}
}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:15,代码来源:ACAppleIMA4Encoder.cpp


示例15: switch

void	ACSimpleCodec::SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData)
{
	switch(inPropertyID)
	{
		case kAudioCodecPropertyInputBufferSize:
			if(inPropertyDataSize == sizeof(UInt32))
			{
				ReallocateInputBuffer(*reinterpret_cast<const UInt32*>(inPropertyData));
			}
			else
			{
				CODEC_THROW(kAudioCodecBadPropertySizeError);
			}
			break;
		default:
            ACBaseCodec::SetProperty(inPropertyID, inPropertyDataSize, inPropertyData);
            break;            
    }
}
开发者ID:0xJoker,项目名称:apple-ios-samples,代码行数:19,代码来源:ACSimpleCodec.cpp


示例16: GetUsedInputBufferByteSize

void	ACSimpleCodec::AppendInputBuffer(const void* inInputData, UInt32 inOffset, UInt32& ioInputDataByteSize)
{
	//	this buffer handling code doesn't care about such things as the packet descriptions
	if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
	
	//	this is a ring buffer we're dealing with, so we need to set up a few things
	UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
	UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;
	
	const Byte* theInputData = static_cast<const Byte*>(inInputData) + inOffset;
	
	if(ioInputDataByteSize > theAvailableByteSize) {
		ioInputDataByteSize = theAvailableByteSize;
	}
	
	//	now we have to copy the data taking into account the wrap around and where the start is
	if(mInputBufferEnd + ioInputDataByteSize < mInputBufferByteSize)
	{
		//	no wrap around here
		memcpy(mInputBuffer + mInputBufferEnd, theInputData, ioInputDataByteSize);
		
		//	adjust the end point
		mInputBufferEnd += ioInputDataByteSize;
	}
	else
	{
		//	the copy will wrap
		
		//	copy the first part
		UInt32 theBeforeWrapByteSize = mInputBufferByteSize - mInputBufferEnd;
		memcpy(mInputBuffer + mInputBufferEnd, theInputData, theBeforeWrapByteSize);
		
		//	and the rest
		UInt32 theAfterWrapByteSize = ioInputDataByteSize - theBeforeWrapByteSize;
		memcpy(mInputBuffer, theInputData + theBeforeWrapByteSize, theAfterWrapByteSize);
		
		//	adjust the end point
		mInputBufferEnd = theAfterWrapByteSize;
	}
}
开发者ID:MaddTheSane,项目名称:a52codec,代码行数:40,代码来源:ACSimpleCodec.cpp


示例17: GetBytes

Byte* ACSimpleCodec::GetBytes(UInt32& ioNumberBytes) const
{
	// if a client's algorithm has to have contiguous data and mInputBuffer wraps, then someone has to make a copy.
	// I can do it more efficiently than the client. 
	
	if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);

	UInt32 theUsedByteSize = GetUsedInputBufferByteSize();
	//UInt32 theAvailableByteSize = GetInputBufferByteSize() - theUsedByteSize;
	
	if (ioNumberBytes > theUsedByteSize) ioNumberBytes = theUsedByteSize;
		
	SInt32 leftOver = mInputBufferStart + ioNumberBytes - mInputBufferByteSize;
	
	if(leftOver > 0)
	{
		// need to copy beginning of buffer to the end. 
		// We cleverly over allocated our buffer space to make this possible.
		memmove(mInputBuffer + mInputBufferByteSize, mInputBuffer, leftOver);
	}
	
	return GetInputBufferStart();
}
开发者ID:0xJoker,项目名称:apple-ios-samples,代码行数:23,代码来源:ACSimpleCodec.cpp


示例18: switch

void	ACBaseCodec::GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, Boolean& outWritable)
{
	switch(inPropertyID)
	{
		case kAudioCodecPropertyNameCFString:
			outPropertyDataSize = SizeOf32(CFStringRef);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyManufacturerCFString:
			outPropertyDataSize = SizeOf32(CFStringRef);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyFormatCFString:
			outPropertyDataSize = SizeOf32(CFStringRef);
			outWritable = false;
			break;
		case kAudioCodecPropertyRequiresPacketDescription:
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyMinimumNumberInputPackets :
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyMinimumNumberOutputPackets :
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;

		case kAudioCodecPropertyCurrentInputFormat:
			outPropertyDataSize = SizeOf32(AudioStreamBasicDescription);
			outWritable = true;
			break;
			
		case kAudioCodecPropertySupportedInputFormats:
		case kAudioCodecPropertyInputFormatsForOutputFormat:
			outPropertyDataSize = GetNumberSupportedInputFormats() * SizeOf32(AudioStreamBasicDescription);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyCurrentOutputFormat:
			outPropertyDataSize = SizeOf32(AudioStreamBasicDescription);
			outWritable = true;
			break;
			
		case kAudioCodecPropertySupportedOutputFormats:
		case kAudioCodecPropertyOutputFormatsForInputFormat:
			outPropertyDataSize = GetNumberSupportedOutputFormats() * SizeOf32(AudioStreamBasicDescription);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyMagicCookie:
			outPropertyDataSize = GetMagicCookieByteSize();
			outWritable = true;
			break;
			
		case kAudioCodecPropertyInputBufferSize:
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;
			
		case kAudioCodecPropertyUsedInputBufferSize:
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;
		
		case kAudioCodecPropertyIsInitialized:
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;

		case kAudioCodecPropertyAvailableNumberChannels:
			outPropertyDataSize = SizeOf32(UInt32) * 2; // Mono, stereo
			outWritable = false;
			break;
			
 		case kAudioCodecPropertyPrimeMethod:
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;

 		case kAudioCodecPropertyPrimeInfo:
			outPropertyDataSize = SizeOf32(AudioCodecPrimeInfo);
			outWritable = false;
			break;

 		case kAudioCodecPropertyDoesSampleRateConversion:
			outPropertyDataSize = SizeOf32(UInt32);
			outWritable = false;
			break;

		default:
			CODEC_THROW(kAudioCodecUnknownPropertyError);
			break;
			
	};
//.........这里部分代码省略.........
开发者ID:abscura,项目名称:audiounitjs,代码行数:101,代码来源:ACBaseCodec.cpp


示例19: memset

void CASpeexDecoder::InitializeCompressionSettings()
{
    if (mCookie == NULL)
        return;

    if (mCompressionInitialized) {
        memset(&mSpeexHeader, 0, sizeof(mSpeexHeader));

        mSpeexStereoState.balance = 1.0;
        mSpeexStereoState.e_ratio = 0.5;
        mSpeexStereoState.smooth_left = 1.0;
        mSpeexStereoState.smooth_right = 1.0;

        if (mSpeexDecoderState != NULL) {
            speex_decoder_destroy(mSpeexDecoderState);
            mSpeexDecoderState = NULL;
        }
    }

    mCompressionInitialized = false;

    OggSerialNoAtom *atom = reinterpret_cast<OggSerialNoAtom*> (mCookie);
    Byte *ptrheader = mCookie + EndianU32_BtoN(atom->size);
    CookieAtomHeader *aheader = reinterpret_cast<CookieAtomHeader*> (ptrheader);

    // scan quickly through the cookie, check types and packet sizes
    if (EndianS32_BtoN(atom->type) != kCookieTypeOggSerialNo || static_cast<UInt32> (ptrheader - mCookie) > mCookieSize)
        return;
    ptrheader += EndianU32_BtoN(aheader->size);
    if (EndianS32_BtoN(aheader->type) != kCookieTypeSpeexHeader || static_cast<UInt32> (ptrheader - mCookie) > mCookieSize)
        return;
    // we ignore the rest: comments and extra headers

    // all OK, back to the first speex packet
    aheader = reinterpret_cast<CookieAtomHeader*> (mCookie + EndianU32_BtoN(atom->size));
    SpeexHeader *inheader = reinterpret_cast<SpeexHeader *> (&aheader->data[0]);

    // TODO: convert, at some point, mSpeexHeader to a pointer?
    mSpeexHeader.bitrate =                 EndianS32_LtoN(inheader->bitrate);
    mSpeexHeader.extra_headers =           EndianS32_LtoN(inheader->extra_headers);
    mSpeexHeader.frame_size =              EndianS32_LtoN(inheader->frame_size);
    mSpeexHeader.frames_per_packet =       EndianS32_LtoN(inheader->frames_per_packet);
    mSpeexHeader.header_size =             EndianS32_LtoN(inheader->header_size);
    mSpeexHeader.mode =                    EndianS32_LtoN(inheader->mode);
    mSpeexHeader.mode_bitstream_version =  EndianS32_LtoN(inheader->mode_bitstream_version);
    mSpeexHeader.nb_channels =             EndianS32_LtoN(inheader->nb_channels);
    mSpeexHeader.rate =                    EndianS32_LtoN(inheader->rate);
    mSpeexHeader.reserved1 =               EndianS32_LtoN(inheader->reserved1);
    mSpeexHeader.reserved2 =               EndianS32_LtoN(inheader->reserved2);
    mSpeexHeader.speex_version_id =        EndianS32_LtoN(inheader->speex_version_id);
    mSpeexHeader.vbr =                     EndianS32_LtoN(inheader->vbr);

    if (mSpeexHeader.mode >= SPEEX_NB_MODES)
        CODEC_THROW(kAudioCodecUnsupportedFormatError);

    //TODO: check bitstream version here

    mSpeexDecoderState = speex_decoder_init(speex_lib_get_mode(mSpeexHeader.mode));

    if (!mSpeexDecoderState)
        CODEC_THROW(kAudioCodecUnsupportedFormatError);

    //TODO: fix some of the header fields here

    int enhzero = 0;
    speex_decoder_ctl(mSpeexDecoderState, SPEEX_SET_ENH, &enhzero);

    if (mSpeexHeader.nb_channels == 2)
    {
        SpeexCallback callback;
        callback.callback_id = SPEEX_INBAND_STEREO;
        callback.func = speex_std_stereo_request_handler;
        callback.data = &mSpeexStereoState;
        speex_decoder_ctl(mSpeexDecoderState, SPEEX_SET_HANDLER, &callback);
    }

    mCompressionInitialized = true;
}
开发者ID:JanX2,项目名称:XiphQT,代码行数:78,代码来源:CASpeexDecoder.cpp


示例20: sizeof

//FLAC__StreamMetadata_StreamInfo
void ACFLACCodec::GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const
{

	Byte *						buffer;
	Byte *						currPtr;
	AudioFormatAtom * frmaAtom;
	FullAtomHeader * flacAtom;
	AudioTerminatorAtom * termAtom;
	SInt32						atomSize;
	UInt32						flacSize;
	UInt32						chanSize;
	UInt32						frmaSize;
	UInt32						termSize;
	FLAC__StreamMetadata_StreamInfo *		config;
	OSStatus					status;
	UInt32						tempMaxFrameBytes;
	
	//RequireAction( sampleDesc != nil, return paramErr; );

	config		= nil;
	
	frmaSize = sizeof(AudioFormatAtom);
	flacSize		= sizeof(FullAtomHeader) + sizeof(FLAC__StreamMetadata_StreamInfo);
	chanSize		= 0;
	termSize = sizeof(AudioTerminatorAtom);

	// if we're encoding more than two channels, add an AudioChannelLayout atom to describe the layout
	if ( mOutputFormat.mChannelsPerFrame > 2 )
	{
		chanSize = sizeof(FullAtomHeader) + offsetof(AudioChannelLayout, mChannelDescriptions);
	}

	// create buffer of the required size
	atomSize = frmaSize + flacSize + chanSize + termSize;
	
	// Someone might have a stereo/mono cookie while we're trying to do surround.
	if ((UInt32)atomSize > ioMagicCookieDataByteSize)
	{
		CODEC_THROW(kAudioCodecBadPropertySizeError);
	}
	
	tempMaxFrameBytes = kInputBufferPackets * mOutputFormat.mChannelsPerFrame * ((10 + kMaxSampleSize) / 8) + 1;

	buffer = (Byte *)calloc( atomSize, 1 );
	currPtr = buffer;

	// fill in the atom stuff
	frmaAtom = (AudioFormatAtom *) currPtr;
	frmaAtom->size			= EndianU32_NtoB( frmaSize );
	frmaAtom->atomType		= EndianU32_NtoB( kAudioFormatAtomType );
	frmaAtom->format	= EndianU32_NtoB( 'flac' );
	currPtr += frmaSize;

	// fill in the FLAC config
	flacAtom = (FullAtomHeader *) currPtr;
	flacAtom->size				= EndianU32_NtoB( flacSize );
	flacAtom->type				= EndianU32_NtoB( 'flac' );
	flacAtom->versionFlags		= 0;
	currPtr += sizeof(FullAtomHeader);

/*
	unsigned min_blocksize, max_blocksize;
	unsigned min_framesize, max_framesize;
	unsigned sample_rate;
	unsigned channels;
	unsigned bits_per_sample;
	FLAC__uint64 total_samples;
	FLAC__byte md5sum[16];
*/
	config = (FLAC__StreamMetadata_StreamInfo *) currPtr;
	if (mCookieDefined)
	{
		config->min_blocksize	= EndianU32_NtoB( mStreamInfo.min_blocksize );
		config->max_blocksize	= EndianU32_NtoB( mStreamInfo.max_blocksize );
		config->min_framesize	= EndianU32_NtoB( mStreamInfo.min_framesize );
		config->max_framesize	= EndianU32_NtoB( mStreamInfo.max_framesize );
		config->sample_rate		= EndianU32_NtoB( mStreamInfo.sample_rate );
		config->channels		= EndianU32_NtoB( mStreamInfo.channels );
		config->bits_per_sample	= EndianU32_NtoB( mStreamInfo.bits_per_sample );
		config->total_samples	= EndianU64_NtoB( mStreamInfo.total_samples );
		config->md5sum[0]		= mStreamInfo.md5sum[0];
		config->md5sum[1]		= mStreamInfo.md5sum[1];
		config->md5sum[2]		= mStreamInfo.md5sum[2];
		config->md5sum[3]		= mStreamInfo.md5sum[3];
		config->md5sum[4]		= mStreamInfo.md5sum[4];
		config->md5sum[5]		= mStreamInfo.md5sum[5];
		config->md5sum[6]		= mStreamInfo.md5sum[6];
		config->md5sum[7]		= mStreamInfo.md5sum[7];
		config->md5sum[8]		= mStreamInfo.md5sum[8];
		config->md5sum[9]		= mStreamInfo.md5sum[9];
		config->md5sum[10]		= mStreamInfo.md5sum[10];
		config->md5sum[11]		= mStreamInfo.md5sum[11];
		config->md5sum[12]		= mStreamInfo.md5sum[12];
		config->md5sum[13]		= mStreamInfo.md5sum[13];
		config->md5sum[14]		= mStreamInfo.md5sum[14];
		config->md5sum[15]		= mStreamInfo.md5sum[15];
	}
	else
	{
//.........这里部分代码省略.........
开发者ID:fruitsamples,项目名称:AudioCodecs,代码行数:101,代码来源:ACFLACCodec.cpp



注:本文中的CODEC_THROW函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ COGL_FRAMEBUFFER函数代码示例发布时间:2022-05-30
下一篇:
C++ CODEC_IO_Write函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap