| 1715 | } |
| 1716 | |
| 1717 | static av_cold int vaapi_encode_init_row_slice_structure(AVCodecContext *avctx, |
| 1718 | uint32_t slice_structure) |
| 1719 | { |
| 1720 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 1721 | int req_slices; |
| 1722 | |
| 1723 | // For fixed-size slices currently we only support whole rows, making |
| 1724 | // rectangular slices. This could be extended to arbitrary runs of |
| 1725 | // blocks, but since slices tend to be a conformance requirement and |
| 1726 | // most cases (such as broadcast or bluray) want rectangular slices |
| 1727 | // only it would need to be gated behind another option. |
| 1728 | if (avctx->slices > ctx->slice_block_rows) { |
| 1729 | av_log(avctx, AV_LOG_WARNING, "Not enough rows to use " |
| 1730 | "configured number of slices (%d < %d); using " |
| 1731 | "maximum.\n", ctx->slice_block_rows, avctx->slices); |
| 1732 | req_slices = ctx->slice_block_rows; |
| 1733 | } else { |
| 1734 | req_slices = avctx->slices; |
| 1735 | } |
| 1736 | if (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS || |
| 1737 | slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) { |
| 1738 | ctx->nb_slices = req_slices; |
| 1739 | ctx->slice_size = ctx->slice_block_rows / ctx->nb_slices; |
| 1740 | } else if (slice_structure & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) { |
| 1741 | int k; |
| 1742 | for (k = 1;; k *= 2) { |
| 1743 | if (2 * k * (req_slices - 1) + 1 >= ctx->slice_block_rows) |
| 1744 | break; |
| 1745 | } |
| 1746 | ctx->nb_slices = (ctx->slice_block_rows + k - 1) / k; |
| 1747 | ctx->slice_size = k; |
| 1748 | #if VA_CHECK_VERSION(1, 0, 0) |
| 1749 | } else if (slice_structure & VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS) { |
| 1750 | ctx->nb_slices = ctx->slice_block_rows; |
| 1751 | ctx->slice_size = 1; |
| 1752 | #endif |
| 1753 | } else { |
| 1754 | av_log(avctx, AV_LOG_ERROR, "Driver does not support any usable " |
| 1755 | "slice structure modes (%#x).\n", slice_structure); |
| 1756 | return AVERROR(EINVAL); |
| 1757 | } |
| 1758 | |
| 1759 | return 0; |
| 1760 | } |
| 1761 | |
| 1762 | static av_cold int vaapi_encode_init_tile_slice_structure(AVCodecContext *avctx, |
| 1763 | uint32_t slice_structure) |
no test coverage detected