⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rasl.c

📁 用于进行real depack
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: rasl.c,v 1.1.1.1.2.1 2005/05/04 18:21:33 hubbe Exp $ *  * REALNETWORKS CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM * Portions Copyright (c) 1995-2005 RealNetworks, Inc. * All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the Real Format Source Code * Porting and Optimization License, available at * https://helixcommunity.org/2005/license/realformatsource (unless * RealNetworks otherwise expressly agrees in writing that you are * subject to a different license).  You may also obtain the license * terms directly from RealNetworks.  You may not use this file except * in compliance with the Real Format Source Code Porting and * Optimization License. There are no redistribution rights for the * source code of this file. Please see the Real Format Source Code * Porting and Optimization License for the rights, obligations and * limitations governing use of the contents of the file. *  * RealNetworks is the developer of the Original Code and owns the * copyrights in the portions it created. *  * This file, and the files included with this file, is distributed and * made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, * EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL * SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT * OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: * https://rarvcode-tck.helixcommunity.org *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */#include <memory.h>#include "helix_types.h"#include "rasl.h"/* * The interleave table was created with the following properties: * -equal contributions from each block * -symmetric (if table[i] = j, then table[j] = i), allows in-place interleave * -random spacing between lost frames, except * -no double losses * Solution was generated by a random-walk optimization loop. *  *//* Loss patterns for a five-block solution:...X..X....X.X.....X.X.X........X..........X...X.X....X........X..X..X..X........X..X....X........X...X..X.....X.X........X...X....X...X..X......X....X.......X...X..X.X.........X..........X.X...X...X..X...X.......X.....X.X.....X......X.X.............X.X..X....X......X.X......X...X...X...X.X.....X.....X.X......X.X......X.......X.....X.X.......X.X........X.X.X............X....X..X.......X......X.X.X*//*static int RASL_InterleaveTable[RASL_NFRAMES * RASL_NBLOCKS] = {	66, 21, 43, 3, 23, 47, 6, 32, 72, 19, 49, 11, 54, 13, 69, 63,	65, 42, 18, 9, 58, 1, 22, 4, 78, 25, 70, 51, 33, 55, 46, 31,	7, 28, 34, 74, 61, 76, 38, 67, 59, 41, 17, 2, 53, 45, 30, 5,	48, 10, 50, 27, 71, 44, 12, 29, 56, 73, 20, 40, 64, 36, 62, 15,	60, 16, 0, 39, 68, 14, 26, 52, 8, 57, 35, 75, 37, 77, 24, 79};*//* Loss pattern for a six-block solution....X.X....X..........X........X....X..X....X........X....X....X....X....X.......X....X...X......X.....X..........X....X...X..X...X...........X...X...X..X...........X.X...X............X.....X...X.......X..X......X...X............X...X.....X........X..X.....X....X...X..........X.X....X...X........X.....X.X........X..X..........X....X......X.......X.X.............X..X.........X...X.X............X.X.X....X......X...X..X.......X....X............X..X.X.....X.....X.X..X...............X.X..X..........X.....X.......X....X...X......X.X...X...........X.........X....X.X......X....*/static const int RASL_InterleaveTable[RASL_NFRAMES * RASL_NBLOCKS] = {	63, 22, 44, 90, 4, 81, 6, 31, 86, 58, 36, 11, 68, 39, 73, 53,	69, 57, 18, 88, 34, 71, 1, 23, 46, 94, 54, 27, 75, 50, 30, 7,	70, 92, 20, 74, 10, 37, 85, 13, 56, 41, 87, 65, 2, 59, 24, 47,	79, 93, 29, 89, 52, 15, 26, 95, 40, 17, 9, 45, 60, 76, 62, 0,	64, 43, 66, 83, 12, 16, 32, 21, 72, 14, 35, 28, 61, 80, 78, 48,	77, 5, 82, 67, 84, 38, 8, 42, 19, 51, 3, 91, 33, 49, 25, 55};/* * DeInterleave operates in-place!. *  * Entry: * buf points to NCODEBYTES * NFRAMES * NBLOCKS bytes of interleaved data. * If an input block is bad, flag[block] should be set. *  * Exit: * data in buf is deinterleaved. * flags[block] stores a bit array for each output block, * where (flags[block] & (1 << F)) is set if Fth frame is bad. */voidRASL_DeInterleave(char *buf, unsigned long ulBufSize, int type, ULONG32 * pFlags){        char temp[RASL_MAXCODEBYTES];     /* space for swapping */ /* Flawfinder: ignore */        INT32 inFlags[RASL_NBLOCKS];           /* save input flags */        int nCodeBytes,nCodeBits;        int fi, fo;                           /* frame in/out */	    int blk;        int bitOffsetTo, bitOffsetFrom;       /* for bit maniputlations */        char *toPtr, *fromPtr;                /* for bit maniputlations */        unsigned long ulToBufSize;        unsigned long ulFromBufSize;        if(type == 0)        {            nCodeBits=RA65_NCODEBITS;           }        if(type == 1)        {            nCodeBits=RA85_NCODEBITS;        }        if(type == 2)        {            nCodeBits=RA50_NCODEBITS;        }        if(type == 3)        {            nCodeBits=RA160_NCODEBITS;          }	/* Save input flags, and initialize output flags */	if(pFlags)        for (blk = 0; blk < RASL_NBLOCKS; blk++) {		inFlags[blk] = pFlags[blk];	    /* save input */		pFlags[blk] = 0;				/* init output to no error */	}        if(nCodeBits%8 == 0)        {            nCodeBytes=nCodeBits>>3;            for (fi = 0; fi < RASL_NFRAMES * RASL_NBLOCKS; fi++)            {		                fo = RASL_InterleaveTable[fi];  /* frame to swap with */		/* 		 * Note that when (fo == fi), the frame doesn't move, 		 * and if (fo < fi), we have swapped it already.		 */                if (fo > fi)             /* do the swap if needed */                {                     memcpy(temp, buf + fo * nCodeBytes, nCodeBytes); /* Flawfinder: ignore */                    memcpy(buf + fo * nCodeBytes, buf + fi * nCodeBytes, nCodeBytes); /* Flawfinder: ignore */                    memcpy(buf + fi * nCodeBytes, temp, nCodeBytes); /* Flawfinder: ignore */		        }		/* 		 * If frame came from bad block, set bit corresponding to new position.		 * Only check one of the swapped pair, since other will be done when		 * fi gets there.		 */                if (pFlags && inFlags[RASL_BLOCK_NUM(fi)])                        pFlags[RASL_BLOCK_NUM(fo)] |= (1 << RASL_BLOCK_OFF(fo));            }        }        else        {            for (fi = 0; fi < RASL_NFRAMES * RASL_NBLOCKS; fi++)            {		                fo = RASL_InterleaveTable[fi];  /* frame to swap with */		/* 		 * Note that when (fo == fi), the frame doesn't move, 		 * and if (fo < fi), we have swapped it already.		 */                if (fo > fi)             /* do the swap if needed */                {                     toPtr=temp;                    ulToBufSize = RASL_MAXCODEBYTES;                    fromPtr=buf;                    ulFromBufSize = ulBufSize;                    bitOffsetTo=0;                    bitOffsetFrom=fo*nCodeBits;                    ra_bitcopy((unsigned char *)toPtr,ulToBufSize,(unsigned char *)fromPtr,ulFromBufSize,bitOffsetTo,bitOffsetFrom,nCodeBits);                    toPtr=buf;                    ulToBufSize = ulBufSize;                    fromPtr=buf;                    ulFromBufSize = ulBufSize;                    bitOffsetTo=fo*nCodeBits;                    bitOffsetFrom=fi*nCodeBits;                    ra_bitcopy((unsigned char *)toPtr,ulToBufSize,(unsigned char *)fromPtr,ulFromBufSize,bitOffsetTo,bitOffsetFrom,nCodeBits);                    toPtr=buf;                    ulToBufSize = ulBufSize;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -