Lines Matching refs:avctx
41 static int vaapi_encode_make_packed_header(AVCodecContext *avctx,
45 VAAPIEncodeContext *ctx = avctx->priv_data;
64 av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer "
75 av_log(avctx, AV_LOG_ERROR, "Failed to create data buffer "
82 av_log(avctx, AV_LOG_DEBUG, "Packed header buffer (%d) is %#x/%#x "
87 static int vaapi_encode_make_param_buffer(AVCodecContext *avctx,
91 VAAPIEncodeContext *ctx = avctx->priv_data;
104 av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer "
110 av_log(avctx, AV_LOG_DEBUG, "Param buffer (%d) is %#x.\n",
115 static int vaapi_encode_make_misc_param_buffer(AVCodecContext *avctx,
133 return vaapi_encode_make_param_buffer(avctx, pic,
138 static int vaapi_encode_wait(AVCodecContext *avctx,
141 VAAPIEncodeContext *ctx = avctx->priv_data;
151 av_log(avctx, AV_LOG_DEBUG, "Sync to pic %"PRId64"/%"PRId64" "
161 av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer completion: "
170 av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
183 static int vaapi_encode_make_row_slice(AVCodecContext *avctx,
186 VAAPIEncodeContext *ctx = avctx->priv_data;
228 av_log(avctx, AV_LOG_DEBUG, "Slice %d: %d-%d (%d rows), "
238 static int vaapi_encode_make_tile_slice(AVCodecContext *avctx,
241 VAAPIEncodeContext *ctx = avctx->priv_data;
255 av_log(avctx, AV_LOG_DEBUG, "Slice %2d: (%2d, %2d) start at: %4d "
265 static int vaapi_encode_issue(AVCodecContext *avctx,
268 VAAPIEncodeContext *ctx = avctx->priv_data;
276 av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
280 av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
282 av_log(avctx, AV_LOG_DEBUG, "Refers to:");
284 av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
287 av_log(avctx, AV_LOG_DEBUG, ".\n");
296 av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
310 av_log(avctx, AV_LOG_DEBUG, "Recon surface is %#x.\n", pic->recon_surface);
318 av_log(avctx, AV_LOG_DEBUG, "Output buffer is %#x.\n",
334 err = vaapi_encode_make_param_buffer(avctx, pic,
344 err = vaapi_encode_make_misc_param_buffer(avctx, pic,
354 err = ctx->codec->init_picture_params(avctx, pic);
356 av_log(avctx, AV_LOG_ERROR, "Failed to initialise picture "
360 err = vaapi_encode_make_param_buffer(avctx, pic,
370 err = vaapi_encode_make_misc_param_buffer(avctx, pic,
383 err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
385 av_log(avctx, AV_LOG_ERROR, "Failed to write per-sequence "
389 err = vaapi_encode_make_packed_header(avctx, pic,
400 err = ctx->codec->write_picture_header(avctx, pic, data, &bit_len);
402 av_log(avctx, AV_LOG_ERROR, "Failed to write per-picture "
406 err = vaapi_encode_make_packed_header(avctx, pic,
417 err = ctx->codec->write_extra_buffer(avctx, pic, i, &type,
422 av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
427 err = vaapi_encode_make_param_buffer(avctx, pic, type,
439 err = ctx->codec->write_extra_header(avctx, pic, i, &type,
444 av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
449 err = vaapi_encode_make_packed_header(avctx, pic, type,
466 vaapi_encode_make_tile_slice(avctx, pic);
468 vaapi_encode_make_row_slice(avctx, pic);
483 err = ctx->codec->init_slice_params(avctx, pic, slice);
485 av_log(avctx, AV_LOG_ERROR, "Failed to initialise slice "
494 err = ctx->codec->write_slice_header(avctx, pic, slice,
497 av_log(avctx, AV_LOG_ERROR, "Failed to write per-slice "
501 err = vaapi_encode_make_packed_header(avctx, pic,
509 err = vaapi_encode_make_param_buffer(avctx, pic,
533 av_log(avctx, AV_LOG_WARNING, "More ROIs set than "
552 av_log(avctx, AV_LOG_DEBUG, "ROI: (%d,%d)-(%d,%d) -> %+d.\n",
574 err = vaapi_encode_make_misc_param_buffer(avctx, pic,
586 av_log(avctx, AV_LOG_ERROR, "Failed to begin picture encode issue: "
595 av_log(avctx, AV_LOG_ERROR, "Failed to upload encode parameters: "
603 av_log(avctx, AV_LOG_ERROR, "Failed to end picture encode issue: "
621 av_log(avctx, AV_LOG_ERROR, "Failed to destroy "
653 static int vaapi_encode_output(AVCodecContext *avctx,
656 VAAPIEncodeContext *ctx = avctx->priv_data;
663 err = vaapi_encode_wait(avctx, pic);
671 av_log(avctx, AV_LOG_ERROR, "Failed to map output buffers: "
680 err = ff_get_encode_buffer(avctx, pkt, total_size, 0);
687 av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
701 av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "
710 av_log(avctx, AV_LOG_DEBUG, "Output read for pic %"PRId64"/%"PRId64".\n",
722 static int vaapi_encode_discard(AVCodecContext *avctx,
725 vaapi_encode_wait(avctx, pic);
728 av_log(avctx, AV_LOG_DEBUG, "Discard output for pic "
739 static VAAPIEncodePicture *vaapi_encode_alloc(AVCodecContext *avctx)
741 VAAPIEncodeContext *ctx = avctx->priv_data;
763 static int vaapi_encode_free(AVCodecContext *avctx,
769 vaapi_encode_discard(avctx, pic);
794 static void vaapi_encode_add_ref(AVCodecContext *avctx,
824 static void vaapi_encode_remove_refs(AVCodecContext *avctx,
854 static void vaapi_encode_set_b_pictures(AVCodecContext *avctx,
861 VAAPIEncodeContext *ctx = avctx->priv_data;
877 vaapi_encode_add_ref(avctx, pic, start, 1, 1, 0);
878 vaapi_encode_add_ref(avctx, pic, end, 1, 1, 0);
879 vaapi_encode_add_ref(avctx, pic, prev, 0, 0, 1);
882 vaapi_encode_add_ref(avctx, pic, ref, 0, 1, 0);
899 vaapi_encode_add_ref(avctx, pic, pic, 0, 1, 0);
900 vaapi_encode_add_ref(avctx, pic, start, 1, 1, 0);
901 vaapi_encode_add_ref(avctx, pic, end, 1, 1, 0);
902 vaapi_encode_add_ref(avctx, pic, prev, 0, 0, 1);
905 vaapi_encode_add_ref(avctx, pic, ref, 0, 1, 0);
908 vaapi_encode_set_b_pictures(avctx, start, pic, pic,
913 vaapi_encode_set_b_pictures(avctx, pic, end, next,
918 static int vaapi_encode_pick_next(AVCodecContext *avctx,
921 VAAPIEncodeContext *ctx = avctx->priv_data;
942 av_log(avctx, AV_LOG_DEBUG, "Pick B-picture at depth %d to "
988 av_log(avctx, AV_LOG_DEBUG, "Pick nothing to encode next - "
993 av_log(avctx, AV_LOG_DEBUG, "Pick nothing to encode next - "
999 av_log(avctx, AV_LOG_DEBUG, "Pick forced IDR-picture to "
1007 av_log(avctx, AV_LOG_DEBUG, "Pick new-GOP IDR-picture to "
1012 av_log(avctx, AV_LOG_DEBUG, "Pick new-GOP I-picture to "
1021 av_log(avctx, AV_LOG_DEBUG, "Pick group-end P-picture to "
1024 av_log(avctx, AV_LOG_DEBUG, "Pick normal P-picture to "
1034 vaapi_encode_add_ref(avctx, pic, pic, 0, 1, 0);
1036 vaapi_encode_add_ref(avctx, pic, start,
1039 vaapi_encode_add_ref(avctx, pic, ctx->next_prev, 0, 0, 1);
1045 vaapi_encode_set_b_pictures(avctx, start, pic, pic, 1,
1054 static int vaapi_encode_clear_old(AVCodecContext *avctx)
1056 VAAPIEncodeContext *ctx = avctx->priv_data;
1064 vaapi_encode_remove_refs(avctx, pic, 0);
1070 vaapi_encode_remove_refs(avctx, pic, 1);
1083 vaapi_encode_free(avctx, pic);
1092 static int vaapi_encode_check_frame(AVCodecContext *avctx,
1095 VAAPIEncodeContext *ctx = avctx->priv_data;
1099 av_log(avctx, AV_LOG_WARNING, "Cropping information on input "
1109 av_log(avctx, AV_LOG_WARNING, "ROI side data on input "
1118 static int vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
1120 VAAPIEncodeContext *ctx = avctx->priv_data;
1125 av_log(avctx, AV_LOG_DEBUG, "Input frame: %ux%u (%"PRId64").\n",
1128 err = vaapi_encode_check_frame(avctx, frame);
1132 pic = vaapi_encode_alloc(avctx);
1181 vaapi_encode_free(avctx, pic);
1185 int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
1187 VAAPIEncodeContext *ctx = avctx->priv_data;
1192 err = ff_encode_get_frame(avctx, frame);
1199 err = vaapi_encode_send_frame(avctx, frame);
1214 err = vaapi_encode_pick_next(avctx, &pic);
1219 err = vaapi_encode_issue(avctx, pic);
1221 av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
1239 err = vaapi_encode_pick_next(avctx, &pic);
1246 err = vaapi_encode_issue(avctx, pic);
1248 av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
1253 err = vaapi_encode_output(avctx, pic, pkt);
1255 av_log(avctx, AV_LOG_ERROR, "Output failed: %d.\n", err);
1270 av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" dts %"PRId64".\n",
1274 vaapi_encode_clear_old(avctx);
1280 static av_cold void vaapi_encode_add_global_param(AVCodecContext *avctx, int type,
1283 VAAPIEncodeContext *ctx = avctx->priv_data;
1332 static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
1334 VAAPIEncodeContext *ctx = avctx->priv_data;
1351 av_log(avctx, AV_LOG_ERROR, "Low-power encoding is not "
1361 av_log(avctx, AV_LOG_ERROR, "Invalid input pixfmt (%d).\n",
1368 av_log(avctx, AV_LOG_ERROR, "Invalid input pixfmt (%s).\n",
1373 av_log(avctx, AV_LOG_VERBOSE, "Input surface format is %s.\n",
1384 av_log(avctx, AV_LOG_ERROR, "Failed to query profiles: %d (%s).\n",
1401 if (avctx->profile != profile->av_profile &&
1402 avctx->profile != FF_PROFILE_UNKNOWN)
1416 av_log(avctx, AV_LOG_VERBOSE, "Compatible profile %s (%d) "
1426 av_log(avctx, AV_LOG_ERROR, "No usable encoding profile found.\n");
1431 avctx->profile = profile->av_profile;
1433 av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n",
1445 av_log(avctx, AV_LOG_ERROR, "Failed to query entrypoints for "
1461 av_log(avctx, AV_LOG_ERROR, "No usable encoding entrypoint found "
1473 av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI entrypoint %s (%d).\n",
1485 av_log(avctx, AV_LOG_ERROR, "No usable render target format "
1498 av_log(avctx, AV_LOG_ERROR, "Failed to query RT format "
1505 av_log(avctx, AV_LOG_VERBOSE, "RT format config attribute not "
1509 av_log(avctx, AV_LOG_ERROR, "Surface RT format %s not supported "
1516 av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI render target "
1553 static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
1555 VAAPIEncodeContext *ctx = avctx->priv_data;
1573 av_log(avctx, AV_LOG_ERROR, "Failed to query rate control "
1578 av_log(avctx, AV_LOG_VERBOSE, "Driver does not report any "
1605 av_log(avctx, AV_LOG_DEBUG, "Driver supports RC modes %s.\n",
1625 av_log(avctx, AV_LOG_ERROR, "Driver does not support %s " \
1630 av_log(avctx, AV_LOG_DEBUG, "Driver does not support %s " \
1647 if (avctx->flags & AV_CODEC_FLAG_QSCALE)
1650 if (avctx->bit_rate > 0 && avctx->global_quality > 0)
1653 if (avctx->global_quality > 0) {
1658 if (avctx->bit_rate > 0 && avctx->rc_max_rate == avctx->bit_rate)
1661 if (avctx->bit_rate > 0) {
1670 av_log(avctx, AV_LOG_ERROR, "Driver does not support any "
1677 if (avctx->bit_rate <= 0) {
1678 av_log(avctx, AV_LOG_ERROR, "Bitrate must be set for %s "
1689 rc_bits_per_second = avctx->bit_rate;
1700 rc_window_size = avctx->gop_size > 0 ? avctx->gop_size : 60;
1703 if (avctx->rc_max_rate > 0) {
1704 if (avctx->rc_max_rate < avctx->bit_rate) {
1705 av_log(avctx, AV_LOG_ERROR, "Invalid bitrate settings: "
1707 "maxrate (%"PRId64").\n", avctx->bit_rate,
1708 avctx->rc_max_rate);
1711 rc_bits_per_second = avctx->rc_max_rate;
1712 rc_target_percentage = (avctx->bit_rate * 100) /
1713 avctx->rc_max_rate;
1719 rc_bits_per_second = 2 * avctx->bit_rate;
1723 if (avctx->rc_max_rate > avctx->bit_rate) {
1724 av_log(avctx, AV_LOG_WARNING, "Max bitrate is ignored "
1727 rc_bits_per_second = avctx->bit_rate;
1738 } else if (avctx->global_quality > 0) {
1739 rc_quality = avctx->global_quality;
1742 av_log(avctx, AV_LOG_WARNING, "No quality level set; "
1750 if (avctx->rc_buffer_size)
1751 hrd_buffer_size = avctx->rc_buffer_size;
1752 else if (avctx->rc_max_rate > 0)
1753 hrd_buffer_size = avctx->rc_max_rate;
1755 hrd_buffer_size = avctx->bit_rate;
1756 if (avctx->rc_initial_buffer_occupancy) {
1757 if (avctx->rc_initial_buffer_occupancy > hrd_buffer_size) {
1758 av_log(avctx, AV_LOG_ERROR, "Invalid RC buffer settings: "
1761 avctx->rc_initial_buffer_occupancy, hrd_buffer_size);
1764 hrd_initial_buffer_fullness = avctx->rc_initial_buffer_occupancy;
1771 if (avctx->rc_buffer_size || avctx->rc_initial_buffer_occupancy) {
1772 av_log(avctx, AV_LOG_WARNING, "Buffering settings are ignored "
1788 av_log(avctx, AV_LOG_ERROR, "RC parameters of 2^32 or "
1798 av_log(avctx, AV_LOG_VERBOSE, "RC mode: %s.\n", rc_mode->name);
1810 av_log(avctx, AV_LOG_VERBOSE, "RC quality: %d.\n", rc_quality);
1814 av_log(avctx, AV_LOG_VERBOSE, "RC target: %"PRId64" bps "
1819 av_log(avctx, AV_LOG_VERBOSE, "RC target: %d%% of "
1829 .min_qp = (avctx->qmin > 0 ? avctx->qmin : 0),
1833 .max_qp = (avctx->qmax > 0 ? avctx->qmax : 0),
1839 vaapi_encode_add_global_param(avctx,
1846 av_log(avctx, AV_LOG_VERBOSE, "RC buffer: %"PRId64" bits, "
1854 vaapi_encode_add_global_param(avctx,
1860 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1862 avctx->framerate.num, avctx->framerate.den, 65535);
1865 avctx->time_base.den, avctx->time_base.num, 65535);
1867 av_log(avctx, AV_LOG_VERBOSE, "RC framerate: %d/%d (%.2f fps).\n",
1874 vaapi_encode_add_global_param(avctx,
1883 static av_cold int vaapi_encode_init_max_frame_size(AVCodecContext *avctx)
1886 VAAPIEncodeContext *ctx = avctx->priv_data;
1892 av_log(avctx, AV_LOG_ERROR, "Max frame size is invalid in CQP rate "
1903 av_log(avctx, AV_LOG_ERROR, "Failed to query max frame size "
1910 av_log(avctx, AV_LOG_ERROR, "Max frame size attribute "
1919 av_log(avctx, AV_LOG_ERROR, "Driver only supports multiple pass "
1928 av_log(avctx, AV_LOG_VERBOSE, "Set max frame size: %d bytes.\n",
1932 av_log(avctx, AV_LOG_ERROR, "The max frame size option is not supported with "
1940 static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx)
1942 VAAPIEncodeContext *ctx = avctx->priv_data;
1953 av_log(avctx, AV_LOG_ERROR, "Failed to query reference frames "
1970 avctx->gop_size <= 1)) {
1977 av_log(avctx, AV_LOG_WARNING, "Failed to query prediction direction "
1981 av_log(avctx, AV_LOG_VERBOSE, "Driver does not report any additional "
1986 av_log(avctx, AV_LOG_ERROR, "Driver report incorrect prediction "
1994 av_log(avctx, AV_LOG_VERBOSE, "Driver only support same reference "
2002 av_log(avctx, AV_LOG_VERBOSE, "Driver does not support P-frames, "
2011 avctx->gop_size <= 1) {
2012 av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n");
2015 av_log(avctx, AV_LOG_ERROR, "Driver does not support any "
2019 ref_l1 < 1 || avctx->max_b_frames < 1 ||
2022 av_log(avctx, AV_LOG_VERBOSE, "Using intra and B-frames "
2026 av_log(avctx, AV_LOG_VERBOSE, "Using intra and P-frames "
2028 ctx->gop_size = avctx->gop_size;
2033 av_log(avctx, AV_LOG_VERBOSE, "Using intra and B-frames "
2037 av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames "
2039 ctx->gop_size = avctx->gop_size;
2041 ctx->b_per_p = avctx->max_b_frames;
2051 ctx->closed_gop = !!(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP);
2061 static av_cold int vaapi_encode_init_row_slice_structure(AVCodecContext *avctx,
2064 VAAPIEncodeContext *ctx = avctx->priv_data;
2072 if (avctx->slices > ctx->slice_block_rows) {
2073 av_log(avctx, AV_LOG_WARNING, "Not enough rows to use "
2075 "maximum.\n", ctx->slice_block_rows, avctx->slices);
2078 req_slices = avctx->slices;
2098 av_log(avctx, AV_LOG_ERROR, "Driver does not support any usable "
2106 static av_cold int vaapi_encode_init_tile_slice_structure(AVCodecContext *avctx,
2109 VAAPIEncodeContext *ctx = avctx->priv_data;
2115 av_log(avctx, AV_LOG_ERROR, "Supported slice structure (%#x) doesn't work for "
2122 av_log(avctx, AV_LOG_WARNING, "Not enough block rows/cols (%d x %d) "
2130 av_log(avctx, AV_LOG_WARNING, "using allowed maximum (%d x %d).\n",
2139 if (avctx->slices != req_tiles)
2140 av_log(avctx, AV_LOG_WARNING, "The number of requested slices "
2143 avctx->slices, req_tiles);
2161 av_log(avctx, AV_LOG_VERBOSE, "Encoding pictures with %d x %d tile.\n",
2167 static av_cold int vaapi_encode_init_slice_structure(AVCodecContext *avctx)
2169 VAAPIEncodeContext *ctx = avctx->priv_data;
2181 if (avctx->slices > 0) {
2182 av_log(avctx, AV_LOG_WARNING, "Multiple slices were requested "
2190 ctx->slice_block_rows = (avctx->height + ctx->slice_block_height - 1) /
2192 ctx->slice_block_cols = (avctx->width + ctx->slice_block_width - 1) /
2195 if (avctx->slices <= 1 && !ctx->tile_rows && !ctx->tile_cols) {
2206 av_log(avctx, AV_LOG_ERROR, "Failed to query slice "
2214 av_log(avctx, AV_LOG_ERROR, "Driver does not support encoding "
2223 av_log(avctx, AV_LOG_ERROR, "Driver does not support encoding "
2228 av_log(avctx, AV_LOG_ERROR, "Tile encoding option is "
2235 ret = vaapi_encode_init_tile_slice_structure(avctx, slice_structure);
2237 ret = vaapi_encode_init_row_slice_structure(avctx, slice_structure);
2241 if (ctx->nb_slices > avctx->slices) {
2242 av_log(avctx, AV_LOG_WARNING, "Slice count rounded up to "
2244 "structure.\n", ctx->nb_slices, avctx->slices);
2247 av_log(avctx, AV_LOG_ERROR, "Driver does not support "
2253 av_log(avctx, AV_LOG_VERBOSE, "Encoding pictures with %d slices.\n",
2258 static av_cold int vaapi_encode_init_packed_headers(AVCodecContext *avctx)
2260 VAAPIEncodeContext *ctx = avctx->priv_data;
2269 av_log(avctx, AV_LOG_ERROR, "Failed to query packed headers "
2276 av_log(avctx, AV_LOG_WARNING, "Driver does not support any "
2280 av_log(avctx, AV_LOG_VERBOSE, "Driver does not support any "
2286 av_log(avctx, AV_LOG_WARNING, "Driver does not support some "
2290 av_log(avctx, AV_LOG_VERBOSE, "All wanted packed headers "
2307 (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
2308 av_log(avctx, AV_LOG_WARNING, "Driver does not support packed "
2310 av_log(avctx, AV_LOG_WARNING, "No global header will be written: "
2318 static av_cold int vaapi_encode_init_quality(AVCodecContext *avctx)
2321 VAAPIEncodeContext *ctx = avctx->priv_data;
2324 int quality = avctx->compression_level;
2331 av_log(avctx, AV_LOG_ERROR, "Failed to query quality "
2338 av_log(avctx, AV_LOG_WARNING, "Quality attribute is not "
2343 av_log(avctx, AV_LOG_WARNING, "Invalid quality level: "
2352 vaapi_encode_add_global_param(avctx,
2358 av_log(avctx, AV_LOG_WARNING, "The encode quality option is "
2365 static av_cold int vaapi_encode_init_roi(AVCodecContext *avctx)
2368 VAAPIEncodeContext *ctx = avctx->priv_data;
2377 av_log(avctx, AV_LOG_ERROR, "Failed to query ROI "
2401 AVCodecContext *avctx = opaque;
2402 VAAPIEncodeContext *ctx = avctx->priv_data;
2409 av_log(avctx, AV_LOG_DEBUG, "Freed output buffer %#x\n", buffer_id);
2415 AVCodecContext *avctx = opaque;
2416 VAAPIEncodeContext *ctx = avctx->priv_data;
2430 av_log(avctx, AV_LOG_ERROR, "Failed to create bitstream "
2435 av_log(avctx, AV_LOG_DEBUG, "Allocated output buffer %#x\n", buffer_id);
2440 avctx, AV_BUFFER_FLAG_READONLY);
2449 static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx)
2451 VAAPIEncodeContext *ctx = avctx->priv_data;
2492 av_log(avctx, AV_LOG_DEBUG, "Using %s as format of "
2499 av_log(avctx, AV_LOG_ERROR, "Hardware does not support encoding at "
2525 av_log(avctx, AV_LOG_ERROR, "Failed to initialise reconstructed "
2537 av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
2539 VAAPIEncodeContext *ctx = avctx->priv_data;
2554 if (!avctx->hw_frames_ctx) {
2555 av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
2560 ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);
2575 err = vaapi_encode_profile_entrypoint(avctx);
2580 err = ctx->codec->get_encoder_caps(avctx);
2585 ctx->surface_width = FFALIGN(avctx->width, 16);
2586 ctx->surface_height = FFALIGN(avctx->height, 16);
2593 err = vaapi_encode_init_rate_control(avctx);
2597 err = vaapi_encode_init_gop_structure(avctx);
2601 err = vaapi_encode_init_slice_structure(avctx);
2605 err = vaapi_encode_init_packed_headers(avctx);
2609 err = vaapi_encode_init_roi(avctx);
2613 if (avctx->compression_level >= 0) {
2614 err = vaapi_encode_init_quality(avctx);
2620 err = vaapi_encode_init_max_frame_size(avctx);
2630 av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
2636 err = vaapi_encode_create_recon_frames(avctx);
2648 av_log(avctx, AV_LOG_ERROR, "Failed to create encode pipeline "
2655 av_buffer_pool_init2(sizeof(VABufferID), avctx,
2663 err = ctx->codec->configure(avctx);
2689 err = ctx->codec->init_sequence_params(avctx);
2691 av_log(avctx, AV_LOG_ERROR, "Codec sequence initialisation "
2699 avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
2703 err = ctx->codec->write_sequence_header(avctx, data, &bit_len);
2705 av_log(avctx, AV_LOG_ERROR, "Failed to write sequence header "
2709 avctx->extradata_size = (bit_len + 7) / 8;
2710 avctx->extradata = av_mallocz(avctx->extradata_size +
2712 if (!avctx->extradata) {
2716 memcpy(avctx->extradata, data, avctx->extradata_size);
2739 av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
2741 VAAPIEncodeContext *ctx = avctx->priv_data;
2751 vaapi_encode_free(avctx, pic);