Revision fabb990e libavformat/ffmdec.c

View differences:

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;

Also available in: Unified diff