The generic code in utils.c sets the AVFrame.pkt_dts field from the
packet it was supposedly decoded. This does not have to be true for a
fully asynchronous decoder like mmaldec. It could be overwritten with an
incorrect value. Even if the decoder doesn't determine the DTS (but sets
it to AV_NOPTS_VALUE), it's impossible to determine a correct value in
utils.c.
Decoders can now be marked with AV_CODEC_CAP_DECODER_SETS_PKT_DTS, in
which case utils.c won't overwrite the field. The decoders are expected
to set this field (even if they only set it to AV_NOPTS_VALUE).
The new codec cap is not useful to API users, and exists only to work
around internal libavcodec issues. Declare it private API. I've still
put it into the public header to avoid that the constant is
accidentally used twice.
---
libavcodec/internal.h | 5 +++++
libavcodec/utils.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index fc90632..16e25bb 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -134,6 +134,11 @@ typedef struct AVCodecInternal {
* hwaccel-specific private data
*/
void *hwaccel_priv_data;
+
+ /**
+ * whether the decoder sets AVFrame.pkt_dts itself
+ */
+ int sets_pkt_dts;
} AVCodecInternal;
struct AVCodecDefault {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1d718b2..9d472a0 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1482,7 +1482,8 @@ int attribute_align_arg
avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
else {
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
avpkt);
- picture->pkt_dts = avpkt->dts;
+ if (!avctx->internal->sets_pkt_dts)
+ picture->pkt_dts = avpkt->dts;
/* get_buffer is supposed to set frame parameters */
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
--
2.5.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel