mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2026-04-22 23:17:48 +08:00
lavc/rkmppenc: add support for reporting average QP
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
@@ -938,7 +938,9 @@ static int rkmpp_get_packet(AVCodecContext *avctx, AVPacket *packet, int timeout
|
||||
MppMeta mpp_meta = NULL;
|
||||
MppFrame mpp_frame = NULL;
|
||||
MppBuffer mpp_buf = NULL;
|
||||
int ret, key_frame = 0;
|
||||
int key_frame = 0;
|
||||
int avg_qp = -1;
|
||||
int ret;
|
||||
|
||||
if ((ret = r->mapi->control(r->mctx, MPP_SET_OUTPUT_TIMEOUT, (MppParam)&timeout)) != MPP_OK) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to set output timeout: %d\n", ret);
|
||||
@@ -988,6 +990,12 @@ static int rkmpp_get_packet(AVCodecContext *avctx, AVPacket *packet, int timeout
|
||||
if (key_frame)
|
||||
packet->flags |= AV_PKT_FLAG_KEY;
|
||||
|
||||
mpp_meta_get_s32(mpp_meta, KEY_ENC_AVERAGE_QP, &avg_qp);
|
||||
if (avg_qp >= 0)
|
||||
ff_side_data_set_encoder_stats(packet, avg_qp * FF_QP2LAMBDA, NULL, 0,
|
||||
(packet->flags & AV_PKT_FLAG_KEY) ?
|
||||
AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P);
|
||||
|
||||
if ((ret = mpp_meta_get_frame(mpp_meta, KEY_INPUT_FRAME, &mpp_frame)) != MPP_OK) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to get key input frame from packet meta: %d\n", ret);
|
||||
ret = AVERROR_EXTERNAL;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "encode.h"
|
||||
#include "hwconfig.h"
|
||||
#include "internal.h"
|
||||
#include "packet_internal.h"
|
||||
|
||||
#include "libavutil/hwcontext_rkmpp.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
Reference in New Issue
Block a user