Ejemplo n.º 1
0
/* decode navigation data subframe 2 -----------------------------------------*/
static int decode_subfrm2(const unsigned char *buff, eph_t *eph)
{
    double sqrtA;
    int i=48;

    trace(4,"decode_subfrm2:\n");
    trace(5,"decode_subfrm2: buff=");
    traceb(5,buff,30);

    eph->iode=getbitu(buff,i, 8);
    i+= 8;
    eph->crs =getbits(buff,i,16)*P2_5;
    i+=16;
    eph->deln=getbits(buff,i,16)*P2_43*SC2RAD;
    i+=16;
    eph->M0  =getbits(buff,i,32)*P2_31*SC2RAD;
    i+=32;
    eph->cuc =getbits(buff,i,16)*P2_29;
    i+=16;
    eph->e   =getbitu(buff,i,32)*P2_33;
    i+=32;
    eph->cus =getbits(buff,i,16)*P2_29;
    i+=16;
    sqrtA    =getbitu(buff,i,32)*P2_19;
    i+=32;
    eph->toes=getbitu(buff,i,16)*16.0;
    i+=16;
    eph->fit =getbitu(buff,i, 1);

    eph->A=sqrtA*sqrtA;

    return 2;
}
Ejemplo n.º 2
0
/* decode gps/qzss navigation data subframe 1 --------------------------------*/
static int decode_subfrm1(const unsigned char *buff, eph_t *eph)
{
    double tow,toc;
    int i=48,week,iodc0,iodc1,tgd;
    
    trace(4,"decode_subfrm1:\n");
    trace(5,"decode_subfrm1: buff="); traceb(5,buff,30);
    
    tow        =getbitu(buff,24,17)*6.0;           /* transmission time */
    week       =getbitu(buff,i,10);       i+=10;
    eph->code  =getbitu(buff,i, 2);       i+= 2;
    eph->sva   =getbitu(buff,i, 4);       i+= 4;   /* ura index */
    eph->svh   =getbitu(buff,i, 6);       i+= 6;
    iodc0      =getbitu(buff,i, 2);       i+= 2;
    eph->flag  =getbitu(buff,i, 1);       i+= 1+87;
    tgd        =getbits(buff,i, 8);       i+= 8;
    iodc1      =getbitu(buff,i, 8);       i+= 8;
    toc        =getbitu(buff,i,16)*16.0;  i+=16;
    eph->f2    =getbits(buff,i, 8)*P2_55; i+= 8;
    eph->f1    =getbits(buff,i,16)*P2_43; i+=16;
    eph->f0    =getbits(buff,i,22)*P2_31;
    
    eph->tgd[0]=tgd==-128?0.0:tgd*P2_31; /* ref [4] */
    eph->iodc=(iodc0<<8)+iodc1;
    eph->week=adjgpsweek(week); /* week of tow */
    eph->ttr=gpst2time(eph->week,tow);
    eph->toc=gpst2time(eph->week,toc);
    
    return 1;
}
Ejemplo n.º 3
0
static void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT],
                       unsigned int scale_index[2][SBLIMIT],struct frame *fr)
{
  int i,n;
  int smpb[2*SBLIMIT]; /* values: 0-65535 */
  int *sample;
  register unsigned int *ba;
  register unsigned int *sca = (unsigned int *) scale_index;

  if(fr->stereo) {
    int jsbound = fr->jsbound;
    register real *f0 = fraction[0];
    register real *f1 = fraction[1];
    ba = balloc;
    for (sample=smpb,i=0;i<jsbound;i++)  {
      if ((n = *ba++))
        *sample++ = getbits(n+1);
      if ((n = *ba++))
        *sample++ = getbits(n+1);
    }
    for (i=jsbound;i<SBLIMIT;i++)
      if ((n = *ba++))
        *sample++ = getbits(n+1);

    ba = balloc;
    for (sample=smpb,i=0;i<jsbound;i++) {
      if((n=*ba++))
        *f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++];
      else
        *f0++ = 0.0;
      if((n=*ba++))
        *f1++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++];
      else
        *f1++ = 0.0;
    }
    for (i=jsbound;i<SBLIMIT;i++) {
      if ((n=*ba++)) {
        real samp = ( ((-1)<<n) + (*sample++) + 1);
        *f0++ = samp * muls[n+1][*sca++];
        *f1++ = samp * muls[n+1][*sca++];
      }
      else
        *f0++ = *f1++ = 0.0;
    }
  }
  else {
    register real *f0 = fraction[0];
    ba = balloc;
    for (sample=smpb,i=0;i<SBLIMIT;i++)
      if ((n = *ba++))
        *sample++ = getbits(n+1);
    ba = balloc;
    for (sample=smpb,i=0;i<SBLIMIT;i++) {
      if((n=*ba++))
        *f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++];
      else
        *f0++ = 0.0;
    }
  }
}
Ejemplo n.º 4
0
Archivo: gethdr.c Proyecto: pierz/vic
int getheader ()
{
  unsigned int code, gob;

  /* look for startcode */
  startcode ();
  code = getbits (PSC_LENGTH);
  gob = getbits (5);
  if (gob == SE_CODE)
    return 0;
  if (gob == 0)
  {
    if (trace)
    {

      fprintf (trace_file, "\nPSC: ");
      printbits ((code << (5 + gob)), 22, 22);
    }
    getpicturehdr ();
    if (syntax_arith_coding)    /* reset decoder after receiving */
      decoder_reset ();         /* fixed length PSC string */
  } 
  else
  {
    if (trace)
    {

      fprintf (trace_file, "\nGBSC: ");
      printbits ((code << (5 + gob)), 22, 22);
    }
  }
  return gob + 1;
}
Ejemplo n.º 5
0
Archivo: sms.c Proyecto: checko/sxx-ril
void decode_bearer_data(char *msg, int length, char *message, int *is_vm) {
    int i=0,j;
    int code,sublength;

    while(i<length) {
        get_code_and_length(msg+i*2,&code,&sublength);
        if(code==1) {
            int encoding=getbits(msg+i*2+4,0,5);
            int nchars=getbits(msg+i*2+4,5,8);
            if(encoding==2 || encoding==3) {
               for(j=0;j<nchars;j++)
                   *message++=getbits(msg+i*2+4,13+7*j,7);
            } else 
               if(encoding==8 || encoding==0) {
                 for(j=0;j<nchars;j++)
                 *message++=getbits(msg+i*2+4,13+8*j,8);
                } else {
                    strcpy(message,"bad SMS encoding");
                    message+=16;
                }
                *message=0;
            } else if (code == 11 && sublength == 1) {
              int msgs;
              if (is_vm) {
                *is_vm = 1;
                msgs = hex2int(msg[i*2+4])+16*hex2int(msg[i*2+5]);
                if (msgs)
                   *is_vm |= 0x10;
            }
        }
        i+=sublength+2;
    }
    
}
Ejemplo n.º 6
0
/* decode GPS/QZS navigation data (subframe 1) ---------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_subfrm1(const uint8_t *buff, sdreph_t *eph)
{
    double toc;
    int week;

    eph->tow_gpst  =getbitu( buff, 30,17)*6.0;
    week           =getbitu( buff, 60,10)+1024;
    eph->eph.code  =getbitu( buff, 70, 2);
    eph->eph.sva   =getbitu( buff, 72, 4);
    eph->eph.svh   =getbitu( buff, 76, 6);
    eph->eph.iodc  =getbitu2(buff, 82, 2,210, 8);
    eph->eph.flag  =getbitu( buff, 90, 1);
    eph->eph.tgd[0]=getbits( buff,196, 8)*P2_31;
    toc            =getbitu( buff,218,16)*16.0;
    eph->eph.f2    =getbits( buff,240, 8)*P2_55;
    eph->eph.f1    =getbits( buff,248,16)*P2_43;
    eph->eph.f0    =getbits( buff,270,22)*P2_31;

    eph->eph.week=adjgpsweek(week);
    eph->week_gpst=eph->eph.week;
    eph->eph.ttr=gpst2time(eph->eph.week,eph->tow_gpst);
    eph->eph.toc=gpst2time(eph->eph.week,toc);

    /* subframe decode counter */
    eph->cnt++;
}
Ejemplo n.º 7
0
/*
 * Description in header
 */
