33 |
#include "mbcoding.h" |
#include "mbcoding.h" |
34 |
|
|
35 |
|
|
36 |
static const uint8_t log2_tab_16[256] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; |
static const uint8_t log2_tab_16[16] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; |
37 |
|
|
38 |
static uint32_t __inline log2bin(uint32_t value) |
static uint32_t __inline log2bin(uint32_t value) |
39 |
{ |
{ |
194 |
DPRINTF(XVID_DEBUG_HEADER,"fcode_backward %i\n", *fcode_backward); |
DPRINTF(XVID_DEBUG_HEADER,"fcode_backward %i\n", *fcode_backward); |
195 |
} |
} |
196 |
} |
} |
|
|
|
197 |
} |
} |
198 |
|
|
199 |
if (dec->newpred_enable) |
if (dec->newpred_enable) |
549 |
dec->time_inc_resolution = BitstreamGetBits(bs, 16); /* vop_time_increment_resolution */ |
dec->time_inc_resolution = BitstreamGetBits(bs, 16); /* vop_time_increment_resolution */ |
550 |
DPRINTF(XVID_DEBUG_HEADER,"vop_time_increment_resolution %i\n", dec->time_inc_resolution); |
DPRINTF(XVID_DEBUG_HEADER,"vop_time_increment_resolution %i\n", dec->time_inc_resolution); |
551 |
|
|
|
#if 0 |
|
|
dec->time_inc_resolution--; |
|
|
#endif |
|
|
|
|
552 |
if (dec->time_inc_resolution > 0) { |
if (dec->time_inc_resolution > 0) { |
553 |
dec->time_inc_bits = MAX(log2bin(dec->time_inc_resolution-1), 1); |
dec->time_inc_bits = MAX(log2bin(dec->time_inc_resolution-1), 1); |
554 |
} else { |
} else { |
|
#if 0 |
|
|
dec->time_inc_bits = 0; |
|
|
#endif |
|
555 |
/* for "old" xvid compatibility, set time_inc_bits = 1 */ |
/* for "old" xvid compatibility, set time_inc_bits = 1 */ |
556 |
dec->time_inc_bits = 1; |
dec->time_inc_bits = 1; |
557 |
} |
} |
1251 |
BitstreamPadAlways(bs); /* next_start_code(); */ |
BitstreamPadAlways(bs); /* next_start_code(); */ |
1252 |
|
|
1253 |
/* divx5 userdata string */ |
/* divx5 userdata string */ |
1254 |
#define DIVX5_ID "DivX503b1393" |
#define DIVX5_ID ((char *)"DivX503b1393") |
1255 |
if ((pParam->global_flags & XVID_GLOBAL_DIVX5_USERDATA)) { |
if ((pParam->global_flags & XVID_GLOBAL_DIVX5_USERDATA)) { |
1256 |
BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID)); |
BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID)); |
1257 |
if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_GLOBAL_PACKED)) |
if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_GLOBAL_PACKED)) |
1387 |
|
|
1388 |
void |
void |
1389 |
BitstreamWriteUserData(Bitstream * const bs, |
BitstreamWriteUserData(Bitstream * const bs, |
1390 |
uint8_t * data, |
const char *data, |
1391 |
const int length) |
const unsigned int length) |
1392 |
{ |
{ |
1393 |
int i; |
int i; |
1394 |
|
|
1447 |
{ |
{ |
1448 |
const int mbnum_bits = log2bin(pParam->mb_width * pParam->mb_height - 1); |
const int mbnum_bits = log2bin(pParam->mb_width * pParam->mb_height - 1); |
1449 |
uint32_t nbitsresyncmarker; |
uint32_t nbitsresyncmarker; |
1450 |
int addbits=0; |
|
1451 |
if (frame->coding_type != I_VOP) |
if (frame->coding_type == I_VOP) |
1452 |
addbits = frame->fcode -1; |
nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER; /* 16 zeros followed by a 1. */ |
1453 |
if (frame->coding_type == B_VOP) |
else if (frame->coding_type == P_VOP) |
1454 |
addbits = MAX(frame->fcode, frame->bcode)-1; |
nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER-1 + frame->fcode; |
1455 |
|
else /* B_VOP */ |
1456 |
|
nbitsresyncmarker = MAX(NUMBITS_VP_RESYNC_MARKER, NUMBITS_VP_RESYNC_MARKER-1 + MAX(frame->fcode, frame->bcode)); |
1457 |
|
|
1458 |
BitstreamPadAlways(bs); |
BitstreamPadAlways(bs); |
|
nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER + addbits; |
|
1459 |
BitstreamPutBits(bs, RESYNC_MARKER, nbitsresyncmarker); |
BitstreamPutBits(bs, RESYNC_MARKER, nbitsresyncmarker); |
1460 |
BitstreamPutBits(bs, mbnum, mbnum_bits); |
BitstreamPutBits(bs, mbnum, mbnum_bits); |
1461 |
BitstreamPutBits(bs, frame->quant, 5); |
BitstreamPutBits(bs, frame->quant, 5); |