}
av_log(avctx, AV_LOG_DEBUG, "Sync to pic %"PRId64"/%"PRId64" "
- "(recon surface %#x).\n", pic->display_order,
- pic->encode_order, pic->recon_surface);
+ "(input surface %#x).\n", pic->display_order,
+ pic->encode_order, pic->input_surface);
- vas = vaSyncSurface(ctx->hwctx->display, pic->recon_surface);
+ vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
"%d (%s).\n", vas, vaErrorStr(vas));
}
if (pic->type == PICTURE_TYPE_IDR) {
- if (ctx->codec->write_sequence_header) {
+ if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&
+ ctx->codec->write_sequence_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
if (err < 0) {
}
}
- if (ctx->codec->write_picture_header) {
+ if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_PICTURE &&
+ ctx->codec->write_picture_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len);
if (err < 0) {
}
}
- if (ctx->codec->write_extra_header) {
+ if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_MISC &&
+ ctx->codec->write_extra_header) {
for (i = 0;; i++) {
int type;
bit_len = 8 * sizeof(data);
}
}
- if (ctx->codec->write_slice_header) {
+ if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SLICE &&
+ ctx->codec->write_slice_header) {
bit_len = 8 * sizeof(data);
err = ctx->codec->write_slice_header(avctx, pic, slice,
data, &bit_len);
VAProfile *profiles = NULL;
VAEntrypoint *entrypoints = NULL;
VAConfigAttrib attr[] = {
- { VAConfigAttribRTFormat },
- { VAConfigAttribRateControl },
- { VAConfigAttribEncMaxRefFrames },
+ { VAConfigAttribRTFormat },
+ { VAConfigAttribRateControl },
+ { VAConfigAttribEncMaxRefFrames },
+ { VAConfigAttribEncPackedHeaders },
};
n = vaMaxNumProfiles(ctx->hwctx->display);
}
}
break;
+ case VAConfigAttribEncPackedHeaders:
+ if (ctx->va_packed_headers & ~attr[i].value) {
+ // This isn't fatal, but packed headers are always
+ // preferable because they are under our control.
+ // When absent, the driver is generating them and some
+ // features may not work (e.g. VUI or SEI in H.264).
+ av_log(avctx, AV_LOG_WARNING, "Warning: some packed "
+ "headers are not supported (want %#x, got %#x).\n",
+ ctx->va_packed_headers, attr[i].value);
+ ctx->va_packed_headers &= attr[i].value;
+ }
+ ctx->config_attributes[ctx->nb_config_attributes++] =
+ (VAConfigAttrib) {
+ .type = VAConfigAttribEncPackedHeaders,
+ .value = ctx->va_packed_headers,
+ };
+ break;
default:
av_assert0(0 && "Unexpected config attribute.");
}
ctx->decode_delay = 1;
ctx->output_order = - ctx->output_delay - 1;
+ // Currently we never generate I frames, only IDR.
+ ctx->i_per_idr = 0;
+ ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
+ (avctx->max_b_frames + 1));
+ ctx->b_per_p = avctx->max_b_frames;
+
if (ctx->codec->sequence_params_size > 0) {
ctx->codec_sequence_params =
av_mallocz(ctx->codec->sequence_params_size);
}
}
- // All I are IDR for now.
- ctx->i_per_idr = 0;
- ctx->p_per_i = ((avctx->gop_size + avctx->max_b_frames) /
- (avctx->max_b_frames + 1));
- ctx->b_per_p = avctx->max_b_frames;
-
// This should be configurable somehow. (Needs testing on a machine
// where it actually overlaps properly, though.)
ctx->issue_mode = ISSUE_MODE_MAXIMISE_THROUGHPUT;
+ if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&
+ ctx->codec->write_sequence_header) {
+ char data[MAX_PARAM_BUFFER_SIZE];
+ size_t bit_len = 8 * sizeof(data);
+
+ err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
+ if (err < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to write sequence header "
+ "for extradata: %d.\n", err);
+ goto fail;
+ } else {
+ avctx->extradata_size = (bit_len + 7) / 8;
+ avctx->extradata = av_mallocz(avctx->extradata_size +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata) {
+ err = AVERROR(ENOMEM);
+ goto fail;
+ }
+ memcpy(avctx->extradata, data, avctx->extradata_size);
+ }
+ }
+
return 0;
fail: