Commit ff86395f authored by Tom Finegan's avatar Tom Finegan

Always prefix OBUs with a size field.

- Make the add_4bytes_obusize experiment part of the obu experiment.
- Remove the add_4bytes_obusize experiment flags.
- Update the encoder, decoder, and tooling sources.

BUG=aomedia:1125

Change-Id: Ia5c443c855e52618257b39c44ca2632703bf83fd
parent ba33d4ce
......@@ -289,11 +289,13 @@ foreach (aom_lib ${AOM_LIB_TARGETS})
endif ()
endforeach ()
# Generate a stub file containing the C function usage_exit(). Users of the
# Generate C/C++ stub files containing the function usage_exit(). Users of the
# aom_common_app_util library must define this function. This is a convenience
# to allow omission of the function from applications that might want to use
# other pieces of the util support without defining the usage_exit().
# other pieces of the util support without defining usage_exit().
file(WRITE "${AOM_CONFIG_DIR}/usage_exit.c" "void usage_exit(void) {}")
file(WRITE "${AOM_CONFIG_DIR}/usage_exit.cc"
"extern \"C\" void usage_exit(void) {}")
#
# Application and application support targets.
......@@ -429,24 +431,32 @@ if (ENABLE_EXAMPLES)
endif ()
if (ENABLE_TOOLS)
if (CONFIG_OBU AND CONFIG_ADD_4BYTES_OBUSIZE)
require_cxx_flag_nomsvc("-std=c++11" YES)
if (CONFIG_AV1_DECODER AND CONFIG_OBU)
require_cxx_flag_nomsvc("-std=c++11" NO)
add_executable(dump_obu
"${AOM_CONFIG_DIR}/usage_exit.c"
"${AOM_CONFIG_DIR}/usage_exit.cc"
"${AOM_ROOT}/tools/dump_obu.cc"
"${AOM_ROOT}/tools/obu_parser.cc"
"${AOM_ROOT}/tools/obu_parser.h"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_TOOL_TARGETS dump_obu)
list(APPEND AOM_APP_TARGETS dump_obu)
endif ()
# Maintain a separate variable listing only the examples to facilitate
# installation of example programs into an tools sub directory of
# $AOM_DIST_DIR/bin when building the dist target.
list(APPEND AOM_TOOL_TARGETS
${AOM_DECODER_TOOL_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
if (NOT MSVC)
target_compile_options(dump_obu PUBLIC -std=c++11)
# TODO(tomfinegan): This can go once the GCC pragma in libwebm is updated
# to silence the auto_ptr warnings for GCC >= v4.
target_compile_options(dump_obu PUBLIC -Wno-deprecated-declarations)
endif ()
# Maintain a separate variable listing only the examples to facilitate
# installation of example programs into an tools sub directory of
# $AOM_DIST_DIR/bin when building the dist target.
list(APPEND AOM_TOOL_TARGETS
${AOM_DECODER_TOOL_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
endif ()
endif ()
if (ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
......
......@@ -1376,9 +1376,7 @@ static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx,
OBU_TEMPORAL_DELIMITER, 0,
(uint8_t *)(ctx->pending_cx_data + PRE_OBU_SIZE_BYTES));
obu_size += write_temporal_delimiter_obu();
#if CONFIG_ADD_4BYTES_OBUSIZE
mem_put_le32(ctx->pending_cx_data, obu_size);
#endif
pkt.data.frame.sz += (obu_size + PRE_OBU_SIZE_BYTES);
#endif
......
......@@ -54,11 +54,8 @@ static INLINE int get_unsigned_bits(unsigned int num_values) {
#define AOM_FRAME_MARKER 0x2
#if CONFIG_ADD_4BYTES_OBUSIZE
// Size of OBU length field.
#define PRE_OBU_SIZE_BYTES 4
#else
#define PRE_OBU_SIZE_BYTES 0
#endif
#ifdef __cplusplus
} // extern "C"
......
......@@ -1797,12 +1797,7 @@ static void get_tile_buffer(const uint8_t *const data_end,
aom_internal_error(error_info, AOM_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt tile size");
} else {
#if !CONFIG_OBU || CONFIG_ADD_4BYTES_OBUSIZE
size = data_end - *data;
#else
size = mem_get_varsize(*data, tile_size_bytes);
*data += tile_size_bytes;
#endif
}
buf->data = *data;
......@@ -1838,6 +1833,7 @@ static void get_tile_buffers(AV1Decoder *pbi, const uint8_t *data,
for (int r = 0; r < tile_rows; ++r) {
for (int c = 0; c < tile_cols; ++c, ++tc) {
TileBufferDec *const buf = &tile_buffers[r][c];
#if CONFIG_OBU
const int is_last = (tc == endTile);
const size_t hdr_offset = 0;
......
......@@ -169,14 +169,10 @@ void av1_decode_frame_from_obus(struct AV1Decoder *pbi, const uint8_t *data,
av1_init_read_bit_buffer(pbi, &rb, data + PRE_OBU_SIZE_BYTES, data_end);
// 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
#if CONFIG_ADD_4BYTES_OBUSIZE
// 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);
#else
const size_t obu_size = (size_t)(data_end - data);
#endif
const OBU_TYPE obu_type = read_obu_header(&rb, &obu_header_size);
data += (PRE_OBU_SIZE_BYTES + obu_header_size);
......
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
* Copyright (c) 2017, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
......
......@@ -4699,12 +4699,8 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
#endif
buf->data = dst + total_size;
// The last tile of the tile group does not have a header.
#if CONFIG_ADD_4BYTES_OBUSIZE
// The last tile of the tile group does not have a header.
if (!is_last_tile_in_tg) total_size += 4;
#else
total_size += 4;
#endif
// Initialise tile context from the frame context
this_tile->tctx = *cm->fc;
......@@ -4738,12 +4734,8 @@ 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 {
#if CONFIG_ADD_4BYTES_OBUSIZE
// write current tile group size
mem_put_le32(data, curr_tg_data_size);
#else
mem_put_le32(buf->data, tile_size);
#endif
}
total_size += tile_size;
......@@ -4782,9 +4774,7 @@ void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
write_obu_header(OBU_SEQUENCE_HEADER, 0, data + PRE_OBU_SIZE_BYTES);
obu_size +=
write_sequence_header_obu(cpi, data + PRE_OBU_SIZE_BYTES + obu_size);
#if CONFIG_ADD_4BYTES_OBUSIZE
mem_put_le32(data, obu_size);
#endif
data += obu_size + PRE_OBU_SIZE_BYTES;
}
......@@ -4802,9 +4792,7 @@ void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
#endif
data + PRE_OBU_SIZE_BYTES + obu_size);
obu_size += frame_header_size;
#if CONFIG_ADD_4BYTES_OBUSIZE
mem_put_le32(data, obu_size);
#endif
data += obu_size + PRE_OBU_SIZE_BYTES;
if (cm->show_existing_frame) {
......
......@@ -106,7 +106,6 @@ set(CONFIG_SPATIAL_RESAMPLING 1 CACHE NUMBER "Spatial resampling.")
set(CONFIG_SYMBOLRATE 0 CACHE NUMBER "Enables symbol rate accounting.")
# AV1 experiment flags.
set(CONFIG_ADD_4BYTES_OBUSIZE 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_AMVR 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_AOM_QM 1 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_BGSPRITE 0 CACHE NUMBER "AV1 experiment flag.")
......
......@@ -40,6 +40,7 @@ if (AOM_DIST_EXAMPLES)
endif ()
if (AOM_DIST_TOOLS)
listify_string("${AOM_DIST_TOOLS}" "AOM_DIST_TOOLS")
foreach (tool ${AOM_DIST_TOOLS})
file(INSTALL "${tool}" DESTINATION "${AOM_DIST_DIR}/bin/tools")
endforeach ()
......
......@@ -317,7 +317,6 @@ EXPERIMENT_LIST="
frame_sign_bias
ext_skip
obu
add_4bytes_obusize
amvr
opt_ref_mv
tmv
......
......@@ -84,8 +84,8 @@ int file_is_obu(struct AvxInputContext *input_ctx) {
uint8_t obutd[PRE_OBU_SIZE_BYTES + OBU_HEADER_SIZE_BYTES];
int size;
#if !CONFIG_ADD_4BYTES_OBUSIZE || !CONFIG_OBU
warn("obudec.c requires CONFIG_ADD_4BYTES_OBUSIZE and CONFIG_OBU");
#if !CONFIG_OBU
warn("obudec.c requires CONFIG_OBU");
return 0;
#endif
......
......@@ -13,13 +13,12 @@
#include <string>
// TODO(tomfinegan): Remove the aom_config.h include as soon as possible. At
// present it's required because w/out aom_config.h it's impossible to know how
// Obus are being written out by the library (because
// CONFIG_ADD_4BYTES_OBUSIZE).
// present it's required because aom_config.h determines if the library writes
// OBUs.
#include "./aom_config.h"
#if !CONFIG_ADD_4BYTES_OBUSIZE || !CONFIG_OBU
#error "obu_parser.cc requires CONFIG_ADD_4BYTES_OBUSIZE and CONFIG_OBU"
#if !CONFIG_OBU
#error "obu_parser.cc requires CONFIG_OBU"
#endif
#include "aom_ports/mem_ops.h"
......@@ -153,7 +152,7 @@ void PrintObuHeader(const ObuHeader *header) {
}
bool DumpObu(const uint8_t *data, int length) {
const int kObuLengthFieldSizeBytes = 4; // Assumes CONFIG_ADD_4BYTES_OBUSIZE.
const int kObuLengthFieldSizeBytes = 4;
const int kObuHeaderLengthSizeBytes = 1;
const int kMinimumBytesRequired =
kObuLengthFieldSizeBytes + kObuHeaderLengthSizeBytes;
......
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