Revision 529d08a9 out-stream-avf.c

View differences:

out-stream-avf.c
13 13
static const char *output_format = "nut";
14 14
static const char *output_file = "/dev/stdout";
15 15

  
16
static int64_t prev_pts, prev_dts;
17

  
16 18
static enum CodecID libav_codec_id(uint8_t mytype)
17 19
{
18 20
  switch (mytype) {
......
81 83
  of->streams[0]->avg_frame_rate.den = frame_rate_d;
82 84
  c->pix_fmt = PIX_FMT_YUV420P;
83 85

  
86
  prev_pts = 0;
87
  prev_dts = 0;
88

  
84 89
  return of;
85 90
}
86 91

  
......
116 121

  
117 122
    frame_size = data[10 + (2 + 2 + 2) * i] << 8 | data[11 + (2 + 2 + 2) * i];
118 123
    pts = data[12 + (2 + 2 + 2) * i] << 8 | data[13 + (2 + 2 + 2) * i];
124
    pts += (pts < prev_pts - (1 << 15)) ? ((prev_pts >> 16) + 1) << 16 : (prev_pts >> 16) << 16;
125
    prev_pts = pts;
119 126
    dts = data[14 + (2 + 2 + 2) * i] << 8 | data[15 + (2 + 2 + 2) * i];
127
    dts += (dts < prev_dts - (1 << 15)) ? ((prev_dts >> 16) + 1) << 16 : (prev_dts >> 16) << 16;
128
    prev_dts = dts;
120 129
    dprintf("Frame %d has size %d --- PTS: %lld DTS: %lld\n", i, frame_size,
121 130
                                             av_rescale_q(pts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q),
122 131
                                             av_rescale_q(dts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q));

Also available in: Unified diff