- 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);

View File

@@ -38,7 +38,7 @@ typedef struct _BR
} BR;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static void init_br(BR *p, const uint8 *buf, uint32 size)
static inline void init_br(BR *p, const uint8 *buf, uint32 size)
{
p->buf = buf;
p->size = size;
@@ -51,7 +51,7 @@ static uint8 get_u8(BR *p)
return p->buf[p->read++];
}
static uint32 get_u24(BR *p)
static inline uint32 get_u24(BR *p)
{
uint32 a = get_u8(p);
uint32 b = get_u8(p);
@@ -60,7 +60,7 @@ static uint32 get_u24(BR *p)
return (a << 16) | (b << 8) | c;
}
static uint32 get_u32(BR *p)
static inline uint32 get_u32(BR *p)
{
uint32 a = get_u8(p);
uint32 b = get_u8(p);
@@ -70,12 +70,12 @@ static uint32 get_u32(BR *p)
return (a << 24) | (b << 16) | (c << 8) | d;
}
static int is_eob(BR *p)
static inline int is_eob(BR *p)
{
return p->read >= p->size;
}
static void skip(BR *p, uint32 skip)
static inline void skip(BR *p, uint32 skip)
{
p->read += skip;
}
@@ -93,7 +93,7 @@ static uint32 show_bits(BR *p, uint32 bits)
return tmp;
}
static int32 show_sbits(BR *p, uint32 bits)
static inline int32 show_sbits(BR *p, uint32 bits)
{
const uint8 *pp;
int32 tmp;
@@ -106,7 +106,7 @@ static int32 show_sbits(BR *p, uint32 bits)
return tmp;
}
static void flash_bits(BR *p, uint32 bits)
static inline void flash_bits(BR *p, uint32 bits)
{
if (bits > 0)
{
@@ -116,21 +116,21 @@ static void flash_bits(BR *p, uint32 bits)
}
}
static uint32 get_bits(BR *p, uint32 bits)
static inline uint32 get_bits(BR *p, uint32 bits)
{
uint32 tmp = show_bits(p, bits);
flash_bits(p, bits);
return tmp;
}
static int32 get_sbits(BR *p, uint32 bits)
static inline int32 get_sbits(BR *p, uint32 bits)
{
int32 tmp = show_sbits(p, bits);
flash_bits(p, bits);
return tmp;
}
static void align_bits(BR *p)
static inline void align_bits(BR *p)
{
if (p->bitoffset > 0)
{

View File

@@ -144,7 +144,9 @@ static inline void m4v_stuffing(BW *p)
put_bits(p, 1, 0);
length = (- p->bitoffset) & 7;
if (length) put_bits(p, length, (1 << length) - 1);
if (length)
put_bits(p, length, (1 << length) - 1);
}
#endif // BITWRITER_H

View File

@@ -25,7 +25,6 @@
#include "dcprediction.h"
// M4V ADDED
static const uint8 mpeg4_y_dc_scale_table[32] =
{
@@ -103,8 +102,10 @@ static inline int get_scale(M4V_DCPRED *pred, int n)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void dcpred_set_qscale(M4V_DCPRED *pred, int qscale)
{
if (qscale < 0) qscale = 0;
if (qscale > 31) qscale = 31;
if (qscale < 0)
qscale = 0;
if (qscale > 31)
qscale = 31;
pred->y_dc_scale = mpeg4_y_dc_scale_table[qscale];
pred->c_dc_scale = mpeg4_c_dc_scale_table[qscale];
}

View File

@@ -39,8 +39,6 @@ typedef struct _M4V_DCPRED
int y_dc_scale;
int c_dc_scale;
} M4V_DCPRED;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -65,7 +65,6 @@ typedef struct _PICTURE
int width;
int height;
#define FLV_I_TYPE 0
#define FLV_P_TYPE 1
@@ -157,5 +156,4 @@ static const int8 rl_inter_run[102] =
static const int rl_inter_n = 102;
static const int rl_inter_last = 58;
#endif // FLV_H

View File

@@ -41,7 +41,6 @@ typedef struct _CONVCTX
M4V_VOL vol;
} CONVCTX;
typedef struct
{
uint8 *out_buf;
@@ -65,7 +64,6 @@ static const uint8 ff_mpeg4_c_dc_scale_table[32] =
0, 8, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25
};
static void copy_vol(PICTURE *flv_pic, M4V_VOL *vol)
{
vol->width = flv_pic->width;
@@ -122,7 +120,7 @@ static void copy_microblock(MICROBLOCK *flv_mb, M4V_MICROBLOCK *m4v_mb)
}
}
static int write_pad_not_coded_frames(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BW *bw, uint32 time)
static int write_pad_not_coded_frames(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BW *bw, int time)
{
// if any timecode padding is needed, then pad.
while (c->frame * 1000 / 30 < time)
@@ -139,10 +137,10 @@ static int write_pad_not_coded_frames(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BW *bw
// write frame
if (pub_ctx->write_packet_cb(pub_ctx->usr_data,
0,
0,//c->frame,
bw->buf,
bw->pos) < 0)
0,
0,//c->frame,
bw->buf,
bw->pos) < 0)
{
return -1;
}
@@ -156,7 +154,7 @@ static int write_pad_not_coded_frames(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BW *bw
return 0;
}
static int write_m4v_picture_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, BW *bw, PICTURE *flvpic, uint32 time)
static int write_m4v_picture_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, BW *bw, PICTURE *flvpic, uint32 time __attribute__((unused)))
{
MICROBLOCK mb;
M4V_VOP vop;
@@ -181,7 +179,8 @@ static int write_m4v_picture_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, B
if (vop.picture_type == M4V_I_TYPE)
{
mb.intra = 1;
if (decode_I_mb(br, &mb, flvpic->escape_type, flvpic->qscale) < 0) return -1;
if (decode_I_mb(br, &mb, flvpic->escape_type, flvpic->qscale) < 0)
return -1;
m4v_mb.qscale = vop.qscale;
copy_microblock(&mb, &m4v_mb);
m4v_encode_I_dcpred(&m4v_mb, &c->vol.dcpred, x, y);
@@ -189,7 +188,8 @@ static int write_m4v_picture_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, B
}
else
{
if (decode_P_mb(br, &mb, flvpic->escape_type, flvpic->qscale) < 0) return -1;
if (decode_P_mb(br, &mb, flvpic->escape_type, flvpic->qscale) < 0)
return -1;
m4v_mb.qscale = vop.qscale;
copy_microblock(&mb, &m4v_mb);
m4v_encode_I_dcpred(&m4v_mb, &c->vol.dcpred, x, y);
@@ -203,10 +203,10 @@ static int write_m4v_picture_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, B
// write frame
if (pub_ctx->write_packet_cb(pub_ctx->usr_data,
vop.picture_type == M4V_I_TYPE,
0,//c->frame,
bw->buf,
bw->pos) < 0)
vop.picture_type == M4V_I_TYPE,
0,//c->frame,
bw->buf,
bw->pos) < 0)
{
return -1;
}
@@ -223,10 +223,10 @@ static int write_m4v_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, BW *bw, u
memset(&picture, 0, sizeof(picture));
init_dcpred(&c->vol.dcpred);
if (decode_picture_header(br, &picture) < 0) return -1;
if (c->width != picture.width || c->height != picture.height) return -1; //size changed..
if (decode_picture_header(br, &picture) < 0)
return -1;
if (c->width != picture.width || c->height != picture.height)
return -1; //size changed..
copy_vol(&picture, &c->vol);
if (picture.picture_type == FLV_I_TYPE)
@@ -235,7 +235,8 @@ static int write_m4v_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, BW *bw, u
}
else
{
if (write_pad_not_coded_frames(pub_ctx, c, bw, time) < 0) return -1;
if (write_pad_not_coded_frames(pub_ctx, c, bw, time) < 0)
return -1;
}
if (write_m4v_picture_frame(pub_ctx, c, br, bw, &picture, time) < 0)
@@ -246,7 +247,7 @@ static int write_m4v_frame(flv2mpeg4_CTX *pub_ctx, CONVCTX *c, BR *br, BW *bw, u
return 0;
}
int flv2mpeg4_process_flv_packet(flv2mpeg4_CTX *ctx, uint8 picture_type, const uint8 *buf, uint32 size, uint32 time)
int flv2mpeg4_process_flv_packet(flv2mpeg4_CTX *ctx, uint8 picture_type __attribute__((unused)), const uint8 *buf, uint32 size, uint32 time)
{
CTX *p = ctx->priv;
BR br;
@@ -320,5 +321,3 @@ void flv2mpeg4_release_ctx(flv2mpeg4_CTX **pub_ctx)
*pub_ctx = NULL;
}

