Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 24a3480

Browse files
committed
Merge remote-tracking branch 'upstream/tags/release-1_3_6'
2 parents 6984e31 + 9f43dcb commit 24a3480

File tree

14 files changed

+293
-279
lines changed

14 files changed

+293
-279
lines changed

ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Note that this ChangeLog covers only main changes to the release branch
22

3+
2019-11-12 14:48 Isibaar
4+
* xvidcore/src/bitstream/bitstream.c
5+
* xvidcore/src/bitstream/bitstream.h
6+
* xvidcore/src/bitstream/mbcoding.c
7+
* xvidcore/src/decoder.c
8+
* xvidcore/src/global.h
9+
* xvidcore/src/image/colorspace.c
10+
* xvidcore/src/motion/gmc.c
11+
* xvidcore/src/quant/quant_matrix.c
12+
* xvidcore/src/xvid.h: Backporting patches from HEAD
13+
14+
2019-01-17 10:33 Isibaar
15+
* xvidcore/src/nasm.inc: always use .text for machine (Patch
16+
by Peter Ross)
17+
318
2017-07-12 08:23 Isibaar
419
* xvidcore/vfw/src/codec.c: Re-add support to decode raw YV12
520
input FourCC video

build/generic/configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dnl ==========================================================================
88

99
AC_PREREQ([2.50])
1010

11-
AC_INIT([Xvid], [1.3.5], [xvid-devel@xvid.org])
11+
AC_INIT([Xvid], [1.3.6], [xvid-devel@xvid.org])
1212
AC_CONFIG_SRCDIR(configure.in)
1313

1414
dnl Do not forget to increase that when needed.

