You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
lavc: allow asynchronous decoders to return correct pkt_dts values
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 FF_CODEC_CAP_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). Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
@@ -46,7 +46,13 @@
|
|||||||
* all.
|
* all.
|
||||||
*/
|
*/
|
||||||
#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1)
|
#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1)
|
||||||
|
/**
|
||||||
|
* Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set
|
||||||
|
* AVFrame.pkt_dts manually. If the flag is set, utils.c won't overwrite
|
||||||
|
* this field. If it's unset, utils.c tries to guess the pkt_dts field
|
||||||
|
* from the input AVPacket.
|
||||||
|
*/
|
||||||
|
#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__)
|
# define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__)
|
||||||
|
@@ -792,6 +792,7 @@ AVCodec ff_h264_mmal_decoder = {
|
|||||||
.flush = ffmmal_flush,
|
.flush = ffmmal_flush,
|
||||||
.priv_class = &ffmmaldec_class,
|
.priv_class = &ffmmaldec_class,
|
||||||
.capabilities = AV_CODEC_CAP_DELAY,
|
.capabilities = AV_CODEC_CAP_DELAY,
|
||||||
|
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL,
|
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL,
|
||||||
AV_PIX_FMT_YUV420P,
|
AV_PIX_FMT_YUV420P,
|
||||||
AV_PIX_FMT_NONE},
|
AV_PIX_FMT_NONE},
|
||||||
|
@@ -1482,6 +1482,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
|
|||||||
else {
|
else {
|
||||||
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
|
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
|
||||||
avpkt);
|
avpkt);
|
||||||
|
if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
|
||||||
picture->pkt_dts = avpkt->dts;
|
picture->pkt_dts = avpkt->dts;
|
||||||
/* get_buffer is supposed to set frame parameters */
|
/* get_buffer is supposed to set frame parameters */
|
||||||
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
|
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
|
||||||
|
Reference in New Issue
Block a user