You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/utils: Pass the next pts/dts to compute_pkt_fields() when available
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -974,7 +974,8 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
|
static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
|
||||||
AVCodecParserContext *pc, AVPacket *pkt)
|
AVCodecParserContext *pc, AVPacket *pkt,
|
||||||
|
int64_t next_dts, int64_t next_pts)
|
||||||
{
|
{
|
||||||
int num, den, presentation_delayed, delay, i;
|
int num, den, presentation_delayed, delay, i;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
@@ -1176,11 +1177,13 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
|
|||||||
got_output = 1;
|
got_output = 1;
|
||||||
} else if (!size && st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
} else if (!size && st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
||||||
// preserve 0-size sync packets
|
// preserve 0-size sync packets
|
||||||
compute_pkt_fields(s, st, st->parser, pkt);
|
compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (size > 0 || (pkt == &flush_pkt && got_output)) {
|
while (size > 0 || (pkt == &flush_pkt && got_output)) {
|
||||||
int len;
|
int len;
|
||||||
|
int64_t next_pts = pkt->pts;
|
||||||
|
int64_t next_dts = pkt->dts;
|
||||||
|
|
||||||
av_init_packet(&out_pkt);
|
av_init_packet(&out_pkt);
|
||||||
len = av_parser_parse2(st->parser, st->codec,
|
len = av_parser_parse2(st->parser, st->codec,
|
||||||
@@ -1233,7 +1236,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
|
|||||||
if (st->parser->key_frame == -1 && st->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
|
if (st->parser->key_frame == -1 && st->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
|
||||||
out_pkt.flags |= AV_PKT_FLAG_KEY;
|
out_pkt.flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
||||||
compute_pkt_fields(s, st, st->parser, &out_pkt);
|
compute_pkt_fields(s, st, st->parser, &out_pkt, next_dts, next_pts);
|
||||||
|
|
||||||
if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) {
|
if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) {
|
||||||
out_pkt.buf = pkt->buf;
|
out_pkt.buf = pkt->buf;
|
||||||
@@ -1352,7 +1355,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
|
|||||||
if (!st->need_parsing || !st->parser) {
|
if (!st->need_parsing || !st->parser) {
|
||||||
/* no parsing needed: we just output the packet as is */
|
/* no parsing needed: we just output the packet as is */
|
||||||
*pkt = cur_pkt;
|
*pkt = cur_pkt;
|
||||||
compute_pkt_fields(s, st, NULL, pkt);
|
compute_pkt_fields(s, st, NULL, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
|
||||||
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
|
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
|
||||||
(pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {
|
(pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {
|
||||||
ff_reduce_index(s, st->index);
|
ff_reduce_index(s, st->index);
|
||||||
|
Reference in New Issue
Block a user