Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/tags/release-1_3_6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Dec 14, 2019
2 parents 6984e31 + 9f43dcb commit 24a3480
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 279 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Note that this ChangeLog covers only main changes to the release branch

2019-11-12 14:48 Isibaar
* xvidcore/src/bitstream/bitstream.c
* xvidcore/src/bitstream/bitstream.h
* xvidcore/src/bitstream/mbcoding.c
* xvidcore/src/decoder.c
* xvidcore/src/global.h
* xvidcore/src/image/colorspace.c
* xvidcore/src/motion/gmc.c
* xvidcore/src/quant/quant_matrix.c
* xvidcore/src/xvid.h: Backporting patches from HEAD

2019-01-17 10:33 Isibaar
* xvidcore/src/nasm.inc: always use .text for machine (Patch
by Peter Ross)

2017-07-12 08:23 Isibaar
* xvidcore/vfw/src/codec.c: Re-add support to decode raw YV12
input FourCC video
Expand Down
2 changes: 1 addition & 1 deletion build/generic/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dnl ==========================================================================

AC_PREREQ([2.50])

AC_INIT([Xvid], [1.3.5], [[email protected]])
AC_INIT([Xvid], [1.3.6], [[email protected]])
AC_CONFIG_SRCDIR(configure.in)

dnl Do not forget to increase that when needed.
Expand Down
41 changes: 21 additions & 20 deletions src/bitstream/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ read_video_packet_header(Bitstream *bs,
READ_MARKER();
if (dec->time_inc_bits)
time_increment = (BitstreamGetBits(bs, dec->time_inc_bits)); /* vop_time_increment */
else
time_increment = 0;
READ_MARKER();
DPRINTF(XVID_DEBUG_HEADER,"time %i:%i\n", time_base, time_increment);

Expand Down Expand Up @@ -398,7 +400,6 @@ BitstreamReadHeaders(Bitstream * bs,
uint32_t start_code;
uint32_t time_incr = 0;
int32_t time_increment = 0;
int resize = 0;

while ((BitstreamPos(bs) >> 3) + 4 <= bs->length) {

Expand Down Expand Up @@ -466,6 +467,7 @@ BitstreamReadHeaders(Bitstream * bs,
BitstreamSkip(bs, 32); /* video_object_start_code */

} else if ((start_code & ~VIDOBJLAY_START_CODE_MASK) == VIDOBJLAY_START_CODE) {
uint32_t width = 0, height = 0;

DPRINTF(XVID_DEBUG_STARTCODE, "<video_object_layer>\n");
DPRINTF(XVID_DEBUG_HEADER, "vol id %i\n", start_code & VIDOBJLAY_START_CODE_MASK);
Expand Down Expand Up @@ -566,8 +568,6 @@ BitstreamReadHeaders(Bitstream * bs,
if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) {

if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR) {
uint32_t width, height;

READ_MARKER();
width = BitstreamGetBits(bs, 13); /* video_object_layer_width */
READ_MARKER();
Expand All @@ -576,18 +576,6 @@ BitstreamReadHeaders(Bitstream * bs,

DPRINTF(XVID_DEBUG_HEADER, "width %i\n", width);
DPRINTF(XVID_DEBUG_HEADER, "height %i\n", height);

if (dec->width != width || dec->height != height)
{
if (dec->fixed_dimensions)
{
DPRINTF(XVID_DEBUG_ERROR, "decoder width/height does not match bitstream\n");
return -1;
}
resize = 1;
dec->width = width;
dec->height = height;
}
}

dec->interlacing = BitstreamGetBit(bs);
Expand Down Expand Up @@ -764,7 +752,19 @@ BitstreamReadHeaders(Bitstream * bs,

}

return (resize ? -3 : -2 ); /* VOL */
if (((width > 0) && (height > 0)) && (dec->width != width || dec->height != height))
{
if (dec->fixed_dimensions)
{
DPRINTF(XVID_DEBUG_ERROR, "decoder width/height does not match bitstream\n");
return -1;
}
dec->width = width;
dec->height = height;
return -3;
}

return -2; /* VOL */

} else if (start_code == GRPOFVOP_START_CODE) {

Expand Down Expand Up @@ -860,8 +860,9 @@ BitstreamReadHeaders(Bitstream * bs,
dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR &&
(coding_type == P_VOP || coding_type == I_VOP)) {

if (BitstreamGetBit(bs));
if (BitstreamGetBit(bs)) {
DPRINTF(XVID_DEBUG_ERROR, "RRV not supported (anymore)\n");
}
}

if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {
Expand Down Expand Up @@ -919,7 +920,7 @@ BitstreamReadHeaders(Bitstream * bs,

int i;

for (i = 0 ; i < dec->sprite_warping_points; i++)
for (i = 0 ; i < MIN(4, dec->sprite_warping_points); i++)
{
int length;
int x = 0, y = 0;
Expand Down Expand Up @@ -981,15 +982,15 @@ BitstreamReadHeaders(Bitstream * bs,

} else if (start_code == USERDATA_START_CODE) {
char tmp[256];
int i, version, build;
int i, version = 0, build = 0;
char packed;

BitstreamSkip(bs, 32); /* user_data_start_code */

memset(tmp, 0, 256);
tmp[0] = BitstreamShowBits(bs, 8);

for(i = 1; i < 256; i++){
for(i = 1; i < 255; i++){
tmp[i] = (BitstreamShowBits(bs, 16) & 0xFF);

if(tmp[i] == 0)
Expand Down
4 changes: 3 additions & 1 deletion src/bitstream/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ void write_video_packet_header(Bitstream * const bs,
the end of the buffer. Padding might be appropriate. If only chunks
of 4bytes are applicable, define XVID_SAFE_BS_TAIL. Note that this will
slow decoding, so consider this as a last-resort solution */
/* #define XVID_SAFE_BS_TAIL */
#ifndef XVID_HAVE_PADDED_BS_BUFFER
#define XVID_SAFE_BS_TAIL
#endif

/* initialise bitstream structure */

Expand Down
7 changes: 4 additions & 3 deletions src/bitstream/mbcoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ get_mv_data(Bitstream * bs)

index -= 4;

BitstreamSkip(bs, TMNMVtab2[index].len);
return TMNMVtab2[index].code;
BitstreamSkip(bs, TMNMVtab2[index&0x7f].len);
return TMNMVtab2[index&0x7f].code;

}

Expand Down Expand Up @@ -1965,7 +1965,8 @@ VLC const TMNMVtab2[] = {
{14, 10}, {14, 10}, {14, 10}, {14, 10},
{-14, 10}, {-14, 10}, {-14, 10}, {-14, 10},
{13, 10}, {13, 10}, {13, 10}, {13, 10},
{-13, 10}, {-13, 10}, {-13, 10}, {-13, 10}
{-13, 10}, {-13, 10}, {-13, 10}, {-13, 10},
{0, 0}, {0, 0}, {0, 0}, {0, 0}
};

short const dc_threshold[] = {
Expand Down
41 changes: 21 additions & 20 deletions src/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ decoder_resize(DECODER * dec)
int
decoder_create(xvid_dec_create_t * create)
{
int ret = 0;
DECODER *dec;

if (XVID_VERSION_MAJOR(create->version) != 1) /* v1.x.x */
Expand All @@ -169,8 +170,8 @@ decoder_create(xvid_dec_create_t * create)

create->handle = dec;

dec->width = create->width;
dec->height = create->height;
dec->width = MAX(0, create->width);
dec->height = MAX(0, create->height);

dec->num_threads = MAX(0, create->num_threads);

Expand Down Expand Up @@ -209,13 +210,10 @@ decoder_create(xvid_dec_create_t * create)

dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);

if (dec->fixed_dimensions) {
int ret = decoder_resize(dec);
if (ret == XVID_ERR_MEMORY) create->handle = NULL;
return ret;
}
else
return 0;
ret = decoder_resize(dec);
if (ret == XVID_ERR_MEMORY) create->handle = NULL;

return ret;
}


Expand Down Expand Up @@ -266,7 +264,7 @@ decoder_mbintra(DECODER * dec,
uint32_t stride2 = stride / 2;
uint32_t next_block = stride * 8;
uint32_t i;
uint32_t iQuant = pMB->quant;
uint32_t iQuant = MAX(1, pMB->quant);
uint8_t *pY_Cur, *pU_Cur, *pV_Cur;

pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
Expand Down Expand Up @@ -363,7 +361,7 @@ decoder_mb_decode(DECODER * dec,

int stride = dec->edged_width;
int i;
const uint32_t iQuant = pMB->quant;
const uint32_t iQuant = MAX(1, pMB->quant);
const int direction = dec->alternate_vertical_scan ? 2 : 0;
typedef void (*get_inter_block_function_t)(
Bitstream * bs,
Expand Down Expand Up @@ -1540,9 +1538,11 @@ static void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs,
img = &dec->tmp;
}

image_output(img, dec->width, dec->height,
dec->edged_width, (uint8_t**)frame->output.plane, frame->output.stride,
frame->output.csp, dec->interlacing);
if ((frame->output.plane[0] != NULL) && (frame->output.stride[0] >= dec->width)) {
image_output(img, dec->width, dec->height,
dec->edged_width, (uint8_t**)frame->output.plane, frame->output.stride,
frame->output.csp, dec->interlacing);
}

if (stats) {
stats->type = coding2type(coding_type);
Expand All @@ -1565,19 +1565,20 @@ decoder_decode(DECODER * dec,
{

Bitstream bs;
uint32_t rounding;
uint32_t rounding = 0;
uint32_t quant = 2;
uint32_t fcode_forward;
uint32_t fcode_backward;
uint32_t intra_dc_threshold;
uint32_t fcode_forward = 0;
uint32_t fcode_backward = 0;
uint32_t intra_dc_threshold = 0;
WARPPOINTS gmc_warp;
int coding_type;
int coding_type = -1;
int success, output, seen_something;

if (XVID_VERSION_MAJOR(frame->version) != 1 || (stats && XVID_VERSION_MAJOR(stats->version) != 1)) /* v1.x.x */
return XVID_ERR_VERSION;

start_global_timer();
memset((void *)&gmc_warp, 0, sizeof(WARPPOINTS));

dec->low_delay_default = (frame->general & XVID_LOWDELAY);
if ((frame->general & XVID_DISCONTINUITY))
Expand Down Expand Up @@ -1664,7 +1665,7 @@ decoder_decode(DECODER * dec,
goto repeat;
}

if(dec->frames == 0 && coding_type != I_VOP) {
if((dec->frames == 0 && coding_type != I_VOP) || (!dec->width || !dec->height)) {
/* 1st frame is not an i-vop */
goto repeat;
}
Expand Down
2 changes: 1 addition & 1 deletion src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ VECTOR;

typedef struct
{
VECTOR duv[3];
VECTOR duv[4];
}
WARPPOINTS;

Expand Down
1 change: 1 addition & 0 deletions src/image/colorspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ NAME(uint8_t * x_ptr, int x_stride, \
int y_dif = y_stride - fixed_width; \
int uv_dif = uv_stride - (fixed_width / 2); \
int x, y; \
if ((x_ptr == NULL) || (x_dif < 0)) return; \
if (vflip) { \
x_ptr += (height - 1) * x_stride; \
x_dif = -(SIZE)*fixed_width - x_stride; \
Expand Down
8 changes: 4 additions & 4 deletions src/image/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ safe_packed_conv(uint8_t * x_ptr, int x_stride,

/* packed conversions require height to be divisable by 2
(or even by 4 for interlaced conversion) */
if (interlacing)
height_opt = height & (~3);
else
height_opt = height & (~1);
if (interlacing)
height_opt = height & (~3);
else
height_opt = height & (~1);

func_opt(x_ptr, x_stride,
y_ptr, u_ptr, v_ptr, y_stride, uv_stride,
Expand Down
2 changes: 1 addition & 1 deletion src/motion/gmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void Predict_1pt_16x16_C(const NEW_GMC_DATA * const This,
{
const int W = This->sW;
const int H = This->sH;
const int rho = 3-This->accuracy;
const int rho = 3-MIN(This->accuracy, 3);
const int32_t Rounder = ( 128 - (rounding<<(2*rho)) ) << 16;


Expand Down
Loading

0 comments on commit 24a3480

Please sign in to comment.