Revision cc6a39bf Chunkiser/input-stream-avs.c

View differences:

Chunkiser/input-stream-avs.c
22 22
  int frames_since_global_headers;
23 23
};
24 24

  
25
#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
26

  
27
static void video_header_fill(uint8_t *data, AVStream *st)
28
{
29
  int num, den;
30

  
31
  data[0] = 1;
32
  data[1] = st->codec->width >> 8;
33
  data[2] = st->codec->width & 0xFF;
34
  data[3] = st->codec->height >> 8;
35
  data[4] = st->codec->height & 0xFF;
36
  num = st->avg_frame_rate.num;
37
  den = st->avg_frame_rate.den;
38
//fprintf(stderr, "Rate: %d/%d\n", num, den);
39
  if (num == 0) {
40
    num = st->r_frame_rate.num;
41
    den = st->r_frame_rate.den;
42
  }
43
  if (num > (1 << 16)) {
44
    num /= 1000;
45
    den /= 1000;
46
  }
47
  data[5] = num >> 8;
48
  data[6] = num & 0xFF;
49
  data[7] = den >> 8;
50
  data[8] = den & 0xFF;
51
} 
52

  
25 53
struct input_stream *input_stream_open(const char *fname, int *period, uint16_t flags)
26 54
{
27 55
  struct input_stream *desc;
......
188 216
    }
189 217

  
190 218
    if (s->s->streams[pkt.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) {
191
      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
219
      header_size = VIDEO_PAYLOAD_HEADER_SIZE;
192 220
    }
193 221
    header_out = (pkt.flags & PKT_FLAG_KEY) != 0;
194 222
    if (header_out == 0) {
......
207 235
      return NULL;
208 236
    }
209 237
    if (s->s->streams[pkt.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) {
210
      int num, den;
211

  
212
      data[0] = 1;
213
      data[1] = s->s->streams[pkt.stream_index]->codec->width >> 8;
214
      data[2] = s->s->streams[pkt.stream_index]->codec->width & 0xFF;
215
      data[3] = s->s->streams[pkt.stream_index]->codec->height >> 8;
216
      data[4] = s->s->streams[pkt.stream_index]->codec->height & 0xFF;
217
      num = s->s->streams[pkt.stream_index]->avg_frame_rate.num;
218
      den = s->s->streams[pkt.stream_index]->avg_frame_rate.den;
219
//fprintf(stderr, "Rate: %d/%d\n", num, den);
220
      if (num == 0) {
221
        num = s->s->streams[pkt.stream_index]->r_frame_rate.num;
222
        den = s->s->streams[pkt.stream_index]->r_frame_rate.den;
223
      }
224
      if (num > (1 << 16)) {
225
        num /= 1000;
226
        den /= 1000;
227
      }
228
      data[5] = num >> 8;
229
      data[6] = num & 0xFF;
230
      data[7] = den >> 8;
231
      data[8] = den & 0xFF;
232
      data[9] = 1;
233
      data[10] = (*size - header_size - 2) >> 8;
234
      data[11] = (*size - header_size - 2) & 0xFF;
238
      video_header_fill(data, s->s->streams[pkt.stream_index]);
235 239
    }
240
    data[9] = 1;
241
    data[10] = (*size - header_size - 2) >> 8;
242
    data[11] = (*size - header_size - 2) & 0xFF;
243

  
236 244
    if (header_out && s->s->streams[pkt.stream_index]->codec->extradata_size) {
237 245
      memcpy(data + header_size + 2, s->s->streams[pkt.stream_index]->codec->extradata, s->s->streams[pkt.stream_index]->codec->extradata_size);
238 246
      memcpy(data + header_size + 2 + s->s->streams[pkt.stream_index]->codec->extradata_size, pkt.data, pkt.size);

Also available in: Unified diff