src/bitstream/bitstream.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ read_video_packet_header(Bitstream *bs,
153153
READ_MARKER();
154154
if (dec->time_inc_bits)
155155
time_increment = (BitstreamGetBits(bs, dec->time_inc_bits)); /* vop_time_increment */
156+
else
157+
time_increment = 0;
156158
READ_MARKER();
157159
DPRINTF(XVID_DEBUG_HEADER,"time %i:%i\n", time_base, time_increment);
158160

@@ -398,7 +400,6 @@ BitstreamReadHeaders(Bitstream * bs,
398400
uint32_t start_code;
399401
uint32_t time_incr = 0;
400402
int32_t time_increment = 0;
401-
int resize = 0;
402403

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

@@ -466,6 +467,7 @@ BitstreamReadHeaders(Bitstream * bs,
466467
BitstreamSkip(bs, 32); /* video_object_start_code */
467468

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

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

568570
if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR) {
569-
uint32_t width, height;
570-
571571
READ_MARKER();
572572
width = BitstreamGetBits(bs, 13); /* video_object_layer_width */
573573
READ_MARKER();
@@ -576,18 +576,6 @@ BitstreamReadHeaders(Bitstream * bs,
576576

577577
DPRINTF(XVID_DEBUG_HEADER, "width %i\n", width);
578578
DPRINTF(XVID_DEBUG_HEADER, "height %i\n", height);
579-
580-
if (dec->width != width || dec->height != height)
581-
{
582-
if (dec->fixed_dimensions)
583-
{
584-
DPRINTF(XVID_DEBUG_ERROR, "decoder width/height does not match bitstream\n");
585-
return -1;
586-
}
587-
resize = 1;
588-
dec->width = width;
589-
dec->height = height;
590-
}
591579
}
592580

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

765753
}
766754

767-
return (resize ? -3 : -2 ); /* VOL */
755+
if (((width > 0) && (height > 0)) && (dec->width != width || dec->height != height))
756+
{
757+
if (dec->fixed_dimensions)
758+
{
759+
DPRINTF(XVID_DEBUG_ERROR, "decoder width/height does not match bitstream\n");
760+
return -1;
761+
}
762+
dec->width = width;
763+
dec->height = height;
764+
return -3;
765+
}
766+
767+
return -2; /* VOL */
768768

769769
} else if (start_code == GRPOFVOP_START_CODE) {
770770

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

863-
if (BitstreamGetBit(bs));
863+
if (BitstreamGetBit(bs)) {
864864
DPRINTF(XVID_DEBUG_ERROR, "RRV not supported (anymore)\n");
865+
}
865866
}
866867

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

920921
int i;
921922

922-
for (i = 0 ; i < dec->sprite_warping_points; i++)
923+
for (i = 0 ; i < MIN(4, dec->sprite_warping_points); i++)
923924
{
924925
int length;
925926
int x = 0, y = 0;
@@ -981,15 +982,15 @@ BitstreamReadHeaders(Bitstream * bs,
981982

982983
} else if (start_code == USERDATA_START_CODE) {
983984
char tmp[256];
984-
int i, version, build;
985+
int i, version = 0, build = 0;
985986
char packed;
986987

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

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

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

995996
if(tmp[i] == 0)

src/bitstream/bitstream.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ void write_video_packet_header(Bitstream * const bs,
171171
the end of the buffer. Padding might be appropriate. If only chunks
172172
of 4bytes are applicable, define XVID_SAFE_BS_TAIL. Note that this will
173173
slow decoding, so consider this as a last-resort solution */
174-
/* #define XVID_SAFE_BS_TAIL */
174+
#ifndef XVID_HAVE_PADDED_BS_BUFFER
175+
#define XVID_SAFE_BS_TAIL
176+
#endif
175177

176178
/* initialise bitstream structure */
177179

src/bitstream/mbcoding.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ get_mv_data(Bitstream * bs)
901901

902902
index -= 4;
903903

904-
BitstreamSkip(bs, TMNMVtab2[index].len);
905-
return TMNMVtab2[index].code;
904+
BitstreamSkip(bs, TMNMVtab2[index&0x7f].len);
905+
return TMNMVtab2[index&0x7f].code;
906906

907907
}
908908

@@ -1965,7 +1965,8 @@ VLC const TMNMVtab2[] = {
19651965
{14, 10}, {14, 10}, {14, 10}, {14, 10},
19661966
{-14, 10}, {-14, 10}, {-14, 10}, {-14, 10},
19671967
{13, 10}, {13, 10}, {13, 10}, {13, 10},
1968-
{-13, 10}, {-13, 10}, {-13, 10}, {-13, 10}
1968+
{-13, 10}, {-13, 10}, {-13, 10}, {-13, 10},
1969+
{0, 0}, {0, 0}, {0, 0}, {0, 0}
19691970
};
19701971

19711972
short const dc_threshold[] = {

src/decoder.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ decoder_resize(DECODER * dec)
149149
int
150150
decoder_create(xvid_dec_create_t * create)
151151
{
152+
int ret = 0;
152153
DECODER *dec;
153154

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

170171
create->handle = dec;
171172

172-
dec->width = create->width;
173-
dec->height = create->height;
173+
dec->width = MAX(0, create->width);
174+
dec->height = MAX(0, create->height);
174175

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

@@ -209,13 +210,10 @@ decoder_create(xvid_dec_create_t * create)
209210

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

212-
if (dec->fixed_dimensions) {
213-
int ret = decoder_resize(dec);
214-
if (ret == XVID_ERR_MEMORY) create->handle = NULL;
215-
return ret;
216-
}
217-
else
218-
return 0;
213+
ret = decoder_resize(dec);
214+
if (ret == XVID_ERR_MEMORY) create->handle = NULL;
215+
216+
return ret;
219217
}
220218

221219

@@ -266,7 +264,7 @@ decoder_mbintra(DECODER * dec,
266264
uint32_t stride2 = stride / 2;
267265
uint32_t next_block = stride * 8;
268266
uint32_t i;
269-
uint32_t iQuant = pMB->quant;
267+
uint32_t iQuant = MAX(1, pMB->quant);
270268
uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
271269

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

364362
int stride = dec->edged_width;
365363
int i;
366-
const uint32_t iQuant = pMB->quant;
364+
const uint32_t iQuant = MAX(1, pMB->quant);
367365
const int direction = dec->alternate_vertical_scan ? 2 : 0;
368366
typedef void (*get_inter_block_function_t)(
369367
Bitstream * bs,
@@ -1540,9 +1538,11 @@ static void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs,
15401538
img = &dec->tmp;
15411539
}
15421540

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

15471547
if (stats) {
15481548
stats->type = coding2type(coding_type);
@@ -1565,19 +1565,20 @@ decoder_decode(DECODER * dec,
15651565
{
15661566

15671567
Bitstream bs;
1568-
uint32_t rounding;
1568+
uint32_t rounding = 0;
15691569
uint32_t quant = 2;
1570-
uint32_t fcode_forward;
1571-
uint32_t fcode_backward;
1572-
uint32_t intra_dc_threshold;
1570+
uint32_t fcode_forward = 0;
1571+
uint32_t fcode_backward = 0;
1572+
uint32_t intra_dc_threshold = 0;
15731573
WARPPOINTS gmc_warp;
1574-
int coding_type;
1574+
int coding_type = -1;
15751575
int success, output, seen_something;
15761576

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

15801580
start_global_timer();
1581+
memset((void *)&gmc_warp, 0, sizeof(WARPPOINTS));
15811582

15821583
dec->low_delay_default = (frame->general & XVID_LOWDELAY);
15831584
if ((frame->general & XVID_DISCONTINUITY))
@@ -1664,7 +1665,7 @@ decoder_decode(DECODER * dec,
16641665
goto repeat;
16651666
}
16661667

1667-
if(dec->frames == 0 && coding_type != I_VOP) {
1668+
if((dec->frames == 0 && coding_type != I_VOP) || (!dec->width || !dec->height)) {
16681669
/* 1st frame is not an i-vop */
16691670
goto repeat;
16701671
}

src/global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ VECTOR;
8181

8282
typedef struct
8383
{
84-
VECTOR duv[3];
84+
VECTOR duv[4];
8585
}
8686
WARPPOINTS;
8787

src/image/colorspace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ NAME(uint8_t * x_ptr, int x_stride, \
102102
int y_dif = y_stride - fixed_width; \
103103
int uv_dif = uv_stride - (fixed_width / 2); \
104104
int x, y; \
105+
if ((x_ptr == NULL) || (x_dif < 0)) return; \
105106
if (vflip) { \
106107
x_ptr += (height - 1) * x_stride; \
107108
x_dif = -(SIZE)*fixed_width - x_stride; \

src/image/image.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ safe_packed_conv(uint8_t * x_ptr, int x_stride,
415415

416416
/* packed conversions require height to be divisable by 2
417417
(or even by 4 for interlaced conversion) */
418-
if (interlacing)
419-
height_opt = height & (~3);
420-
else
421-
height_opt = height & (~1);
418+
if (interlacing)
419+
height_opt = height & (~3);
420+
else
421+
height_opt = height & (~1);
422422

423423
func_opt(x_ptr, x_stride,
424424
y_ptr, u_ptr, v_ptr, y_stride, uv_stride,

src/motion/gmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void Predict_1pt_16x16_C(const NEW_GMC_DATA * const This,
269269
{
270270
const int W = This->sW;
271271
const int H = This->sH;
272-
const int rho = 3-This->accuracy;
272+
const int rho = 3-MIN(This->accuracy, 3);
273273
const int32_t Rounder = ( 128 - (rounding<<(2*rho)) ) << 16;
274274

275275

0 commit comments

Comments
 (0)