mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-12 02:04:58 +00:00
mpegts: add and use mpegts_get_dts()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
04ac0d7994
commit
de9862a95e
@ -1760,6 +1760,33 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
|
||||
return AV_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
|
||||
int64_t *ppos, int64_t pos_limit)
|
||||
{
|
||||
MpegTSContext *ts = s->priv_data;
|
||||
int64_t pos, timestamp;
|
||||
pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47;
|
||||
ff_read_frame_flush(s);
|
||||
if (avio_seek(s->pb, pos, SEEK_SET) < 0)
|
||||
return AV_NOPTS_VALUE;
|
||||
while(pos < pos_limit) {
|
||||
int ret;
|
||||
AVPacket pkt;
|
||||
av_init_packet(&pkt);
|
||||
ret= av_read_frame(s, &pkt);
|
||||
if(ret < 0)
|
||||
return AV_NOPTS_VALUE;
|
||||
av_free_packet(&pkt);
|
||||
if(pkt.stream_index == stream_index && pkt.dts != AV_NOPTS_VALUE){
|
||||
*ppos= pkt.pos;
|
||||
return pkt.dts;
|
||||
}
|
||||
pos = pkt.pos;
|
||||
}
|
||||
|
||||
return AV_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
#ifdef USE_SYNCPOINT_SEARCH
|
||||
|
||||
static int read_seek2(AVFormatContext *s,
|
||||
@ -1853,7 +1880,8 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, in
|
||||
|
||||
if(av_seek_frame_binary(s, stream_index, target_ts, flags) < 0)
|
||||
return -1;
|
||||
|
||||
ff_read_frame_flush(s);
|
||||
return 0;
|
||||
pos= avio_tell(s->pb);
|
||||
|
||||
for(;;) {
|
||||
@ -1936,7 +1964,7 @@ AVInputFormat ff_mpegts_demuxer = {
|
||||
.read_packet = mpegts_read_packet,
|
||||
.read_close = mpegts_read_close,
|
||||
.read_seek = read_seek,
|
||||
.read_timestamp = mpegts_get_pcr,
|
||||
.read_timestamp = mpegts_get_dts,
|
||||
.flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
|
||||
#ifdef USE_SYNCPOINT_SEARCH
|
||||
.read_seek2 = read_seek2,
|
||||
@ -1951,7 +1979,7 @@ AVInputFormat ff_mpegtsraw_demuxer = {
|
||||
.read_packet = mpegts_raw_read_packet,
|
||||
.read_close = mpegts_read_close,
|
||||
.read_seek = read_seek,
|
||||
.read_timestamp = mpegts_get_pcr,
|
||||
.read_timestamp = mpegts_get_dts,
|
||||
.flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
|
||||
#ifdef USE_SYNCPOINT_SEARCH
|
||||
.read_seek2 = read_seek2,
|
||||
|
@ -1,53 +1,53 @@
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st:-1 flags:0 ts:-1.000000
|
||||
ret: 0 st: 0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st:-1 flags:1 ts: 1.894167
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 0 flags:0 dts: 1.880000 pts: 1.920000 pos: 216012 size: 17441
|
||||
ret: 0 st: 0 flags:0 ts: 0.788333
|
||||
ret: 0 st: 0 flags:0 dts: 1.520000 pts: 1.560000 pos: 74260 size: 13388
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st: 0 flags:1 ts:-0.317500
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st: 1 flags:0 ts: 2.576667
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 1 flags:1 ts: 1.470833
|
||||
ret: 0 st: 0 flags:0 dts: 2.160000 pts: 2.200000 pos: 325240 size: 12679
|
||||
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
|
||||
ret: 0 st:-1 flags:0 ts: 0.365002
|
||||
ret: 0 st: 0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st:-1 flags:1 ts:-0.740831
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st: 0 flags:0 ts: 2.153333
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 0 flags:0 dts: 2.160000 pts: 2.200000 pos: 325240 size: 12679
|
||||
ret: 0 st: 0 flags:1 ts: 1.047500
|
||||
ret: 0 st: 0 flags:0 dts: 1.680000 pts: 1.720000 pos: 130096 size: 14133
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st: 1 flags:0 ts:-0.058333
|
||||
ret: 0 st: 0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
|
||||
ret: 0 st: 1 flags:1 dts: 1.765711 pts: 1.765711 pos: 322232 size: 209
|
||||
ret: 0 st: 1 flags:1 ts: 2.835833
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st:-1 flags:0 ts: 1.730004
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
|
||||
ret: 0 st:-1 flags:1 ts: 0.624171
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st: 0 flags:0 ts:-0.481667
|
||||
ret: 0 st: 0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st: 0 flags:1 ts: 2.412500
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 1 flags:0 ts: 1.306667
|
||||
ret: 0 st: 0 flags:0 dts: 2.080000 pts: 2.120000 pos: 294032 size: 13839
|
||||
ret: 0 st: 1 flags:1 dts: 1.765711 pts: 1.765711 pos: 322232 size: 209
|
||||
ret: 0 st: 1 flags:1 ts: 0.200844
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
|
||||
ret: 0 st:-1 flags:0 ts:-0.904994
|
||||
ret: 0 st: 0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st:-1 flags:1 ts: 1.989173
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 0 flags:0 dts: 1.960000 pts: 2.000000 pos: 250980 size: 13438
|
||||
ret: 0 st: 0 flags:0 ts: 0.883344
|
||||
ret: 0 st: 0 flags:0 dts: 1.600000 pts: 1.640000 pos: 102836 size: 12781
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st: 0 flags:1 ts:-0.222489
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
ret: 0 st: 1 flags:0 ts: 2.671678
|
||||
ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
|
||||
ret: 0 st: 1 flags:1 ts: 1.565844
|
||||
ret: 0 st: 0 flags:0 dts: 2.240000 pts: 2.280000 pos: 350996 size: 11307
|
||||
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
|
||||
ret: 0 st:-1 flags:0 ts: 0.460008
|
||||
ret: 0 st: 0 flags:0 dts: 1.440000 pts: 1.480000 pos: 44932 size: 14502
|
||||
ret: 0 st: 0 flags:0 dts: 1.400000 pts: 1.440000 pos: 27072 size: 16433
|
||||
ret: 0 st:-1 flags:1 ts:-0.645825
|
||||
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
|
||||
|
Loading…
Reference in New Issue
Block a user