📄 bits.c
字号:
/*
// $Header: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/AviDrm/libDrmDecrypt/Bits.c 2 2/15/04 7:41p Lotan $
// Copyright (c) DivXNetworks, Inc. http://www.divxnetworks.com
// All rights reserved.
//
// This software is the confidential and proprietary information of DivxNetworks
// Inc. ("Confidential Information"). You shall not disclose such Confidential
// Information and shall use it only in accordance with the terms of the license
// agreement you entered into with DivXNetworks, Inc.
*/
#include "Playcore\Nav_Clips\AviDrm\libDrmDecrypt\Bits.h"
#ifdef AVI_DRM_SUPPORT
#include <stdio.h> /* sprintf */
#include <string.h> /* strcpy */
#include <limits.h> /* CHAR_BIT */
#include <stdlib.h> /* atoi */
void assign(uint8_t *a, uint8_t *b, uint8_t direction) /* Used to make packLogic generic. */
{
if (direction == A_BECOMES_B)
{
a[0] = b[0];
}
if (direction == B_BECOMES_A)
{
b[0] = a[0];
}
}
void quarterByteSwap(uint8_t *a, uint8_t *b, uint8_t position)
{
uint8_t mask;
switch (position)
{
case 0:
mask = 0x3F;
break;
case 1:
mask = 0xCF;
break;
case 2:
mask = 0xF3;
break;
case 3:
mask = 0xFC;
break;
default:
mask = 0x3F;
}
maskSwap(a, b, mask);
}
void halfByteSwap(uint8_t *a, uint8_t *b, uint8_t position)
{
uint8_t mask;
switch (position)
{
case 0:
mask = 0x0F;
break;
case 1:
mask = 0xF0;
break;
default:
mask = 0x0F;
}
maskSwap(a, b, mask);
}
void maskSwap(uint8_t *a, uint8_t *b, uint8_t mask)
{
uint8_t aResult;
uint8_t bResult;
aResult = (*a & mask) | (*b & ~mask);
bResult = (*b & mask) | (*a & ~mask);
*a = aResult;
*b = bResult;
}
uint16_t pack(uint8_t low, uint8_t hi)
{
uint16_t result = hi;
result = (result << 8) | low;
return result;
}
void unpack(uint16_t whole, uint8_t *hi, uint8_t *low)
{
*hi = (whole & 0xff00) >> 8;
*low = whole & 0xff;
}
uint8_t getByteLoopSizeFromBits(uint8_t sizeInBits)
{
uint8_t result;
result = sizeInBits / CHAR_BIT;
if ((sizeInBits % CHAR_BIT) > 0)
{
result++;
}
return result;
}
#endif // AVI_DRM_SUPPORT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -