当前位置: 首页>>代码示例>>C++>>正文


C++ BMediaFormats::GetCodeFor方法代码示例

本文整理汇总了C++中BMediaFormats::GetCodeFor方法的典型用法代码示例。如果您正苦于以下问题:C++ BMediaFormats::GetCodeFor方法的具体用法?C++ BMediaFormats::GetCodeFor怎么用?C++ BMediaFormats::GetCodeFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BMediaFormats的用法示例。


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

示例1: if

status_t
XvidDecoder::Setup(media_format* inputFormat, const void* inInfo,
	size_t inSize)
{
	if (inputFormat == NULL)
		return B_BAD_VALUE;

	if (inputFormat->type != B_MEDIA_ENCODED_VIDEO)
		return B_BAD_VALUE;

//	PRINT(("%p->XvidDecoder::Setup()\n", this));

//#if DEBUG
//	char buffer[1024];
//	string_for_format(*inputFormat, buffer, sizeof(buffer));
//	PRINT(("   inputFormat=%s\n", buffer));
//	PRINT(("   inSize=%d\n", inSize));
//	print_hex((uchar*)inInfo, inSize);
//	PRINT(("   user_data_type=%08lx\n", (int)inputFormat->user_data_type));
//	print_hex((uchar*)inputFormat->user_data, 48);
//#endif

	uint32 codecID = 0;
	media_format_family familyID = B_ANY_FORMAT_FAMILY;

	// hacky... get the exact 4CC from there if it's in, to help xvid
	// handle broken files
//	if ((inputFormat->user_data_type == B_CODEC_TYPE_INFO)
//	 && !memcmp(inputFormat->user_data, "AVI ", 4)) {
//		codecID = ((uint32*)inputFormat->user_data)[1];
//		familyID = B_AVI_FORMAT_FAMILY;
//		PRINT(("XvidDecoder::Setup() - AVI 4CC: %4s\n",
//			inputFormat->user_data + 4));
//	}

	if (codecID == 0) {
		BMediaFormats formats;
		media_format_description descr;
		if (formats.GetCodeFor(*inputFormat, B_QUICKTIME_FORMAT_FAMILY,
				&descr) == B_OK) {
			codecID = descr.u.quicktime.codec;
			familyID = B_QUICKTIME_FORMAT_FAMILY;

			#if PRINT_FOURCC
			uint32 bigEndianID = B_HOST_TO_BENDIAN_INT32(codecID);
			printf("%p->XvidDecoder::Setup() - QT 4CC: %.4s\n", this,
				(const char*)&bigEndianID);
			#endif
		} else if (formats.GetCodeFor(*inputFormat, B_AVI_FORMAT_FAMILY,
				&descr) == B_OK) {
			codecID = descr.u.avi.codec;
			familyID = B_AVI_FORMAT_FAMILY;

			#if PRINT_FOURCC
			uint32 bigEndianID = B_HOST_TO_BENDIAN_INT32(codecID);
			printf("%p->XvidDecoder::Setup() - AVI 4CC: %.4s\n", this,
				(const char*)&bigEndianID);
			#endif
		} else if (formats.GetCodeFor(*inputFormat, B_MPEG_FORMAT_FAMILY,
				&descr) == B_OK) {
			codecID = descr.u.mpeg.id;
			familyID = B_MPEG_FORMAT_FAMILY;

			#if PRINT_FOURCC
			printf("%p->XvidDecoder::Setup() - MPEG ID: %ld\n", this, codecID);
			#endif
		}
	}

	if (codecID == 0)
		return B_ERROR;

	for (int32 i = 0; i < gSupportedCodecsCount; i++) {
		if (gCodecTable[i].family == familyID
			&& gCodecTable[i].fourcc == codecID) {
			PRINT(("%p->XvidDecoder::Setup() - found codec in the table "
				"at %ld.\n", this, i));
			fIndexInCodecTable = i;
			fInputFormat = *inputFormat;
			return B_OK;
		}
	}

	#if PRINT_FOURCC
	printf("%p->XvidDecoder::Setup() - no matching codec found in the "
		"table.\n", this);
	#endif

	return B_ERROR;
}
开发者ID:mmanley,项目名称:Antares,代码行数:90,代码来源:XvidDecoder.cpp


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