Revision 9c45209f Chunkiser/input-stream-avs.c

View differences:

Chunkiser/input-stream-avs.c
15 15
  int audio_stream;
16 16
  int video_stream;
17 17
  int64_t last_ts;
18
  int frames_since_global_headers;
18 19
};
19 20

  
20 21
struct input_stream *input_stream_open(const char *fname, int *period)
......
45 46
  desc->video_stream = -1;
46 47
  desc->audio_stream = -1;
47 48
  desc->last_ts = 0;
49
  desc->frames_since_global_headers = 0;
48 50
  for (i = 0; i < desc->s->nb_streams; i++) {
49 51
    if (desc->video_stream == -1 && desc->s->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) {
50 52
      desc->video_stream = i;
......
160 162
      return NULL;
161 163
    }
162 164
    header_out = (pkt.flags & PKT_FLAG_KEY) != 0;
163
    header_out = ((id % HEADER_REFRESH_PERIOD) == 0);
165
    if (header_out == 0) {
166
      s->frames_since_global_headers++;
167
      if (s->frames_since_global_headers == HEADER_REFRESH_PERIOD) {
168
        s->frames_since_global_headers = 0;
169
        header_out = 1;
170
      }
171
    }
164 172
    *size = pkt.size + s->s->streams[pkt.stream_index]->codec->extradata_size * header_out;
165 173
    data = malloc(*size);
166 174
    if (data == NULL) {

Also available in: Unified diff