Commit 778023d2 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Add sequence (kf) level flag for reference buffer

Allows saving bits when reference buffer is not to be used in
cases where error resilience is unimportant.

Change-Id: I2ef002a7cce96a158e1e58c2b00f0a6846049fff
parent a5fefa76
......@@ -1286,11 +1286,13 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
&dst_time_stamp, &dst_end_time_stamp,
!img)) {
#if CONFIG_REFERENCE_BUFFER
if (cpi->common.invalid_delta_frame_id_minus1) {
ctx->base.err_detail = "Invalid delta_frame_id_minus1";
return AOM_CODEC_ERROR;
if (cpi->common.use_reference_buffer) {
if (cpi->common.invalid_delta_frame_id_minus1) {
ctx->base.err_detail = "Invalid delta_frame_id_minus1";
return AOM_CODEC_ERROR;
}
}
#endif
#endif // CONFIG_REFERENCE_BUFFER
if (frame_size) {
if (ctx->pending_cx_data == 0) ctx->pending_cx_data = cx_data;
......
......@@ -242,7 +242,6 @@ static aom_codec_err_t decoder_peek_si_internal(
si->is_kf = 1;
intra_only_flag = 1;
si->h = 1;
#else
int show_frame;
int error_resilient;
......@@ -273,29 +272,38 @@ static aom_codec_err_t decoder_peek_si_internal(
si->is_kf = !aom_rb_read_bit(&rb);
show_frame = aom_rb_read_bit(&rb);
if (!si->is_kf) {
if (!show_frame) intra_only_flag = show_frame ? 0 : aom_rb_read_bit(&rb);
}
error_resilient = aom_rb_read_bit(&rb);
#if CONFIG_REFERENCE_BUFFER
{
int use_reference_buffer = 1;
SequenceHeader seq_params = { 0, 0, 0 };
if (si->is_kf) {
/* TODO: Move outside frame loop or inside key-frame branch */
int frame_id_len;
SequenceHeader seq_params;
read_sequence_header(&seq_params);
use_reference_buffer = aom_rb_read_bit(&rb);
if (use_reference_buffer) {
read_sequence_header(&seq_params);
#if CONFIG_EXT_TILE
if (large_scale_tile) seq_params.frame_id_numbers_present_flag = 0;
if (large_scale_tile) seq_params.frame_id_numbers_present_flag = 0;
#endif // CONFIG_EXT_TILE
}
}
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_REFERENCE_BUFFER
if (use_reference_buffer) {
int frame_id_len;
if (seq_params.frame_id_numbers_present_flag) {
frame_id_len = seq_params.frame_id_length_minus7 + 7;
aom_rb_read_literal(&rb, frame_id_len);
}
}
#endif
#endif // CONFIG_REFERENCE_BUFFER
if (si->is_kf) {
if (!parse_bitdepth_colorspace_sampling(profile, &rb))
return AOM_CODEC_UNSUP_BITSTREAM;
av1_read_frame_size(&rb, (int *)&si->w, (int *)&si->h);
} else {
intra_only_flag = show_frame ? 0 : aom_rb_read_bit(&rb);
rb.bit_offset += error_resilient ? 0 : 2; // reset_frame_context
if (intra_only_flag) {
......@@ -307,7 +315,7 @@ static aom_codec_err_t decoder_peek_si_internal(
av1_read_frame_size(&rb, (int *)&si->w, (int *)&si->h);
}
}
#endif
#endif // CONFIG_OBU
}
if (is_intra_only != NULL) *is_intra_only = intra_only_flag;
return AOM_CODEC_OK;
......
......@@ -64,7 +64,7 @@ extern "C" {
#define FRAME_ID_NUMBERS_PRESENT_FLAG 1
#define FRAME_ID_LENGTH_MINUS7 8 // Allows frame id up to 2^15-1
#define DELTA_FRAME_ID_LENGTH_MINUS2 12 // Allows frame id deltas up to 2^14-1
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING
#define FRAME_CONTEXTS (FRAME_BUFFERS + 1)
......@@ -508,12 +508,13 @@ typedef struct AV1Common {
#endif
int num_tg;
#if CONFIG_REFERENCE_BUFFER
int use_reference_buffer;
int current_frame_id;
int ref_frame_id[REF_FRAMES];
int valid_for_referencing[REF_FRAMES];
int refresh_mask;
int invalid_delta_frame_id_minus1;
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_ANS && ANS_MAX_SYMBOLS
int ans_window_size_log2;
#endif
......@@ -535,7 +536,7 @@ typedef struct SequenceHeader {
int frame_id_length_minus7;
int delta_frame_id_length_minus2;
} SequenceHeader;
#endif
#endif // CONFIG_REFERENCE_BUFFER
// TODO(hkuang): Don't need to lock the whole pool after implementing atomic
// frame reference count.
......@@ -1276,6 +1277,10 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
return base_partitions[split_idx];
}
static INLINE void set_use_reference_buffer(AV1_COMMON *const cm, int use) {
cm->use_reference_buffer = use;
}
static INLINE void set_sb_size(AV1_COMMON *const cm, BLOCK_SIZE sb_size) {
cm->sb_size = sb_size;
cm->mib_size = mi_size_wide[cm->sb_size];
......
This diff is collapsed.
......@@ -142,7 +142,7 @@ typedef struct AV1Decoder {
int tg_size_bit_offset;
#if CONFIG_REFERENCE_BUFFER
SequenceHeader seq_params;
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_INSPECTION
aom_inspect_cb inspect_cb;
void *inspect_ctx;
......
This diff is collapsed.
......@@ -368,6 +368,9 @@ static void setup_frame(AV1_COMP *cpi) {
cpi->refresh_alt_ref_frame = 1;
av1_zero(cpi->interp_filter_selected);
set_sb_size(cm, select_sb_size(cpi));
#if CONFIG_REFERENCE_BUFFER
set_use_reference_buffer(cm, 0);
#endif // CONFIG_REFERENCE_BUFFER
} else {
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING
if (frame_is_intra_only(cm) || cm->error_resilient_mode ||
......@@ -5397,7 +5400,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
#endif
#if CONFIG_REFERENCE_BUFFER
{
if (cm->use_reference_buffer) {
/* Non-normative definition of current_frame_id ("frame counter" with
* wraparound) */
const int frame_id_length = FRAME_ID_LENGTH_MINUS7 + 7;
......@@ -5422,7 +5425,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
(1 << frame_id_length);
}
}
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_EXT_DELTA_Q
cm->delta_q_present_flag = cpi->oxcf.deltaq_mode != NO_DELTA_Q;
......@@ -5497,7 +5500,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
}
#if CONFIG_REFERENCE_BUFFER
{
if (cm->use_reference_buffer) {
int i;
/* Update reference frame id values based on the value of refresh_mask */
for (i = 0; i < REF_FRAMES; i++) {
......@@ -5506,7 +5509,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
}
}
}
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if DUMP_RECON_FRAMES == 1
// NOTE(zoeliu): For debug - Output the filtered reconstructed video.
......@@ -6463,10 +6466,12 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
#endif
#if CONFIG_REFERENCE_BUFFER
if (*time_stamp == 0) {
cpi->common.current_frame_id = -1;
if (cm->use_reference_buffer) {
if (*time_stamp == 0) {
cpi->common.current_frame_id = -1;
}
}
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_AMVR
cpi->cur_poc++;
if (oxcf->pass != 1 && cpi->common.allow_screen_content_tools) {
......
......@@ -624,7 +624,7 @@ typedef struct AV1_COMP {
#endif
#if CONFIG_REFERENCE_BUFFER
SequenceHeader seq_params;
#endif
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_LV_MAP
tran_low_t *tcoeff_buf[MAX_MB_PLANE];
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment