Commit 5e70a114 authored by David Barker's avatar David Barker

Deduplicate use_reference_buffer/frame_id_numbers_present_flag

These two flags serve essentially the same purpose, so we can
simplify down to just having one flag. Since the
frame_id_numbers_present_flag is older and listed in the
reference-buffer design doc, this is the one we'll keep.

Note that, previously, frame_id_numbers_present_flag was only
sent when CONFIG_OBU was enabled - otherwise it was always set
to 1. On the other hand, use_reference_buffer was always signalled
so that allowed us to disable frame ids even without CONFIG_OBU.

In order to keep the ability to disable frame IDs without
CONFIG_OBU, we send a "real" sequence header (ie, with the same
data as in CONFIG_OBU) in-line within the uncompressed header.
This is sent every keyframe and every intra-only frame, just
as the use_reference_buffer flag was before this patch.

BUG=aomedia:853

Change-Id: I4bb6c7a222aeddfb6d3737a39d10782d32ee2eee
parent c5a1f263
......@@ -1286,7 +1286,7 @@ 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.use_reference_buffer) {
if (cpi->common.seq_params.frame_id_numbers_present_flag) {
if (cpi->common.invalid_delta_frame_id_minus1) {
ctx->base.err_detail = "Invalid delta_frame_id_minus1";
return AOM_CODEC_ERROR;
......
......@@ -277,26 +277,20 @@ static aom_codec_err_t decoder_peek_si_internal(
}
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 */
use_reference_buffer = aom_rb_read_bit(&rb);
if (use_reference_buffer) {
read_sequence_header(&seq_params);
read_sequence_header(&seq_params, &rb);
#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) {
if (seq_params.frame_id_numbers_present_flag) {
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);
}
frame_id_len = seq_params.frame_id_length_minus7 + 7;
aom_rb_read_literal(&rb, frame_id_len);
}
#endif // CONFIG_REFERENCE_BUFFER
if (si->is_kf) {
......
......@@ -204,6 +204,15 @@ typedef int BASE_CTX_TABLE[2 /*col*/][2 /*sig_map*/]
[BASE_CONTEXT_POSITION_NUM + 1];
#endif
#if CONFIG_REFERENCE_BUFFER
/* Initial version of sequence header structure */
typedef struct SequenceHeader {
int frame_id_numbers_present_flag;
int frame_id_length_minus7;
int delta_frame_id_length_minus2;
} SequenceHeader;
#endif // CONFIG_REFERENCE_BUFFER
typedef struct AV1Common {
struct aom_internal_error_info error;
aom_color_space_t color_space;
......@@ -507,7 +516,7 @@ typedef struct AV1Common {
#endif
int num_tg;
#if CONFIG_REFERENCE_BUFFER
int use_reference_buffer;
SequenceHeader seq_params;
int current_frame_id;
int ref_frame_id[REF_FRAMES];
int valid_for_referencing[REF_FRAMES];
......@@ -528,15 +537,6 @@ typedef struct AV1Common {
#endif
} AV1_COMMON;
#if CONFIG_REFERENCE_BUFFER
/* Initial version of sequence header structure */
typedef struct SequenceHeader {
int frame_id_numbers_present_flag;
int frame_id_length_minus7;
int delta_frame_id_length_minus2;
} SequenceHeader;
#endif // CONFIG_REFERENCE_BUFFER
// TODO(hkuang): Don't need to lock the whole pool after implementing atomic
// frame reference count.
static void lock_buffer_pool(BufferPool *const pool) {
......@@ -1329,7 +1329,7 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
static INLINE void set_use_reference_buffer(AV1_COMMON *const cm, int use) {
#if CONFIG_REFERENCE_BUFFER
cm->use_reference_buffer = use;
cm->seq_params.frame_id_numbers_present_flag = use;
#else
(void)cm;
(void)use;
......
This diff is collapsed.
......@@ -21,7 +21,8 @@ struct aom_read_bit_buffer;
#if CONFIG_REFERENCE_BUFFER
/* Placeholder for now */
void read_sequence_header(SequenceHeader *seq_params);
void read_sequence_header(SequenceHeader *seq_params,
struct aom_read_bit_buffer *rb);
#endif
void av1_read_frame_size(struct aom_read_bit_buffer *rb, int *width,
......
......@@ -140,9 +140,6 @@ typedef struct AV1Decoder {
int tg_size; // Number of tiles in the current tilegroup
int tg_start; // First tile in the current tilegroup
int tg_size_bit_offset;
#if CONFIG_REFERENCE_BUFFER
SequenceHeader seq_params;
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_INSPECTION
aom_inspect_cb inspect_cb;
void *inspect_ctx;
......
This diff is collapsed.
......@@ -18,12 +18,11 @@ extern "C" {
#include "av1/encoder/encoder.h"
struct aom_write_bit_buffer;
#if CONFIG_REFERENCE_BUFFER
void write_sequence_header(
#if CONFIG_EXT_TILE
AV1_COMMON *const cm,
#endif // CONFIG_EXT_TILE
SequenceHeader *seq_params);
void write_sequence_header(AV1_COMMON *const cm,
struct aom_write_bit_buffer *wb);
#endif
void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dest, size_t *size);
......
......@@ -5522,7 +5522,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
#endif
#if CONFIG_REFERENCE_BUFFER
if (cm->use_reference_buffer) {
if (cm->seq_params.frame_id_numbers_present_flag) {
/* Non-normative definition of current_frame_id ("frame counter" with
* wraparound) */
const int frame_id_length = FRAME_ID_LENGTH_MINUS7 + 7;
......@@ -5622,7 +5622,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
}
#if CONFIG_REFERENCE_BUFFER
if (cm->use_reference_buffer) {
if (cm->seq_params.frame_id_numbers_present_flag) {
int i;
/* Update reference frame id values based on the value of refresh_mask */
for (i = 0; i < REF_FRAMES; i++) {
......@@ -6588,7 +6588,7 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
#endif
#if CONFIG_REFERENCE_BUFFER
if (cm->use_reference_buffer) {
if (cm->seq_params.frame_id_numbers_present_flag) {
if (*time_stamp == 0) {
cpi->common.current_frame_id = -1;
}
......
......@@ -618,9 +618,6 @@ typedef struct AV1_COMP {
#if CONFIG_GLOBAL_MOTION
int global_motion_search_done;
#endif
#if CONFIG_REFERENCE_BUFFER
SequenceHeader seq_params;
#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