View File

@@ -38,7 +38,6 @@ static const uint8 zig_zag_scan[64] =
58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
};
static const VLCtab vlc_table_intra_MCBPC[] = //: table_size=72 table_allocated=128 bits=6
{
{64, -3},
@@ -128,7 +127,6 @@ static const VLCtab vlc_table_rl_inter[] = //: table_size=554 table_allocated=10
{100, 3}, {101, 3}, {8, 1}, {7, 1}
};
static const VLCtab vlc_table_mv[] = //mv_vlc: table_size=538 table_allocated=1024 bits=9
{
{512, -3}, {520, -2}, {524, -1}, {526, -1}, {528, -1}, {530, -1}, {532, -1}, {534, -1}, {536, -1}, {10, 9},
@@ -182,7 +180,9 @@ static inline int decode_DC(BR *p)
printf("illigal dc\n");
return -1;
}
if (level == 255) level = 128;
if (level == 255)
level = 128;
// printf("DC: %d\n", level);
return level;
@@ -225,7 +225,9 @@ static inline int decode_AC(BR *p, BLOCK *block, int escape_type, int i)
run = get_bits(p, 6);
level = get_bits(p, 8);
sign = level >= 128;
if (sign) level = 256 - level;
if (sign)
level = 256 - level;
}
}
else
@@ -235,7 +237,9 @@ static inline int decode_AC(BR *p, BLOCK *block, int escape_type, int i)
last = code >= rl_inter_last;
sign = get_bits(p, 1);
if (sign) level = -level;
if (sign)
level = -level;
}
i += run;
@@ -245,7 +249,9 @@ static inline int decode_AC(BR *p, BLOCK *block, int escape_type, int i)
return -1;
}
block->block[zig_zag_scan[i]] = level;
if (last) break;
if (last)
break;
i++;
}
@@ -270,7 +276,9 @@ static inline int decode_intra_block(BR *p, BLOCK *block, int escape_type, int c
return 0;
}
if (decode_AC(p, block, escape_type, 1) < 0) return -1;
if (decode_AC(p, block, escape_type, 1) < 0)
return -1;
return 0;
}
@@ -283,7 +291,9 @@ static inline int decode_inter_block(BR *p, BLOCK *block, int escape_type, int c
return 0;
}
if (decode_AC(p, block, escape_type, 0) < 0) return -1;
if (decode_AC(p, block, escape_type, 0) < 0)
return -1;
return 0;
}
@@ -293,7 +303,8 @@ static inline int get_intra_MCBPC(BR *br)
do
{
cbpc = get_vlc(br, vlc_table_intra_MCBPC, 6, 2);
if (cbpc < 0) return -1;
if (cbpc < 0)
return -1;
}
while (cbpc == 8);
return cbpc;
@@ -309,7 +320,8 @@ static inline int get_inter_MCBPC(BR *br)
return -2;
}
cbpc = get_vlc(br, vlc_table_inter_MCBPC, 7, 2);
if (cbpc < 0) return -1;
if (cbpc < 0)
return -1;
}
while (cbpc == 20);
@@ -375,7 +387,8 @@ static inline int decode_intra_mb_internal(BR *p, MICROBLOCK *mb, int escape_typ
for (i = 0; i < 6; i++)
{
if (decode_intra_block(p, &mb->block[i], escape_type, cbp & 32) != 0) return -1;
if (decode_intra_block(p, &mb->block[i], escape_type, cbp & 32) != 0)
return -1;
cbp += cbp;
}
@@ -423,7 +436,8 @@ static inline int decode_inter_mb_internal(BR *p, MICROBLOCK *mb, int escape_typ
for (i = 0; i < 6; i++)
{
if (decode_inter_block(p, &mb->block[i], escape_type, cbp & 32) != 0) return -1;
if (decode_inter_block(p, &mb->block[i], escape_type, cbp & 32) != 0)
return -1;
cbp += cbp;
}
@@ -496,14 +510,12 @@ int decode_picture_header(BR *p, PICTURE *picture)
if (get_bits(p, 17) != 1)
{
fprintf(stderr, "start code error\n");
return -1;
}
tmp = get_bits(p, 5);
if (tmp != 0 && tmp != 1)
{
fprintf(stderr, "picture format error\n");
return -1;
}
@@ -537,7 +549,6 @@ int decode_picture_header(BR *p, PICTURE *picture)
width = 160, height = 120;
break;
default:
fprintf(stderr, "size error\n");
return -1;
}

View File

@@ -134,6 +134,5 @@ static const uint8 alternate_vertical_scan[64] =
38, 46, 54, 62, 39, 47, 55, 63,
};
#endif // M4V_H

