Ejemplo n.º 1
0
/* (Re)initialize the hash table. Should be locked. */
static int
BCMINITFN(nvram_rehash)(struct nvram_header *header)
{
	char buf[] = "0xXXXXXXXX", *name, *value, *end, *eq;
	struct nvram_header *hdrptr;
	/* (Re)initialize hash table */
	nvram_free();

	hdrptr = header;

	/* Parse and set "name=value\0 ... \0\0" */
	name = (char *) &hdrptr[1];
	end = (char *) hdrptr + NVRAM_SPACE - 2;
	end[0] = end[1] = '\0';

again:
	for (; *name; name = value + strlen(value) + 1) {
		if (!(eq = strchr(name, '=')))
			break;
		*eq = '\0';
		value = eq + 1;
		_nvram_set(name, value);
		*eq = '=';
	}

printk("rehash %x %x\n", header, name);
{
	int j;

	for(j=0;j<64;j++) {
		if(j%16==0) printk("\n");
		printk("%x ", *(name-32+j));
	}
	printk("\n");
}
	hdrptr = find_next_header(header, name+2);

	if(hdrptr)
		printk("magic: %x\n", hdrptr->magic);

	if(hdrptr && hdrptr->magic==NVRAM_MAGIC) {
		name = (char *)&hdrptr[1];
		goto again;
	}

	/* Set special SDRAM parameters */
	if (!_nvram_get("sdram_init")) {
		sprintf(buf, "0x%04X", (uint16)(header->crc_ver_init >> 16));
		_nvram_set("sdram_init", buf);
	}
Ejemplo n.º 2
0
static int next_packet_flac(bgav_demuxer_context_t * ctx)
  {
  int pos, size;
  bgav_stream_t * s;
  bgav_packet_t * p;
  bgav_flac_frame_header_t next_fh;
  
  flac_priv_t * priv = ctx->priv;
  
  s = bgav_track_find_stream(ctx, 0);

  if(!s)
    return 0;

  if(ctx->next_packet_pos)
    {
    size = ctx->next_packet_pos - ctx->input->position;
    if(ctx->input->position + size > ctx->input->total_bytes)
      size = ctx->input->total_bytes - ctx->input->position;
    }
  else
    {
    if(!priv->has_sync)
      {
      pos = find_next_header(ctx, 0, &next_fh);
      if(pos < 0)
        return 0;

      if(pos > 0)
        bgav_bytebuffer_remove(&priv->buf, pos);

      memcpy(&priv->this_fh, &next_fh, sizeof(next_fh));
    
      priv->has_sync = 1;
      }
  
    /* Get next header */
    pos = find_next_header(ctx, BGAV_FLAC_FRAMEHEADER_MIN, &next_fh);

    //  if(pos < 0)
    //  fprintf(stderr, "pos < 0!!\n");
  
    if(pos < 0) // EOF
      size = priv->buf.size;
    else
      size = pos;

    if((pos < 0) && !size)
      return 0;
    }
  
  p = bgav_stream_get_packet_write(s);
  bgav_packet_alloc(p, size);

  if(ctx->next_packet_pos)
    {
    if(bgav_input_read_data(ctx->input, p->data, size) < size)
      return 0;
    p->position = ctx->input->position - size;

    if(!bgav_flac_frame_header_read(p->data, size,
                                    &priv->streaminfo, &priv->this_fh))
      return 0;
    }
  else
    {
    memcpy(p->data, priv->buf.buffer, size);
    p->position = ctx->input->position - priv->buf.size;
    bgav_bytebuffer_remove(&priv->buf, size);
    }
  
  //  p->pts = fh.sample_number;
  
  p->duration = priv->this_fh.blocksize;
  p->pts = priv->pts;

  //  fprintf(stderr, "Duration: %ld ", p->duration);
  
  if(priv->streaminfo.total_samples &&
     (p->pts < priv->streaminfo.total_samples) &&
     (p->pts + p->duration > priv->streaminfo.total_samples))
    {
    p->duration = priv->streaminfo.total_samples - p->pts;
    }
  // fprintf(stderr, "Packet pts %ld sn: %ld dur: %ld pos: %ld\n",
  // p->pts, priv->this_fh.sample_number, p->duration, p->position);

  //  fprintf(stderr, "%ld\n", p->duration);
  
  priv->pts += p->duration;
  p->data_size = size;
  
  //  memcpy(&priv->fh, &fh, sizeof(fh));

//  bgav_packet_dump(p);
  
  bgav_stream_done_packet_write(s, p);

  if(!ctx->next_packet_pos)
    {
    /* Save frame header for later use */
    memcpy(&priv->this_fh, &next_fh, sizeof(next_fh));
    }
  
  return 1;
  }