AVBufferRef *input_frames_ref;
AVHWFramesContext *input_frames;
- AVBufferRef *output_frames_ref;
- AVHWFramesContext *output_frames;
int output_height;
int output_width;
DeintVAAPIContext *ctx = avctx->priv;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
+ AVHWFramesContext *output_frames;
AVVAAPIFramesContext *va_frames;
VAStatus vas;
int err;
goto fail;
}
- ctx->output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
- if (!ctx->output_frames_ref) {
+ outlink->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->device_ref);
+ if (!outlink->hw_frames_ctx) {
av_log(avctx, AV_LOG_ERROR, "Failed to create HW frame context "
"for output.\n");
err = AVERROR(ENOMEM);
goto fail;
}
- ctx->output_frames = (AVHWFramesContext*)ctx->output_frames_ref->data;
+ output_frames = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
- ctx->output_frames->format = AV_PIX_FMT_VAAPI;
- ctx->output_frames->sw_format = ctx->input_frames->sw_format;
- ctx->output_frames->width = ctx->output_width;
- ctx->output_frames->height = ctx->output_height;
+ output_frames->format = AV_PIX_FMT_VAAPI;
+ output_frames->sw_format = ctx->input_frames->sw_format;
+ output_frames->width = ctx->output_width;
+ output_frames->height = ctx->output_height;
- // The number of output frames we need is determined by what follows
- // the filter. If it's an encoder with complex frame reference
- // structures then this could be very high.
- ctx->output_frames->initial_pool_size = 10;
+ output_frames->initial_pool_size = 4;
+
+ err = ff_filter_init_hw_frames(avctx, outlink, 10);
+ if (err < 0)
+ goto fail;
- err = av_hwframe_ctx_init(ctx->output_frames_ref);
+ err = av_hwframe_ctx_init(outlink->hw_frames_ctx);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to initialise VAAPI frame "
"context for output: %d\n", err);
goto fail;
}
- va_frames = ctx->output_frames->hwctx;
+ va_frames = output_frames->hwctx;
av_assert0(ctx->va_context == VA_INVALID_ID);
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
outlink->frame_rate = av_mul_q(inlink->frame_rate,
(AVRational) { ctx->field_rate, 1 });
- outlink->hw_frames_ctx = av_buffer_ref(ctx->output_frames_ref);
- if (!outlink->hw_frames_ctx) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
-
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
return 0;
fail:
- av_buffer_unref(&ctx->output_frames_ref);
+ av_buffer_unref(&outlink->hw_frames_ctx);
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
return err;
deint_vaapi_pipeline_uninit(avctx);
av_buffer_unref(&ctx->input_frames_ref);
- av_buffer_unref(&ctx->output_frames_ref);
av_buffer_unref(&ctx->device_ref);
}
#include <va/va_vpp.h>
#include "libavutil/avassert.h"
+#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_vaapi.h"
#include "libavutil/mem.h"
AVBufferRef *input_frames_ref;
AVHWFramesContext *input_frames;
- AVBufferRef *output_frames_ref;
- AVHWFramesContext *output_frames;
-
char *output_format_string;
enum AVPixelFormat output_format;
int output_width;
ctx->va_config = VA_INVALID_ID;
}
- av_buffer_unref(&ctx->output_frames_ref);
av_buffer_unref(&ctx->device_ref);
ctx->hwctx = 0;
ScaleVAAPIContext *ctx = avctx->priv;
AVVAAPIHWConfig *hwconfig = NULL;
AVHWFramesConstraints *constraints = NULL;
+ AVHWFramesContext *output_frames;
AVVAAPIFramesContext *va_frames;
VAStatus vas;
int err, i;
goto fail;
}
- ctx->output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
- if (!ctx->output_frames_ref) {
+ outlink->hw_frames_ctx = av_hwframe_ctx_alloc(ctx->device_ref);
+ if (!outlink->hw_frames_ctx) {
av_log(ctx, AV_LOG_ERROR, "Failed to create HW frame context "
"for output.\n");
err = AVERROR(ENOMEM);
goto fail;
}
- ctx->output_frames = (AVHWFramesContext*)ctx->output_frames_ref->data;
+ output_frames = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
+
+ output_frames->format = AV_PIX_FMT_VAAPI;
+ output_frames->sw_format = ctx->output_format;
+ output_frames->width = ctx->output_width;
+ output_frames->height = ctx->output_height;
- ctx->output_frames->format = AV_PIX_FMT_VAAPI;
- ctx->output_frames->sw_format = ctx->output_format;
- ctx->output_frames->width = ctx->output_width;
- ctx->output_frames->height = ctx->output_height;
+ output_frames->initial_pool_size = 4;
- // The number of output frames we need is determined by what follows
- // the filter. If it's an encoder with complex frame reference
- // structures then this could be very high.
- ctx->output_frames->initial_pool_size = 10;
+ err = ff_filter_init_hw_frames(avctx, outlink, 10);
+ if (err < 0)
+ goto fail;
- err = av_hwframe_ctx_init(ctx->output_frames_ref);
+ err = av_hwframe_ctx_init(outlink->hw_frames_ctx);
if (err < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to initialise VAAPI frame "
"context for output: %d\n", err);
goto fail;
}
- va_frames = ctx->output_frames->hwctx;
+ va_frames = output_frames->hwctx;
av_assert0(ctx->va_context == VA_INVALID_ID);
vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
outlink->w = ctx->output_width;
outlink->h = ctx->output_height;
- outlink->hw_frames_ctx = av_buffer_ref(ctx->output_frames_ref);
- if (!outlink->hw_frames_ctx) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
-
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
return 0;
fail:
- av_buffer_unref(&ctx->output_frames_ref);
+ av_buffer_unref(&outlink->hw_frames_ctx);
av_freep(&hwconfig);
av_hwframe_constraints_free(&constraints);
return err;
scale_vaapi_pipeline_uninit(ctx);
av_buffer_unref(&ctx->input_frames_ref);
- av_buffer_unref(&ctx->output_frames_ref);
av_buffer_unref(&ctx->device_ref);
}