| 1821 | } |
| 1822 | |
| 1823 | static av_cold int vaapi_encode_init_slice_structure(AVCodecContext *avctx) |
| 1824 | { |
| 1825 | FFHWBaseEncodeContext *base_ctx = avctx->priv_data; |
| 1826 | VAAPIEncodeContext *ctx = avctx->priv_data; |
| 1827 | VAConfigAttrib attr[3] = { { VAConfigAttribEncMaxSlices }, |
| 1828 | { VAConfigAttribEncSliceStructure }, |
| 1829 | #if VA_CHECK_VERSION(1, 1, 0) |
| 1830 | { VAConfigAttribEncTileSupport }, |
| 1831 | #endif |
| 1832 | }; |
| 1833 | VAStatus vas; |
| 1834 | uint32_t max_slices, slice_structure; |
| 1835 | int ret; |
| 1836 | |
| 1837 | if (!(ctx->codec->flags & FF_HW_FLAG_SLICE_CONTROL)) { |
| 1838 | if (avctx->slices > 0) { |
| 1839 | av_log(avctx, AV_LOG_WARNING, "Multiple slices were requested " |
| 1840 | "but this codec does not support controlling slices.\n"); |
| 1841 | } |
| 1842 | return 0; |
| 1843 | } |
| 1844 | |
| 1845 | av_assert0(base_ctx->slice_block_height > 0 && base_ctx->slice_block_width > 0); |
| 1846 | |
| 1847 | ctx->slice_block_rows = (avctx->height + base_ctx->slice_block_height - 1) / |
| 1848 | base_ctx->slice_block_height; |
| 1849 | ctx->slice_block_cols = (avctx->width + base_ctx->slice_block_width - 1) / |
| 1850 | base_ctx->slice_block_width; |
| 1851 | |
| 1852 | if (avctx->slices <= 1 && !ctx->tile_rows && !ctx->tile_cols) { |
| 1853 | ctx->nb_slices = 1; |
| 1854 | ctx->slice_size = ctx->slice_block_rows; |
| 1855 | return 0; |
| 1856 | } |
| 1857 | |
| 1858 | vas = vaGetConfigAttributes(ctx->hwctx->display, |
| 1859 | ctx->va_profile, |
| 1860 | ctx->va_entrypoint, |
| 1861 | attr, FF_ARRAY_ELEMS(attr)); |
| 1862 | if (vas != VA_STATUS_SUCCESS) { |
| 1863 | av_log(avctx, AV_LOG_ERROR, "Failed to query slice " |
| 1864 | "attributes: %d (%s).\n", vas, vaErrorStr(vas)); |
| 1865 | return AVERROR_EXTERNAL; |
| 1866 | } |
| 1867 | max_slices = attr[0].value; |
| 1868 | slice_structure = attr[1].value; |
| 1869 | if (max_slices == VA_ATTRIB_NOT_SUPPORTED || |
| 1870 | slice_structure == VA_ATTRIB_NOT_SUPPORTED) { |
| 1871 | av_log(avctx, AV_LOG_ERROR, "Driver does not support encoding " |
| 1872 | "pictures as multiple slices.\n."); |
| 1873 | return AVERROR(EINVAL); |
| 1874 | } |
| 1875 | |
| 1876 | if (ctx->tile_rows && ctx->tile_cols) { |
| 1877 | #if VA_CHECK_VERSION(1, 1, 0) |
| 1878 | uint32_t tile_support = attr[2].value; |
| 1879 | if (tile_support == VA_ATTRIB_NOT_SUPPORTED) { |
| 1880 | av_log(avctx, AV_LOG_ERROR, "Driver does not support encoding " |
no test coverage detected