diff options
author | James Almer <jamrial@gmail.com> | 2020-05-19 21:55:13 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-05-20 01:12:17 +0300 |
commit | 74dfc88b638f0c3768aee090054bb2fc41e8ae04 (patch) | |
tree | 117859c34783a90c6eae75dbe47a48f7efc021b6 /libavcodec/libx265.c | |
parent | 050b72ab5ef318605b305aa6cb920e8b52f1002e (diff) |
avcodec/libx265: add support for reordered_opaque
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libx265.c')
-rw-r--r-- | libavcodec/libx265.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 573ecc8cb0..821175c1b6 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -504,6 +504,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ret = libx265_encode_set_roi(ctx, pic, &x265pic); if (ret < 0) return ret; + + if (pic->reordered_opaque) { + x265pic.userData = av_malloc(sizeof(pic->reordered_opaque)); + if (!x265pic.userData) { + av_freep(&x265pic.quantOffsets); + return AVERROR(ENOMEM); + } + + memcpy(x265pic.userData, &pic->reordered_opaque, sizeof(pic->reordered_opaque)); + } } ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, @@ -570,6 +580,12 @@ FF_ENABLE_DEPRECATION_WARNINGS ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type); + if (x265pic_out.userData) { + memcpy(&avctx->reordered_opaque, x265pic_out.userData, sizeof(avctx->reordered_opaque)); + av_freep(&x265pic_out.userData); + } else + avctx->reordered_opaque = 0; + *got_packet = 1; return 0; } @@ -683,6 +699,7 @@ AVCodec ff_libx265_encoder = { .priv_data_size = sizeof(libx265Context), .priv_class = &class, .defaults = x265_defaults, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .wrapper_name = "libx265", }; |