Move initialization of look ahead queue context Moved the call to function av1_lookahead_init to encoder_encode. check_initial_width will now be called in encoder_encode, instead of av1_receive_raw_frame. Change-Id: I8dd366e0e4578666f7bb43fbec7e4240076848d4
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index f235c70..6658f4b 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -1896,7 +1896,25 @@ if (img != NULL) { YV12_BUFFER_CONFIG sd; + int use_highbitdepth, subsampling_x, subsampling_y; res = image2yuvconfig(img, &sd); + use_highbitdepth = (sd.flags & YV12_FLAG_HIGHBITDEPTH) != 0; + subsampling_x = sd.subsampling_x; + subsampling_y = sd.subsampling_y; + + if (!cpi->lookahead) { + cpi->lookahead = av1_lookahead_init( + cpi->oxcf.width, cpi->oxcf.height, subsampling_x, subsampling_y, + use_highbitdepth, cpi->oxcf.lag_in_frames, + cpi->oxcf.border_in_pixels, + (cpi->oxcf.resize_mode || cpi->oxcf.superres_mode)); + } + if (!cpi->lookahead) + aom_internal_error(&cpi->common.error, AOM_CODEC_MEM_ERROR, + "Failed to allocate lag buffers"); + + av1_check_initial_width(cpi, use_highbitdepth, subsampling_x, + subsampling_y); // Store the original flags in to the frame buffer. Will extract the // key frame flag when we actually encode this frame.
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index 37d14a4..4486dca 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -934,22 +934,12 @@ } } -static void alloc_raw_frame_buffers(AV1_COMP *cpi) { +static void alloc_altref_frame_buffer(AV1_COMP *cpi) { AV1_COMMON *cm = &cpi->common; const SequenceHeader *const seq_params = &cm->seq_params; const AV1EncoderConfig *oxcf = &cpi->oxcf; int is_scale = (oxcf->resize_mode || oxcf->superres_mode); - if (!cpi->lookahead) { - cpi->lookahead = av1_lookahead_init( - oxcf->width, oxcf->height, seq_params->subsampling_x, - seq_params->subsampling_y, seq_params->use_highbitdepth, - oxcf->lag_in_frames, oxcf->border_in_pixels, is_scale); - } - if (!cpi->lookahead) - aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR, - "Failed to allocate lag buffers"); - // TODO(agrange) Check if ARF is enabled and skip allocation if not. // (yunqing)Here use same border as lookahead buffers. if (aom_realloc_frame_buffer( @@ -4107,8 +4097,8 @@ } } -static void check_initial_width(AV1_COMP *cpi, int use_highbitdepth, - int subsampling_x, int subsampling_y) { +void av1_check_initial_width(AV1_COMP *cpi, int use_highbitdepth, + int subsampling_x, int subsampling_y) { AV1_COMMON *const cm = &cpi->common; SequenceHeader *const seq_params = &cm->seq_params; @@ -4119,7 +4109,7 @@ seq_params->subsampling_y = subsampling_y; seq_params->use_highbitdepth = use_highbitdepth; - alloc_raw_frame_buffers(cpi); + alloc_altref_frame_buffer(cpi); init_ref_frame_bufs(cpi); alloc_util_frame_buffers(cpi); @@ -4135,9 +4125,9 @@ int av1_set_size_literal(AV1_COMP *cpi, int width, int height) { AV1_COMMON *cm = &cpi->common; const int num_planes = av1_num_planes(cm); - check_initial_width(cpi, cm->seq_params.use_highbitdepth, - cm->seq_params.subsampling_x, - cm->seq_params.subsampling_y); + av1_check_initial_width(cpi, cm->seq_params.use_highbitdepth, + cm->seq_params.subsampling_x, + cm->seq_params.subsampling_y); if (width <= 0 || height <= 0) return 1; @@ -6252,8 +6242,6 @@ const int subsampling_y = sd->subsampling_y; const int use_highbitdepth = (sd->flags & YV12_FLAG_HIGHBITDEPTH) != 0; - check_initial_width(cpi, use_highbitdepth, subsampling_x, subsampling_y); - #if CONFIG_INTERNAL_STATS struct aom_usec_timer timer; aom_usec_timer_start(&timer);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index 8fd07ce..b07d918 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -1166,6 +1166,9 @@ void av1_change_config(AV1_COMP *cpi, const AV1EncoderConfig *oxcf); +void av1_check_initial_width(AV1_COMP *cpi, int use_highbitdepth, + int subsampling_x, int subsampling_y); + // receive a frames worth of data. caller can assume that a copy of this // frame is made and not just a copy of the pointer.. int av1_receive_raw_frame(AV1_COMP *cpi, aom_enc_frame_flags_t frame_flags,