예제 #1
0
//Swap int16 to system endianness
int16_t swapBytes_i16(int16_t val, bql_file *blendfile)
{
    if(blendfile->endianness == CFByteOrderLittleEndian)
        return CFSwapInt16LittleToHost(val);
    else if(blendfile->endianness == CFByteOrderBigEndian)
        return CFSwapInt16BigToHost(val);
    else return val;
}
예제 #2
0
static void show(const AudioBufferList &abl, int framesToPrint, int wordSize, const char *label, const char *fmtstr=NULL)
{
	printf("%s %p (%d fr%s):\n", label ? label : "AudioBufferList", &abl, framesToPrint, fmtstr ? fmtstr : "");
	const AudioBuffer *buf = abl.mBuffers;
	for (UInt32 i = 0; i < abl.mNumberBuffers; ++i, ++buf) {
		printf("    [%2d] %5dbytes %dch @ %p", (int)i, (int)buf->mDataByteSize, (int)buf->mNumberChannels, buf->mData);
		if (framesToPrint && buf->mData != NULL) {
			printf(":");
			Byte *p = (Byte *)buf->mData;
			for (int j = framesToPrint * buf->mNumberChannels; --j >= 0; )
				switch (wordSize) {
				case 0:	// native float
					printf(" %6.3f", *(Float32 *)p);
					p += sizeof(Float32);
					break;
				// positive: big endian
				case 1:
				case -1:
					printf(" %02X", *p);
					p += 1;
					break;
				case 2:
					printf(" %04X", CFSwapInt16BigToHost(*(UInt16 *)p));
					p += 2;
					break;
				case 3:
					printf(" %06X", (p[0] << 16) | (p[1] << 8) | p[2]);
					p += 3;
					break;
				case 4:
					printf(" %08X", (unsigned int)CFSwapInt32BigToHost(*(UInt32 *)p));
					p += 4;
					break;
				case 10:
					printf(" %6.3f", CASwapFloat32BigToHost(*(Float32 *)p));
					p += sizeof(Float32);
					break;
				case -2:
					printf(" %04X", CFSwapInt16LittleToHost(*(UInt16 *)p));
					p += 2;
					break;
				case -3:
					printf(" %06X", (p[2] << 16) | (p[1] << 8) | p[0]);
					p += 3;
					break;
				case -4:
					printf(" %08X", (unsigned int)CFSwapInt32LittleToHost(*(UInt32 *)p));
					p += 4;
					break;
				case -10:
					printf(" %6.3f", CASwapFloat32LittleToHost(*(Float32 *)p));
					p += sizeof(Float32);
					break;
				}
		}
		printf("\n");
	}
}
예제 #3
0
UInt16 littleEndianUInt16(FILE *stream)
{
	UInt16 n;
	fread(&n, 2, 1, stream);
	return CFSwapInt16LittleToHost(n);
}