Commit 6d0a90d142 for ffmpeg
commit 6d0a90d1427e9df83e25697e8093a29518e63948
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Thu Dec 3 00:29:26 2026 -0600
avcodec/parser: add avpriv_parser_full_picture()
It tells whether a decoder given every frame the parser was given would
output the last one as a full picture, as after a recovery point.
A parser reports it through an FFCodecParser callback, so that a
demuxer can find where a key frame recovers without parsing the
bitstream itself.
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index cf5d65ee16..f64446b68e 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -303,3 +303,10 @@ av_cold void ff_parse_close(AVCodecParserContext *s)
av_freep(&pc->buffer);
}
+
+int avpriv_parser_full_picture(const AVCodecParserContext *s)
+{
+ const FFCodecParser *parser = ffcodecparser(s->parser);
+
+ return parser->full_picture ? parser->full_picture(s) : -1;
+}
diff --git a/libavcodec/parser.h b/libavcodec/parser.h
index 2cee5ae4ff..262a6ba72b 100644
--- a/libavcodec/parser.h
+++ b/libavcodec/parser.h
@@ -55,4 +55,13 @@ void ff_parse_close(AVCodecParserContext *s);
*/
void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy);
+/**
+ * Whether a decoder given every frame the parser was given would output the
+ * last one as a full picture.
+ *
+ * @return 1 when it would, 0 while a recovery point is pending, -1 when the
+ * parser does not know
+ */
+int avpriv_parser_full_picture(const AVCodecParserContext *s);
+
#endif /* AVCODEC_PARSER_H */
diff --git a/libavcodec/parser_internal.h b/libavcodec/parser_internal.h
index d0e0c8beb5..71d2ec77ef 100644
--- a/libavcodec/parser_internal.h
+++ b/libavcodec/parser_internal.h
@@ -33,6 +33,10 @@ typedef struct FFCodecParser {
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size);
void (*close)(AVCodecParserContext *s);
+ /**
+ * @see avpriv_parser_full_picture()
+ */
+ int (*full_picture)(const AVCodecParserContext *s);
} FFCodecParser;
static inline const FFCodecParser *ffcodecparser(const AVCodecParser *parser)