Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
da9db832
Commit
da9db832
authored
Jul 13, 2015
by
Jim Bankoski
Browse files
Revert "Fill buffer speed up"
This reverts commit
9b4f9f45
. Change-Id: I23545ac8c7464127f7466fc6a58de517874fe0cf
parent
9b4f9f45
Changes
3
Hide whitespace changes
Inline
Side-by-side
vp9/decoder/vp9_reader.c
View file @
da9db832
...
...
@@ -7,24 +7,12 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include
<stdlib.h>
#include
"vpx_ports/mem.h"
#include
"vpx_mem/vpx_mem.h"
#include
"./vpx_config.h"
#include
"vp9/decoder/vp9_reader.h"
#include
"vpx_util/endian_inl.h"
#if CONFIG_BIG_ENDIAN
#define BIGENDIFY64(X) (X)
#define BIGENDIFY32(X) (X)
#else
#define BIGENDIFY64(X) BSwap64(X)
#define BIGENDIFY32(X) BSwap32(X)
#endif
int
vp9_reader_init
(
vp9_reader
*
r
,
const
uint8_t
*
buffer
,
size_t
size
,
...
...
@@ -51,9 +39,11 @@ void vp9_reader_fill(vp9_reader *r) {
const
uint8_t
*
buffer_start
=
buffer
;
BD_VALUE
value
=
r
->
value
;
int
count
=
r
->
count
;
int
shift
=
BD_VALUE_SIZE
-
CHAR_BIT
-
(
count
+
CHAR_BIT
);
int
loop_end
=
0
;
const
size_t
bytes_left
=
buffer_end
-
buffer
;
const
size_t
bits_left
=
bytes_left
*
CHAR_BIT
;
int
shift
=
BD_VALUE_SIZE
-
CHAR_BIT
-
(
count
+
CHAR_BIT
);
const
int
x
=
(
int
)(
shift
+
CHAR_BIT
-
bits_left
);
if
(
r
->
decrypt_cb
)
{
size_t
n
=
MIN
(
sizeof
(
r
->
clear_buffer
),
bytes_left
);
...
...
@@ -61,31 +51,17 @@ void vp9_reader_fill(vp9_reader *r) {
buffer
=
r
->
clear_buffer
;
buffer_start
=
r
->
clear_buffer
;
}
if
(
bits_left
>
BD_VALUE_SIZE
)
{
#if UINTPTR_MAX == 0xffffffffffffffff
BD_VALUE
big_endian_values
=
BIGENDIFY64
(
*
((
const
BD_VALUE
*
)
buffer
));
#else
BD_VALUE
big_endian_values
=
BIGENDIFY32
(
*
((
const
BD_VALUE
*
)
buffer
));
#endif
const
int
bits
=
(
shift
&
0xfffffff8
)
+
CHAR_BIT
;
const
BD_VALUE
nv
=
big_endian_values
>>
(
BD_VALUE_SIZE
-
bits
);
count
+=
bits
;
buffer
+=
(
bits
>>
3
);
value
=
r
->
value
|
(
nv
<<
(
shift
&
0x7
));
}
else
{
const
int
bits_over
=
(
int
)(
shift
+
CHAR_BIT
-
bits_left
);
int
loop_end
=
0
;
if
(
bits_over
>=
0
)
{
count
+=
LOTS_OF_BITS
;
loop_end
=
bits_over
;
}
if
(
bits_over
<
0
||
bits_left
)
{
while
(
shift
>=
loop_end
)
{
count
+=
CHAR_BIT
;
value
|=
(
BD_VALUE
)
*
buffer
++
<<
shift
;
shift
-=
CHAR_BIT
;
}
if
(
x
>=
0
)
{
count
+=
LOTS_OF_BITS
;
loop_end
=
x
;
}
if
(
x
<
0
||
bits_left
)
{
while
(
shift
>=
loop_end
)
{
count
+=
CHAR_BIT
;
value
|=
(
BD_VALUE
)
*
buffer
++
<<
shift
;
shift
-=
CHAR_BIT
;
}
}
...
...
vpx_util/endian_inl.h
deleted
100644 → 0
View file @
9b4f9f45
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Endian related functions.
#ifndef VPX_UTIL_ENDIAN_INL_H_
#define VPX_UTIL_ENDIAN_INL_H_
#include
<stdlib.h>
#include
"./vpx_config.h"
#include
"vpx/vpx_integer.h"
#if defined(__GNUC__)
# define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__)
# define LOCAL_GCC_PREREQ(maj, min) \
(LOCAL_GCC_VERSION >= (((maj) << 8) | (min)))
#else
# define LOCAL_GCC_VERSION 0
# define LOCAL_GCC_PREREQ(maj, min) 0
#endif
#ifdef __clang__
# define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__)
# define LOCAL_CLANG_PREREQ(maj, min) \
(LOCAL_CLANG_VERSION >= (((maj) << 8) | (min)))
#else
# define LOCAL_CLANG_VERSION 0
# define LOCAL_CLANG_PREREQ(maj, min) 0
#endif // __clang__
// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
#if !defined(WORDS_BIGENDIAN) && \
(defined(__BIG_ENDIAN__) || defined(_M_PPC) || \
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)))
#define WORDS_BIGENDIAN
#endif
#if defined(WORDS_BIGENDIAN)
#define HToLE32 BSwap32
#define HToLE16 BSwap16
#else
#define HToLE32(x) (x)
#define HToLE16(x) (x)
#endif
// clang-3.3 and gcc-4.3 have builtin functions for swap32/swap64
#if LOCAL_GCC_PREREQ(4, 3) || LOCAL_CLANG_PREREQ(3, 3)
#define HAVE_BUILTIN_BSWAP32
#define HAVE_BUILTIN_BSWAP64
#endif
// clang-3.3 and gcc-4.8 have a builtin function for swap16
#if LOCAL_GCC_PREREQ(4, 8) || LOCAL_CLANG_PREREQ(3, 3)
#define HAVE_BUILTIN_BSWAP16
#endif
static
INLINE
uint16_t
BSwap16
(
uint16_t
x
)
{
#if defined(HAVE_BUILTIN_BSWAP16)
return
__builtin_bswap16
(
x
);
#elif defined(_MSC_VER)
return
_byteswap_ushort
(
x
);
#else
// gcc will recognize a 'rorw $8, ...' here:
return
(
x
>>
8
)
|
((
x
&
0xff
)
<<
8
);
#endif // HAVE_BUILTIN_BSWAP16
}
static
INLINE
uint32_t
BSwap32
(
uint32_t
x
)
{
#if HAVE_MIPS32
uint32_t
ret
;
__asm__
volatile
(
"wsbh %[ret], %[x]
\n\t
"
"rotr %[ret], %[ret], 16
\n\t
"
:
[
ret
]
"=r"
(
ret
)
:
[
x
]
"r"
(
x
)
);
return
ret
;
#elif defined(HAVE_BUILTIN_BSWAP32)
return
__builtin_bswap32
(
x
);
#elif defined(__i386__) || defined(__x86_64__)
uint32_t
swapped_bytes
;
__asm__
volatile
(
"bswap %0"
:
"=r"
(
swapped_bytes
)
:
"0"
(
x
));
return
swapped_bytes
;
#elif defined(_MSC_VER)
return
(
uint32_t
)
_byteswap_ulong
(
x
);
#else
return
(
x
>>
24
)
|
((
x
>>
8
)
&
0xff00
)
|
((
x
<<
8
)
&
0xff0000
)
|
(
x
<<
24
);
#endif // HAVE_BUILTIN_BSWAP32
}
static
INLINE
uint64_t
BSwap64
(
uint64_t
x
)
{
#if defined(HAVE_BUILTIN_BSWAP64)
return
__builtin_bswap64
(
x
);
#elif defined(__x86_64__)
uint64_t
swapped_bytes
;
__asm__
volatile
(
"bswapq %0"
:
"=r"
(
swapped_bytes
)
:
"0"
(
x
));
return
swapped_bytes
;
#elif defined(_MSC_VER)
return
(
uint64_t
)
_byteswap_uint64
(
x
);
#else // generic code for swapping 64-bit values (suggested by bdb@)
x
=
((
x
&
0xffffffff00000000ull
)
>>
32
)
|
((
x
&
0x00000000ffffffffull
)
<<
32
);
x
=
((
x
&
0xffff0000ffff0000ull
)
>>
16
)
|
((
x
&
0x0000ffff0000ffffull
)
<<
16
);
x
=
((
x
&
0xff00ff00ff00ff00ull
)
>>
8
)
|
((
x
&
0x00ff00ff00ff00ffull
)
<<
8
);
return
x
;
#endif // HAVE_BUILTIN_BSWAP64
}
#endif // VPX_UTIL_ENDIAN_INL_H_
vpx_util/vpx_util.mk
View file @
da9db832
...
...
@@ -11,4 +11,3 @@
UTIL_SRCS-yes
+=
vpx_util.mk
UTIL_SRCS-yes
+=
vpx_thread.c
UTIL_SRCS-yes
+=
vpx_thread.h
UTIL_SRCS-yes
+=
endian_inl.h
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment