avcodec/vaapi_encode: add async_depth to common options

Signed-off-by: Tong Wu <tong1.wu@intel.com>
release/7.1
Tong Wu 10 months ago committed by Lynne
parent ab944e06bc
commit ff06343d7e
  1. 10
      libavcodec/hw_base_encode.h
  2. 13
      libavcodec/vaapi_encode.c
  3. 7
      libavcodec/vaapi_encode.h
  4. 1
      libavcodec/vaapi_encode_av1.c
  5. 1
      libavcodec/vaapi_encode_h264.c
  6. 1
      libavcodec/vaapi_encode_h265.c
  7. 1
      libavcodec/vaapi_encode_mjpeg.c
  8. 1
      libavcodec/vaapi_encode_mpeg2.c
  9. 1
      libavcodec/vaapi_encode_vp8.c
  10. 1
      libavcodec/vaapi_encode_vp9.c

@ -50,7 +50,15 @@ enum {
typedef struct FFHWBaseEncodeContext {
const AVClass *class;
// Max number of frame buffered in encoder.
int async_depth;
} FFHWBaseEncodeContext;
#endif /* AVCODEC_HW_BASE_ENCODE_H */
#define HW_BASE_ENCODE_COMMON_OPTIONS \
{ "async_depth", "Maximum processing parallelism. " \
"Increase this to improve single channel performance.", \
OFFSET(common.base.async_depth), AV_OPT_TYPE_INT, \
{ .i64 = 2 }, 1, MAX_ASYNC_DEPTH, FLAGS }
#endif /* AVCODEC_HW_BASE_ENCODE_H */

@ -669,7 +669,8 @@ static int vaapi_encode_set_output_property(AVCodecContext *avctx,
VAAPIEncodePicture *pic,
AVPacket *pkt)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
VAAPIEncodeContext *ctx = avctx->priv_data;
if (pic->type == FF_HW_PICTURE_TYPE_IDR)
pkt->flags |= AV_PKT_FLAG_KEY;
@ -699,7 +700,7 @@ static int vaapi_encode_set_output_property(AVCodecContext *avctx,
pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
} else {
pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
(3 * ctx->output_delay + ctx->async_depth)];
(3 * ctx->output_delay + base_ctx->async_depth)];
}
return 0;
@ -1320,6 +1321,7 @@ static int vaapi_encode_check_frame(AVCodecContext *avctx,
static int vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
{
FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodePicture *pic;
int err;
@ -1365,7 +1367,7 @@ static int vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
ctx->dts_pts_diff = pic->pts - ctx->first_pts;
if (ctx->output_delay > 0)
ctx->ts_ring[ctx->input_order %
(3 * ctx->output_delay + ctx->async_depth)] = pic->pts;
(3 * ctx->output_delay + base_ctx->async_depth)] = pic->pts;
pic->display_order = ctx->input_order;
++ctx->input_order;
@ -2773,7 +2775,8 @@ static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx)
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
VAAPIEncodeContext *ctx = avctx->priv_data;
AVVAAPIFramesContext *recon_hwctx = NULL;
VAStatus vas;
int err;
@ -2966,7 +2969,7 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
vas = vaSyncBuffer(ctx->hwctx->display, VA_INVALID_ID, 0);
if (vas != VA_STATUS_ERROR_UNIMPLEMENTED) {
ctx->has_sync_buffer_func = 1;
ctx->encode_fifo = av_fifo_alloc2(ctx->async_depth,
ctx->encode_fifo = av_fifo_alloc2(base_ctx->async_depth,
sizeof(VAAPIEncodePicture *),
0);
if (!ctx->encode_fifo)

@ -374,8 +374,6 @@ typedef struct VAAPIEncodeContext {
int has_sync_buffer_func;
// Store buffered pic
AVFifo *encode_fifo;
// Max number of frame buffered in encoder.
int async_depth;
/** Head data for current output pkt, used only for AV1. */
//void *header_data;
@ -491,11 +489,6 @@ int ff_vaapi_encode_close(AVCodecContext *avctx);
"Maximum B-frame reference depth", \
OFFSET(common.desired_b_depth), AV_OPT_TYPE_INT, \
{ .i64 = 1 }, 1, INT_MAX, FLAGS }, \
{ "async_depth", "Maximum processing parallelism. " \
"Increase this to improve single channel performance. This option " \
"doesn't work if driver doesn't implement vaSyncBuffer function.", \
OFFSET(common.async_depth), AV_OPT_TYPE_INT, \
{ .i64 = 2 }, 1, MAX_ASYNC_DEPTH, FLAGS }, \
{ "max_frame_size", \
"Maximum frame size (in bytes)",\
OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \

@ -965,6 +965,7 @@ static av_cold int vaapi_encode_av1_close(AVCodecContext *avctx)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_av1_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_RC_OPTIONS,
{ "profile", "Set profile (seq_profile)",

@ -1276,6 +1276,7 @@ static av_cold int vaapi_encode_h264_close(AVCodecContext *avctx)
#define OFFSET(x) offsetof(VAAPIEncodeH264Context, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_h264_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_RC_OPTIONS,

@ -1395,6 +1395,7 @@ static av_cold int vaapi_encode_h265_close(AVCodecContext *avctx)
#define OFFSET(x) offsetof(VAAPIEncodeH265Context, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_h265_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_RC_OPTIONS,

@ -540,6 +540,7 @@ static av_cold int vaapi_encode_mjpeg_close(AVCodecContext *avctx)
#define OFFSET(x) offsetof(VAAPIEncodeMJPEGContext, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_mjpeg_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
{ "jfif", "Include JFIF header",

@ -639,6 +639,7 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)
#define OFFSET(x) offsetof(VAAPIEncodeMPEG2Context, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_mpeg2_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_RC_OPTIONS,

@ -216,6 +216,7 @@ static av_cold int vaapi_encode_vp8_init(AVCodecContext *avctx)
#define OFFSET(x) offsetof(VAAPIEncodeVP8Context, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_vp8_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_RC_OPTIONS,

@ -273,6 +273,7 @@ static av_cold int vaapi_encode_vp9_init(AVCodecContext *avctx)
#define OFFSET(x) offsetof(VAAPIEncodeVP9Context, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static const AVOption vaapi_encode_vp9_options[] = {
HW_BASE_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_COMMON_OPTIONS,
VAAPI_ENCODE_RC_OPTIONS,

Loading…
Cancel
Save