[FFmpeg-devel] [PATCH 2/6] avcodec: add FF_CODEC_CAP_SETS_PKT_POS
Michael Niedermayer
michael at niedermayer.cc
Sat Aug 24 21:18:25 EEST 2019
Suggested-by: James Almer <jamrial at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavcodec/decode.c | 2 +-
libavcodec/internal.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index cf9676e2ac..5976da78c8 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -434,7 +434,7 @@ static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
frame->pkt_dts = pkt->dts;
if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
- if(!avctx->has_b_frames)
+ if(!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_POS) && !avctx->has_b_frames)
frame->pkt_pos = pkt->pos;
//FIXME these should be under if(!avctx->has_b_frames)
/* get_buffer is supposed to set frame parameters */
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 5f964148fd..f9e87eacc6 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -68,6 +68,13 @@
* Codec initializes slice-based threading with a main function
*/
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5)
+/**
+ * Decoders marked with FF_CODEC_CAP_SETS_PKT_POS want to set
+ * AVFrame.pkt_pos manually. If the flag is set, decode.c won't overwrite
+ * this field. If it's unset, decode.c tries to guess the pkt_pos field
+ * from the input AVPacket.
+ */
+#define FF_CODEC_CAP_SETS_PKT_POS (1 << 6)
#ifdef TRACE
# define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
--
2.23.0
More information about the ffmpeg-devel
mailing list