Skip to content

Commit

Permalink
mpegts-mythtv.c: harmonize functions 1g mpegts_get_dts
Browse files Browse the repository at this point in the history
partial harmonize, pos47 -> pos47_full change not done
  • Loading branch information
ulmus-scott authored and bennettpeter committed Aug 15, 2022
1 parent 941b0d7 commit 74e01be
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c
Expand Up @@ -3611,30 +3611,36 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index,
int64_t *ppos, int64_t pos_limit)
{
MpegTSContext *ts = s->priv_data;
AVPacket *pkt;
int64_t pos;
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;
pkt = av_packet_alloc();
if (!pkt)
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)
int ret = av_read_frame(s, pkt);
if (ret < 0) {
av_packet_free(&pkt);
return AV_NOPTS_VALUE;
av_free_packet(&pkt);
if(pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0){
ff_reduce_index(s, pkt.stream_index);
av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
if(pkt.stream_index == stream_index){
*ppos= pkt.pos;
return pkt.dts;
}
if (pkt->dts != AV_NOPTS_VALUE && pkt->pos >= 0) {
ff_reduce_index(s, pkt->stream_index);
av_add_index_entry(s->streams[pkt->stream_index], pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
if (pkt->stream_index == stream_index && pkt->pos >= *ppos) {
int64_t dts = pkt->dts;
*ppos = pkt->pos;
av_packet_free(&pkt);
return dts;
}
}
pos = pkt.pos;
pos = pkt->pos;
av_packet_unref(pkt);
}

av_packet_free(&pkt);
return AV_NOPTS_VALUE;
}

Expand Down

0 comments on commit 74e01be

Please sign in to comment.