summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-07-12 14:37:15 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-23 16:50:33 +0200
commit06c941a5eb19cd6c0ccb3611b591f9d13ce7394c (patch)
tree6f30ae4c908d61cdd94df533029dbf33af5ef4f1
parentccb919f86cb5c046f7453400db10feb23c6ce483 (diff)
lavc/libaomenc: pass through frame durations to encoded packets
-rw-r--r--libavcodec/libaomenc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 1fd69d59a7..2ca829222a 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -1093,6 +1093,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
}
memcpy(pkt->data, cx_frame->buf, pkt->size);
pkt->pts = pkt->dts = cx_frame->pts;
+ pkt->duration = cx_frame->duration;
if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) {
pkt->flags |= AV_PKT_FLAG_KEY;
@@ -1271,6 +1272,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
AOMContext *ctx = avctx->priv_data;
struct aom_image *rawimg = NULL;
int64_t timestamp = 0;
+ unsigned long duration = 0;
int res, coded_size;
aom_enc_frame_flags_t flags = 0;
@@ -1283,6 +1285,8 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
rawimg->stride[AOM_PLANE_U] = frame->linesize[1];
rawimg->stride[AOM_PLANE_V] = frame->linesize[2];
timestamp = frame->pts;
+ duration = frame->duration ? frame->duration :
+ avctx->ticks_per_frame;
switch (frame->color_range) {
case AVCOL_RANGE_MPEG:
rawimg->range = AOM_CR_STUDIO_RANGE;
@@ -1296,8 +1300,7 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
flags |= AOM_EFLAG_FORCE_KF;
}
- res = aom_codec_encode(&ctx->encoder, rawimg, timestamp,
- avctx->ticks_per_frame, flags);
+ res = aom_codec_encode(&ctx->encoder, rawimg, timestamp, duration, flags);
if (res != AOM_CODEC_OK) {
log_encoder_error(avctx, "Error encoding frame");
return AVERROR_INVALIDDATA;