obu: Remove trailing_bits for OBU_FRAME
It is sufficient to have byte_alignment after the frame_header_obu
in an OBU_FRAME per the spec and as per the discussion in the bug.
BUG=aomedia:1712
Change-Id: I29e6d1b2513d1f1ad7cd86aec6dc5667af73217e
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 7fba606..9649056 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3250,7 +3250,8 @@
int av1_decode_frame_headers_and_setup(AV1Decoder *pbi,
struct aom_read_bit_buffer *rb,
const uint8_t *data,
- const uint8_t **p_data_end) {
+ const uint8_t **p_data_end,
+ int trailing_bits_present) {
AV1_COMMON *const cm = &pbi->common;
const int num_planes = av1_num_planes(cm);
MACROBLOCKD *const xd = &pbi->mb;
@@ -3270,7 +3271,7 @@
read_uncompressed_header(pbi, rb);
- av1_check_trailing_bits(pbi, rb);
+ if (trailing_bits_present) av1_check_trailing_bits(pbi, rb);
// If cm->single_tile_decoding = 0, the independent decoding of a single tile
// or a section of a frame is not allowed.
diff --git a/av1/decoder/decodeframe.h b/av1/decoder/decodeframe.h
index d1e682c..e537f27 100644
--- a/av1/decoder/decodeframe.h
+++ b/av1/decoder/decodeframe.h
@@ -35,7 +35,8 @@
int av1_decode_frame_headers_and_setup(struct AV1Decoder *pbi,
struct aom_read_bit_buffer *rb,
const uint8_t *data,
- const uint8_t **p_data_end);
+ const uint8_t **p_data_end,
+ int trailing_bits_present);
void av1_decode_tg_tiles_and_wrapup(struct AV1Decoder *pbi, const uint8_t *data,
const uint8_t *data_end,
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c
index e84fa85..f376775 100644
--- a/av1/decoder/obu.c
+++ b/av1/decoder/obu.c
@@ -248,8 +248,10 @@
static uint32_t read_frame_header_obu(AV1Decoder *pbi,
struct aom_read_bit_buffer *rb,
const uint8_t *data,
- const uint8_t **p_data_end) {
- av1_decode_frame_headers_and_setup(pbi, rb, data, p_data_end);
+ const uint8_t **p_data_end,
+ int trailing_bits_present) {
+ av1_decode_frame_headers_and_setup(pbi, rb, data, p_data_end,
+ trailing_bits_present);
return (uint32_t)(pbi->uncomp_hdr_size);
}
@@ -512,7 +514,8 @@
// Only decode first frame header received
if (!frame_header_received) {
av1_init_read_bit_buffer(pbi, &rb, data, data_end);
- frame_header_size = read_frame_header_obu(pbi, &rb, data, p_data_end);
+ frame_header_size = read_frame_header_obu(
+ pbi, &rb, data, p_data_end, obu_header.type != OBU_FRAME);
frame_header_received = 1;
}
decoded_payload_size = frame_header_size;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ef66e99..9db463a 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3523,24 +3523,12 @@
static uint32_t write_frame_header_obu(AV1_COMP *cpi,
struct aom_write_bit_buffer *saved_wb,
- uint8_t *const dst) {
- AV1_COMMON *const cm = &cpi->common;
+ uint8_t *const dst,
+ int append_trailing_bits) {
struct aom_write_bit_buffer wb = { dst, 0 };
- uint32_t total_size = 0;
- uint32_t uncompressed_hdr_size;
-
write_uncompressed_header_obu(cpi, saved_wb, &wb);
-
- add_trailing_bits(&wb);
-
- if (cm->show_existing_frame) {
- total_size = aom_wb_bytes_written(&wb);
- return total_size;
- }
-
- uncompressed_hdr_size = aom_wb_bytes_written(&wb);
- total_size = uncompressed_hdr_size;
- return total_size;
+ if (append_trailing_bits) add_trailing_bits(&wb);
+ return aom_wb_bytes_written(&wb);
}
static uint32_t write_tile_group_header(uint8_t *const dst, int startTile,
@@ -3607,7 +3595,7 @@
data += tg_hdr_size;
const uint32_t frame_header_size =
- write_frame_header_obu(cpi, saved_wb, data);
+ write_frame_header_obu(cpi, saved_wb, data, 0);
data += frame_header_size;
total_size += frame_header_size;
@@ -3752,8 +3740,8 @@
obu_header_size = curr_tg_data_size;
if (num_tg_hdrs == 1) {
- curr_tg_data_size +=
- write_frame_header_obu(cpi, saved_wb, data + curr_tg_data_size);
+ curr_tg_data_size += write_frame_header_obu(
+ cpi, saved_wb, data + curr_tg_data_size, 0);
}
curr_tg_data_size += write_tile_group_header(
data + curr_tg_data_size, tile_idx,
@@ -3927,7 +3915,7 @@
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);
+ write_frame_header_obu(cpi, &saved_wb, data + obu_header_size, 1);
const size_t length_field_size =
obu_memmove(obu_header_size, obu_payload_size, data);