On Mon, 17 May 2021, Timo Rothenpieler wrote:
On 17.05.2021 10:19, Brad Hards wrote:
Signed-off-by: Brad Hards <br...@frogmouth.net>
---
libavcodec/nvenc.c | 64 ++++++++++++++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 11 deletions(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0dcd93a99c..e22fdfb5a8 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2170,9 +2170,10 @@ static int nvenc_send_frame(AVCodecContext *avctx,
const AVFrame *frame)
NVENCSTATUS nv_status;
NvencSurface *tmp_out_surf, *in_surf;
int res, res2;
- NV_ENC_SEI_PAYLOAD sei_data[8];
+ NV_ENC_SEI_PAYLOAD *sei_data = 0;
int sei_count = 0;
int i;
+ int total_unregistered_sei = 0;
NvencContext *ctx = avctx->priv_data;
NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;
@@ -2185,6 +2186,8 @@ static int nvenc_send_frame(AVCodecContext *avctx,
const AVFrame *frame)
return AVERROR(EINVAL);
if (frame && frame->buf[0]) {
+ void *a53_data = NULL;
+ void *tc_data = NULL;
in_surf = get_free_frame(ctx);
if (!in_surf)
return AVERROR(EAGAIN);
@@ -2230,7 +2233,6 @@ static int nvenc_send_frame(AVCodecContext *avctx,
const AVFrame *frame)
pic_params.inputTimeStamp = frame->pts;
if (ctx->a53_cc && av_frame_get_side_data(frame,
AV_FRAME_DATA_A53_CC)) {
- void *a53_data = NULL;
size_t a53_size = 0;
if (ff_alloc_a53_sei(frame, 0, (void**)&a53_data,
&a53_size) < 0) {
@@ -2238,15 +2240,21 @@ static int nvenc_send_frame(AVCodecContext *avctx,
const AVFrame *frame)
}
if (a53_data) {
- sei_data[sei_count].payloadSize = (uint32_t)a53_size;
- sei_data[sei_count].payloadType = 4;
- sei_data[sei_count].payload = (uint8_t*)a53_data;
- sei_count ++;
+ sei_data = av_realloc_array(sei_data, sei_count + 1,
sizeof(NV_ENC_SEI_PAYLOAD));
Doing this realloc dance every frame is extremely inefficient.
The sei_data array and its current size could instead be stored in the nvenc
context, with a best-guess initial size, and then only grow when the already
allocated size is too small.
Don't we have av_fast_realloc for this?
Thanks,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".