Example #1
0
int main(int argc, char const *argv[])
{
	int n = HuffmanInit("aabcdaaa");
	std::map<char, std::string> code_table;
	std::string encoded_str = HuffmanEncode(n, "aabcdaaa",code_table);
	std::cout << "encoded string : " << encoded_str << std::endl;
	std::string target_str = HuffmanDecode(encoded_str);
	std::cout << "decoded string : " << target_str << std::endl;
	return 0;
}
Example #2
0
int main()
{
	const unsigned char input[] = {0xee, 0xfc, 0xdd, 0xc9, 0xb4, 0x53, 0x60, 0xd7, 0x7c, 0xaa, 0xb2, 0xdc, 0xb4, 0x7a, 0xbe, 0xb3, 0xc8, 0xed, 0x71, 0x4d, 0x42, 0x83, 0x55, 0x0b, 0x0b, 0xcf, 0x14, 0xac, 0x02, 0x93, 0xf4, 0xd8, 0x53, 0xc3, 0x3a, 0xb0, 0xce, 0x9e, 0x3b, 0x58, 0x05, 0x26, 0x1d, 0xec, 0xd1, 0x9b, 0xa4, 0x37, 0xe9, 0xec, 0x39, 0xb0, 0x8e, 0x49, 0x07, 0x7b, 0x72, 0x93, 0x8e, 0x49, 0x67, 0xcf, 0x1f, 0xd6, 0x81, 0x95, 0xef, 0x31, 0x61, 0x55, 0x99, 0xd4, 0xef, 0x11, 0x93, 0xa6, 0x4c, 0xea, 0xf7, 0xdc, 0x4c, 0xd2, 0x9b, 0xd4, 0xef, 0xd9, 0xc0, 0x4a, 0x80, 0x65, 0x0a, 0xe1, 0xd9, 0x61, 0x15, 0xc0, 0xda, 0x60, 0xcf, 0x02, 0x56, 0x81, 0x49, 0x3b, 0x66, 0x56, 0xd9, 0x83, 0x85, 0x50, 0xf1, 0x02, 0x71, 0xa5, 0x61, 0x21, 0xb0, 0xde, 0xf5, 0xf5, 0xb8, 0xcd, 0x87, 0x1f, 0xfd, 0x9b, 0xa0, 0x69, 0x75, 0xcd, 0x50, 0x89, 0x6b, 0x90, 0xc6, 0xb1, 0x1c, 0x2b, 0x14, 0xdf, 0x8f, 0xae, 0xd4, 0x44, 0x16, 0x92, 0x92, 0x1c, 0xef, 0x2b, 0xdd, 0x49, 0x52, 0x27, 0xc7, 0xfb, 0x4a, 0x77, 0x92, 0xd4, 0xc9, 0xf1, 0xbe, 0xd2, 0x9d, 0xa4, 0x24, 0xc7, 0xfb, 0x4a, 0x77, 0x1c, 0xe4, 0xae, 0x41, 0x1b, 0x4d, 0xbe, 0xb1, 0x80, 0x32, 0x69, 0xb0, 0x52, 0x2b, 0x24, 0xa9, 0x93, 0xe3, 0xe9, 0x9c, 0x24, 0x75, 0x72, 0xbc, 0xaf, 0x74, 0x27, 0x49, 0x9d, 0x1c, 0xef, 0x2b, 0xdd, 0x49, 0x4a, 0x72, 0xbc, 0xaf, 0x74, 0x87, 0x2a, 0x4b, 0x4a, 0xba, 0xd3, 0x48, 0x9d, 0x2e, 0x47, 0x7d, 0x7c, 0xc5, 0x0d};
	unsigned char output[1394];
	int outsize;
	Huffman hf;
	HuffmanInit(&hf);
	outsize = HuffmanDecompress(&hf, input, sizeof(input), &output, sizeof(output));
	hexdump(output, outsize);
	return 0;
}
Example #3
0
File: init.c Project: AEUG/400plus
void my_task_Startup() {
	DebugManager(1, 0x1F, 0x180000, 0x40000, 0x1C0000);

	dmstart();
	dmProcInit();

#ifdef ENABLE_MASSIVE_DEBUG
	// the 2nd level is 32 flags for debug classes
	// the 3rd arg is log level, 0 == full debug, >0 == less debug
	dmSetStoreLevel(hDbgMgr, 0xFF, 0);
	dmSetPrintLevel(hDbgMgr, 0xFF, 0);
#endif

	initialize();
	
	sub_FFAFE5BC();
	SetAssert();
	EventProcedureServiceInit();
	ShutDownProcInit();
	Install3VMemory(0xF8000000);
	RomManagerInit();
	CreateParamPubInstance();
	PropertyServiceInit();
	ErrorNumberListInit();
	FatalErrorsProcInit();
	RegisterISRs_OCH();
	BlockUntilAfterTimeoutProcInit(50);

	sub_FFB07740(0x10, 8, 0x1BBC);
	ResourceNameServiceInit();

	MemorySuite(0);

	sysClockRateSet_100(3);

	sub_FFB2BD6C();

	InitializeSerialIO();

	RtcInit(0x386D4380);

	AdjDefectsInit();

	CameraAdjsInit();

	SetAssertProc(AssertPrepare, 0);

	my_InitializeIntercom(); // InitializeIntercom();

	AfeGainCmosParamInit();

	EngineInit();

	EDmacPriorityManager();

	EngineResourceInit();

	PowerMgrInit(0);

	ClockInit(1);

	RegisterISR_CAPREADY();

	FaceSensorInit();

	RemDrvInit();
	ActSweepInit();

	LcdInit();

	DisplayInit1();

	DisplayInit2();

	PowerSaveProcInit();

	sub_FFA03B0C();

	sub_FFA05114();

	InitializeImagePlayDriver();

	LensNameTblInit();

	LensPOTblInit();

	FlyingInit();

	CaptureInit();

	BathtubSaturateInit();

	Module_CaptureImagePass();

	ClearSomeCapMem();

	ColorAdjustmentsInit();

	Module_PreDarkPassInit();

	LoadSystemInfo();

	SharedBufferInit(0x10800000, 0x18000000, 0xEE0000, 0xEE0000);

	FileCacheInit();
	PackMemInit();

	ImagePropInit();
	DigPropInit();

	ShootMainInit();

	OlcInfoInit();

	RegisterISR_EMERGENCY_CARDDOOR();

	my_MainCtrlInit();

	CaptureSemaphoreInit();

	VShadingInit();

	Module_CaptureDarkPassInit();

	Module_DarkSubtractionPassInit();
	BathtubInit();

	Module_BathtubCorrectPassInit();

	Module_VObIntegPassInit();

	SetProjectionInit();
	Module_DefectsDetectPassInit();

	DefsInit();
	WbDetectionInit();
	ObInit();

	Module_WbDetectionPassInit();
	DefsProcInit();

	Module_ObAreaCopyPassInit();
	Module_AdditionVTwoLinePassInit();

	VShadingProcInit();
	Module_VShadingCorrectPassInit();

	sub_FFA24838();
	HuffmanInit();

	RawToJpegPass_L_Init();
	RawToJpegPass_M2_Init();

	RawToJpegPass_S_Init();
	YcToJpegLargeFastInit();

	YcToJpegM2FastInit();
	YcToJpegSFastInit();

	RawToLosslessInit();
	Module_YcToTwainInit();

	RawToYcPass_S_Init();
	RawToYPackPass_S_Init();

	DvlpInit();
	DecodeJpegPassInit();
	HistPassInit();
	RectangleColorPassInit();
	RectangleCopyPassInit();

	ResizeYuvPassInit();
	sub_FFA35354();
	LpfPassInit();

	EncodeJpegPassInit();
	AdjRgbGainInit();
	LuckyInit();

	SysInfoProcInit();

	TablesInit();

	ColorInit();

	CtrlManRecursiveLock();

	CtrlSrvInit(0x19);

	LangConInit();
	sub_FF926E40();

	CreateDispSwControlPubInstance();

	CreateMemoryManagerPubInstance();

	my_GUIInit(); //GUIInit();
	GUIApiCalls();

	InitializeImagePlayer();

	ColorBarProcsInit();
	LcdAdjustProcsInit();

	sub_FFB29348();
	CMOSParamInit();

	CameraSettingsInit();
	BootDiskProcsInit();

	DDDInit();
	TFTInit();

	RegisterResourceName(hResourceName, "USR ROOT DEVICE HANDLE", 0x7B);

	RegisterResource_env(0xC02200B8, "U2VBUS");
	RegisterResource_env(1, "USBC20 VBUS SUPPORT");

	RegisterResource_env(0x14, "DEVICESPEED");
	USBC20_Init();
	USBC20_USBIF_Init();

	USBC20_BUFCON_Init();
	USBC20_CLK_Init();
	USBC20_HDMAC_Init();

	DCPClassFunctionsInit();
	USBDriverInit();
	RapiSwitcherInit();

	DCPClassInit();
	RAPITransportUSBInit();
	PTPRespondInit();

	PTPFrameworkInit();
	StartupPtpResponder();

	RapiTransportManagerInit();
	DCPClassInit();

	EventProcServerInit();
	sub_FFA5D8A0();
	DCPInit();

	SesnMngrInit();
	MemMngrInit();
	InitializeRapiTransportManager();

	PrintInit();
	sub_FF95EC54();
	SomePrintInit();
	sub_FF9EB94C();

	InitializeUSBDriver();
	TransMemoryInit();
	InitializeComCtrl();

	FactoryModeInit();
	DP_Init(0, 0x1B, 0, 0);
	return_0();

	sub_FF98CF4C();
	EdLedProcsInit();
	CallBacksInit();

	RegistNotifyConnectDT();
	DPOF_Initialize();

	MpuMonInit();

	StartConsole();
}
Example #4
0
faacEncHandle FAACAPI faacEncOpen(unsigned long sampleRate,
                                  unsigned int numChannels,
                                  unsigned long *inputSamples,
                                  unsigned long *maxOutputBytes)
{
    unsigned int channel;
    faacEncHandle hEncoder;

    *inputSamples = FRAME_LEN*numChannels;
    *maxOutputBytes = (6144/8)*numChannels;

#ifdef DRM
    *maxOutputBytes += 1; /* for CRC */
#endif

    hEncoder = (faacEncStruct*)AllocMemory(sizeof(faacEncStruct));
    SetMemory(hEncoder, 0, sizeof(faacEncStruct));

    hEncoder->numChannels = numChannels;
    hEncoder->sampleRate = sampleRate;
    hEncoder->sampleRateIdx = GetSRIndex(sampleRate);

    /* Initialize variables to default values */
    hEncoder->frameNum = 0;
    hEncoder->flushFrame = 0;

    /* Default configuration */
    hEncoder->config.version = FAAC_CFG_VERSION;
    hEncoder->config.name = libfaacName;
    hEncoder->config.copyright = libCopyright;
    hEncoder->config.mpegVersion = MPEG4;
    hEncoder->config.aacObjectType = LTP;
    hEncoder->config.allowMidside = 1;
    hEncoder->config.useLfe = 1;
    hEncoder->config.useTns = 0;
    hEncoder->config.bitRate = 0; /* default bitrate / channel */
    hEncoder->config.bandWidth = bwfac * hEncoder->sampleRate;
    if (hEncoder->config.bandWidth > bwbase)
		hEncoder->config.bandWidth = bwbase;
    hEncoder->config.quantqual = 100;
    hEncoder->config.psymodellist = (psymodellist_t *)psymodellist;
    hEncoder->config.psymodelidx = 0;
    hEncoder->psymodel =
      hEncoder->config.psymodellist[hEncoder->config.psymodelidx].model;
    hEncoder->config.shortctl = SHORTCTL_NORMAL;

	/* default channel map is straight-through */
	for( channel = 0; channel < 64; channel++ )
		hEncoder->config.channel_map[channel] = channel;
	
    /*
        by default we have to be compatible with all previous software
        which assumes that we will generate ADTS
        /AV
    */
    hEncoder->config.outputFormat = 1;

    /*
        be compatible with software which assumes 24bit in 32bit PCM
    */
    hEncoder->config.inputFormat = FAAC_INPUT_32BIT;

    /* find correct sampling rate depending parameters */
    hEncoder->srInfo = &srInfo[hEncoder->sampleRateIdx];

    for (channel = 0; channel < numChannels; channel++) 
	{
        hEncoder->coderInfo[channel].prev_window_shape = SINE_WINDOW;
        hEncoder->coderInfo[channel].window_shape = SINE_WINDOW;
        hEncoder->coderInfo[channel].block_type = ONLY_LONG_WINDOW;
        hEncoder->coderInfo[channel].num_window_groups = 1;
        hEncoder->coderInfo[channel].window_group_length[0] = 1;

        /* FIXME: Use sr_idx here */
        hEncoder->coderInfo[channel].max_pred_sfb = GetMaxPredSfb(hEncoder->sampleRateIdx);

        hEncoder->sampleBuff[channel] = NULL;
        hEncoder->nextSampleBuff[channel] = NULL;
        hEncoder->next2SampleBuff[channel] = NULL;
        hEncoder->ltpTimeBuff[channel] = (double*)AllocMemory(2*BLOCK_LEN_LONG*sizeof(double));
        SetMemory(hEncoder->ltpTimeBuff[channel], 0, 2*BLOCK_LEN_LONG*sizeof(double));
    }

    /* Initialize coder functions */
	fft_initialize( &hEncoder->fft_tables );
    
	hEncoder->psymodel->PsyInit(&hEncoder->gpsyInfo, hEncoder->psyInfo, hEncoder->numChannels,
        hEncoder->sampleRate, hEncoder->srInfo->cb_width_long,
        hEncoder->srInfo->num_cb_long, hEncoder->srInfo->cb_width_short,
        hEncoder->srInfo->num_cb_short);

    FilterBankInit(hEncoder);

    TnsInit(hEncoder);

    LtpInit(hEncoder);

    PredInit(hEncoder);

    AACQuantizeInit(hEncoder->coderInfo, hEncoder->numChannels,
		    &(hEncoder->aacquantCfg));

	

    HuffmanInit(hEncoder->coderInfo, hEncoder->numChannels);

    /* Return handle */
    return hEncoder;
}