Commit e536a1cc authored by Debargha Mukherjee's avatar Debargha Mukherjee Committed by Gerrit Code Review

Merge "Compute end of frame data precisely with ext-tile." into nextgenv2

parents 4f504529 cba70d29
......@@ -18,8 +18,11 @@ namespace {
const int kTestMode = 0;
const int kSuperframeSyntax = 1;
const int kTileCols = 2;
const int kTileRows = 3;
typedef std::tr1::tuple<libvpx_test::TestMode,int> SuperframeTestParam;
typedef std::tr1::tuple<libvpx_test::TestMode, int,
int, int> SuperframeTestParam;
class SuperframeTest : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWithParam<SuperframeTestParam> {
......@@ -37,6 +40,8 @@ class SuperframeTest : public ::libvpx_test::EncoderTest,
sf_count_ = 0;
sf_count_max_ = INT_MAX;
is_vp10_style_superframe_ = syntax;
n_tile_cols_ = std::tr1::get<kTileCols>(input);
n_tile_rows_ = std::tr1::get<kTileRows>(input);
}
virtual void TearDown() {
......@@ -48,6 +53,8 @@ class SuperframeTest : public ::libvpx_test::EncoderTest,
if (video->frame() == 1) {
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
encoder->Control(VP8E_SET_CPUUSED, 2);
encoder->Control(VP9E_SET_TILE_COLUMNS, n_tile_cols_);
encoder->Control(VP9E_SET_TILE_ROWS, n_tile_rows_);
}
}
......@@ -92,6 +99,10 @@ class SuperframeTest : public ::libvpx_test::EncoderTest,
vpx_codec_cx_pkt_t modified_pkt_;
uint8_t *modified_buf_;
vpx_codec_pts_t last_sf_pts_;
private:
int n_tile_cols_;
int n_tile_rows_;
};
TEST_P(SuperframeTest, TestSuperframeIndexIsOptional) {
......@@ -106,13 +117,28 @@ TEST_P(SuperframeTest, TestSuperframeIndexIsOptional) {
VP9_INSTANTIATE_TEST_CASE(SuperframeTest, ::testing::Combine(
::testing::Values(::libvpx_test::kTwoPassGood),
::testing::Values(0)));
::testing::Values(0), ::testing::Values(0), ::testing::Values(0)));
// The superframe index is currently mandatory with ANS due to the decoder
// starting at the end of the buffer.
#if CONFIG_EXT_TILE
// Single tile does not work with ANS (see comment above).
#if CONFIG_ANS
const int tile_col_values[] = { 1, 2 };
#else
const int tile_col_values[] = { 1, 2, 32 };
#endif
const int tile_row_values[] = { 1, 2, 32 };
VP10_INSTANTIATE_TEST_CASE(SuperframeTest, ::testing::Combine(
::testing::Values(::libvpx_test::kTwoPassGood),
::testing::Values(1),
::testing::ValuesIn(tile_col_values),
::testing::ValuesIn(tile_row_values)));
#else
#if !CONFIG_ANS
VP10_INSTANTIATE_TEST_CASE(SuperframeTest, ::testing::Combine(
::testing::Values(::libvpx_test::kTwoPassGood),
::testing::Values(1)));
#endif
::testing::Values(1), ::testing::Values(0), ::testing::Values(0)));
#endif // !CONFIG_ANS
#endif // CONFIG_EXT_TILE
} // namespace
......@@ -2924,6 +2924,8 @@ static void get_tile_buffer(const uint8_t *const data_end,
}
*data += size;
tile_buffers[row][col].raw_data_end = *data;
}
static void get_tile_buffers(
......@@ -2939,6 +2941,7 @@ static void get_tile_buffers(
const uint32_t tile_size = data_end - data;
tile_buffers[0][0].data = data;
tile_buffers[0][0].size = tile_size;
tile_buffers[0][0].raw_data_end = NULL;
} else {
const uint8_t *tile_col_data_end[MAX_TILE_COLS];
const uint8_t *const data_start = data;
......@@ -3060,6 +3063,7 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi,
const VPxWorkerInterface *const winterface = vpx_get_worker_interface();
const int tile_cols = cm->tile_cols;
const int tile_rows = cm->tile_rows;
const int n_tiles = tile_cols * tile_rows;
TileBufferDec (*const tile_buffers)[MAX_TILE_COLS] = pbi->tile_buffers;
#if CONFIG_EXT_TILE
const int dec_tile_row = VPXMIN(pbi->dec_tile_row, tile_rows);
......@@ -3083,7 +3087,7 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi,
int tile_row, tile_col;
#if CONFIG_ENTROPY
cm->do_subframe_update = cm->tile_cols == 1 && cm->tile_rows == 1;
cm->do_subframe_update = n_tiles == 1;
#endif // CONFIG_ENTROPY
if (cm->lf.filter_level && !cm->skip_loop_filter &&
......@@ -3110,14 +3114,13 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi,
get_tile_buffers(pbi, data, data_end, tile_buffers);
if (pbi->tile_data == NULL ||
(tile_cols * tile_rows) != pbi->allocated_tiles) {
if (pbi->tile_data == NULL || n_tiles != pbi->allocated_tiles) {
vpx_free(pbi->tile_data);
CHECK_MEM_ERROR(
cm,
pbi->tile_data,
vpx_memalign(32, tile_cols * tile_rows * (sizeof(*pbi->tile_data))));
pbi->allocated_tiles = tile_rows * tile_cols;
vpx_memalign(32, n_tiles * (sizeof(*pbi->tile_data))));
pbi->allocated_tiles = n_tiles;
}
// Load all tile information into tile_data.
......@@ -3251,7 +3254,20 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi,
if (cm->frame_parallel_decode)
vp10_frameworker_broadcast(pbi->cur_buf, INT_MAX);
#if CONFIG_ANS || CONFIG_EXT_TILE
#if CONFIG_EXT_TILE
if (n_tiles == 1) {
#if CONFIG_ANS
return data_end;
#else
// Find the end of the single tile buffer
return vpx_reader_find_end(&pbi->tile_data->bit_reader);
#endif // CONFIG_ANS
} else {
// Return the end of the last tile buffer
return tile_buffers[tile_rows - 1][tile_cols - 1].raw_data_end;
}
#else
#if CONFIG_ANS
return data_end;
#else
{
......@@ -3259,7 +3275,8 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi,
TileData *const td = pbi->tile_data + tile_cols * tile_rows - 1;
return vpx_reader_find_end(&td->bit_reader);
}
#endif // CONFIG_ANS || CONFIG_EXT_TILE
#endif // CONFIG_ANS
#endif // CONFIG_EXT_TILE
}
static int tile_worker_hook(TileWorkerData *const tile_data,
......@@ -3337,6 +3354,8 @@ static const uint8_t *decode_tiles_mt(VP10Decoder *pbi,
assert(tile_rows <= MAX_TILE_ROWS);
assert(tile_cols <= MAX_TILE_COLS);
assert(tile_cols * tile_rows > 1);
#if CONFIG_ANS
// TODO(any): This might just work now. Needs to be tested.
abort(); // FIXME: Tile parsing broken
......@@ -3476,7 +3495,11 @@ static const uint8_t *decode_tiles_mt(VP10Decoder *pbi,
}
}
#if CONFIG_ANS || CONFIG_EXT_TILE
#if CONFIG_EXT_TILE
// Return the end of the last tile buffer
return tile_buffers[tile_rows - 1][tile_cols - 1].raw_data_end;
#else
#if CONFIG_ANS
return data_end;
#else
assert(final_worker != -1);
......@@ -3485,7 +3508,8 @@ static const uint8_t *decode_tiles_mt(VP10Decoder *pbi,
(TileWorkerData*)pbi->tile_workers[final_worker].data1;
return vpx_reader_find_end(&twd->bit_reader);
}
#endif // CONFIG_ANS || CONFIG_EXT_TILE
#endif // CONFIG_ANS
#endif // CONFIG_EXT_TILE
}
static void error_handler(void *data) {
......
......@@ -51,6 +51,8 @@ typedef struct TileWorkerData {
typedef struct TileBufferDec {
const uint8_t *data;
size_t size;
const uint8_t *raw_data_end; // The end of the raw tile buffer in the
// bit stream.
int col; // only used with multi-threaded decoding
} TileBufferDec;
......
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