[FFmpeg-devel] [PATCH 1/2] avcodec/parser: fix fetch_timestamp in a scenario with unaligned packets
Nicolas Gaullier
nicolas.gaullier at cji.paris
Tue Feb 20 18:33:01 EET 2024
Fix fetch_timestamp when the frame start is in a previous packet.
Signed-off-by: Nicolas Gaullier <nicolas.gaullier at cji.paris>
---
libavcodec/parser.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index efc28b8918..853b5323b0 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -153,11 +153,11 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
}
if (s->fetch_timestamp) {
- s->fetch_timestamp = 0;
s->last_pts = s->pts;
s->last_dts = s->dts;
s->last_pos = s->pos;
- ff_fetch_timestamp(s, 0, 0, 0);
+ ff_fetch_timestamp(s, FFMIN(s->fetch_timestamp, 0), 0, 0);
+ s->fetch_timestamp = 0;
}
/* WARNING: the returned index can be negative */
index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,
@@ -179,7 +179,7 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
/* offset of the next frame */
s->next_frame_offset = s->cur_offset + index;
- s->fetch_timestamp = 1;
+ s->fetch_timestamp = index >= 0 ? 1 : index;
} else {
/* Don't return a pointer to dummy_buf. */
*poutbuf = NULL;
--
2.30.2
More information about the ffmpeg-devel
mailing list