void analyze_hms(bucket_t *b, uint8_t *datatype, uint8_t *obuf, uint8_t *oby)
{
  if (IS868MHZ && *datatype == 0 && b->state == STATE_HMS) {
    input_t in;
    in.byte = 0;
    in.bit = 7;
    in.data = b->data;

    if(b->byteidx*8 + (7-b->bitidx) < 69) 
      return; // failed

    uint8_t crc = 0, i = 0;
    for(i = 0; i < 6; i++) {
      obuf[i] = getbits(&in, 8, 0);
      if(parity_even_bit(obuf[i]) != getbit( &in ))
        return; // failed
      if(getbit(&in))
        return; // failed
      crc = crc ^ obuf[i];
    }
    *oby = i;
    // Read crc
    uint8_t CRC = getbits(&in, 8, 0);
    if(parity_even_bit(CRC) != getbit(&in))
      return; // failed
    if(crc!=CRC)
      return; // failes
     
    *datatype = TYPE_HMS;
    return; // OK
  }
}
Ejemplo n.º 8
0
int getslicehdr()
{
  int slice_vertical_position_extension, intra_slice;
  int qs;

  slice_vertical_position_extension =
    (ld->mpeg2 && vertical_size>2800) ? getbits(3) : 0;

  qs = getbits(5);
  ld->quant_scale =
    ld->mpeg2 ? (ld->qscale_type ? non_linear_mquant_table[qs] : qs<<1) : qs;

  if (getbits(1))
  {
    intra_slice = getbits(1);
    flushbits(7);
    ext_bit_info();
  }
  else
    intra_slice = 0;

  if (verbose>2)
  {
    if (verbose>3)
    {
      if (ld->mpeg2 && vertical_size>2800)
        printf("  slice_vertical_position_extension=%d\n",slice_vertical_position_extension);
      printf("  quantizer_scale_code=%d\n",qs);
    }
  }
  return slice_vertical_position_extension;
}
Ejemplo n.º 9
0
END_TEST

