|
|
@ -32,14 +32,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct VAAPIEncodeVP8Context { |
|
|
|
typedef struct VAAPIEncodeVP8Context { |
|
|
|
int q_index_i; |
|
|
|
VAAPIEncodeContext common; |
|
|
|
int q_index_p; |
|
|
|
|
|
|
|
} VAAPIEncodeVP8Context; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct VAAPIEncodeVP8Options { |
|
|
|
// User options.
|
|
|
|
int loop_filter_level; |
|
|
|
int loop_filter_level; |
|
|
|
int loop_filter_sharpness; |
|
|
|
int loop_filter_sharpness; |
|
|
|
} VAAPIEncodeVP8Options; |
|
|
|
|
|
|
|
|
|
|
|
// Derived settings.
|
|
|
|
|
|
|
|
int q_index_i; |
|
|
|
|
|
|
|
int q_index_p; |
|
|
|
|
|
|
|
} VAAPIEncodeVP8Context; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define vseq_var(name) vseq->name, name |
|
|
|
#define vseq_var(name) vseq->name, name |
|
|
@ -73,9 +75,8 @@ static int vaapi_encode_vp8_init_sequence_params(AVCodecContext *avctx) |
|
|
|
static int vaapi_encode_vp8_init_picture_params(AVCodecContext *avctx, |
|
|
|
static int vaapi_encode_vp8_init_picture_params(AVCodecContext *avctx, |
|
|
|
VAAPIEncodePicture *pic) |
|
|
|
VAAPIEncodePicture *pic) |
|
|
|
{ |
|
|
|
{ |
|
|
|
VAAPIEncodeContext *ctx = avctx->priv_data; |
|
|
|
VAAPIEncodeVP8Context *priv = avctx->priv_data; |
|
|
|
VAEncPictureParameterBufferVP8 *vpic = pic->codec_picture_params; |
|
|
|
VAEncPictureParameterBufferVP8 *vpic = pic->codec_picture_params; |
|
|
|
VAAPIEncodeVP8Options *opt = ctx->codec_options; |
|
|
|
|
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
vpic->reconstructed_frame = pic->recon_surface; |
|
|
|
vpic->reconstructed_frame = pic->recon_surface; |
|
|
@ -116,8 +117,8 @@ static int vaapi_encode_vp8_init_picture_params(AVCodecContext *avctx, |
|
|
|
vpic->pic_flags.bits.version = 0; |
|
|
|
vpic->pic_flags.bits.version = 0; |
|
|
|
vpic->pic_flags.bits.loop_filter_type = 0; |
|
|
|
vpic->pic_flags.bits.loop_filter_type = 0; |
|
|
|
for (i = 0; i < 4; i++) |
|
|
|
for (i = 0; i < 4; i++) |
|
|
|
vpic->loop_filter_level[i] = opt->loop_filter_level; |
|
|
|
vpic->loop_filter_level[i] = priv->loop_filter_level; |
|
|
|
vpic->sharpness_level = opt->loop_filter_sharpness; |
|
|
|
vpic->sharpness_level = priv->loop_filter_sharpness; |
|
|
|
|
|
|
|
|
|
|
|
vpic->clamp_qindex_low = 0; |
|
|
|
vpic->clamp_qindex_low = 0; |
|
|
|
vpic->clamp_qindex_high = 127; |
|
|
|
vpic->clamp_qindex_high = 127; |
|
|
@ -130,8 +131,7 @@ static int vaapi_encode_vp8_write_quant_table(AVCodecContext *avctx, |
|
|
|
int index, int *type, |
|
|
|
int index, int *type, |
|
|
|
char *data, size_t *data_len) |
|
|
|
char *data, size_t *data_len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
VAAPIEncodeContext *ctx = avctx->priv_data; |
|
|
|
VAAPIEncodeVP8Context *priv = avctx->priv_data; |
|
|
|
VAAPIEncodeVP8Context *priv = ctx->priv_data; |
|
|
|
|
|
|
|
VAQMatrixBufferVP8 quant; |
|
|
|
VAQMatrixBufferVP8 quant; |
|
|
|
int i, q; |
|
|
|
int i, q; |
|
|
|
|
|
|
|
|
|
|
@ -161,8 +161,7 @@ static int vaapi_encode_vp8_write_quant_table(AVCodecContext *avctx, |
|
|
|
|
|
|
|
|
|
|
|
static av_cold int vaapi_encode_vp8_configure(AVCodecContext *avctx) |
|
|
|
static av_cold int vaapi_encode_vp8_configure(AVCodecContext *avctx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
VAAPIEncodeContext *ctx = avctx->priv_data; |
|
|
|
VAAPIEncodeVP8Context *priv = avctx->priv_data; |
|
|
|
VAAPIEncodeVP8Context *priv = ctx->priv_data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
priv->q_index_p = av_clip(avctx->global_quality, 0, VP8_MAX_QUANT); |
|
|
|
priv->q_index_p = av_clip(avctx->global_quality, 0, VP8_MAX_QUANT); |
|
|
|
if (avctx->i_quant_factor > 0.0) |
|
|
|
if (avctx->i_quant_factor > 0.0) |
|
|
@ -225,8 +224,7 @@ static av_cold int vaapi_encode_vp8_init(AVCodecContext *avctx) |
|
|
|
return ff_vaapi_encode_init(avctx); |
|
|
|
return ff_vaapi_encode_init(avctx); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define OFFSET(x) (offsetof(VAAPIEncodeContext, codec_options_data) + \ |
|
|
|
#define OFFSET(x) offsetof(VAAPIEncodeVP8Context, x) |
|
|
|
offsetof(VAAPIEncodeVP8Options, x)) |
|
|
|
|
|
|
|
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) |
|
|
|
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) |
|
|
|
static const AVOption vaapi_encode_vp8_options[] = { |
|
|
|
static const AVOption vaapi_encode_vp8_options[] = { |
|
|
|
{ "loop_filter_level", "Loop filter level", |
|
|
|
{ "loop_filter_level", "Loop filter level", |
|
|
@ -256,8 +254,7 @@ AVCodec ff_vp8_vaapi_encoder = { |
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("VP8 (VAAPI)"), |
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("VP8 (VAAPI)"), |
|
|
|
.type = AVMEDIA_TYPE_VIDEO, |
|
|
|
.type = AVMEDIA_TYPE_VIDEO, |
|
|
|
.id = AV_CODEC_ID_VP8, |
|
|
|
.id = AV_CODEC_ID_VP8, |
|
|
|
.priv_data_size = (sizeof(VAAPIEncodeContext) + |
|
|
|
.priv_data_size = sizeof(VAAPIEncodeVP8Context), |
|
|
|
sizeof(VAAPIEncodeVP8Options)), |
|
|
|
|
|
|
|
.init = &vaapi_encode_vp8_init, |
|
|
|
.init = &vaapi_encode_vp8_init, |
|
|
|
.encode2 = &ff_vaapi_encode2, |
|
|
|
.encode2 = &ff_vaapi_encode2, |
|
|
|
.close = &ff_vaapi_encode_close, |
|
|
|
.close = &ff_vaapi_encode_close, |
|
|
|