- libeplayer3: sync with max_10

This commit is contained in:
vanhofen
2023-01-24 21:00:47 +01:00
committed by Thilo Graf
parent 02994964e7
commit c0034ff0b7
65 changed files with 1100 additions and 959 deletions

View File

@@ -91,58 +91,54 @@ typedef struct GetBitContext
*/
#ifdef LONG_BITSTREAM_READER
# define MIN_CACHE_BITS 32
#define MIN_CACHE_BITS 32
#else
# define MIN_CACHE_BITS 25
#define MIN_CACHE_BITS 25
#endif
#define OPEN_READER_NOSIZE(name, gb) \
unsigned int name ## _index = (gb)->index; \
unsigned int av_unused name ## _cache
#define OPEN_READER(name, gb) OPEN_READER_NOSIZE(name, gb)
#define BITS_AVAILABLE(name, gb) 1
#define CLOSE_READER(name, gb) (gb)->index = name ## _index
# ifdef LONG_BITSTREAM_READER
# define UPDATE_CACHE_LE(name, gb) name ## _cache = \
AV_RL64((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
AV_RL64((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
# define UPDATE_CACHE_BE(name, gb) name ## _cache = \
AV_RB64((gb)->buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
AV_RB64((gb)->buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
#else
# define UPDATE_CACHE_LE(name, gb) name ## _cache = \
AV_RL32((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
AV_RL32((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
# define UPDATE_CACHE_BE(name, gb) name ## _cache = \
AV_RB32((gb)->buffer + (name ## _index >> 3)) << (name ## _index & 7)
AV_RB32((gb)->buffer + (name ## _index >> 3)) << (name ## _index & 7)
#endif
#ifdef BITSTREAM_READER_LE
# define UPDATE_CACHE(name, gb) UPDATE_CACHE_LE(name, gb)
#define UPDATE_CACHE(name, gb) UPDATE_CACHE_LE(name, gb)
# define SKIP_CACHE(name, gb, num) name ## _cache >>= (num)
#define SKIP_CACHE(name, gb, num) name ## _cache >>= (num)
#else
# define UPDATE_CACHE(name, gb) UPDATE_CACHE_BE(name, gb)
#define UPDATE_CACHE(name, gb) UPDATE_CACHE_BE(name, gb)
# define SKIP_CACHE(name, gb, num) name ## _cache <<= (num)
#define SKIP_CACHE(name, gb, num) name ## _cache <<= (num)
#endif
#define SKIP_COUNTER(name, gb, num) name ## _index += (num)
#define BITS_LEFT(name, gb) ((int)((gb)->size_in_bits - name ## _index))
#define SKIP_BITS(name, gb, num) \
@@ -160,11 +156,11 @@ typedef struct GetBitContext
#define SHOW_SBITS_BE(name, gb, num) NEG_SSR32(name ## _cache, num)
#ifdef BITSTREAM_READER_LE
# define SHOW_UBITS(name, gb, num) SHOW_UBITS_LE(name, gb, num)
# define SHOW_SBITS(name, gb, num) SHOW_SBITS_LE(name, gb, num)
#define SHOW_UBITS(name, gb, num) SHOW_UBITS_LE(name, gb, num)
#define SHOW_SBITS(name, gb, num) SHOW_SBITS_LE(name, gb, num)
#else
# define SHOW_UBITS(name, gb, num) SHOW_UBITS_BE(name, gb, num)
# define SHOW_SBITS(name, gb, num) SHOW_SBITS_BE(name, gb, num)
#define SHOW_UBITS(name, gb, num) SHOW_UBITS_BE(name, gb, num)
#define SHOW_SBITS(name, gb, num) SHOW_SBITS_BE(name, gb, num)
#endif
#define GET_CACHE(name, gb) ((uint32_t) name ## _cache)
@@ -388,8 +384,7 @@ static inline int check_marker(void *logctx __attribute__((unused)), GetBitConte
* @param bit_size the size of the buffer in bits
* @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
*/
static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
int bit_size)
static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
{
int buffer_size;
int ret = 0;
@@ -420,8 +415,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
* @param byte_size the size of the buffer in bytes
* @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
*/
static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer,
int byte_size)
static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
{
if (byte_size > INT_MAX / 8 || byte_size < 0)
byte_size = -1;
@@ -474,7 +468,7 @@ static inline const uint8_t *align_get_bits(GetBitContext *s)
} while (0)
#define GET_RL_VLC(level, run, name, gb, table, bits, \
max_depth, need_update) \
max_depth, need_update) \
do { \
int n, nb_bits; \
unsigned int index; \
@@ -510,7 +504,6 @@ do { \
SKIP_BITS(name, gb, n); \
} while (0)
static inline int decode012(GetBitContext *gb)
{
int n;

View File

@@ -26,11 +26,11 @@
#include <libavutil/common.h>
#ifndef NEG_USR32
# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
#define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
#endif
#ifndef NEG_SSR32
# define NEG_SSR32(a,s) (((int32_t)(a))>>(32-(s)))
#define NEG_SSR32(a,s) (((int32_t)(a))>>(32-(s)))
#endif
#ifndef sign_extend

View File

@@ -53,8 +53,7 @@ extern const uint8_t ff_mpeg4audio_channels[8];
* @param[in] sync_extension look for a sync extension after config if true.
* @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
*/
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
int bit_size, int sync_extension);
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension);
enum AudioObjectType
{
@@ -108,5 +107,6 @@ enum AudioObjectType
///<marker and the comment
int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb);
uint8_t get_chan_config(int channels);
#endif /* AVCODEC_MPEG4AUDIO_H */

View File

@@ -48,8 +48,7 @@ typedef struct PutBitContext
* @param buffer the buffer where to put bits
* @param buffer_size the size in bytes of buffer
*/
static inline void init_put_bits(PutBitContext *s, uint8_t *buffer,
int buffer_size)
static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
{
if (buffer_size < 0)
{
@@ -72,8 +71,7 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer,
* @param buffer_size the size in bytes of buffer,
* must be larger than the previous size
*/
static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer,
int buffer_size)
static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
{
av_assert0(8 * buffer_size > s->size_in_bits);
@@ -139,8 +137,7 @@ void avpriv_align_put_bits(PutBitContext *s);
*
* @param terminate_string 0-terminates the written string if value is 1
*/
void avpriv_put_string(PutBitContext *pb, const char *string,
int terminate_string);
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string);
/**
* Copy the content of src to the bitstream.

View File

@@ -32,7 +32,6 @@
#include <ffmpeg/put_bits.h>
#include <string.h>
void avpriv_align_put_bits(PutBitContext *s)
{
put_bits(s, s->bit_left & 7, 0);

View File

@@ -79,8 +79,22 @@ static inline int get_sample_rate(GetBitContext *gb, int *index)
return *index == 0x0f ? (int)get_bits(gb, 24) : avpriv_mpeg4audio_sample_rates[*index];
}
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
int bit_size, int sync_extension)
uint8_t get_chan_config(int channels)
{
uint8_t chan_config = 0;
unsigned int i;
for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
{
if (channels == ff_mpeg4audio_channels[i])
{
chan_config = i;
break;
}
}
return chan_config;
}
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
{
GetBitContext gb;
int specific_config_bitindex, ret;
@@ -100,8 +114,8 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
c->sbr = -1;
c->ps = -1;
if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
// check for W6132 Annex YYYY draft MP3onMP4
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F))))
// check for W6132 Annex YYYY draft MP3onMP4
!(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F))))
{
if (c->object_type == AOT_PS)
c->ps = 1;
@@ -164,9 +178,7 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
return specific_config_bitindex;
}
static av_always_inline unsigned int copy_bits(PutBitContext *pb,
GetBitContext *gb,
int bits)
static av_always_inline unsigned int copy_bits(PutBitContext *pb, GetBitContext *gb, int bits)
{
unsigned int el = get_bits(gb, bits);
put_bits(pb, bits, el);