START_TEST(test_getbits)
{
  u8 test_data[] = {
    0x00, 0x03, 0x80, 0xFF, 0xFF, 0xFF, 0xFF
  };

  s32 ret;

  ret = getbits(test_data, 0, 8);
  fail_unless(ret == 0,
      "Test case 1 expected 0, got %d", ret);

  ret = getbits(test_data, 13, 3);
  fail_unless(ret == 3,
      "Test case 2 expected 3, got %d", ret);

  ret = getbits(test_data, 14, 3);
  fail_unless(ret == -1,
      "Test case 3 expected -1, got %d", ret);

  ret = getbits(test_data, 14, 4);
  fail_unless(ret == -2,
      "Test case 4 expected -2, got %d", ret);

  ret = getbits(test_data, 24, 32);
  fail_unless(ret == -1,
      "Test case 5 expected -1, got %d", ret);
}
Ejemplo n.º 10
0
/* decode type 1/9: differential gps correction/partial correction set -------*/
static int decode_type1(rtcm_t *rtcm)
{
    int i=48,fact,udre,prn,sat,iod;
    double prc,rrc;
    
    rtklib_trace(4,"decode_type1: len=%d\n",rtcm->len);
    
    while (i+40<=rtcm->len*8) {
        fact=getbitu(rtcm->buff,i, 1); i+= 1;
        udre=getbitu(rtcm->buff,i, 2); i+= 2;
        prn =getbitu(rtcm->buff,i, 5); i+= 5;
        prc =getbits(rtcm->buff,i,16); i+=16;
        rrc =getbits(rtcm->buff,i, 8); i+= 8;
        iod =getbits(rtcm->buff,i, 8); i+= 8;
        if (prn==0) prn=32;
        if (prc==0x80000000||rrc==0xFFFF8000) {
            rtklib_trace(2,"rtcm2 1 prc/rrc indicates satellite problem: prn=%d\n",prn);
            continue;
        }
        if (rtcm->dgps) {
            sat=satno(SYS_GPS,prn);
            rtcm->dgps[sat-1].t0=rtcm->time;
            rtcm->dgps[sat-1].prc=prc*(fact?0.32:0.02);
            rtcm->dgps[sat-1].rrc=rrc*(fact?0.032:0.002);
            rtcm->dgps[sat-1].iod=iod;
            rtcm->dgps[sat-1].udre=udre;
        }
    }
    return 7;
}
Ejemplo n.º 11
0
static void read_pt_len(int nn, int nbit, int i_special)
{
  int i, c, n;
  unsigned short mask;

  n = getbits(nbit);
  if (n == 0) {
    c = getbits(nbit);
    for (i = 0; i < nn; i++) pt_len[i] = 0;
    for (i = 0; i < 256; i++) pt_table[i] = c;
  } else {
    i = 0;
    while (i < n) {
      c = bitbuf >> (BITBUFSIZ - 3);
      if (c == 7) {
	mask = 1U << (BITBUFSIZ - 1 - 3);
	while (mask & bitbuf) {  mask >>= 1;  c++;  }
      }
      fillbuf((c < 7) ? 3 : c - 3);
      pt_len[i++] = c;
      if (i == i_special) {
	c = getbits(2);
	while (--c >= 0) pt_len[i++] = 0;
      }
    }
    while (i < nn) pt_len[i++] = 0;
    make_table(nn, pt_len, 8, pt_table);
  }
Ejemplo n.º 12
0
void strb_inst(int inst, ARMProc *proc) {
	int i;
	int address;
	int rd;
	int **rd_ptr;
	int (*func)(int, ARMProc *);
	int data;

	if(!check_condition(proc, inst))
                return;

	ls_addr_modes = ls_addressing_dict();

	for(i = 0; i < LS_ADDRESSING_NUMBER; i++) {
                if(test_inst(ls_addr_modes[i], inst)) {
                        func = ls_addr_modes[i]->execute;
                        address = (*func)(inst, proc);
			break;
                }
        }

	rd = getbits(inst, 12, 4);
	rd_ptr = &proc->r0;
	rd_ptr += rd;

	write_mem(proc, address, 1, getbits(**rd_ptr, 0, 8));
}
Ejemplo n.º 13
0
/* decode Galileo navigation data (I/NAV word 4) -------------------------------
*
* args   : uint8_t  *buff   I   navigation data bits
*          sdreph_t *eph    I/O sdr ephemeris structure
* return : none
*-----------------------------------------------------------------------------*/
void decode_word4(const uint8_t *buff, sdrnav_t *nav)
{
    sdreph_t *eph = &nav->sdreph;
    int oldiodc=eph->eph.iodc;

    eph->eph.iodc  =getbitu( buff,OFFSET1+ 6,10);
    eph->eph.cic   =getbits( buff,OFFSET1+22,16)*P2_29;
    eph->eph.cis   =getbits( buff,OFFSET1+38,16)*P2_29;
    eph->toc_gst   =getbitu( buff,OFFSET1+54,14)*60;
    eph->eph.f0    =getbits( buff,OFFSET1+68,31)*P2_34;
    eph->eph.f1    =getbits2(buff,OFFSET1+99,13,OFFSET2+ 0, 8)*P2_46;
    eph->eph.f2    =getbits( buff,OFFSET2+ 8, 6)*P2_59;
    eph->eph.iode  =eph->eph.iodc;

    /* compute time of clock */
    if (eph->week_gst!=0) {
        eph->eph.toc=gst2time(eph->week_gst,eph->toc_gst);
        Ephemeris[nav->sat].Page4(eph->eph.iodc, eph->eph.cic, eph->eph.cis, eph->eph.f0, eph->eph.f1, eph->eph.f2, time2gpst(eph->eph.toc, NULL));
    } else {
        Ephemeris[nav->sat].Page4(eph->eph.iodc, eph->eph.cic, eph->eph.cis, eph->eph.f0, eph->eph.f1, eph->eph.f2);
    }

    /* ephemeris update flag */
    if (oldiodc-eph->eph.iodc!=0) eph->update=ON;

    /* subframe counter */
    eph->cnt++;
}
Ejemplo n.º 14
0
Archivo: HUF.CPP Proyecto: r043v/yAnl
void CLhaArchive::read_pt_len(short nn, short nbit, short i_special)
{
	short i, c, n;

	n = getbits(nbit);
	if (n == 0) {
		c = getbits(nbit);
		for (i = 0; i < nn; i++) gpHufData->pt_len[i] = 0;
		for (i = 0; i < 256; i++) gpHufData->pt_table[i] = c;
	} else {
		i = 0;
		while (i < n) {
			c = bitbuf >> (16 - 3);
			if (c == 7) {
				unsigned short mask = 1 << (16 - 4);
				while (mask & bitbuf) {  mask >>= 1;  c++;  }
			}
			fillbuf((c < 7) ? 3 : c - 3);
			gpHufData->pt_len[i++] = (unsigned char)c;
			if (i == i_special) {
				c = getbits(2);
				while (--c >= 0) gpHufData->pt_len[i++] = 0;
			}
		}
		while (i < nn) gpHufData->pt_len[i++] = 0;
		make_table(nn, gpHufData->pt_len, 8, gpHufData->pt_table);
	}
Ejemplo n.º 15
0
void picture_temporal_scalable_extension()
{
  zprintf(1, "  picture_temporal_scalable_extension_id = %01X\n", getbits(4));
  zprintf(2, "  reference_select_code = %d\n", getbits(2));
  zprintf(2, "  forward_temporal_reference = %d\n", getbits(10));
  zprintf(2, "  marker bit = %d\n", get1bit());
  zprintf(2, "  backward_temporal_reference = %d\n", getbits(10));
  next_start_code();
}
Ejemplo n.º 16
0
Archivo: sms.c Proyecto: checko/sxx-ril
void decode_number(char *msg, int length, char *no) {
	
	int ndigits=getbits(msg,2,8);
	int j,digit;

	for(j=0;j<ndigits;j++) 
		*no++=decode_table[getbits(msg,10+j*4,4)];
	*no=0;
}
Ejemplo n.º 17
0
void user_data()
{
  zprintf(1, "\nuser_data_start_code = 0x000001%02X\n", getbits(8));
  while (nextbits(24) != START_CODE_PREFIX)
  {
    getbits(8);
    user_data_bytes++;
  }
  next_start_code();
}
Ejemplo n.º 18
0
/*
 * Setup the callbacks.
 */
static int
compress_bidder_init(struct archive_read_filter *self)
{
    struct private_data *state;
    static const size_t out_block_size = 64 * 1024;
    void *out_block;
    int code;

    self->code = ARCHIVE_FILTER_COMPRESS;
    self->name = "compress (.Z)";

    state = (struct private_data *)calloc(sizeof(*state), 1);
    out_block = malloc(out_block_size);
    if (state == NULL || out_block == NULL) {
        free(out_block);
        free(state);
        archive_set_error(&self->archive->archive, ENOMEM,
                          "Can't allocate data for %s decompression",
                          self->name);
        return (ARCHIVE_FATAL);
    }

    self->data = state;
    state->out_block_size = out_block_size;
    state->out_block = out_block;
    self->read = compress_filter_read;
    self->skip = NULL; /* not supported */
    self->close = compress_filter_close;

    /* XXX MOVE THE FOLLOWING OUT OF INIT() XXX */

    (void)getbits(self, 8); /* Skip first signature byte. */
    (void)getbits(self, 8); /* Skip second signature byte. */

    code = getbits(self, 8);
    state->maxcode_bits = code & 0x1f;
    state->maxcode = (1 << state->maxcode_bits);
    state->use_reset_code = code & 0x80;

    /* Initialize decompressor. */
    state->free_ent = 256;
    state->stackp = state->stack;
    if (state->use_reset_code)
        state->free_ent++;
    state->bits = 9;
    state->section_end_code = (1<<state->bits) - 1;
    state->oldcode = -1;
    for (code = 255; code >= 0; code--) {
        state->prefix[code] = 0;
        state->suffix[code] = code;
    }
    next_code(self);

    return (ARCHIVE_OK);
}
Ejemplo n.º 19
0
Archivo: larc.c Proyecto: yoheie/lha
/* lzs */
unsigned short
decode_c_lzs( /*void*/ )
{
    if (getbits(1)) {
        return getbits(8);
    }
    else {
        matchpos = getbits(11);
        return getbits(4) + 0x100;
    }
}
Ejemplo n.º 20
0
void group_of_pictures_header()
{
  zprintf(1, "\ngroup_start_code = 0x000001%02X\n", getbits(8));
  zprintf(2, "  drop_frame_flag = %d\n", get1bit());
  zprintf(2, "  time_code_hours = %d\n", getbits(5));
  zprintf(2, "  time_code_minutes = %d\n", getbits(6));
  zprintf(2, "  marker_bit = %d\n", get1bit());
  zprintf(2, "  time_code_seconds = %d\n", getbits(6));
  zprintf(2, "  time_code_pictures = %d\n", getbits(6));
  zprintf(2, "  closed_gop = %d\n", get1bit());
  zprintf(2, "  broken_link = %d\n", get1bit());
  next_start_code();
}
Ejemplo n.º 21
0
void picture_spatial_scalable_extension()
{
  zprintf(1, "  picture_spatial_scalable_extension_id = %01X\n", getbits(4));
  zprintf(2, "  lower_layer_temporal_reference = %d\n", getbits(10));
  zprintf(2, "  marker bit = %d\n", get1bit());
  zprintf(2, "  lower_layer_horizontal_offset = %d\n", getbits(15));
  zprintf(2, "  marker bit = %d\n", get1bit());
  zprintf(2, "  lower_layer_vertical_offset = %d\n", getbits(15));
  zprintf(2, "  spatial_temporal_weight_code_table_index = %d\n", getbits(2));
  zprintf(2, "  lower_layer_progressive_frame = %d\n", get1bit());
  zprintf(2, "  lower_layer_deinterlaced_field_select = %d\n", get1bit());
  next_start_code();
}
Ejemplo n.º 22
0
/* decode gps/qzss almanac ---------------------------------------------------*/
static void decode_almanac(const unsigned char *buff, int sat, alm_t *alm)
{
    gtime_t toa;
    double deltai,sqrtA,tt;
    int i=50,f0;
    
    trace(4,"decode_almanac: sat=%2d\n",sat);
    
    if (!alm||alm[sat-1].week==0) return;
    
    alm[sat-1].sat =sat;
    alm[sat-1].e   =getbits(buff,i,16)*P2_21;        i+=16;
    alm[sat-1].toas=getbitu(buff,i, 8)*4096.0;       i+= 8;
    deltai         =getbits(buff,i,16)*P2_19*SC2RAD; i+=16;
    alm[sat-1].OMGd=getbits(buff,i,16)*P2_38*SC2RAD; i+=16;
    alm[sat-1].svh =getbitu(buff,i, 8);              i+= 8;
    sqrtA          =getbitu(buff,i,24)*P2_11;        i+=24;
    alm[sat-1].OMG0=getbits(buff,i,24)*P2_23*SC2RAD; i+=24;
    alm[sat-1].omg =getbits(buff,i,24)*P2_23*SC2RAD; i+=24;
    alm[sat-1].M0  =getbits(buff,i,24)*P2_23*SC2RAD; i+=24;
    f0             =getbitu(buff,i, 8);              i+= 8;
    alm[sat-1].f1  =getbits(buff,i,11)*P2_38;        i+=11;
    alm[sat-1].f0  =getbits(buff,i, 3)*P2_17+f0*P2_20;
    alm[sat-1].A   =sqrtA*sqrtA;
    alm[sat-1].i0  =0.3*SC2RAD+deltai;
    
    toa=gpst2time(alm[sat-1].week,alm[sat-1].toas);
    tt=timediff(toa,alm[sat-1].toa);
    if      (tt<302400.0) alm[sat-1].week--;
    else if (tt>302400.0) alm[sat-1].week++;
    alm[sat-1].toa=gpst2time(alm[sat-1].week,alm[sat-1].toas);
}
Ejemplo n.º 23
0
/* decode ionosphere correction field (ref [1] 5.7.2.2.1.3) ------------------*/
static int decode_lexion(const unsigned char *buff, int i, gtime_t tof,
                         nav_t *nav)
{
    lexion_t ion={{0}};
    int tow,week;
    
    trace(3,"decode_lexion: tof=%s\n",time_str(tof,0));
    
    tow=getbitu(buff,i,20); i+=20;
    
    if (tow==0xFFFFF) { /* correction not available */
        return i+192;
    }
    week=getbitu(buff,i,13); i+=13;
    ion.t0=gpst2time(week,tow);
    ion.tspan     =getbitu(buff,i, 8)*60.0; i+= 8; /* time span (s) */
    ion.pos0[0]   =getbits(buff,i,19)*1E-5; i+=19; /* latitude  (rad) */
    ion.pos0[1]   =getbits(buff,i,20)*1E-5; i+=20; /* longitude (rad) */
    ion.coef[0][0]=getbits(buff,i,22)*1E-3; i+=22;
    ion.coef[1][0]=getbits(buff,i,22)*1E-2; i+=22;
    ion.coef[2][0]=getbits(buff,i,22)*1E-2; i+=22;
    ion.coef[0][1]=getbits(buff,i,22)*1E-2; i+=22;
    ion.coef[1][1]=getbits(buff,i,22)*1E-2; i+=22;
    ion.coef[2][1]=getbits(buff,i,22)*1E-1; i+=22;
    nav->lexion=ion;
    
    trace(4,"t0=%s tspan=%.0f pos0=%.1f %.1f coef=%.3f %.3f %.3f %.3f %.3f %.3f\n",
          time_str(ion.t0,0),ion.tspan,ion.pos0[0]*R2D,ion.pos0[1]*R2D,
          ion.coef[0][0],ion.coef[1][0],ion.coef[2][0],ion.coef[0][1],
          ion.coef[1][1],ion.coef[2][1]);
    return i;
}
Ejemplo n.º 24
0
/* decode gps/qzss navigation data subframe 3 --------------------------------*/
static int decode_subfrm3(const unsigned char *buff, eph_t *eph)
{
    double tow,toc;
    int i=48,iode;
    
    trace(4,"decode_subfrm3:\n");
    trace(5,"decode_subfrm3: buff="); traceb(5,buff,30);
    
    eph->cic =getbits(buff,i,16)*P2_29;        i+=16;
    eph->OMG0=getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->cis =getbits(buff,i,16)*P2_29;        i+=16;
    eph->i0  =getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->crc =getbits(buff,i,16)*P2_5;         i+=16;
    eph->omg =getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->OMGd=getbits(buff,i,24)*P2_43*SC2RAD; i+=24;
    iode     =getbitu(buff,i, 8);              i+= 8;
    eph->idot=getbits(buff,i,14)*P2_43*SC2RAD;
    
    /* check iode and iodc consistency */
    if (iode!=eph->iode||iode!=(eph->iodc&0xFF)) return 0;
    
    /* adjustment for week handover */
    tow=time2gpst(eph->ttr,&eph->week);
    toc=time2gpst(eph->toc,NULL);
    if      (eph->toes<tow-302400.0) {eph->week++; tow-=604800.0;}
    else if (eph->toes>tow+302400.0) {eph->week--; tow+=604800.0;}
    eph->toe=gpst2time(eph->week,eph->toes);
    eph->toc=gpst2time(eph->week,toc);
    eph->ttr=gpst2time(eph->week,tow);
    
    return 3;
}
Ejemplo n.º 25
0
static int
unpackech2(EiceChain2 *ec2, Chain *ch)
{

	getbits(&ec2->data, ch, DataSz);
	getbits(&ec2->addr, ch, AddrSz);
	getbits(&ec2->rw, ch, RWSz);

	if(!valregaddr(ec2->addr))
		return -1;

	ec2->data = lehgetl(&ec2->data);

	return 0;
}
Ejemplo n.º 26
0
static int64_t get_pts(unsigned char * packet)
{
	int64_t pts;
	int pts_dts_flag;

	pts_dts_flag = getbits(packet, 7*8, 2);
	if ((pts_dts_flag == 2) || (pts_dts_flag == 3)) {
		pts = (uint64_t)getbits(packet, 9*8+4, 3) << 30;  /* PTS[32..30] */
		pts |= getbits(packet, 10*8, 15) << 15;           /* PTS[29..15] */
		pts |= getbits(packet, 12*8, 15);                 /* PTS[14..0] */
	} else {
		pts = 0;
	}
	return pts;
}
Ejemplo n.º 27
0
main(){
    int r= getbits(0xdddd,10,3);
    printf("%d\n",r);
    int r1= setbits(0xffff,10,8,0x4444);
    printf("%d  %d",r1,0xffff);

} 
Ejemplo n.º 28
0
void extension_data(int i)
{
  while (nextbits(8) == EXTENSION_START_CODE)
  {
    zprintf(1, "\nextension_start_code = 0x000001%02X\n", getbits(8));
    if (i == 0)
    {
      if (nextbits(4) == SEQUENCE_DISPLAY_EXTENSION_ID)
        sequence_display_extension();
      if (nextbits(4) == SEQUENCE_SCALABLE_EXTENSION_ID)
        sequence_scalable_extension();
    }
    if (i == 2)
    {
      if (nextbits(4) == QUANT_MATRIX_EXTENSION_ID)
        quant_matrix_extension();
      if (nextbits(4) == PICTURE_DISPLAY_EXTENSION_ID)
        picture_display_extension();
      if (nextbits(4) == PICTURE_SPATIAL_SCALABLE_EXTENSION_ID)
        picture_spatial_scalable_extension();
      if (nextbits(4) == PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID)
        picture_temporal_scalable_extension();
    }
  }
}
Ejemplo n.º 29
0
extern int32_t getbits2(const uint8_t *buff, int p1, int l1, int p2, int l2)
{
    if (getbitu(buff,p1,1))
        return (int32_t)((getbits(buff,p1,l1)<<l2)+getbitu(buff,p2,l2));
    else
        return (int32_t)getbitu2(buff,p1,l1,p2,l2);
}
Ejemplo n.º 30
0
static void
make_instruction (void)
{
  int i;
  unsigned int shift;

  for (i = 0; i < currInsn.nargs; i++)
    {
      argument a;

      memset (&a, 0, sizeof (a));
      a.type = getargtype (instruction->operands[i].op_type);
      if (instruction->operands[i].op_type == cst4
	  || instruction->operands[i].op_type == rbase_dispu4)
	cst4flag = 1;
      a.size = getbits (instruction->operands[i].op_type);
      shift = instruction->operands[i].shift;

      make_argument (&a, shift);
      currInsn.arg[i] = a;
    }

  /* Calculate instruction size (in bytes).  */
  currInsn.size = instruction->size + (size_changed ? 1 : 0);
  /* Now in bits.  */
  currInsn.size *= 2;
}