Revision fabb990e

View differences:

libavformat/ffm.h
48 48
    int first_packet; /* true if first packet, needed to set the discontinuity tag */
49 49
    int packet_size;
50 50
    int frame_offset;
51
    int64_t pts;
51
    int64_t dts;
52 52
    uint8_t *packet_ptr, *packet_end;
53 53
    uint8_t packet[FFM_PACKET_SIZE];
54 54
} FFMContext;
libavformat/ffmdec.c
99 99
    retry_read:
100 100
            get_be16(pb); /* PACKET_ID */
101 101
            fill_size = get_be16(pb);
102
            ffm->pts = get_be64(pb);
102
            ffm->dts = get_be64(pb);
103 103
            frame_offset = get_be16(pb);
104 104
            get_buffer(pb, ffm->packet, ffm->packet_size - FFM_HEADER_SIZE);
105 105
            ffm->packet_end = ffm->packet + (ffm->packet_size - FFM_HEADER_SIZE - fill_size);
......
156 156
    url_fseek(pb, pos, SEEK_SET);
157 157
}
158 158

  
159
static int64_t get_pts(AVFormatContext *s, offset_t pos)
159
static int64_t get_dts(AVFormatContext *s, offset_t pos)
160 160
{
161 161
    ByteIOContext *pb = s->pb;
162
    int64_t pts;
162
    int64_t dts;
163 163

  
164 164
    ffm_seek1(s, pos);
165 165
    url_fskip(pb, 4);
166
    pts = get_be64(pb);
166
    dts = get_be64(pb);
167 167
#ifdef DEBUG_SEEK
168 168
    av_log(s, AV_LOG_DEBUG, "pts=%0.6f\n", pts / 1000000.0);
169 169
#endif
170
    return pts;
170
    return dts;
171 171
}
172 172

  
173 173
static void adjust_write_index(AVFormatContext *s)
......
184 184
    pos_min = 0;
185 185
    pos_max = ffm->file_size - 2 * FFM_PACKET_SIZE;
186 186

  
187
    pts_start = get_pts(s, pos_min);
187
    pts_start = get_dts(s, pos_min);
188 188

  
189
    pts = get_pts(s, pos_max);
189
    pts = get_dts(s, pos_max);
190 190

  
191 191
    if (pts - 100000 > pts_start)
192 192
        goto end;
193 193

  
194 194
    ffm->write_index = FFM_PACKET_SIZE;
195 195

  
196
    pts_start = get_pts(s, pos_min);
196
    pts_start = get_dts(s, pos_min);
197 197

  
198
    pts = get_pts(s, pos_max);
198
    pts = get_dts(s, pos_max);
199 199

  
200 200
    if (pts - 100000 <= pts_start) {
201 201
        while (1) {
......
207 207
            if (newpos == pos_min)
208 208
                break;
209 209

  
210
            newpts = get_pts(s, newpos);
210
            newpts = get_dts(s, newpos);
211 211

  
212 212
            if (newpts - 100000 <= pts) {
213 213
                pos_max = newpos;
......
220 220
    }
221 221

  
222 222
    //printf("Adjusted write index from %"PRId64" to %"PRId64": pts=%0.6f\n", orig_write_index, ffm->write_index, pts / 1000000.);
223
    //printf("pts range %0.6f - %0.6f\n", get_pts(s, 0) / 1000000. , get_pts(s, ffm->file_size - 2 * FFM_PACKET_SIZE) / 1000000. );
223
    //printf("pts range %0.6f - %0.6f\n", get_dts(s, 0) / 1000000. , get_dts(s, ffm->file_size - 2 * FFM_PACKET_SIZE) / 1000000. );
224 224

  
225 225
 end:
226 226
    url_fseek(pb, ptr, SEEK_SET);
......
337 337
    ffm->packet_ptr = ffm->packet;
338 338
    ffm->packet_end = ffm->packet;
339 339
    ffm->frame_offset = 0;
340
    ffm->pts = 0;
340
    ffm->dts = 0;
341 341
    ffm->read_state = READ_HEADER;
342 342
    ffm->first_packet = 1;
343 343
    return 0;
......
431 431
    pos_min = 0;
432 432
    pos_max = ffm->file_size - 2 * FFM_PACKET_SIZE;
433 433
    while (pos_min <= pos_max) {
434
        pts_min = get_pts(s, pos_min);
435
        pts_max = get_pts(s, pos_max);
434
        pts_min = get_dts(s, pos_min);
435
        pts_max = get_dts(s, pos_max);
436 436
        /* linear interpolation */
437 437
        pos1 = (double)(pos_max - pos_min) * (double)(wanted_pts - pts_min) /
438 438
            (double)(pts_max - pts_min);
......
441 441
            pos = pos_min;
442 442
        else if (pos >= pos_max)
443 443
            pos = pos_max;
444
        pts = get_pts(s, pos);
444
        pts = get_dts(s, pos);
445 445
        /* check if we are lucky */
446 446
        if (pts == wanted_pts) {
447 447
            goto found;
libavformat/ffmenc.c
37 37
    /* put header */
38 38
    put_be16(pb, PACKET_ID);
39 39
    put_be16(pb, fill_size);
40
    put_be64(pb, ffm->pts);
40
    put_be64(pb, ffm->dts);
41 41
    h = ffm->frame_offset;
42 42
    if (ffm->first_packet)
43 43
        h |= 0x8000;
......
54 54
/* 'first' is true if first data of a frame */
55 55
static void ffm_write_data(AVFormatContext *s,
56 56
                           const uint8_t *buf, int size,
57
                           int64_t pts, int header)
57
                           int64_t dts, int header)
58 58
{
59 59
    FFMContext *ffm = s->priv_data;
60 60
    int len;
61 61

  
62 62
    if (header && ffm->frame_offset == 0) {
63 63
        ffm->frame_offset = ffm->packet_ptr - ffm->packet + FFM_HEADER_SIZE;
64
        ffm->pts = pts;
64
        ffm->dts = dts;
65 65
    }
66 66

  
67 67
    /* write as many packets as needed */
......
180 180
    ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE;
181 181
    assert(ffm->packet_end >= ffm->packet);
182 182
    ffm->frame_offset = 0;
183
    ffm->pts = 0;
183
    ffm->dts = 0;
184 184
    ffm->first_packet = 1;
185 185

  
186 186
    return 0;

Also available in: Unified diff