Use signed int type for av1_lookahead_init params Callers of av1_lookahead_init pass signed int variables as those parameters, and av1_lookahead_init passes those parameters to a function that receives signed int parameters. Also change av1_lookahead_depth to return signed int. A port of the libaom CL https://aomedia-review.googlesource.com/c/aom/+/201201.
diff --git a/av1/encoder/lookahead.c b/av1/encoder/lookahead.c index 476ea8e..78fcf92 100644 --- a/av1/encoder/lookahead.c +++ b/av1/encoder/lookahead.c
@@ -43,15 +43,16 @@ } } -struct lookahead_ctx *av1_lookahead_init( - unsigned int width, unsigned int height, unsigned int subsampling_x, - unsigned int subsampling_y, unsigned int depth, const int border_in_pixels, - int byte_alignment, int num_lap_buffers, +struct lookahead_ctx *av1_lookahead_init(int width, int height, + int subsampling_x, int subsampling_y, + int depth, const int border_in_pixels, + int byte_alignment, + int num_lap_buffers, #if CONFIG_BRU // BRU need extra look ahead buffer to store the src of // reference frame (org pixels) - int num_extra_buffers, + int num_extra_buffers, #endif // CONFIG_BRU - bool alloc_pyramid) { + bool alloc_pyramid) { struct lookahead_ctx *ctx = NULL; int lag_in_frames = AOMMAX(1, depth); @@ -67,7 +68,6 @@ // Allocate the lookahead structures ctx = calloc(1, sizeof(*ctx)); if (ctx) { - unsigned int i; ctx->max_sz = depth; #if CONFIG_BRU ctx->read_ctxs[ENCODE_STAGE].pop_sz = @@ -84,7 +84,7 @@ } ctx->buf = calloc(depth, sizeof(*ctx->buf)); if (!ctx->buf) goto fail; - for (i = 0; i < depth; i++) { + for (int i = 0; i < depth; i++) { aom_free_frame_buffer(&ctx->buf[i].img); if (aom_realloc_frame_buffer(&ctx->buf[i].img, width, height, subsampling_x, subsampling_y, @@ -284,8 +284,7 @@ return buf; } -unsigned int av1_lookahead_depth(struct lookahead_ctx *ctx, - COMPRESSOR_STAGE stage) { +int av1_lookahead_depth(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage) { struct read_ctx *read_ctx = NULL; assert(ctx != NULL);
diff --git a/av1/encoder/lookahead.h b/av1/encoder/lookahead.h index 45ff485..f12f888 100644 --- a/av1/encoder/lookahead.h +++ b/av1/encoder/lookahead.h
@@ -68,14 +68,15 @@ * The lookahead stage is a queue of frame buffers on which some analysis * may be done when buffers are enqueued. */ -struct lookahead_ctx *av1_lookahead_init( - unsigned int width, unsigned int height, unsigned int subsampling_x, - unsigned int subsampling_y, unsigned int depth, const int border_in_pixels, - int byte_alignment, int num_lap_buffers, +struct lookahead_ctx *av1_lookahead_init(int width, int height, + int subsampling_x, int subsampling_y, + int depth, const int border_in_pixels, + int byte_alignment, + int num_lap_buffers, #if CONFIG_BRU - int num_extra_buffers, + int num_extra_buffers, #endif // CONFIG_BRU - bool alloc_pyramid); + bool alloc_pyramid); /**\brief Destroys the lookahead stage */ @@ -152,8 +153,7 @@ /**\brief Get the number of frames currently in the lookahead queue */ -unsigned int av1_lookahead_depth(struct lookahead_ctx *ctx, - COMPRESSOR_STAGE stage); +int av1_lookahead_depth(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage); /**\brief Get pop_sz value */
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c index 389c2cf..1029f2f 100644 --- a/av1/encoder/pass2_strategy.c +++ b/av1/encoder/pass2_strategy.c
@@ -1413,7 +1413,7 @@ static void correct_frames_to_key(AV1_COMP *cpi) { int lookahead_size = - (int)av1_lookahead_depth(cpi->lookahead, cpi->compressor_stage); + av1_lookahead_depth(cpi->lookahead, cpi->compressor_stage); if (lookahead_size < av1_lookahead_pop_sz(cpi->lookahead, cpi->compressor_stage)) { cpi->rc.frames_to_key = AOMMIN(cpi->rc.frames_to_key, lookahead_size); @@ -1425,7 +1425,7 @@ static int is_last_subgop(AV1_COMP *cpi) { const int lookahead_size = - (int)av1_lookahead_depth(cpi->lookahead, cpi->compressor_stage); + av1_lookahead_depth(cpi->lookahead, cpi->compressor_stage); // Check if last subgop in the clip. const int is_last_sub = (cpi->oxcf.gf_cfg.lag_in_frames > lookahead_size) && (lookahead_size == cpi->rc.frames_to_key);