Statistics
| Branch: | Revision:

streamers / payload.h @ 421c2dc2

History | View | Annotate | Download (866 Bytes)

1
#define VIDEO_PAYLOAD_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
2
#define FRAME_HEADER_SIZE (3 + 4 + 1)        // 3 Frame size + 4 PTS + 1 DeltaTS
3

    
4
static inline void frame_header_parse(const uint8_t *data, int *size, int32_t *pts, int32_t *dts)
5
{
6
  int i;
7

    
8
  *size = 0;
9
  for (i = 0; i < 3; i++) {
10
    *size = *size << 8;
11
    *size |= data[i];
12
  }
13
  *pts = 0;
14
  for (i = 0; i < 4; i++) {
15
    *pts = *pts << 8;
16
    *pts |= data[3 + i];
17
  }
18
  *dts = *pts - data[7];
19
}
20

    
21
static inline void payload_header_parse(const uint8_t *data, uint8_t *codec, int *width, int *height, int *frame_rate_n, int *frame_rate_d)
22
{
23
  *codec = data[0];
24
  *width = data[1] << 8 | data[2];
25
  *height = data[3] << 8 | data[4];
26
  *frame_rate_n = data[5] << 8 | data[6];
27
  *frame_rate_d = data[7] << 8 | data[8];
28
}