Lines Matching defs:avctx

108 static int vaapi_encode_h264_write_access_unit(AVCodecContext *avctx,
112 VAAPIEncodeH264Context *priv = avctx->priv_data;
117 av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
122 av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
134 static int vaapi_encode_h264_add_nal(AVCodecContext *avctx,
144 av_log(avctx, AV_LOG_ERROR, "Failed to add NAL unit: "
152 static int vaapi_encode_h264_write_sequence_header(AVCodecContext *avctx,
155 VAAPIEncodeH264Context *priv = avctx->priv_data;
160 err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
166 err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_sps);
170 err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_pps);
174 err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
180 static int vaapi_encode_h264_write_slice_header(AVCodecContext *avctx,
185 VAAPIEncodeH264Context *priv = avctx->priv_data;
190 err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
196 err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_slice);
200 err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
206 static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
211 VAAPIEncodeH264Context *priv = avctx->priv_data;
217 err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
254 err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
284 static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
286 VAAPIEncodeContext *ctx = avctx->priv_data;
287 VAAPIEncodeH264Context *priv = avctx->priv_data;
299 sps->profile_idc = avctx->profile & 0xff;
301 if (avctx->profile == FF_PROFILE_H264_CONSTRAINED_BASELINE ||
302 avctx->profile == FF_PROFILE_H264_MAIN)
305 if (avctx->profile == FF_PROFILE_H264_HIGH)
308 if (avctx->profile == FF_PROFILE_H264_MAIN ||
309 avctx->profile == FF_PROFILE_H264_HIGH) {
319 if (avctx->level != FF_LEVEL_UNKNOWN) {
320 sps->level_idc = avctx->level;
325 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
326 framerate = avctx->framerate.num / avctx->framerate.den;
331 avctx->bit_rate,
337 av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
342 av_log(avctx, AV_LOG_WARNING, "Stream will not conform "
363 if (avctx->width != 16 * priv->mb_width ||
364 avctx->height != 16 * priv->mb_height) {
369 (16 * priv->mb_width - avctx->width) / 2;
372 (16 * priv->mb_height - avctx->height) / 2;
379 if (avctx->sample_aspect_ratio.num != 0 &&
380 avctx->sample_aspect_ratio.den != 0) {
389 av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
390 avctx->sample_aspect_ratio.den, 65535);
409 avctx->color_range == AVCOL_RANGE_JPEG;
410 sps->vui.colour_primaries = avctx->color_primaries;
411 sps->vui.transfer_characteristics = avctx->color_trc;
412 sps->vui.matrix_coefficients = avctx->colorspace;
413 if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
414 avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
415 avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
417 if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED ||
421 if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) {
425 avctx->chroma_sample_location - 1;
429 if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
430 sps->vui.num_units_in_tick = avctx->framerate.den;
431 sps->vui.time_scale = 2 * avctx->framerate.num;
434 sps->vui.num_units_in_tick = avctx->time_base.num;
435 sps->vui.time_scale = 2 * avctx->time_base.den;
601 static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
604 VAAPIEncodeContext *ctx = avctx->priv_data;
605 VAAPIEncodeH264Context *priv = avctx->priv_data;
724 static void vaapi_encode_h264_default_ref_pic_list(AVCodecContext *avctx,
798 av_log(avctx, AV_LOG_DEBUG, "Default RefPicList0 for fn=%d/poc=%d:",
802 av_log(avctx, AV_LOG_DEBUG, " fn=%d/poc=%d",
805 av_log(avctx, AV_LOG_DEBUG, "\n");
808 av_log(avctx, AV_LOG_DEBUG, "Default RefPicList1 for fn=%d/poc=%d:",
812 av_log(avctx, AV_LOG_DEBUG, " fn=%d/poc=%d",
815 av_log(avctx, AV_LOG_DEBUG, "\n");
821 static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
825 VAAPIEncodeH264Context *priv = avctx->priv_data;
905 vaapi_encode_h264_default_ref_pic_list(avctx, pic,
1042 static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
1044 VAAPIEncodeContext *ctx = avctx->priv_data;
1045 VAAPIEncodeH264Context *priv = avctx->priv_data;
1048 err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_H264, avctx);
1052 priv->mb_width = FFALIGN(avctx->width, 16) / 16;
1053 priv->mb_height = FFALIGN(avctx->height, 16) / 16;
1057 if (avctx->i_quant_factor > 0.0)
1059 av_clip((avctx->i_quant_factor * priv->fixed_qp_p +
1060 avctx->i_quant_offset) + 0.5, 1, 51);
1063 if (avctx->b_quant_factor > 0.0)
1065 av_clip((avctx->b_quant_factor * priv->fixed_qp_p +
1066 avctx->b_quant_offset) + 0.5, 1, 51);
1070 av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
1159 static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
1161 VAAPIEncodeContext *ctx = avctx->priv_data;
1162 VAAPIEncodeH264Context *priv = avctx->priv_data;
1166 if (avctx->profile == FF_PROFILE_UNKNOWN)
1167 avctx->profile = priv->profile;
1168 if (avctx->level == FF_LEVEL_UNKNOWN)
1169 avctx->level = priv->level;
1170 if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
1171 avctx->compression_level = priv->quality;
1174 switch (avctx->profile) {
1176 av_log(avctx, AV_LOG_WARNING, "H.264 baseline profile is not "
1178 avctx->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
1181 av_log(avctx, AV_LOG_ERROR, "H.264 extended profile "
1186 av_log(avctx, AV_LOG_ERROR, "H.264 10-bit profiles "
1195 av_log(avctx, AV_LOG_ERROR, "H.264 non-4:2:0 profiles "
1200 if (avctx->level != FF_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1201 av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1202 "in 8-bit unsigned integer.\n", avctx->level);
1211 ctx->surface_width = FFALIGN(avctx->width, 16);
1212 ctx->surface_height = FFALIGN(avctx->height, 16);
1219 return ff_vaapi_encode_init(avctx);
1222 static av_cold int vaapi_encode_h264_close(AVCodecContext *avctx)
1224 VAAPIEncodeH264Context *priv = avctx->priv_data;
1230 return ff_vaapi_encode_close(avctx);