/*
- * 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
*/
int cpb_delay;
int dpb_delay;
- CodedBitstreamContext cbc;
+ CodedBitstreamContext *cbc;
CodedBitstreamFragment current_access_unit;
int aud_needed;
int sei_needed;
int qp;
int quality;
int low_power;
+ // Entropy encoder type.
+ int coder;
int aud;
int sei;
} VAAPIEncodeH264Options;
VAAPIEncodeH264Context *priv = ctx->priv_data;
int err;
- err = ff_cbs_write_fragment_data(&priv->cbc, au);
+ err = ff_cbs_write_fragment_data(priv->cbc, au);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
return err;
H264RawNALUnitHeader *header = nal_unit;
int err;
- err = ff_cbs_insert_unit_content(&priv->cbc, au, -1,
+ err = ff_cbs_insert_unit_content(priv->cbc, au, -1,
header->nal_unit_type, nal_unit);
if (err < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to add NAL unit: "
err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
fail:
- ff_cbs_fragment_uninit(&priv->cbc, au);
+ ff_cbs_fragment_uninit(priv->cbc, au);
return err;
}
err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
fail:
- ff_cbs_fragment_uninit(&priv->cbc, au);
+ ff_cbs_fragment_uninit(priv->cbc, au);
return err;
}
if (priv->sei_needed) {
if (priv->aud_needed) {
- vaapi_encode_h264_add_nal(avctx, au, &priv->aud);
+ err = vaapi_encode_h264_add_nal(avctx, au, &priv->aud);
+ if (err < 0)
+ goto fail;
priv->aud_needed = 0;
}
if (err < 0)
goto fail;
- ff_cbs_fragment_uninit(&priv->cbc, au);
+ ff_cbs_fragment_uninit(priv->cbc, au);
*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
}
fail:
- ff_cbs_fragment_uninit(&priv->cbc, au);
+ ff_cbs_fragment_uninit(priv->cbc, au);
return err;
}
sps->vui.log2_max_mv_length_horizontal = 16;
sps->vui.log2_max_mv_length_vertical = 16;
sps->vui.max_num_reorder_frames = (ctx->b_per_p > 0);
- sps->vui.max_dec_frame_buffering = vseq->max_num_ref_frames;
+ sps->vui.max_dec_frame_buffering = sps->max_num_ref_frames;
pps->nal_unit_header.nal_ref_idc = 3;
pps->nal_unit_header.nal_unit_type = H264_NAL_PPS;
!(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;
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
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);
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;
{ "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 },
{ "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 },
};