diff options
author | agalin89 <[email protected]> | 2020-03-05 20:54:16 +0000 |
---|---|---|
committer | Scott <[email protected]> | 2020-03-08 18:16:12 +0000 |
commit | bd6cd008363cdc39837a21fa11611d816beb9b78 (patch) | |
tree | 04546f134d593d31564d00d26a12510c236118e5 /libhb | |
parent | c121bf7c797218d4ba90b23c2c31d0eea0c64692 (diff) |
qsv: decrease memory footprint
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/handbrake/qsv_common.h | 4 | ||||
-rw-r--r-- | libhb/qsv_common.c | 67 |
2 files changed, 4 insertions, 67 deletions
diff --git a/libhb/handbrake/qsv_common.h b/libhb/handbrake/qsv_common.h index 99685ae34..611762fa6 100644 --- a/libhb/handbrake/qsv_common.h +++ b/libhb/handbrake/qsv_common.h @@ -231,7 +231,6 @@ typedef struct QSVFrame { typedef struct EncQSVFramesContext { AVBufferRef *hw_frames_ctx; - AVBufferRef *hw_frames_ctx2; //void *logctx; /* The memory ids for the external frames. @@ -239,12 +238,9 @@ typedef struct EncQSVFramesContext { * (i.e. by the encoder/decoder) and another one given to the MFX session * from the frame allocator. */ AVBufferRef *mids_buf; - AVBufferRef *mids_buf2; QSVMid *mids; - QSVMid *mids2; int nb_mids; int pool[HB_POOL_SURFACE_SIZE]; - int pool2[HB_POOL_SURFACE_SIZE]; void *input_texture; } EncQSVFramesContext; diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c index 5d667c908..d5f73c543 100644 --- a/libhb/qsv_common.c +++ b/libhb/qsv_common.c @@ -2549,16 +2549,8 @@ int hb_qsv_replace_surface_mid(const QSVMid *mid, mfxFrameSurface1 *surface) int ret = hb_qsv_find_surface_idx(hb_enc_qsv_frames_ctx.mids, hb_enc_qsv_frames_ctx.nb_mids, mid); if (ret < 0) { - ret = hb_qsv_find_surface_idx(hb_enc_qsv_frames_ctx.mids2, hb_enc_qsv_frames_ctx.nb_mids, mid); - if (ret < 0) - { - hb_error("encqsv: Surface with MemId=%p has not been found in the pool\n", mid); - return -1; - } - else - { - surface->Data.MemId = &hb_enc_qsv_frames_ctx.mids2[ret]; - } + hb_error("encqsv: Surface with MemId=%p has not been found in the pool\n", mid); + return -1; } else { @@ -2572,16 +2564,8 @@ int hb_qsv_release_surface_from_pool(const QSVMid *mid) int ret = hb_qsv_find_surface_idx(hb_enc_qsv_frames_ctx.mids, hb_enc_qsv_frames_ctx.nb_mids, mid); if (ret < 0) { - ret = hb_qsv_find_surface_idx(hb_enc_qsv_frames_ctx.mids2, hb_enc_qsv_frames_ctx.nb_mids, mid); - if (ret < 0) - { - hb_error("encqsv: Surface with MemId=%p has not been found in the pool\n", mid); - return -1; - } - else - { - ff_qsv_atomic_dec(&hb_enc_qsv_frames_ctx.pool2[ret]); - } + hb_error("encqsv: Surface with MemId=%p has not been found in the pool\n", mid); + return -1; } else { @@ -2598,9 +2582,6 @@ void hb_qsv_get_free_surface_from_pool(const int start_index, const int end_inde AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hb_enc_qsv_frames_ctx.hw_frames_ctx->data; AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; - AVHWFramesContext *frames_ctx2 = (AVHWFramesContext*)hb_enc_qsv_frames_ctx.hw_frames_ctx2->data; - AVQSVFramesContext *frames_hwctx2 = frames_ctx2->hwctx; - // find the first available surface in the pool int count = 0; while(1) @@ -2627,22 +2608,6 @@ void hb_qsv_get_free_surface_from_pool(const int start_index, const int end_inde } } - for(int i = start_index; i < end_index; i++) - { - if(hb_enc_qsv_frames_ctx.pool2[i] == 0) - { - mid = &hb_enc_qsv_frames_ctx.mids2[i]; - output_surface = &frames_hwctx2->surfaces[i]; - if(output_surface->Data.Locked == 0) - { - *out_mid = mid; - *out_surface = output_surface; - ff_qsv_atomic_inc(&hb_enc_qsv_frames_ctx.pool2[i]); - return; - } - } - } - count++; } } @@ -2884,38 +2849,14 @@ static int qsv_init(AVCodecContext *s) if (!enc_hw_frames_ctx) return AVERROR(ENOMEM); - hb_enc_qsv_frames_ctx.hw_frames_ctx2 = enc_hw_frames_ctx; - frames_ctx = (AVHWFramesContext*)enc_hw_frames_ctx->data; - frames_hwctx = frames_ctx->hwctx; - - frames_ctx->width = FFALIGN(s->coded_width, 32); - frames_ctx->height = FFALIGN(s->coded_height, 32); - frames_ctx->format = AV_PIX_FMT_QSV; - frames_ctx->sw_format = s->sw_pix_fmt; - frames_ctx->initial_pool_size = HB_POOL_SURFACE_SIZE; - frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; - - ret = av_hwframe_ctx_init(enc_hw_frames_ctx); - if (ret < 0) { - hb_error("qsv_init: av_hwframe_ctx_init failed %d", ret); - return ret; - } - /* allocate the memory ids for the external frames */ av_buffer_unref(&hb_enc_qsv_frames_ctx.mids_buf); hb_enc_qsv_frames_ctx.mids_buf = hb_qsv_create_mids(hb_enc_qsv_frames_ctx.hw_frames_ctx); if (!hb_enc_qsv_frames_ctx.mids_buf) return AVERROR(ENOMEM); - av_buffer_unref(&hb_enc_qsv_frames_ctx.mids_buf2); - hb_enc_qsv_frames_ctx.mids_buf2 = hb_qsv_create_mids(hb_enc_qsv_frames_ctx.hw_frames_ctx2); - if (!hb_enc_qsv_frames_ctx.mids_buf2) - return AVERROR(ENOMEM); - hb_enc_qsv_frames_ctx.mids = (QSVMid*)hb_enc_qsv_frames_ctx.mids_buf->data; - hb_enc_qsv_frames_ctx.mids2 = (QSVMid*)hb_enc_qsv_frames_ctx.mids_buf2->data; hb_enc_qsv_frames_ctx.nb_mids = frames_hwctx->nb_surfaces; memset(hb_enc_qsv_frames_ctx.pool, 0, hb_enc_qsv_frames_ctx.nb_mids * sizeof(hb_enc_qsv_frames_ctx.pool[0])); - memset(hb_enc_qsv_frames_ctx.pool2, 0, hb_enc_qsv_frames_ctx.nb_mids * sizeof(hb_enc_qsv_frames_ctx.pool2[0])); return 0; } |