diff mbox

[FFmpeg-devel,3/4,v2] avcodec/libx265: export encoded frame stats

Message ID 20191230192009.2462-3-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Dec. 30, 2019, 7:20 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
No changes.

 libavcodec/libx265.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Derek Buitenhuis Dec. 30, 2019, 11:06 p.m. UTC | #1
On 30/12/2019 19:20, James Almer wrote:
> +    ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type);

Does multiplying by FF_QP2LAMBDA even make sense here? That contsant
is for H.263's QP scale, not HEVC's.

- Derek
diff mbox

Patch

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 9646e208f4..a97bf19e91 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -484,6 +484,7 @@  static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     x265_picture x265pic_out = { 0 };
     x265_nal *nal;
     uint8_t *dst;
+    int pict_type;
     int payload = 0;
     int nnal;
     int ret;
@@ -543,20 +544,23 @@  static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     pkt->pts = x265pic_out.pts;
     pkt->dts = x265pic_out.dts;
 
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
     switch (x265pic_out.sliceType) {
     case X265_TYPE_IDR:
     case X265_TYPE_I:
-        avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+        pict_type = AV_PICTURE_TYPE_I;
         break;
     case X265_TYPE_P:
-        avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+        pict_type = AV_PICTURE_TYPE_P;
         break;
     case X265_TYPE_B:
-        avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+    case X265_TYPE_BREF:
+        pict_type = AV_PICTURE_TYPE_B;
         break;
     }
+
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+    avctx->coded_frame->pict_type = pict_type;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
@@ -567,6 +571,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
 #endif
         pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
 
+    ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type);
+
     *got_packet = 1;
     return 0;
 }