View File

@@ -62,8 +62,8 @@ static const uint32 vlce_inter_MCBPC_bits[28] =
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static inline void encode_DC(BW *p, int level, int n)
{
if (level < -255 || level > 255) printf("dc overflow\n");
if (level < -255 || level > 255)
printf("dc overflow\n");
#if 1
level += 256;
if (n < 4)
@@ -75,7 +75,6 @@ static inline void encode_DC(BW *p, int level, int n)
put_bits(p, uni_DCtab_chrom_len[level], uni_DCtab_chrom_bits[level]);
}
#else
int size, v;
/* find number of bits */
size = 0;
@@ -106,17 +105,15 @@ static inline void encode_DC(BW *p, int level, int n)
if (size > 8)
put_bits(p, 1, 1);
}
#endif
}
static inline void encode_escape_3(BW *p, int last, int run, int level)
{
#if 0
put_bits(p,
7 + 2 + 1 + 6 + 1 + 12 + 1, //30bit
(3 << 23) + (3 << 21) + (last << 20) + (run << 14) + (1 << 13) + (((level - 64) & 0xfff) << 1) + 1);
7 + 2 + 1 + 6 + 1 + 12 + 1, //30bit
(3 << 23) + (3 << 21) + (last << 20) + (run << 14) + (1 << 13) + (((level - 64) & 0xfff) << 1) + 1);
#else
put_bits(p, 7, 3); // escape
put_bits(p, 2, 3); // escape3
@@ -271,10 +268,7 @@ esc3:
last_non_zero = i;
}
}
#endif
}
static inline void encode_intra_block(BW *bw, M4V_BLOCK *block, int n)
@@ -312,7 +306,6 @@ static inline void encode_inter_8x8_MCBPC(BW *bw, int cbpc)
put_bits(bw, vlce_inter_MCBPC_bits[cbpc + 16], vlce_inter_MCBPC_code[cbpc + 16]);
}
// same as H.263
static inline void encode_cbpy(BW *bw, int cbpy)
{
@@ -340,7 +333,6 @@ static inline void encode_motion(BW *bw, VLCDEC *mv_x, VLCDEC *mv_y)
{
put_bits(bw, mv_x->bits_ex - 1, mv_x->value_ex >> 1);
}
}
put_vlcdec(bw, mv_y);
if (mv_y->bits_ex)
@@ -371,7 +363,8 @@ static inline void encode_mb_inter_internal(BW *bw, M4V_MICROBLOCK *mb)
cbpy = cbp >> 2;
cbpy ^= 0xF;
if (mb->dquant) cbpc += 8;
if (mb->dquant)
cbpc += 8;
switch (mb->mv_type)
{
@@ -414,12 +407,16 @@ static inline void encode_mb_intra_internal(BW *bw, M4V_MICROBLOCK *mb, int ifra
cbpc = cbp & 3;
if (iframe)
{
if (mb->dquant) cbpc += 4;
if (mb->dquant)
cbpc += 4;
encode_intra_I_MCBPC(bw, cbpc);
}
else
{
if (mb->dquant) cbpc += 8;
if (mb->dquant)
cbpc += 8;
encode_intra_P_MCBPC(bw, cbpc);
}
@@ -430,7 +427,6 @@ static inline void encode_mb_intra_internal(BW *bw, M4V_MICROBLOCK *mb, int ifra
encode_cbpy(bw, cbpy);
encode_dquant(bw, mb->dquant);
for (i = 0; i < 6; i++)
{
encode_intra_block(bw, &mb->block[i], i);
@@ -482,7 +478,9 @@ static inline int encode_vol_header(BW *p, M4V_VOL *vol)
put_bits(p, 2, 0); // shape_type
put_bits(p, 1, 1); // marker
if (vol->time_bits != 5) return -1; // for vop_time_increment_resolution = 30
if (vol->time_bits != 5)
return -1; // for vop_time_increment_resolution = 30
put_bits(p, 16, 30); // *** vop_time_increment_resolution = 30
put_bits(p, 1, 1); // marker
@@ -520,7 +518,6 @@ static inline int encode_vop_header(BW *p, M4V_VOP *vop, int time_bits, int vop_
put_bits(p, 2, vop->picture_type);
// printf("not_code:%d vop_time: %d\n", vop_not_coded, vop->time);
// printf("pic:%d icount:%d vop_time: %d\n", vop->picture_type, time_incr, vop->time);
@@ -619,7 +616,7 @@ static inline int encode_user_header(BW *p)
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void m4v_encode_m4v_header(BW *bw, M4V_VOL *vol, uint32 time)
void m4v_encode_m4v_header(BW *bw, M4V_VOL *vol, uint32 time __attribute__((unused)))
{
encode_vo_header(bw);
encode_vol_header(bw, vol);