]> granicus.if.org Git - libvpx/commitdiff
Using network byte order (big-endian) to encode tile size.
authorDmitry Kovalev <dkovalev@google.com>
Mon, 10 Jun 2013 23:13:08 +0000 (16:13 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Mon, 10 Jun 2013 23:13:08 +0000 (16:13 -0700)
This is consistent with uncompressed header encoding.

Change-Id: Iccf40a44b493ed36ee085b81ed56f7952cde70a9

vp9/decoder/vp9_decodframe.c
vp9/encoder/vp9_bitstream.c

index 21ac3987f0f6fec601c7aabf57e61c883038f411..8b44472071d244b94b48db7beac9ccb89741b3c3 100644 (file)
@@ -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;
         }
       }
index 12a11f1c107d3d02bc99eb3b76373c458ae1f1e5..a63beedd05474385b8ebe8ae23f0271b501db3f6 100644 (file)
@@ -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;
         }