diff options
Diffstat (limited to 'libavcodec/vaapi_encode_h264.c')
-rw-r--r-- | libavcodec/vaapi_encode_h264.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 74a6417..56ad217 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -89,6 +89,8 @@ typedef struct VAAPIEncodeH264Options { int qp; int quality; int low_power; + // Entropy encoder type. + int coder; int aud; int sei; int profile; @@ -260,7 +262,7 @@ static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx, *type = VAEncPackedHeaderRawData; return 0; -#if !HAVE_VAAPI_1 +#if !CONFIG_VAAPI_1 } else if (priv->sei_cbr_workaround_needed) { // Insert a zero-length header using the old SEI type. This is // required to avoid triggering broken behaviour on Intel platforms @@ -467,6 +469,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) !(sps->profile_idc == FF_PROFILE_H264_BASELINE || sps->profile_idc == FF_PROFILE_H264_EXTENDED || sps->profile_idc == FF_PROFILE_H264_CAVLC_444); + if (!opt->coder && pps->entropy_coding_mode_flag) + pps->entropy_coding_mode_flag = 0; pps->num_ref_idx_l0_default_active_minus1 = 0; pps->num_ref_idx_l1_default_active_minus1 = 0; @@ -626,7 +630,7 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, if (opt->sei & SEI_IDENTIFIER && pic->encode_order == 0) priv->sei_needed = 1; -#if !HAVE_VAAPI_1 +#if !CONFIG_VAAPI_1 if (ctx->va_rc_mode == VA_RC_CBR) priv->sei_cbr_workaround_needed = 1; #endif @@ -811,7 +815,7 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx) priv->fixed_qp_p = 26; priv->fixed_qp_b = 26; - av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %d bps.\n", + av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n", ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable", avctx->bit_rate); @@ -896,6 +900,11 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx) avctx->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE; case FF_PROFILE_H264_CONSTRAINED_BASELINE: ctx->va_profile = VAProfileH264ConstrainedBaseline; + if (avctx->max_b_frames != 0) { + avctx->max_b_frames = 0; + av_log(avctx, AV_LOG_WARNING, "H.264 constrained baseline profile " + "doesn't support encoding with B frames, disabling them.\n"); + } break; case FF_PROFILE_H264_MAIN: ctx->va_profile = VAProfileH264Main; @@ -985,6 +994,12 @@ static const AVOption vaapi_encode_h264_options[] = { { "low_power", "Use low-power encoding mode (experimental: only supported " "on some platforms, does not support all features)", OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, + { "coder", "Entropy coder type", + OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" }, + { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" }, + { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, "coder" }, + { "vlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" }, + { "ac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, "coder" }, { "aud", "Include AUD", OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, @@ -1048,10 +1063,10 @@ static const AVCodecDefault vaapi_encode_h264_defaults[] = { { "b", "0" }, { "bf", "2" }, { "g", "120" }, - { "i_qfactor", "1.0" }, - { "i_qoffset", "0.0" }, - { "b_qfactor", "1.2" }, - { "b_qoffset", "0.0" }, + { "i_qfactor", "1" }, + { "i_qoffset", "0" }, + { "b_qfactor", "6/5" }, + { "b_qoffset", "0" }, { "qmin", "0" }, { NULL }, }; |