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
diff --git a/CMakeLists.txt b/CMakeLists.txt index 23f291b..c10e33c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -289,11 +289,13 @@ 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 @@ 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)
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index 9066965..95f6a05 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -1376,9 +1376,7 @@ 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
diff --git a/av1/common/common.h b/av1/common/common.h index 0c6ef49..286c1f1 100644 --- a/av1/common/common.h +++ b/av1/common/common.h
@@ -54,11 +54,8 @@ #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"
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 23073e8..15adb74 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -1797,12 +1797,7 @@ 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 @@ 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;
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c index 6416ece..67e9bb9 100644 --- a/av1/decoder/obu.c +++ b/av1/decoder/obu.c
@@ -169,14 +169,10 @@ 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);
diff --git a/av1/decoder/obu.h b/av1/decoder/obu.h index fec25fb..fe7d2ad 100644 --- a/av1/decoder/obu.h +++ b/av1/decoder/obu.h
@@ -1,5 +1,5 @@ /* - * 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
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index beeb30d..92d10c3 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -4699,12 +4699,8 @@ #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 @@ // 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 @@ 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 @@ #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) {
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake index 75b9c34..1719e89 100644 --- a/build/cmake/aom_config_defaults.cmake +++ b/build/cmake/aom_config_defaults.cmake
@@ -106,7 +106,6 @@ 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.")
diff --git a/build/cmake/dist.cmake b/build/cmake/dist.cmake index ad1e069..b517765 100644 --- a/build/cmake/dist.cmake +++ b/build/cmake/dist.cmake
@@ -40,6 +40,7 @@ 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 ()
diff --git a/configure b/configure index cf35d5f..cb3a97f 100755 --- a/configure +++ b/configure
@@ -317,7 +317,6 @@ frame_sign_bias ext_skip obu - add_4bytes_obusize amvr opt_ref_mv tmv
diff --git a/obudec.c b/obudec.c index acd3b27..9cc907a 100644 --- a/obudec.c +++ b/obudec.c
@@ -84,8 +84,8 @@ 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
diff --git a/tools/obu_parser.cc b/tools/obu_parser.cc index fb904ae..6c5f23b 100644 --- a/tools/obu_parser.cc +++ b/tools/obu_parser.cc
@@ -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 @@ } 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;