/*
 * VobSubCodec.r
 *
 * This file is part of Perian.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "VobSubCodec.h"

/*
 thng_RezTemplateVersion:
 0 - original 'thng' template    <-- default
 1 - extended 'thng' template	<-- used for multiplatform things
 2 - extended 'thng' template including resource map id
 */
#define thng_RezTemplateVersion 1

/*
 cfrg_RezTemplateVersion:
 0 - original					<-- default
 1 - extended					<-- we use the extended version
 */
#define cfrg_RezTemplateVersion 1

#define TARGET_REZ_CARBON_MACHO 1

#if TARGET_REZ_CARBON_MACHO

    #if defined(ppc_YES)
        // PPC architecture
        #define TARGET_REZ_MAC_PPC 1
    #else
        #define TARGET_REZ_MAC_PPC 0
    #endif

    #if defined(i386_YES)
        // x86 architecture
        #define TARGET_REZ_MAC_X86 1
    #else
        #define TARGET_REZ_MAC_X86 0
    #endif

    #define TARGET_REZ_WIN32 0
#else
    // Must be building on Windows
    #define TARGET_REZ_WIN32 1
#endif

#if TARGET_REZ_CARBON_MACHO
    #include <Carbon/Carbon.r>
    #include <QuickTime/QuickTime.r>
	#undef __CARBON_R__
	#undef __CORESERVICES_R__
	#undef __CARBONCORE_R__
	#undef __COMPONENTS_R__
#else
    #include "ConditionalMacros.r"
    #include "MacTypes.r"
    #include "Components.r"
    #include "ImageCodec.r"
    #include "CodeFragments.r"
	#undef __COMPONENTS_R__
#endif


// These flags specify information about the capabilities of the component
// Works with 1-bit, 8-bit, 16-bit and 32-bit Pixel Maps
#define kVobSubDecoFlags ( codecInfoDoes32 | codecInfoDoes16 | codecInfoDoes8 | codecInfoDoes1 | cmpThreadSafe )

// These flags specify the possible format of compressed data produced by the component
// and the format of compressed files that the component can handle during decompression
// The component can decompress from files at 1-bit, 8-bit, 16-bit, 24-bit and 32-bit depths
#define kVobSubFormatFlags	( codecInfoDepth32 | codecInfoDepth24 | codecInfoDepth16 | codecInfoDepth8 | codecInfoDepth1 )

// Component Description
resource 'cdci' (kVobSubCodecResource) {
	kVobSubCodecFormatName,	// Type
	1,						// Version
	1,						// Revision level
	kManufacturer,			// Manufacturer
	kVobSubDecoFlags,		// Decompression Flags
	0,						// Compression Flags
	kVobSubFormatFlags,		// Format Flags
	128,					// Compression Accuracy
	128,					// Decomression Accuracy
	200,					// Compression Speed
	200,					// Decompression Speed
	128,					// Compression Level
	0,						// Reserved
	1,						// Minimum Height
	1,						// Minimum Width
	0,						// Decompression Pipeline Latency
	0,						// Compression Pipeline Latency
	0						// Private Data
};

resource 'thng' (kVobSubCodecResource) {
	decompressorComponentType,				// Type			
	kSubFormatVobSub,							// SubType
	kManufacturer,							// Manufacturer
											// - use componentHasMultiplePlatforms
	0,										// not used Component flags
	0,										// not used Component flags Mask
	0,										// not used Code Type
	0,										// not used Code ID
	'STR ',									// Name Type
	kVobSubCodecResource,									// Name ID
	'STR ',									// Info Type
	kVobSubCodecResource + 1,									// Info ID
	0,										// Icon Type
	0,										// Icon ID
	kVobSubCodecVersion,					// Version
	componentHasMultiplePlatforms +			// Registration Flags 
	componentDoAutoVersion,
	0,										// Resource ID of Icon Family
	{
#if TARGET_OS_MAC
	#if TARGET_REZ_CARBON_MACHO
        #if !(TARGET_REZ_MAC_PPC || TARGET_REZ_MAC_X86)
        	#error "Platform architecture not defined, TARGET_REZ_MAC_PPC and/or TARGET_REZ_MAC_X86 must be defined!"
        #endif
		#if TARGET_REZ_MAC_PPC
            kVobSubDecoFlags, 
            'dlle',								// Code Resource type - Entry point found by symbol name 'dlle' resource
            kVobSubCodecResource,								// ID of 'dlle' resource
            platformPowerPCNativeEntryPoint,	// PPC
        #endif
        #if TARGET_REZ_MAC_X86
			kVobSubDecoFlags, 
			'dlle',
			kVobSubCodecResource,
			platformIA32NativeEntryPoint,		// INTEL
        #endif
	#else
		#error "At least one non-obsolete TARGET_REZ_XXX_XXX platform must be defined."
	#endif
#endif
#if TARGET_OS_WIN32
	kVobSubDecoFlags, 
	'dlle',
	kVobSubCodecResource,
	platformWin32,
#endif
	};
};

// Component Name
resource 'STR ' (kVobSubCodecResource) {
	"VobSub"
};

// Component Information
resource 'STR ' (kVobSubCodecResource + 1) {
	"Decompresses subtitles stored in the VobSub format."
};

#if	TARGET_REZ_CARBON_MACHO || TARGET_REZ_WIN32
// Code Entry Point for Mach-O and Windows
	resource 'dlle' (kVobSubCodecResource) {
		"VobSubCodecComponentDispatch"
	};
#endif
