Using network byte order (big-endian) to encode tile size.

This is consistent with uncompressed header encoding.

Change-Id: Iccf40a44b493ed36ee085b81ed56f7952cde70a9
This commit is contained in:
Dmitry Kovalev 2013-06-10 16:13:08 -07:00
Родитель ba2af976cb
Коммит 85381e3416
2 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -40,8 +40,8 @@
int dec_debug = 0;
#endif
static int read_le32(const uint8_t *p) {
return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
static int read_be32(const uint8_t *p) {
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
// len == 0 is not allowed
@ -914,13 +914,13 @@ static void decode_tiles(VP9D_COMP *pbi,
data_ptr2[0][0] = data_ptr;
for (tile_row = 0; tile_row < pc->tile_rows; tile_row++) {
if (tile_row) {
const int size = read_le32(data_ptr2[tile_row - 1][n_cols - 1]);
const int size = read_be32(data_ptr2[tile_row - 1][n_cols - 1]);
data_ptr2[tile_row - 1][n_cols - 1] += 4;
data_ptr2[tile_row][0] = data_ptr2[tile_row - 1][n_cols - 1] + size;
}
for (tile_col = 1; tile_col < n_cols; tile_col++) {
const int size = read_le32(data_ptr2[tile_row][tile_col - 1]);
const int size = read_be32(data_ptr2[tile_row][tile_col - 1]);
data_ptr2[tile_row][tile_col - 1] += 4;
data_ptr2[tile_row][tile_col] =
data_ptr2[tile_row][tile_col - 1] + size;
@ -953,7 +953,7 @@ static void decode_tiles(VP9D_COMP *pbi,
decode_tile(pbi, residual_bc);
if (has_more) {
const int size = read_le32(data_ptr);
const int size = read_be32(data_ptr);
data_ptr += 4 + size;
}
}

Просмотреть файл

@ -124,11 +124,11 @@ void write_tx_count_stats() {
static int update_bits[255];
static INLINE void write_le32(uint8_t *p, int value) {
p[0] = value;
p[1] = value >> 8;
p[2] = value >> 16;
p[3] = value >> 24;
static INLINE void write_be32(uint8_t *p, int value) {
p[0] = value >> 24;
p[1] = value >> 16;
p[2] = value >> 8;
p[3] = value;
}
@ -1723,7 +1723,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
vp9_stop_encode(&residual_bc);
if (tile_col < pc->tile_columns - 1 || tile_row < pc->tile_rows - 1) {
// size of this tile
write_le32(data_ptr + total_size, residual_bc.pos);
write_be32(data_ptr + total_size, residual_bc.pos);
total_size += 4;
}