Revision 69ae8acb

View differences:

Chunkiser/input-stream-avs.c
90 90
  if (fps.num == 0) {
91 91
    fps = st->r_frame_rate;
92 92
  }
93
  pts = av_rescale_q(pkt->pts, st->time_base, (AVRational){fps.den, fps.num}),
94
  pts += av_rescale_q(base_ts, AV_TIME_BASE_Q, (AVRational){fps.den, fps.num});
93
  if (pkt->pts != AV_NOPTS_VALUE) {
94
    pts = av_rescale_q(pkt->pts, st->time_base, (AVRational){fps.den, fps.num}),
95
    pts += av_rescale_q(base_ts, AV_TIME_BASE_Q, (AVRational){fps.den, fps.num});
96
  } else {
97
    pts = -1;
98
  }
95 99
  dprintf("pkt->pts=%ld PTS=%d",pkt->pts, pts);
96
  dts = av_rescale_q(pkt->dts, st->time_base, (AVRational){fps.den, fps.num});
97
  dts += av_rescale_q(base_ts, AV_TIME_BASE_Q, (AVRational){fps.den, fps.num});
100
  if (pkt->dts != AV_NOPTS_VALUE) {
101
    dts = av_rescale_q(pkt->dts, st->time_base, (AVRational){fps.den, fps.num});
102
    dts += av_rescale_q(base_ts, AV_TIME_BASE_Q, (AVRational){fps.den, fps.num});
103
  } else {
104
    fprintf(stderr, "No DTS???\n");
105
    dts = 0;
106
  }
98 107
  dprintf(" DTS=%d\n",dts);
99 108
  frame_header_write(data, size, pts, dts);
100 109
}
out-stream-avf.c
122 122
    frame_header_parse(data + header_size + FRAME_HEADER_SIZE * i,
123 123
                       &frame_size, &pts, &dts);
124 124
    dprintf("Frame %d PTS1: %d\n", i, pts);
125
    pts += (pts < prev_pts - (1 << 15)) ? ((prev_pts >> 16) + 1) << 16 : (prev_pts >> 16) << 16;
126
    dprintf(" PTS2: %d\n", pts);
127
    prev_pts = pts;
128
    dts += (dts < prev_dts - (1 << 15)) ? ((prev_dts >> 16) + 1) << 16 : (prev_dts >> 16) << 16;
129
    prev_dts = dts;
130
    dprintf("Frame %d has size %d --- PTS: %lld DTS: %lld\n", i, frame_size,
131
                                             av_rescale_q(pts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q),
132
                                             av_rescale_q(dts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q));
133 125
    av_init_packet(&pkt);
134 126
    pkt.stream_index = 0;	// FIXME!
135
    pkt.pts = av_rescale_q(pts, outctx->streams[0]->codec->time_base, outctx->streams[0]->time_base);
127
    if (pts != -1) {
128
      pts += (pts < prev_pts - (1 << 15)) ? ((prev_pts >> 16) + 1) << 16 : (prev_pts >> 16) << 16;
129
      dprintf(" PTS2: %d\n", pts);
130
      prev_pts = pts;
131
      dts += (dts < prev_dts - (1 << 15)) ? ((prev_dts >> 16) + 1) << 16 : (prev_dts >> 16) << 16;
132
      prev_dts = dts;
133
      dprintf("Frame %d has size %d --- PTS: %lld DTS: %lld\n", i, frame_size,
134
                                             av_rescale_q(pts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q),
135
                                             av_rescale_q(dts, outctx->streams[0]->codec->time_base, AV_TIME_BASE_Q));
136
      pkt.pts = av_rescale_q(pts, outctx->streams[0]->codec->time_base, outctx->streams[0]->time_base);
137
    } else {
138
      pkt.pts = AV_NOPTS_VALUE;
139
    }
136 140
    pkt.dts = av_rescale_q(dts, outctx->streams[0]->codec->time_base, outctx->streams[0]->time_base);
137 141
    pkt.data = p;
138 142
    p += frame_size;
payload.h
10 10
    *size = *size << 8;
11 11
    *size |= data[i];
12 12
  }
13
  *pts = 0;
13
  *dts = 0;
14 14
  for (i = 0; i < 4; i++) {
15
    *pts = *pts << 8;
16
    *pts |= data[3 + i];
15
    *dts = *dts << 8;
16
    *dts |= data[3 + i];
17
  }
18
  if (data[7] != 255) {
19
    *pts = *dts + data[7];
20
  } else {
21
    *pts = -1;
17 22
  }
18
  *dts = *pts - data[7];
19 23
}
20 24

  
21 25
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)
......
45 49
  data[0] = size >> 16;
46 50
  data[1] = size >> 8;
47 51
  data[2] = size & 0xFF;
48
  data[3] = pts >> 24;
49
  data[4] = pts >> 16;
50
  data[5] = pts >> 8;
51
  data[6] = pts & 0xFF;
52
  data[7] = (pts - dts) & 0xFF;
52
  data[3] = dts >> 24;
53
  data[4] = dts >> 16;
54
  data[5] = dts >> 8;
55
  data[6] = dts & 0xFF;
56
  if (pts != -1) {
57
    data[7] = (pts - dts) & 0xFF;
58
  } else {
59
    data[7] = 255;
60
  }
53 61
}

Also available in: Unified diff