MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vaapi_encode_init_tile_slice_structure

Function vaapi_encode_init_tile_slice_structure

libavcodec/vaapi_encode.c:1762–1821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1760}
1761
1762static av_cold int vaapi_encode_init_tile_slice_structure(AVCodecContext *avctx,
1763 uint32_t slice_structure)
1764{
1765 VAAPIEncodeContext *ctx = avctx->priv_data;
1766 int i, req_tiles;
1767
1768 if (!(slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS ||
1769 (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS &&
1770 ctx->tile_cols == 1))) {
1771 av_log(avctx, AV_LOG_ERROR, "Supported slice structure (%#x) doesn't work for "
1772 "current tile requirement.\n", slice_structure);
1773 return AVERROR(EINVAL);
1774 }
1775
1776 if (ctx->tile_rows > ctx->slice_block_rows ||
1777 ctx->tile_cols > ctx->slice_block_cols) {
1778 av_log(avctx, AV_LOG_WARNING, "Not enough block rows/cols (%d x %d) "
1779 "for configured number of tile (%d x %d); ",
1780 ctx->slice_block_rows, ctx->slice_block_cols,
1781 ctx->tile_rows, ctx->tile_cols);
1782 ctx->tile_rows = ctx->tile_rows > ctx->slice_block_rows ?
1783 ctx->slice_block_rows : ctx->tile_rows;
1784 ctx->tile_cols = ctx->tile_cols > ctx->slice_block_cols ?
1785 ctx->slice_block_cols : ctx->tile_cols;
1786 av_log(avctx, AV_LOG_WARNING, "using allowed maximum (%d x %d).\n",
1787 ctx->tile_rows, ctx->tile_cols);
1788 }
1789
1790 req_tiles = ctx->tile_rows * ctx->tile_cols;
1791
1792 // Tile slice is not allowed to cross the boundary of a tile due to
1793 // the constraints of media-driver. Currently we support one slice
1794 // per tile. This could be extended to multiple slices per tile.
1795 if (avctx->slices != req_tiles)
1796 av_log(avctx, AV_LOG_WARNING, "The number of requested slices "
1797 "mismatches with configured number of tile (%d != %d); "
1798 "using requested tile number for slice.\n",
1799 avctx->slices, req_tiles);
1800
1801 ctx->nb_slices = req_tiles;
1802
1803 // Default in uniform spacing
1804 // 6-3, 6-5
1805 for (i = 0; i < ctx->tile_cols; i++) {
1806 ctx->col_width[i] = ( i + 1 ) * ctx->slice_block_cols / ctx->tile_cols -
1807 i * ctx->slice_block_cols / ctx->tile_cols;
1808 ctx->col_bd[i + 1] = ctx->col_bd[i] + ctx->col_width[i];
1809 }
1810 // 6-4, 6-6
1811 for (i = 0; i < ctx->tile_rows; i++) {
1812 ctx->row_height[i] = ( i + 1 ) * ctx->slice_block_rows / ctx->tile_rows -
1813 i * ctx->slice_block_rows / ctx->tile_rows;
1814 ctx->row_bd[i + 1] = ctx->row_bd[i] + ctx->row_height[i];
1815 }
1816
1817 av_log(avctx, AV_LOG_VERBOSE, "Encoding pictures with %d x %d tile.\n",
1818 ctx->tile_rows, ctx->tile_cols);
1819

Callers 1

Calls 1

av_logFunction · 0.85

Tested by

no test coverage detected