Revision 74ff12bb out-stream.c

View differences:

out-stream.c
9 9

  
10 10
void chunk_write(int id, const uint8_t *data, int size)
11 11
{
12
  const int header_size = 1 + 2 + 2 + 1 + 2; // 1 Frame type + 2 width + 2 height + 1 number of frames + 2 frame len
13
  int width, height, frames;
12
  const int header_size = 1 + 2 + 2 + 2 + 2 + 1; // 1 Frame type + 2 width + 2 height + 2 frame rate num + 2 frame rate den + 1 number of frames
13
  int width, height, frame_rate_n, frame_rate_d, frames;
14 14
  int i;
15 15

  
16 16
  if (data[0] != 1) {
17
    fprintf(stderr, "Error! Non video chunk!!!\n");
17
    fprintf(stderr, "Error! Non video chunk: %x!!!\n", data[0]);
18 18
    return;
19 19
  }
20 20
  width = data[1] << 8 | data[2];
21 21
  height = data[3] << 8 | data[4];
22
  dprintf("Frame size: %dx%d\n", width, height);
23
  frames = data[5];
22
  frame_rate_n = data[5] << 8 | data[6];
23
  frame_rate_d = data[7] << 8 | data[8];
24
  dprintf("Frame size: %dx%d -- Frame rate: %d / %d\n", width, height, frame_rate_n, frame_rate_d);
25
  frames = data[9];
24 26
  for (i = 0; i < frames; i++) {
25
    dprintf("Frame %d has size %d\n", i, data[6 + 2 * i] << 8 | data[7 + 2 * i]);
27
    dprintf("Frame %d has size %d\n", i, data[10 + 2 * i] << 8 | data[11 + 2 * i]);
26 28
  }
27 29
#ifdef DEBUG
28 30
#define buff_size 8 // HACK!
29
  fprintf(stderr, "\tOut Chunk[%d] - %d: %s\n", id, id % buff_size, data + header_size);
31
  fprintf(stderr, "\tOut Chunk[%d] - %d: %s\n", id, id % buff_size, data + header_size + frames * 2);
30 32
#else
31
  write(outfd, data + header_size, size - header_size);
33
  write(outfd, data + header_size + frames * 2, size - header_size - frames * 2);
32 34
#endif
33 35
}

Also available in: Unified diff