本文整理匯總了C++中GET_BITS函數的典型用法代碼示例。如果您正苦於以下問題:C++ GET_BITS函數的具體用法?C++ GET_BITS怎麽用?C++ GET_BITS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GET_BITS函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: spi_txrx
int spi_txrx(int port, const uint8_t* outBuffer, int outLen, uint8_t* inBuffer, int inLen, int block)
{
if(port > (NUM_SPIPORTS - 1)) {
return -1;
}
SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2));
SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3));
spi_info[port].txBuffer = outBuffer;
if(outLen > MAX_TX_BUFFER)
spi_info[port].txCurrentLen = MAX_TX_BUFFER;
else
spi_info[port].txCurrentLen = outLen;
spi_info[port].txTotalLen = outLen;
spi_info[port].txDone = FALSE;
spi_info[port].rxBuffer = inBuffer;
spi_info[port].rxDone = FALSE;
spi_info[port].rxCurrentLen = 0;
spi_info[port].rxTotalLen = inLen;
spi_info[port].counter = 0;
spi_txdata(port, outBuffer, 0, spi_info[port].txCurrentLen);
SET_REG(SPIRegs[port].cnt, (inLen + ((1<<spi_info[port].wordSize)-1)) >> spi_info[port].wordSize);
SET_REG(SPIRegs[port].control, 1);
if(block) {
while(!spi_info[port].txDone || !spi_info[port].rxDone || GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) {
// yield
}
return inLen;
} else {
return 0;
}
}
示例2: spi_tx
int spi_tx(int port, uint8_t* buffer, int len, int block, int unknown) {
if(port >= (NUM_SPIPORTS - 1)) {
return -1;
}
SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2));
SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3));
spi_info[port].txBuffer = buffer;
if(len > MAX_TX_BUFFER)
spi_info[port].txCurrentLen = MAX_TX_BUFFER;
else
spi_info[port].txCurrentLen = len;
spi_info[port].txTotalLen = len;
spi_info[port].txDone = FALSE;
if(unknown == 0) {
SET_REG(SPIRegs[port].unkReg2, 0);
}
int i;
for(i = 0; i < spi_info[port].txCurrentLen; i++) {
SET_REG(SPIRegs[port].txData, buffer[i]);
}
SET_REG(SPIRegs[port].control, 1);
if(block) {
while(!spi_info[port].txDone || GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) {
// yield
}
return len;
} else {
return 0;
}
}
示例3: de_get_mclk_src
u32 de_get_mclk_src(__hdle clk_hdl)
{
u32 i;
u32 count;
u32 src_sel;
u32 reg_val;
clk_mod_para *hdl = (clk_mod_para*)clk_hdl;
count = sizeof(disp_clk_mod_tbl) / sizeof(clk_mod_para);
for(i = 0; i < count; i++)
{
if(disp_clk_mod_tbl[i].clk_id == hdl->clk_id)
{
reg_val = readl(disp_clk_mod_tbl[i].mod_adr);
src_sel = GET_BITS(disp_clk_mod_tbl[i].mod_src_shift, disp_clk_mod_tbl[i].mod_src_bit_num, reg_val);
if(src_sel == 0)
{
return SYS_CLK_PLL3;
}
else if(src_sel == 4)
{
return SYS_CLK_MIPIPLL;
}
else if(src_sel == 5)
{
return SYS_CLK_PLL10;
}
else
{
break;
}
}
}
__wrn("get mod clock src fail!\n");
return 0;
}
示例4: gpio_pulldown_configure
void gpio_pulldown_configure(int port, GPIOPDSetting setting)
{
uint32_t bit = 1 << GET_BITS(port, 0, 3);
switch(setting)
{
case GPIOPDDisabled:
GPIORegs[GET_BITS(port, 8, 5)].PUD1 &= ~bit;
GPIORegs[GET_BITS(port, 8, 5)].PUD2 &= ~bit;
break;
case GPIOPDUp:
GPIORegs[GET_BITS(port, 8, 5)].PUD1 |= bit;
GPIORegs[GET_BITS(port, 8, 5)].PUD2 &= ~bit;
break;
case GPIOPDDown:
GPIORegs[GET_BITS(port, 8, 5)].PUD1 &= ~bit;
GPIORegs[GET_BITS(port, 8, 5)].PUD2 |= bit;
break;
}
}
示例5: aac_sensor_read
static int aac_sensor_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
struct sensor_device *dev;
//sensors_vec_t vec[ID_MAX];
int x=0,y=0,z=0,temp;
char data[255],*curr;
char bit;
int event;
int result;
dev=&sensor_priv;
event=wait_for_completion_timeout(&dev->data_comp,get_poll_time());
result = aac_sensor_query(dev,event); //get new data
down(&sensor_data_mutex);
curr=data;
if(result == 0){
if(event){
bit=GET_BITS(dev->values[MMA_TILT],MMA_TILT_ALERT);
if(!bit){
bit=GET_BITS(dev->values[3],MMA_TILT_POLA);
// board e2
#if defined(CONFIG_BOARD_E2)
if(bit==POLA_LEFT){
x=180;
}else if(bit==POLA_RIGHT){
x=0;
}else if(bit==POLA_UP){
x=270;
}else if(bit==POLA_DOWN){
x=90;
}else{
event=0;
}
#endif
//board 3e
#if defined(CONFIG_BOARD_E3)
if(bit==POLA_LEFT){
x=0;
}else if(bit==POLA_RIGHT){
x=180;
}else if(bit==POLA_UP){
x=270;
}else if(bit==POLA_DOWN){
x=90;
}else{
event=0;
}
#endif
//board g0
#if defined(CONFIG_BOARD_G0)||defined(CONFIG_BOARD_G0_3G)
if(bit==POLA_LEFT){
x=90;
}else if(bit==POLA_RIGHT){
x=270;
}else if(bit==POLA_UP){
x=180;
}else if(bit==POLA_DOWN){
x=0;
}else{
event=0;
}
#endif
//board h0
#if defined(CONFIG_BOARD_H0)
if(bit==POLA_LEFT){
x=180;
}else if(bit==POLA_RIGHT){
x=0;
}else if(bit==POLA_UP){
x=90;
}else if(bit==POLA_DOWN){
x=270;
}else{
event=0;
}
#endif
//board i0
#if defined(CONFIG_BOARD_I0)||defined(CONFIG_BOARD_K0)
if(bit==POLA_LEFT){
x=270;
}else if(bit==POLA_RIGHT){
x=90;
}else if(bit==POLA_UP){
x=0;
}else if(bit==POLA_DOWN){
x=180;
}else{
event=0;
}
#endif
//board j0
#if defined(CONFIG_BOARD_J0)||defined(CONFIG_BOARD_L0)
if(bit==POLA_LEFT){
//.........這裏部分代碼省略.........
示例6: sunxi_clk_factors_set_rate
static int sunxi_clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate)
{
unsigned long reg;
struct clk_factors_value factor_val;
struct sunxi_clk_factors *factor = to_clk_factor(hw);
struct sunxi_clk_factors_config *config = factor->config;
unsigned long flags = 0;
if(!factor->get_factors)
return 0;
/* factor_val is initialized with its original value,
* it's factors(such as:M,N,K,P,d1,d2...) are Random Value.
* if donot judge the return value of "factor->get_factors",
* it may change the original register value.
*/
if(factor->get_factors(rate, parent_rate, &factor_val) < 0)
{
/* cannot get right factors for clk,just break */
WARN(1, "clk %s set rate failed! Because cannot get right factors for clk\n", hw->clk->name);
return 0;
}
if(factor->flags & CLK_RATE_FLAT_FACTORS)
return sunxi_clk_factors_set_flat_facotrs(factor, &factor_val);
if(factor->lock)
spin_lock_irqsave(factor->lock, flags);
sunxi_clk_disable_plllock(factor);
reg = factor_readl(factor, factor->reg);
if(config->sdmwidth)
{
factor_writel(factor, config->sdmval, (void __iomem *)config->sdmpat);
reg = SET_BITS(config->sdmshift, config->sdmwidth, reg, 1);
}
if(config->nwidth)
reg = SET_BITS(config->nshift, config->nwidth, reg, factor_val.factorn);
if(config->kwidth)
reg = SET_BITS(config->kshift, config->kwidth, reg, factor_val.factork);
if(config->mwidth)
reg = SET_BITS(config->mshift, config->mwidth, reg, factor_val.factorm);
if(config->pwidth)
reg = SET_BITS(config->pshift, config->pwidth, reg, factor_val.factorp);
if(config->d1width)
reg = SET_BITS(config->d1shift, config->d1width, reg, factor_val.factord1);
if(config->d2width)
reg = SET_BITS(config->d2shift, config->d2width, reg, factor_val.factord2);
if(config->frac) {
reg = SET_BITS(config->modeshift, 1, reg, factor_val.frac_mode);
reg = SET_BITS(config->outshift, 1, reg, factor_val.frac_freq);
}
if(config->updshift) //update for pll_ddr register
reg = SET_BITS(config->updshift, 1, reg, 1);
factor_writel(factor,reg, factor->reg);
#ifndef CONFIG_SUNXI_CLK_DUMMY_DEBUG
if(GET_BITS(config->enshift, 1, reg)) {
if (sunxi_clk_is_lock(factor)) {
if(factor->lock)
spin_unlock_irqrestore(factor->lock, flags);
WARN(1, "clk %s wait lock timeout\n", factor->hw.clk->name);
return -1;
}
}
#endif
if(factor->lock)
spin_unlock_irqrestore(factor->lock, flags);
return 0;
}
示例7: decode_mcu_AC_first
boolean decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int Se = cinfo->Se;
int Al = cinfo->Al;
register int s, k, r;
unsigned int EOBRUN;
JBLOCKROW block;
BITREAD_STATE_VARS;
d_derived_tbl * tbl;
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval)
{
if (entropy->restarts_to_go == 0)
if (! process_restart(cinfo))
return FALSE;
}
/* If we've run out of data, just leave the MCU set to zeroes.
* This way, we return uniform gray for the remainder of the segment.
*/
if (! entropy->pub.insufficient_data)
{
/* Load up working state.
* We can avoid loading/saving bitread state if in an EOB run.
*/
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
/* There is always only one block per MCU */
if (EOBRUN > 0) /* if it's a band of zeroes... */
EOBRUN--; /* ...process it now (we do nothing) */
else
{
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
block = MCU_data[0];
tbl = entropy->ac_derived_tbl;
for (k = cinfo->Ss; k <= Se; k++)
{
if ( ! br_state.HUFF_DECODE(s, bits_left, get_buffer, tbl) )
return FALSE;
r = s >> 4;
s &= 15;
if (s)
{
k += r;
if ( ! br_state.CHECK_BIT_BUFFER(s, bits_left, get_buffer) )
return FALSE;
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
/* Scale and output coefficient in natural (dezigzagged) order */
(*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
}
else
{
if (r == 15) /* ZRL */
{
k += 15; /* skip 15 zeroes in band */
}
else /* EOBr, run length is 2^r + appended bits */
{
EOBRUN = 1 << r;
if (r) /* EOBr, r > 0 */
{
if ( ! br_state.CHECK_BIT_BUFFER(r, bits_left, get_buffer) )
return FALSE;
r = GET_BITS(r);
EOBRUN += r;
}
EOBRUN--; /* this band is processed at this moment */
break; /* force end-of-band */
}
}
}
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
}
/* Completed MCU, so update state */
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
}
示例8: crc_free_data_register_read
/*!
\brief read the free data register
\param[in] none
\param[out] none
\retval 32-bit value of the free data register
*/
uint32_t crc_free_data_register_read(void)
{
uint32_t fdata;
fdata = GET_BITS(CRC_FDATA, 0, 7);
return (fdata);
}
示例9: decode_mcu_AC_first
METHODDEF boolean decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW * MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int Se = cinfo->Se;
int Al = cinfo->Al;
register int s, k, r;
unsigned int EOBRUN;
JBLOCKROW block;
BITREAD_STATE_VARS;
d_derived_tbl *tbl;
/* Process restart marker if needed; may have to suspend */
if(cinfo->restart_interval)
{
if(entropy->restarts_to_go == 0)
if(!process_restart(cinfo))
return FALSE;
}
/* Load up working state.
* We can avoid loading/saving bitread state if in an EOB run.
*/
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we care about */
/* There is always only one block per MCU */
if(EOBRUN > 0) /* if it's a band of zeroes... */
EOBRUN--; /* ...process it now (we do nothing) */
else
{
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
block = MCU_data[0];
tbl = entropy->ac_derived_tbl;
for(k = cinfo->Ss; k <= Se; k++)
{
HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
r = s >> 4;
s &= 15;
if(s)
{
k += r;
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
/* Scale and output coefficient in natural (dezigzagged) order */
(*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
}
else
{
if(r == 15)
{ /* ZRL */
k += 15; /* skip 15 zeroes in band */
}
else
{ /* EOBr, run length is 2^r + appended bits */
EOBRUN = 1 << r;
if(r)
{ /* EOBr, r > 0 */
CHECK_BIT_BUFFER(br_state, r, return FALSE);
r = GET_BITS(r);
EOBRUN += r;
}
EOBRUN--; /* this band is processed at this moment */
break; /* force end-of-band */
}
}
}
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
}
示例10: decode_mcu
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
__boundcheck_metadata_store((void *)(&entropy),(void *)((size_t)(&entropy)+sizeof(entropy)*8-1));
register int s, k, r;
int blkn;
__boundcheck_metadata_store((void *)(&blkn),(void *)((size_t)(&blkn)+sizeof(blkn)*8-1));
int ci;
__boundcheck_metadata_store((void *)(&ci),(void *)((size_t)(&ci)+sizeof(ci)*8-1));
JBLOCKROW block;
__boundcheck_metadata_store((void *)(&block),(void *)((size_t)(&block)+sizeof(block)*8-1));
BITREAD_STATE_VARS;
__boundcheck_metadata_store((void *)(&br_state),(void *)((size_t)(&br_state)+sizeof(br_state)*8-1));
savable_state state;
__boundcheck_metadata_store((void *)(&state),(void *)((size_t)(&state)+sizeof(state)*8-1));
d_derived_tbl * dctbl;
__boundcheck_metadata_store((void *)(&dctbl),(void *)((size_t)(&dctbl)+sizeof(dctbl)*8-1));
d_derived_tbl * actbl;
__boundcheck_metadata_store((void *)(&actbl),(void *)((size_t)(&actbl)+sizeof(actbl)*8-1));
jpeg_component_info * compptr;
__boundcheck_metadata_store((void *)(&compptr),(void *)((size_t)(&compptr)+sizeof(compptr)*8-1));
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restart(cinfo))
return FALSE;
}
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
ASSIGN_STATE(state, entropy->saved);
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = (*(JBLOCKROW *)(__boundcheck_ptr_reference(463,13,"decode_mcu",(void *)(&MCU_data[0]),(void *)(&MCU_data[blkn]))));
ci = cinfo->MCU_membership[_RV_insert_check(0,10,464,10,"decode_mcu",blkn)];
compptr = cinfo->cur_comp_info[_RV_insert_check(0,4,465,15,"decode_mcu",ci)];
dctbl = entropy->dc_derived_tbls[_RV_insert_check(0,4,466,13,"decode_mcu",compptr->dc_tbl_no)];
actbl = entropy->ac_derived_tbls[_RV_insert_check(0,4,467,13,"decode_mcu",compptr->ac_tbl_no)];
/* Decode a single block's worth of coefficients */
/* Section F.2.2.1: decode the DC coefficient difference */
HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
if (s) {
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
}
/* Shortcut if component's values are not interesting */
if (! compptr->component_needed)
goto skip_ACs;
/* Convert DC difference to actual value, update last_dc_val */
s += state.last_dc_val[_RV_insert_check(0,4,484,10,"decode_mcu",ci)];
state.last_dc_val[_RV_insert_check(0,4,485,5,"decode_mcu",ci)] = s;
/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
(*(JBLOCKROW)(__boundcheck_ptr_reference(487,7,"decode_mcu",(void *)(block),(void *)(block))))[0] = (JCOEF) s;
/* Do we need to decode the AC coefficients for this component? */
if (compptr->DCT_scaled_size > 1) {
/* Section F.2.2.2: decode the AC coefficients */
/* Since zeroes are skipped, output area must be cleared beforehand */
for (k = 1; k < DCTSIZE2; k++) {
HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
r = s >> 4;
s &= 15;
if (s) {
k += r;
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
/* Output coefficient in natural (dezigzagged) order.
* Note: the extra entries in jpeg_natural_order[] will save us
* if k >= DCTSIZE2, which could happen if the data is corrupted.
*/
(*(JBLOCKROW)(__boundcheck_ptr_reference(509,6,"decode_mcu",(void *)(block),(void *)(block))))[(*(const int *)(__boundcheck_ptr_reference(509,13,"decode_mcu",(void *)(&jpeg_natural_order[0]),(void *)(&jpeg_natural_order[k]))))] = (JCOEF) s;
} else {
if (r != 15)
break;
k += 15;
}
}
} else {
示例11: xge_rx_poll
static int xge_rx_poll(struct net_device *ndev, unsigned int budget)
{
struct xge_pdata *pdata = netdev_priv(ndev);
struct device *dev = &pdata->pdev->dev;
struct xge_desc_ring *rx_ring;
struct xge_raw_desc *raw_desc;
struct sk_buff *skb;
dma_addr_t dma_addr;
int processed = 0;
u8 head, rx_error;
int i, ret;
u32 data;
u16 len;
rx_ring = pdata->rx_ring;
head = rx_ring->head;
data = xge_rd_csr(pdata, DMARXSTATUS);
if (!GET_BITS(RXPKTCOUNT, data))
return 0;
for (i = 0; i < budget; i++) {
raw_desc = &rx_ring->raw_desc[head];
if (GET_BITS(E, le64_to_cpu(raw_desc->m0)))
break;
dma_rmb();
skb = rx_ring->pkt_info[head].skb;
rx_ring->pkt_info[head].skb = NULL;
dma_addr = rx_ring->pkt_info[head].dma_addr;
len = GET_BITS(PKT_SIZE, le64_to_cpu(raw_desc->m0));
dma_unmap_single(dev, dma_addr, XGENE_ENET_STD_MTU,
DMA_FROM_DEVICE);
rx_error = GET_BITS(D, le64_to_cpu(raw_desc->m2));
if (unlikely(rx_error)) {
pdata->stats.rx_errors++;
dev_kfree_skb_any(skb);
goto out;
}
skb_put(skb, len);
skb->protocol = eth_type_trans(skb, ndev);
pdata->stats.rx_packets++;
pdata->stats.rx_bytes += len;
napi_gro_receive(&pdata->napi, skb);
out:
ret = xge_refill_buffers(ndev, 1);
xge_wr_csr(pdata, DMARXSTATUS, 1);
xge_wr_csr(pdata, DMARXCTRL, 1);
if (ret)
break;
head = (head + 1) & (XGENE_ENET_NUM_DESC - 1);
processed++;
}
rx_ring->head = head;
return processed;
}
示例12: decode_mcus
decode_mcus (j_decompress_ptr cinfo, JDIFFIMAGE diff_buf,
JDIMENSION MCU_row_num, JDIMENSION MCU_col_num, JDIMENSION nMCU)
{
j_lossless_d_ptr losslsd = (j_lossless_d_ptr) cinfo->codec;
lhuff_entropy_ptr entropy = (lhuff_entropy_ptr) losslsd->entropy_private;
unsigned int mcu_num;
int sampn, ci, yoffset, MCU_width, ptrn;
BITREAD_STATE_VARS;
/* Set output pointer locations based on MCU_col_num */
for (ptrn = 0; ptrn < entropy->num_output_ptrs; ptrn++) {
ci = entropy->output_ptr_info[ptrn].ci;
yoffset = entropy->output_ptr_info[ptrn].yoffset;
MCU_width = entropy->output_ptr_info[ptrn].MCU_width;
entropy->output_ptr[ptrn] =
diff_buf[ci][MCU_row_num + (JDIMENSION)yoffset] + MCU_col_num * (JDIMENSION)MCU_width;
}
/*
* If we've run out of data, zero out the buffers and return.
* By resetting the undifferencer, the output samples will be CENTERJSAMPLE.
*
* NB: We should find a way to do this without interacting with the
* undifferencer module directly.
*/
if (entropy->insufficient_data) {
for (ptrn = 0; ptrn < entropy->num_output_ptrs; ptrn++)
jzero_far((void FAR *) entropy->output_ptr[ptrn],
nMCU * (size_t)entropy->output_ptr_info[ptrn].MCU_width * SIZEOF(JDIFF));
(*losslsd->predict_process_restart) (cinfo);
}
else {
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
/* Outer loop handles the number of MCU requested */
for (mcu_num = 0; mcu_num < nMCU; mcu_num++) {
/* Inner loop handles the samples in the MCU */
for (sampn = 0; sampn < cinfo->data_units_in_MCU; sampn++) {
d_derived_tbl * dctbl = entropy->cur_tbls[sampn];
register int s, r;
/* Section H.2.2: decode the sample difference */
HUFF_DECODE(s, br_state, dctbl, return mcu_num, label1);
if (s) {
if (s == 16) /* special case: always output 32768 */
s = 32768;
else { /* normal case: fetch subsequent bits */
CHECK_BIT_BUFFER(br_state, s, return mcu_num);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
}
}
/* Output the sample difference */
*entropy->output_ptr[entropy->output_ptr_index[sampn]]++ = (JDIFF) s;
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
}
}
return nMCU;
}
示例13: spiIRQHandler
static void spiIRQHandler(uint32_t port) {
if(port >= (NUM_SPIPORTS - 1)) {
return;
}
uint32_t status = GET_REG(SPIRegs[port].status);
if(status & (1 << 3)) {
spi_info[port].counter++;
}
int i;
if(status & (1 << 1)) {
while(TRUE) {
// take care of tx
if(spi_info[port].txBuffer != NULL) {
if(spi_info[port].txCurrentLen < spi_info[port].txTotalLen) {
int toTX = spi_info[port].txTotalLen - spi_info[port].txCurrentLen;
int canTX = MAX_TX_BUFFER - TX_BUFFER_LEFT(status);
if(toTX > canTX)
toTX = canTX;
for(i = 0; i < toTX; i++) {
SET_REG(SPIRegs[port].txData, spi_info[port].txBuffer[spi_info[port].txCurrentLen + i]);
}
spi_info[port].txCurrentLen += toTX;
} else {
spi_info[port].txDone = TRUE;
spi_info[port].txBuffer = NULL;
}
}
dorx:
// take care of rx
if(spi_info[port].rxBuffer == NULL)
break;
int toRX = spi_info[port].rxTotalLen - spi_info[port].rxCurrentLen;
int canRX = GET_BITS(status, 8, 4);
if(toRX > canRX)
toRX = canRX;
for(i = 0; i < toRX; i++) {
spi_info[port].rxBuffer[spi_info[port].rxCurrentLen + i] = GET_REG(SPIRegs[port].rxData);
}
spi_info[port].rxCurrentLen += toRX;
if(spi_info[port].rxCurrentLen < spi_info[port].rxTotalLen)
break;
spi_info[port].rxDone = TRUE;
spi_info[port].rxBuffer = NULL;
}
} else if(status & (1 << 0)) {
// jump into middle of the loop to handle rx only, stupidly
goto dorx;
}
// acknowledge interrupt handling complete
SET_REG(SPIRegs[port].status, status);
}
示例14: decode_mcu
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
j_lossy_d_ptr lossyd = (j_lossy_d_ptr) cinfo->codec;
shuff_entropy_ptr entropy = (shuff_entropy_ptr) lossyd->entropy_private;
int blkn;
BITREAD_STATE_VARS;
savable_state state;
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restart(cinfo))
return FALSE;
}
/* If we've run out of data, just leave the MCU set to zeroes.
* This way, we return uniform gray for the remainder of the segment.
*/
if (! entropy->insufficient_data) {
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
ASSIGN_STATE(state, entropy->saved);
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->data_units_in_MCU; blkn++) {
JBLOCKROW block = MCU_data[blkn];
d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn];
d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn];
register int s, k, r;
/* Decode a single block's worth of coefficients */
/* Section F.2.2.1: decode the DC coefficient difference */
HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
if (s) {
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
}
if (entropy->dc_needed[blkn]) {
/* Convert DC difference to actual value, update last_dc_val */
int ci = cinfo->MCU_membership[blkn];
s += state.last_dc_val[ci];
state.last_dc_val[ci] = s;
/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
(*block)[0] = (JCOEF) s;
}
if (entropy->ac_needed[blkn]) {
/* Section F.2.2.2: decode the AC coefficients */
/* Since zeroes are skipped, output area must be cleared beforehand */
for (k = 1; k < DCTSIZE2; k++) {
HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
r = s >> 4;
s &= 15;
if (s) {
k += r;
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
/* Output coefficient in natural (dezigzagged) order.
* Note: the extra entries in jpeg_natural_order[] will save us
* if k >= DCTSIZE2, which could happen if the data is corrupted.
*/
(*block)[jpeg_natural_order[k]] = (JCOEF) s;
} else {
if (r != 15)
break;
k += 15;
}
}
} else {
/* Section F.2.2.2: decode the AC coefficients */
/* In this path we just discard the values */
for (k = 1; k < DCTSIZE2; k++) {
示例15: gst_mpeg4_params_parse_vo
static gboolean
gst_mpeg4_params_parse_vo (MPEG4Params * params, GstBitReader * br)
{
guint32 bits;
guint16 time_increment_resolution = 0;
guint16 fixed_time_increment = 0;
gint aspect_ratio_width = -1, aspect_ratio_height = -1;
gint height = -1, width = -1;
/* expecting a video object startcode */
GET_BITS (br, 32, &bits);
if (bits > 0x11F)
goto failed;
/* expecting a video object layer startcode */
GET_BITS (br, 32, &bits);
if (bits < 0x120 || bits > 0x12F)
goto failed;
/* ignore random accessible vol and video object type indication */
GET_BITS (br, 9, &bits);
GET_BITS (br, 1, &bits);
if (bits) {
/* skip video object layer verid and priority */
GET_BITS (br, 7, &bits);
}
/* aspect ratio info */
GET_BITS (br, 4, &bits);
if (bits == 0)
goto failed;
/* check if aspect ratio info is extended par */
if (bits == 0xf) {
GET_BITS (br, 8, &bits);
aspect_ratio_width = bits;
GET_BITS (br, 8, &bits);
aspect_ratio_height = bits;
} else if (bits < 0x6) {
aspect_ratio_width = aspect_ratio_table[bits][0];
aspect_ratio_height = aspect_ratio_table[bits][1];
}
GST_DEBUG ("aspect ratio %d/%d", aspect_ratio_width, aspect_ratio_height);
GET_BITS (br, 1, &bits);
if (bits) {
/* vol control parameters, skip chroma and low delay */
GET_BITS (br, 3, &bits);
GET_BITS (br, 1, &bits);
if (bits) {
/* skip vbv_parameters */
GET_BITS (br, 79, &bits);
}
}
/* layer shape */
GET_BITS (br, 2, &bits);
/* only support rectangular */
if (bits != 0)
goto failed;
MARKER_BIT (br);
GET_BITS (br, 16, &bits);
time_increment_resolution = bits;
MARKER_BIT (br);
GST_DEBUG ("time increment resolution %d", time_increment_resolution);
GET_BITS (br, 1, &bits);
if (bits) {
/* fixed time increment */
int n;
/* Length of the time increment is the minimal number of bits needed to
* represent time_increment_resolution */
for (n = 0; (time_increment_resolution >> n) != 0; n++);
GET_BITS (br, n, &bits);
fixed_time_increment = bits;
} else {