Revision 74ff12bb Chunkiser/input-stream-avs.c

View differences:

Chunkiser/input-stream-avs.c
188 188
    }
189 189

  
190 190
    if (s->s->streams[pkt.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) {
191
      header_size = 1 + 2 + 2 + 1 + 2; // 1 Frame type + 2 width + 2 height + 1 number of frames + 2 frame len
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
192 192
    }
193 193
    header_out = (pkt.flags & PKT_FLAG_KEY) != 0;
194 194
    if (header_out == 0) {
......
198 198
        header_out = 1;
199 199
      }
200 200
    }
201
    *size = pkt.size + s->s->streams[pkt.stream_index]->codec->extradata_size * header_out + header_size;
201
    *size = pkt.size + s->s->streams[pkt.stream_index]->codec->extradata_size * header_out + header_size + 2;
202 202
    data = malloc(*size);
203 203
    if (data == NULL) {
204 204
      *size = -1;
......
207 207
      return NULL;
208 208
    }
209 209
    if (s->s->streams[pkt.stream_index]->codec->codec_type == CODEC_TYPE_VIDEO) {
210
      int num, den;
211

  
210 212
      data[0] = 1;
211 213
      data[1] = s->s->streams[pkt.stream_index]->codec->width >> 8;
212 214
      data[2] = s->s->streams[pkt.stream_index]->codec->width & 0xFF;
213 215
      data[3] = s->s->streams[pkt.stream_index]->codec->height >> 8;
214 216
      data[4] = s->s->streams[pkt.stream_index]->codec->height & 0xFF;
215
      data[5] = 1;
216
      data[6] = (*size - header_size) >> 8;
217
      data[7] = (*size - header_size) & 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;
218 235
    }
219 236
    if (header_out && s->s->streams[pkt.stream_index]->codec->extradata_size) {
220
      memcpy(data + header_size, s->s->streams[pkt.stream_index]->codec->extradata, s->s->streams[pkt.stream_index]->codec->extradata_size);
221
      memcpy(data + header_size + s->s->streams[pkt.stream_index]->codec->extradata_size, pkt.data, pkt.size);
237
      memcpy(data + header_size + 2, s->s->streams[pkt.stream_index]->codec->extradata, s->s->streams[pkt.stream_index]->codec->extradata_size);
238
      memcpy(data + header_size + 2 + s->s->streams[pkt.stream_index]->codec->extradata_size, pkt.data, pkt.size);
222 239
    } else {
223
      memcpy(data + header_size, pkt.data, pkt.size);
240
      memcpy(data + header_size + 2, pkt.data, pkt.size);
224 241
    }
225 242
    *ts = av_rescale_q(pkt.dts, s->s->streams[pkt.stream_index]->time_base, AV_TIME_BASE_Q);
226 243
    *ts += s->base_ts;

Also available in: Unified diff