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

Function vaapi_encode_av1_set_tile

libavcodec/vaapi_encode_av1.c:216–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216static int vaapi_encode_av1_set_tile(AVCodecContext *avctx)
217{
218 VAAPIEncodeAV1Context *priv = avctx->priv_data;
219 int mi_cols, mi_rows, sb_shift, sb_size;
220 int max_tile_area_sb, max_tile_area_sb_varied;
221 int tile_width_sb, tile_height_sb, widest_tile_sb;
222 int tile_cols, tile_rows;
223 int min_log2_tiles;
224 int i;
225
226 if (priv->tile_cols > AV1_MAX_TILE_COLS ||
227 priv->tile_rows > AV1_MAX_TILE_ROWS) {
228 av_log(avctx, AV_LOG_ERROR, "Invalid tile number %dx%d, should less than %dx%d.\n",
229 priv->tile_cols, priv->tile_rows, AV1_MAX_TILE_COLS, AV1_MAX_TILE_ROWS);
230 return AVERROR(EINVAL);
231 }
232
233 mi_cols = 2 * ((avctx->width + 7) >> 3);
234 mi_rows = 2 * ((avctx->height + 7) >> 3);
235 priv->sb_cols = priv->use_128x128_superblock ?
236 ((mi_cols + 31) >> 5) : ((mi_cols + 15) >> 4);
237 priv->sb_rows = priv->use_128x128_superblock ?
238 ((mi_rows + 31) >> 5) : ((mi_rows + 15) >> 4);
239 sb_shift = priv->use_128x128_superblock ? 5 : 4;
240 sb_size = sb_shift + 2;
241 priv->max_tile_width_sb = AV1_MAX_TILE_WIDTH >> sb_size;
242 max_tile_area_sb = AV1_MAX_TILE_AREA >> (2 * sb_size);
243
244 priv->min_log2_tile_cols = tile_log2(priv->max_tile_width_sb, priv->sb_cols);
245 priv->max_log2_tile_cols = tile_log2(1, FFMIN(priv->sb_cols, AV1_MAX_TILE_COLS));
246 priv->max_log2_tile_rows = tile_log2(1, FFMIN(priv->sb_rows, AV1_MAX_TILE_ROWS));
247 min_log2_tiles = FFMAX(priv->min_log2_tile_cols,
248 tile_log2(max_tile_area_sb, priv->sb_rows * priv->sb_cols));
249
250 tile_cols = av_clip(priv->tile_cols, (priv->sb_cols + priv->max_tile_width_sb - 1) / priv->max_tile_width_sb, priv->sb_cols);
251
252 if (!priv->tile_cols)
253 priv->tile_cols = tile_cols;
254 else if (priv->tile_cols != tile_cols){
255 av_log(avctx, AV_LOG_ERROR, "Invalid tile cols %d, should be in range of %d~%d\n",
256 priv->tile_cols,
257 (priv->sb_cols + priv->max_tile_width_sb - 1) / priv->max_tile_width_sb,
258 priv->sb_cols);
259 return AVERROR(EINVAL);
260 }
261
262 priv->tile_cols_log2 = tile_log2(1, priv->tile_cols);
263 tile_width_sb = (priv->sb_cols + (1 << priv->tile_cols_log2) - 1) >>
264 priv->tile_cols_log2;
265
266 if (priv->tile_rows > priv->sb_rows) {
267 av_log(avctx, AV_LOG_ERROR, "Invalid tile rows %d, should be less than %d.\n",
268 priv->tile_rows, priv->sb_rows);
269 return AVERROR(EINVAL);
270 }
271
272 /** Try user setting tile rows number first. */
273 tile_rows = priv->tile_rows ? priv->tile_rows : 1;

Callers 1

vaapi_encode_av1_initFunction · 0.85

Calls 2

av_logFunction · 0.85
tile_log2Function · 0.85

Tested by

no test coverage detected