From: Tong Wu <tong1...@intel.com>

Signed-off-by: Tong Wu <tong1...@intel.com>
---
 libavcodec/hw_base_encode.h |  4 ++++
 libavcodec/vaapi_encode.c   | 22 +++++++++++-----------
 libavcodec/vaapi_encode.h   |  4 ----
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h
index 1f6d7882bc..3eea3ef998 100644
--- a/libavcodec/hw_base_encode.h
+++ b/libavcodec/hw_base_encode.h
@@ -134,6 +134,10 @@ typedef struct HWBaseEncodeContext {
     AVBufferRef    *input_frames_ref;
     AVHWFramesContext *input_frames;
 
+    // The hardware frame context containing the reconstructed frames.
+    AVBufferRef    *recon_frames_ref;
+    AVHWFramesContext *recon_frames;
+
     // Current encoding window, in display (input) order.
     HWBaseEncodePicture *pic_start, *pic_end;
     // The next picture to use as the previous reference picture in
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 993b2640a9..8640a888b7 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -314,7 +314,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
 
     av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
 
-    err = av_hwframe_get_buffer(ctx->recon_frames_ref, base_pic->recon_image, 
0);
+    err = av_hwframe_get_buffer(base_ctx->recon_frames_ref, 
base_pic->recon_image, 0);
     if (err < 0) {
         err = AVERROR(ENOMEM);
         goto fail;
@@ -2149,19 +2149,19 @@ static av_cold int 
vaapi_encode_create_recon_frames(AVCodecContext *avctx)
     av_freep(&hwconfig);
     av_hwframe_constraints_free(&constraints);
 
-    ctx->recon_frames_ref = av_hwframe_ctx_alloc(base_ctx->device_ref);
-    if (!ctx->recon_frames_ref) {
+    base_ctx->recon_frames_ref = av_hwframe_ctx_alloc(base_ctx->device_ref);
+    if (!base_ctx->recon_frames_ref) {
         err = AVERROR(ENOMEM);
         goto fail;
     }
-    ctx->recon_frames = (AVHWFramesContext*)ctx->recon_frames_ref->data;
+    base_ctx->recon_frames = 
(AVHWFramesContext*)base_ctx->recon_frames_ref->data;
 
-    ctx->recon_frames->format    = AV_PIX_FMT_VAAPI;
-    ctx->recon_frames->sw_format = recon_format;
-    ctx->recon_frames->width     = ctx->surface_width;
-    ctx->recon_frames->height    = ctx->surface_height;
+    base_ctx->recon_frames->format    = AV_PIX_FMT_VAAPI;
+    base_ctx->recon_frames->sw_format = recon_format;
+    base_ctx->recon_frames->width     = ctx->surface_width;
+    base_ctx->recon_frames->height    = ctx->surface_height;
 
-    err = av_hwframe_ctx_init(ctx->recon_frames_ref);
+    err = av_hwframe_ctx_init(base_ctx->recon_frames_ref);
     if (err < 0) {
         av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed "
                "frame context: %d.\n", err);
@@ -2269,7 +2269,7 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
     if (err < 0)
         goto fail;
 
-    recon_hwctx = ctx->recon_frames->hwctx;
+    recon_hwctx = base_ctx->recon_frames->hwctx;
     vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
                           ctx->surface_width, ctx->surface_height,
                           VA_PROGRESSIVE,
@@ -2404,7 +2404,7 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
     av_freep(&ctx->codec_picture_params);
     av_fifo_freep2(&base_ctx->encode_fifo);
 
-    av_buffer_unref(&ctx->recon_frames_ref);
+    av_buffer_unref(&base_ctx->recon_frames_ref);
     av_buffer_unref(&base_ctx->input_frames_ref);
     av_buffer_unref(&base_ctx->device_ref);
 
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index 0d3d8e2ed0..76fb645d71 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -213,10 +213,6 @@ typedef struct VAAPIEncodeContext {
 
     AVVAAPIDeviceContext *hwctx;
 
-    // The hardware frame context containing the reconstructed frames.
-    AVBufferRef    *recon_frames_ref;
-    AVHWFramesContext *recon_frames;
-
     // Pool of (reusable) bitstream output buffers.
     struct FFRefStructPool *output_buffer_pool;
 
-- 
2.41.0.windows.1

_______________________________________________
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".

Reply via email to