Commit 9d9ec1fc authored by Tom Finegan's avatar Tom Finegan

Remove CONFIG_OBU_SIZING preprocessor guards.

Remove the guards and clear out the unused code.

Change-Id: I65f7bfc3f303b0247649daa23ef718ba16b55516
parent 019a8db2
......@@ -1342,16 +1342,12 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
write_temporal_delimiter = !cpi->common.enhancement_layer_id;
#endif // CONFIG_SCALABILITY
if (write_temporal_delimiter) {
// move data PRE_OBU_SIZE_BYTES + 1 bytes and insert OBU_TD preceded by
// optional 4 byte size
// move data and insert OBU_TD preceded by optional 4 byte size
uint32_t obu_header_size = 1;
const uint32_t obu_payload_size = 0;
#if CONFIG_OBU_SIZING
const size_t length_field_size =
get_uleb_obu_size_in_bytes(obu_header_size, obu_payload_size);
#else
const size_t length_field_size = PRE_OBU_SIZE_BYTES;
#endif
if (ctx->pending_cx_data) {
const size_t move_offset = length_field_size + 1;
memmove(ctx->pending_cx_data + move_offset, ctx->pending_cx_data,
......@@ -1366,15 +1362,12 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
OBU_TEMPORAL_DELIMITER, 0,
(uint8_t *)(ctx->pending_cx_data + obu_header_offset));
#if CONFIG_OBU_SIZING
// OBUs are preceded/succeeded by an unsigned leb128 coded integer.
if (write_uleb_obu_size(obu_header_size, obu_payload_size,
ctx->pending_cx_data) != AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
#else
mem_put_le32(ctx->pending_cx_data, obu_header_size + obu_payload_size);
#endif // CONFIG_OBU_SIZING
pkt.data.frame.sz +=
obu_header_size + obu_payload_size + length_field_size;
}
......
......@@ -190,15 +190,11 @@ static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
#if CONFIG_OBU_SIZE_AFTER_HEADER
struct aom_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL };
#elif CONFIG_OBU_SIZING
#else
const size_t length_field_size = get_obu_length_field_size(data);
struct aom_read_bit_buffer rb = { data + length_field_size, data + data_sz, 0,
NULL, NULL };
#else
struct aom_read_bit_buffer rb = { data + PRE_OBU_SIZE_BYTES, data + data_sz,
0, NULL, NULL };
mem_get_le32(data);
#endif
#endif // CONFIG_OBU_SIZE_AFTER_HEADER
const uint8_t obu_header = (uint8_t)aom_rb_read_literal(&rb, 8);
OBU_TYPE obu_type;
......@@ -209,7 +205,7 @@ static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
#if CONFIG_OBU_SIZE_AFTER_HEADER
// One byte has been consumed by the OBU header.
rb.bit_offset += get_obu_length_field_size(data + 1);
#endif
#endif // CONFIG_OBU_SIZE_AFTER_HEADER
// This check is disabled because existing behavior is depended upon by
// decoder tests (see decode_test_driver.cc), scalability_decoder (see
......
......@@ -54,14 +54,6 @@ static INLINE int get_unsigned_bits(unsigned int num_values) {
#define AOM_FRAME_MARKER 0x2
#if CONFIG_OBU_SIZING
// Variable size LEB128 unsigned integer length field.
#define PRE_OBU_SIZE_BYTES 0
#else
// Fixed size OBU length field.
#define PRE_OBU_SIZE_BYTES 4
#endif
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -308,7 +308,6 @@ static size_t read_metadata(const uint8_t *data, size_t sz) {
return sz;
}
#if CONFIG_OBU_SIZING
static aom_codec_err_t read_obu_size(const uint8_t *data,
size_t bytes_available,
size_t *const obu_size,
......@@ -322,7 +321,6 @@ static aom_codec_err_t read_obu_size(const uint8_t *data,
*obu_size = (size_t)u_obu_size;
return AOM_CODEC_OK;
}
#endif // CONFIG_OBU_SIZING
void av1_decode_frame_from_obus(struct AV1Decoder *pbi, const uint8_t *data,
const uint8_t *data_end,
......@@ -357,7 +355,7 @@ void av1_decode_frame_from_obus(struct AV1Decoder *pbi, const uint8_t *data,
#if CONFIG_OBU_SIZE_AFTER_HEADER
size_t length_field_size = 0;
#elif CONFIG_OBU_SIZING
#else
size_t length_field_size;
size_t obu_size;
if (read_obu_size(data, bytes_available, &obu_size, &length_field_size) !=
......@@ -365,16 +363,6 @@ void av1_decode_frame_from_obus(struct AV1Decoder *pbi, const uint8_t *data,
cm->error.error_code = AOM_CODEC_CORRUPT_FRAME;
return;
}
#else
// every obu is preceded by PRE_OBU_SIZE_BYTES-byte size of obu (obu header
// + payload size)
// The obu size is only needed for tile group OBUs
const size_t obu_size = mem_get_le32(data);
const size_t length_field_size = PRE_OBU_SIZE_BYTES;
if (obu_size > bytes_available) {
cm->error.error_code = AOM_CODEC_CORRUPT_FRAME;
return;
}
#endif // CONFIG_OBU_SIZE_AFTER_HEADER
if (data_end < data + length_field_size) {
......
......@@ -3523,7 +3523,6 @@ uint32_t write_obu_header(OBU_TYPE obu_type, int obu_extension,
return size;
}
#if CONFIG_OBU_SIZING
size_t get_uleb_obu_size_in_bytes(uint32_t obu_header_size,
uint32_t obu_payload_size) {
#if CONFIG_OBU_SIZE_AFTER_HEADER
......@@ -3571,7 +3570,6 @@ static size_t obu_memmove(uint32_t obu_header_size, uint32_t obu_payload_size,
memmove(data + move_dst_offset, data + move_src_offset, move_size);
return length_field_size;
}
#endif // CONFIG_OBU_SIZING
static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst
#if CONFIG_SCALABILITY
......@@ -3697,9 +3695,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
#else
const OBU_TYPE obu_type = OBU_TILE_GROUP;
#endif // CONFIG_OBU_FRAME
uint32_t tg_hdr_size =
write_obu_header(obu_type, 0, data + PRE_OBU_SIZE_BYTES);
tg_hdr_size += PRE_OBU_SIZE_BYTES;
const uint32_t tg_hdr_size = write_obu_header(obu_type, 0, data);
data += tg_hdr_size;
#if CONFIG_OBU_FRAME
......@@ -3806,8 +3802,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
// In EXT_TILE case, only use 1 tile group. Follow the obu syntax, write
// current tile group size before tile data(include tile column header).
// Tile group size doesn't include the bytes storing tg size.
total_size += tg_hdr_size - PRE_OBU_SIZE_BYTES;
#if CONFIG_OBU_SIZING
total_size += tg_hdr_size;
const uint32_t obu_payload_size = total_size - tg_hdr_size;
const size_t length_field_size =
obu_memmove(tg_hdr_size, obu_payload_size, dst);
......@@ -3819,10 +3814,6 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
#if CONFIG_OBU_FRAME
saved_wb->bit_buffer += length_field_size;
#endif // CONFIG_OBU_FRAME
#else
mem_put_le32(dst, total_size);
total_size += PRE_OBU_SIZE_BYTES;
#endif // CONFIG_OBU_SIZING
// Now fill in the gaps in the uncompressed header.
if (have_tiles) {
......@@ -3835,9 +3826,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
return (uint32_t)total_size;
}
#if CONFIG_OBU_SIZING
uint32_t obu_header_size = 0;
#endif // CONFIG_OBU_SIZING
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
TileInfo tile_info;
const int is_last_row = (tile_row == tile_rows - 1);
......@@ -3864,22 +3853,21 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
#else
const OBU_TYPE obu_type = OBU_TILE_GROUP;
#endif
curr_tg_data_size = write_obu_header(obu_type, obu_extension_header,
data + PRE_OBU_SIZE_BYTES);
#if CONFIG_OBU_SIZING
curr_tg_data_size =
write_obu_header(obu_type, obu_extension_header, data);
obu_header_size = curr_tg_data_size;
#endif // CONFIG_OBU_SIZING
#if CONFIG_OBU_FRAME
if (num_tg_hdrs == 1) {
curr_tg_data_size += write_frame_header_obu(
cpi, saved_wb, data + curr_tg_data_size + PRE_OBU_SIZE_BYTES);
curr_tg_data_size +=
write_frame_header_obu(cpi, saved_wb, data + curr_tg_data_size);
}
#endif
curr_tg_data_size += write_tile_group_header(
data + curr_tg_data_size + PRE_OBU_SIZE_BYTES, tile_idx,
data + curr_tg_data_size, tile_idx,
AOMMIN(tile_idx + tg_size - 1, tile_cols * tile_rows - 1),
n_log2_tiles, cm->num_tg > 1);
total_size += curr_tg_data_size + PRE_OBU_SIZE_BYTES;
total_size += curr_tg_data_size;
new_tg = 0;
tile_count = 0;
}
......@@ -3931,8 +3919,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
// size of this tile
mem_put_le32(buf->data, tile_size);
} else {
// write current tile group size
#if CONFIG_OBU_SIZING
// write current tile group size
const uint32_t obu_payload_size = curr_tg_data_size - obu_header_size;
const size_t length_field_size =
obu_memmove(obu_header_size, obu_payload_size, data);
......@@ -3942,9 +3929,6 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
}
curr_tg_data_size += (int)length_field_size;
total_size += (uint32_t)length_field_size;
#else
mem_put_le32(data, curr_tg_data_size);
#endif // CONFIG_OBU_SIZING
if (!first_tg && cm->error_resilient_mode) {
// Make room for a duplicate Frame Header OBU.
......@@ -3999,28 +3983,21 @@ int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
// write sequence header obu if KEY_FRAME, preceded by 4-byte size
if (cm->frame_type == KEY_FRAME) {
obu_header_size =
write_obu_header(OBU_SEQUENCE_HEADER, 0, data + PRE_OBU_SIZE_BYTES);
obu_header_size = write_obu_header(OBU_SEQUENCE_HEADER, 0, data);
#if CONFIG_SCALABILITY
obu_payload_size = write_sequence_header_obu(
cpi, data + PRE_OBU_SIZE_BYTES + obu_header_size,
enhancement_layers_cnt);
obu_payload_size = write_sequence_header_obu(cpi, data + obu_header_size,
enhancement_layers_cnt);
#else
obu_payload_size = write_sequence_header_obu(
cpi, data + PRE_OBU_SIZE_BYTES + obu_header_size);
obu_payload_size = write_sequence_header_obu(cpi, data + obu_header_size);
#endif // CONFIG_SCALABILITY
#if CONFIG_OBU_SIZING
const size_t length_field_size =
obu_memmove(obu_header_size, obu_payload_size, data);
if (write_uleb_obu_size(obu_header_size, obu_payload_size, data) !=
AOM_CODEC_OK)
AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
#else
const size_t length_field_size = PRE_OBU_SIZE_BYTES;
mem_put_le32(data, obu_header_size + obu_payload_size);
#endif // CONFIG_OBU_SIZING
}
data += obu_header_size + obu_payload_size + length_field_size;
}
......@@ -4035,23 +4012,17 @@ int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
if (write_frame_header) {
// Write Frame Header OBU.
fh_info.frame_header = data;
obu_header_size = write_obu_header(OBU_FRAME_HEADER, obu_extension_header,
data + PRE_OBU_SIZE_BYTES);
obu_payload_size = write_frame_header_obu(
cpi, &saved_wb, data + PRE_OBU_SIZE_BYTES + obu_header_size);
obu_header_size =
write_obu_header(OBU_FRAME_HEADER, obu_extension_header, data);
obu_payload_size =
write_frame_header_obu(cpi, &saved_wb, data + obu_header_size);
#if CONFIG_OBU_SIZING
const size_t length_field_size =
obu_memmove(obu_header_size, obu_payload_size, data);
if (write_uleb_obu_size(obu_header_size, obu_payload_size, data) !=
AOM_CODEC_OK) {
return AOM_CODEC_ERROR;
}
#else
const size_t length_field_size = PRE_OBU_SIZE_BYTES;
fh_info.obu_header_byte_offset = length_field_size;
mem_put_le32(data, obu_header_size + obu_payload_size);
#endif // CONFIG_OBU_SIZING
#if CONFIG_OBU_REDUNDANT_FRAME_HEADER
#if CONFIG_OBU_SIZE_AFTER_HEADER
......
......@@ -25,12 +25,11 @@ void write_sequence_header(AV1_COMP *cpi, struct aom_write_bit_buffer *wb);
uint32_t write_obu_header(OBU_TYPE obu_type, int obu_extension,
uint8_t *const dst);
#if CONFIG_OBU_SIZING
size_t get_uleb_obu_size_in_bytes(uint32_t obu_header_size,
uint32_t obu_payload_size);
int write_uleb_obu_size(uint32_t obu_header_size, uint32_t obu_payload_size,
uint8_t *dest);
#endif // CONFIG_OBU_SIZING
int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dest, size_t *size);
......
......@@ -116,7 +116,6 @@ set(CONFIG_OBU_FRAME 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_OBU_NO_IVF 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_OBU_REDUNDANT_FRAME_HEADER 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_OBU_SIZE_AFTER_HEADER 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_OBU_SIZING 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_RD_DEBUG 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SCALABILITY 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_SEGMENT_GLOBALMV 1 CACHE NUMBER "AV1 experiment flag.")
......
......@@ -26,19 +26,12 @@ macro (fix_experiment_configs)
endif ()
endif ()
if (CONFIG_OBU_SIZE_AFTER_HEADER)
if (NOT CONFIG_OBU_SIZING)
change_config_and_warn(CONFIG_OBU_SIZING 1 CONFIG_OBU_SIZE_AFTER_HEADER)
endif ()
endif ()
if (CONFIG_ANALYZER)
if (NOT CONFIG_INSPECTION)
change_config_and_warn(CONFIG_INSPECTION 1 CONFIG_ANALYZER)
endif ()
endif ()
if (CONFIG_LOOPFILTER_LEVEL)
if (NOT CONFIG_EXT_DELTA_Q)
change_config_and_warn(CONFIG_EXT_DELTA_Q 1 CONFIG_LOOPFILTER_LEVEL)
......
......@@ -22,17 +22,11 @@
#define OBU_HEADER_SIZE_BYTES 1
#define OBU_HEADER_EXTENSION_SIZE_BYTES 1
#if CONFIG_OBU_SIZING
// Unsigned LEB128 OBU length field has maximum size of 8 bytes.
#define OBU_MAX_LENGTH_FIELD_SIZE 8
#define OBU_MAX_HEADER_SIZE \
(OBU_HEADER_SIZE_BYTES + OBU_HEADER_EXTENSION_SIZE_BYTES + \
OBU_MAX_LENGTH_FIELD_SIZE)
#else
#define OBU_MAX_LENGTH_FIELD_SIZE PRE_OBU_SIZE_BYTES
#define OBU_MAX_HEADER_SIZE \
(OBU_HEADER_SIZE_BYTES + OBU_HEADER_EXTENSION_SIZE_BYTES + PRE_OBU_SIZE_BYTES)
#endif
#if CONFIG_OBU_NO_IVF
......@@ -54,15 +48,10 @@ int read_obu_size(FILE *infile, uint64_t *obu_size, size_t *length_field_size) {
const int seek_pos = (int)bytes_read;
if (seek_pos != 0 && fseek(infile, -seek_pos, SEEK_CUR) != 0) return 1;
#if CONFIG_OBU_SIZING
if (aom_uleb_decode(read_buffer, bytes_read, obu_size, length_field_size) !=
0) {
return 1;
}
#else
if (length_field_size) *length_field_size = PRE_OBU_SIZE_BYTES;
*obu_size = mem_get_le32(read_buffer);
#endif
return 0;
}
......@@ -166,16 +155,12 @@ int file_is_obu(struct AvxInputContext *input_ctx) {
return 0;
}
#if CONFIG_OBU_SIZING
if (aom_uleb_decode(obutd, OBU_MAX_HEADER_SIZE, &size, NULL) != 0) {
warn("OBU size parse failed.\n");
return 0;
}
const size_t obu_header_offset = aom_uleb_size_in_bytes(size);
#else
const size_t obu_header_offset = PRE_OBU_SIZE_BYTES;
size = mem_get_le32(obutd);
#endif // CONFIG_OBU_SIZING
fseek(input_ctx->file, obu_header_offset + OBU_HEADER_SIZE_BYTES, SEEK_SET);
......
......@@ -174,15 +174,11 @@ bool DumpObu(const uint8_t *data, int length, int *obu_overhead_bytes) {
size_t length_field_size = 0;
int current_obu_length = 0;
int obu_header_size = 0;
#elif CONFIG_OBU_SIZING
#else
uint64_t obu_size = 0;
size_t length_field_size;
aom_uleb_decode(data + consumed, remaining, &obu_size, &length_field_size);
const int current_obu_length = static_cast<int>(obu_size);
#else
const int current_obu_length = mem_get_le32(data + consumed);
const int kObuLengthFieldSizeBytes = 4;
const size_t length_field_size = kObuLengthFieldSizeBytes;
#endif // CONFIG_OBU_SIZE_AFTER_HEADER
obu_overhead += (int)length_field_size;
......
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