Commit e83fcfeb authored by Frederic Barbier's avatar Frederic Barbier Committed by Sebastien Alaiwan
Browse files

Hide coding details of fid_length/delta_fid_length

Let the writing/parsing logic do the +7/+2 offseting,
and let the rest of the code directly manipulate the actual values.

Change-Id: I460d5bf18446c028f326cb747b3c26c8d451637c
parent 77ea41c3
......@@ -292,9 +292,7 @@ static aom_codec_err_t decoder_peek_si_internal(
#endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_REFERENCE_BUFFER
if (seq_params.frame_id_numbers_present_flag) {
int frame_id_len;
frame_id_len = seq_params.frame_id_length_minus7 + 7;
aom_rb_read_literal(&rb, frame_id_len);
aom_rb_read_literal(&rb, seq_params.frame_id_length);
}
#endif // CONFIG_REFERENCE_BUFFER
if (si->is_kf) {
......
......@@ -199,8 +199,8 @@ typedef int BASE_CTX_TABLE[2 /*col*/][2 /*sig_map*/]
/* 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;
int frame_id_length;
int delta_frame_id_length;
} SequenceHeader;
#endif // CONFIG_REFERENCE_BUFFER
......
......@@ -3367,8 +3367,8 @@ void read_sequence_header(SequenceHeader *seq_params,
/* Placeholder for actually reading from the bitstream */
seq_params->frame_id_numbers_present_flag = aom_rb_read_bit(rb);
if (seq_params->frame_id_numbers_present_flag) {
seq_params->frame_id_length_minus7 = aom_rb_read_literal(rb, 4);
seq_params->delta_frame_id_length_minus2 = aom_rb_read_literal(rb, 4);
seq_params->frame_id_length = aom_rb_read_literal(rb, 4) + 7;
seq_params->delta_frame_id_length = aom_rb_read_literal(rb, 4) + 2;
}
}
#endif // CONFIG_REFERENCE_BUFFER
......@@ -3610,7 +3610,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
const int frame_to_show = cm->ref_frame_map[existing_frame_idx];
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_length = cm->seq_params.frame_id_length_minus7 + 7;
int frame_id_length = cm->seq_params.frame_id_length;
int display_frame_id = aom_rb_read_literal(rb, frame_id_length);
/* Compare display_frame_id with ref_frame_id and check valid for
* referencing */
......@@ -3663,8 +3663,8 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
if (frame_is_intra_only(cm)) read_sequence_header(&cm->seq_params, rb);
#endif // !CONFIG_OBU
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_length = cm->seq_params.frame_id_length_minus7 + 7;
int diff_len = cm->seq_params.delta_frame_id_length_minus2 + 2;
int frame_id_length = cm->seq_params.frame_id_length;
int diff_len = cm->seq_params.delta_frame_id_length;
int prev_frame_id = 0;
if (cm->frame_type != KEY_FRAME) {
prev_frame_id = cm->current_frame_id;
......@@ -3833,8 +3833,8 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#endif // CONFIG_FRAME_SIGN_BIAS
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_length = cm->seq_params.frame_id_length_minus7 + 7;
int diff_len = cm->seq_params.delta_frame_id_length_minus2 + 2;
int frame_id_length = cm->seq_params.frame_id_length;
int diff_len = cm->seq_params.delta_frame_id_length;
int delta_frame_id_minus1 = aom_rb_read_literal(rb, diff_len);
int ref_frame_id =
((cm->current_frame_id - (delta_frame_id_minus1 + 1) +
......@@ -4753,8 +4753,8 @@ static uint32_t read_sequence_header_obu(AV1Decoder *pbi,
seq_params->frame_id_numbers_present_flag = aom_rb_read_bit(rb);
if (seq_params->frame_id_numbers_present_flag) {
seq_params->frame_id_length_minus7 = aom_rb_read_literal(rb, 4);
seq_params->delta_frame_id_length_minus2 = aom_rb_read_literal(rb, 4);
seq_params->frame_id_length = aom_rb_read_literal(rb, 4) + 7;
seq_params->delta_frame_id_length = aom_rb_read_literal(rb, 4) + 2;
}
read_bitdepth_colorspace_sampling(cm, rb, pbi->allow_lowbitdepth);
......
......@@ -4149,13 +4149,13 @@ void write_sequence_header(AV1_COMMON *const cm,
cm->large_scale_tile ? 0 :
#endif // CONFIG_EXT_TILE
FRAME_ID_NUMBERS_PRESENT_FLAG;
seq_params->frame_id_length_minus7 = FRAME_ID_LENGTH_MINUS7;
seq_params->delta_frame_id_length_minus2 = DELTA_FRAME_ID_LENGTH_MINUS2;
seq_params->frame_id_length = FRAME_ID_LENGTH_MINUS7 + 7;
seq_params->delta_frame_id_length = DELTA_FRAME_ID_LENGTH_MINUS2 + 2;
aom_wb_write_bit(wb, seq_params->frame_id_numbers_present_flag);
if (seq_params->frame_id_numbers_present_flag) {
aom_wb_write_literal(wb, seq_params->frame_id_length_minus7, 4);
aom_wb_write_literal(wb, seq_params->delta_frame_id_length_minus2, 4);
aom_wb_write_literal(wb, seq_params->frame_id_length - 7, 4);
aom_wb_write_literal(wb, seq_params->delta_frame_id_length - 2, 4);
}
}
#endif // CONFIG_REFERENCE_BUFFER
......@@ -4347,7 +4347,7 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int frame_id_len = cm->seq_params.frame_id_length;
int display_frame_id = cm->ref_frame_id[cpi->existing_fb_idx_to_show];
aom_wb_write_literal(wb, display_frame_id, frame_id_len);
/* Add a zero byte to prevent emulation of superframe marker */
......@@ -4376,7 +4376,7 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
cm->invalid_delta_frame_id_minus1 = 0;
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int frame_id_len = cm->seq_params.frame_id_length;
aom_wb_write_literal(wb, cm->current_frame_id, frame_id_len);
}
#endif // CONFIG_REFERENCE_BUFFER
......@@ -4451,8 +4451,8 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int i = get_ref_frame_map_idx(cpi, ref_frame);
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int diff_len = cm->seq_params.delta_frame_id_length_minus2 + 2;
int frame_id_len = cm->seq_params.frame_id_length;
int diff_len = cm->seq_params.delta_frame_id_length;
int delta_frame_id_minus1 =
((cm->current_frame_id - cm->ref_frame_id[i] +
(1 << frame_id_len)) %
......@@ -4628,7 +4628,7 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int frame_id_len = cm->seq_params.frame_id_length;
int display_frame_id = cm->ref_frame_id[cpi->existing_fb_idx_to_show];
aom_wb_write_literal(wb, display_frame_id, frame_id_len);
/* Add a zero byte to prevent emulation of superframe marker */
......@@ -4654,7 +4654,7 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
cm->invalid_delta_frame_id_minus1 = 0;
if (cm->seq_params.frame_id_numbers_present_flag) {
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int frame_id_len = cm->seq_params.frame_id_length;
aom_wb_write_literal(wb, cm->current_frame_id, frame_id_len);
}
#endif // CONFIG_REFERENCE_BUFFER
......@@ -4730,8 +4730,8 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int i = get_ref_frame_map_idx(cpi, ref_frame);
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int diff_len = cm->seq_params.delta_frame_id_length_minus2 + 2;
int frame_id_len = cm->seq_params.frame_id_length;
int diff_len = cm->seq_params.delta_frame_id_length;
int delta_frame_id_minus1 =
((cm->current_frame_id - cm->ref_frame_id[i] +
(1 << frame_id_len)) %
......@@ -4795,8 +4795,8 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
#if CONFIG_REFERENCE_BUFFER
if (cm->seq_params.frame_id_numbers_present_flag) {
int i = get_ref_frame_map_idx(cpi, ref_frame);
int frame_id_len = cm->seq_params.frame_id_length_minus7 + 7;
int diff_len = cm->seq_params.delta_frame_id_length_minus2 + 2;
int frame_id_len = cm->seq_params.frame_id_length;
int diff_len = cm->seq_params.delta_frame_id_length;
int delta_frame_id_minus1 =
((cm->current_frame_id - cm->ref_frame_id[i] +
(1 << frame_id_len)) %
......@@ -5237,10 +5237,10 @@ static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst) {
seq_params->frame_id_numbers_present_flag = FRAME_ID_NUMBERS_PRESENT_FLAG;
aom_wb_write_literal(&wb, seq_params->frame_id_numbers_present_flag, 1);
if (seq_params->frame_id_numbers_present_flag) {
seq_params->frame_id_length_minus7 = FRAME_ID_LENGTH_MINUS7;
seq_params->delta_frame_id_length_minus2 = DELTA_FRAME_ID_LENGTH_MINUS2;
aom_wb_write_literal(&wb, seq_params->frame_id_length_minus7, 4);
aom_wb_write_literal(&wb, seq_params->delta_frame_id_length_minus2, 4);
seq_params->frame_id_length = FRAME_ID_LENGTH_MINUS7 + 7;
seq_params->delta_frame_id_length = DELTA_FRAME_ID_LENGTH_MINUS2 + 2;
aom_wb_write_literal(&wb, seq_params->frame_id_length - 7, 4);
aom_wb_write_literal(&wb, seq_params->delta_frame_id_length - 2, 4);
}
// color_config
......
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