diff --git a/ChangeLog b/ChangeLog index 870dfe64..bde04546 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/build/generic/configure.in b/build/generic/configure.in index 902fc418..a3c0c34d 100644 --- a/build/generic/configure.in +++ b/build/generic/configure.in @@ -8,7 +8,7 @@ dnl ========================================================================== AC_PREREQ([2.50]) -AC_INIT([Xvid], [1.3.5], [xvid-devel@xvid.org]) +AC_INIT([Xvid], [1.3.6], [xvid-devel@xvid.org]) AC_CONFIG_SRCDIR(configure.in) dnl Do not forget to increase that when needed. diff --git a/src/bitstream/bitstream.c b/src/bitstream/bitstream.c index 5f318d36..886a0927 100644 --- a/src/bitstream/bitstream.c +++ b/src/bitstream/bitstream.c @@ -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); @@ -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) { @@ -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, "\n"); DPRINTF(XVID_DEBUG_HEADER, "vol id %i\n", start_code & VIDOBJLAY_START_CODE_MASK); @@ -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(); @@ -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); @@ -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) { @@ -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) { @@ -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; @@ -981,7 +982,7 @@ 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 */ @@ -989,7 +990,7 @@ BitstreamReadHeaders(Bitstream * bs, 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) diff --git a/src/bitstream/bitstream.h b/src/bitstream/bitstream.h index 2bf6b3f0..73b11f9d 100644 --- a/src/bitstream/bitstream.h +++ b/src/bitstream/bitstream.h @@ -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 */ diff --git a/src/bitstream/mbcoding.c b/src/bitstream/mbcoding.c index 06c0d0d4..679809e6 100644 --- a/src/bitstream/mbcoding.c +++ b/src/bitstream/mbcoding.c @@ -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; } @@ -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[] = { diff --git a/src/decoder.c b/src/decoder.c index e91fbe1e..f8611fcd 100644 --- a/src/decoder.c +++ b/src/decoder.c @@ -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 */ @@ -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); @@ -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; } @@ -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); @@ -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, @@ -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); @@ -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)) @@ -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; } diff --git a/src/global.h b/src/global.h index 67e1d37d..83fe5ba4 100644 --- a/src/global.h +++ b/src/global.h @@ -81,7 +81,7 @@ VECTOR; typedef struct { - VECTOR duv[3]; + VECTOR duv[4]; } WARPPOINTS; diff --git a/src/image/colorspace.c b/src/image/colorspace.c index d72f6c80..01438e69 100644 --- a/src/image/colorspace.c +++ b/src/image/colorspace.c @@ -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; \ diff --git a/src/image/image.c b/src/image/image.c index b61f957f..a3d1323d 100644 --- a/src/image/image.c +++ b/src/image/image.c @@ -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, diff --git a/src/motion/gmc.c b/src/motion/gmc.c index b1780b8a..24192f44 100644 --- a/src/motion/gmc.c +++ b/src/motion/gmc.c @@ -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; diff --git a/src/nasm.inc b/src/nasm.inc index e5181c93..547011c9 100644 --- a/src/nasm.inc +++ b/src/nasm.inc @@ -1,221 +1,213 @@ -;/**************************************************************************** -; * -; * XVID MPEG-4 VIDEO CODEC -; * - NASM common header - -; * -; * Copyright (C) 2008 Michael Militzer -; * -; * This program is free software ; you can redistribute it and/or modify -; * it under the terms of the GNU General Public License as published by -; * the Free Software Foundation ; either version 2 of the License, or -; * (at your option) any later version. -; * -; * This program is distributed in the hope that it will be useful, -; * but WITHOUT ANY WARRANTY ; without even the implied warranty of -; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; * GNU General Public License for more details. -; * -; * You should have received a copy of the GNU General Public License -; * along with this program ; if not, write to the Free Software -; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; * -; * $Id: nasm.inc,v 1.7.2.2 2011-02-25 12:40:25 Isibaar Exp $ -; * -; ***************************************************************************/ - -%ifdef ARCH_IS_X86_64 - -BITS 64 -DEFAULT REL - -%define SECTION_ALIGN 32 - -%ifdef WINDOWS - -%define prm1 rcx -%define prm2 rdx -%define prm3 r8 -%define prm4 r9 -%define prm5 [rsp+40] -%define prm6 [rsp+48] -%define prm7 [rsp+56] -%define prm8 [rsp+64] - -%define prm1d ecx -%define prm2d edx -%define prm3d r8d -%define prm4d r9d -%define prm5d dword prm5 -%define prm6d dword prm6 -%define prm7d dword prm7 -%define prm8d dword prm8 - -%macro PUSH_XMM6_XMM7 0 - movdqa [_ESP+PTR_SIZE], xmm6 - movdqa [_ESP+PTR_SIZE+16], xmm7 -%endmacro - -%macro POP_XMM6_XMM7 0 - movdqa xmm6, [_ESP+PTR_SIZE] - movdqa xmm7, [_ESP+PTR_SIZE+16] -%endmacro - -%else ; Linux - -%define prm1 rdi -%define prm2 rsi -%define prm3 rdx -%define prm4 rcx -%define prm5 r8 -%define prm6 r9 -%define prm7 [rsp+8] -%define prm8 [rsp+16] - -%define prm1d edi -%define prm2d esi -%define prm3d edx -%define prm4d ecx -%define prm5d r8d -%define prm6d r9d -%define prm7d dword prm7 -%define prm8d dword prm8 - -%define PUSH_XMM6_XMM7 -%define POP_XMM6_XMM7 - -%endif - -%define _EAX rax -%define _EBX rbx -%define _ECX rcx -%define _EDX rdx -%define _ESI rsi -%define _EDI rdi -%define _EBP rbp -%define _ESP rsp - -%define TMP0 r10 -%define TMP1 r11 - -%define TMP0d r10d -%define TMP1d r11d - -%define PTR_SIZE 8 -%define PTR_TYPE qword - -%ifdef __YASM_VERSION_ID__ -%define XVID_MOVSXD movsxd -%else -%define XVID_MOVSXD movsx -%endif - -%else - -%define SECTION_ALIGN 16 - -BITS 32 - -%define prm1 [esp + 4] -%define prm2 [esp + 8] -%define prm3 [esp + 12] -%define prm4 [esp + 16] -%define prm5 [esp + 20] -%define prm6 [esp + 24] -%define prm7 [esp + 28] -%define prm8 [esp + 32] - -%define prm1d dword prm1 -%define prm2d dword prm2 -%define prm3d dword prm3 -%define prm4d dword prm4 -%define prm5d dword prm5 -%define prm6d dword prm6 -%define prm7d dword prm7 -%define prm8d dword prm8 - -%define _EAX eax -%define _EBX ebx -%define _ECX ecx -%define _EDX edx -%define _ESI esi -%define _EDI edi -%define _EBP ebp -%define _ESP esp - -%define TMP0 ecx -%define TMP1 edx - -%define TMP0d ecx -%define TMP1d edx - -%define PTR_SIZE 4 -%define PTR_TYPE dword - -%define PUSH_XMM6_XMM7 -%define POP_XMM6_XMM7 - -%define XVID_MOVSXD movsx -%endif - - -%ifdef WINDOWS - %define PREFIX -%endif - -%ifdef NO_PREFIX - %undef PREFIX -%endif - -%macro DATA 0 - %ifdef FORMAT_COFF - SECTION .rodata - %else - SECTION .rodata align=SECTION_ALIGN - %endif -%endmacro - -%macro TEXT 0 -%ifidn __OUTPUT_FORMAT__,macho32 - SECTION .text align=SECTION_ALIGN -%else -%ifidn __OUTPUT_FORMAT__,macho64 - SECTION .text align=SECTION_ALIGN -%else - SECTION .rotext align=SECTION_ALIGN -%endif -%endif -%endmacro - -%macro cglobal 1 - %ifdef PREFIX - %ifdef MARK_FUNCS - global _%1:function %1.endfunc-%1 - %define %1 _%1:function %1.endfunc-%1 - %define ENDFUNC .endfunc: - %else - global _%1 - %define %1 _%1 - %define ENDFUNC - %endif - %else - %ifdef MARK_FUNCS - global %1:function %1.endfunc-%1 - %define ENDFUNC .endfunc: - %else - global %1 - %define ENDFUNC - %endif - %endif -%endmacro - -%macro NON_EXEC_STACK 0 -%ifidn __OUTPUT_FORMAT__,elf -section .note.GNU-stack noalloc noexec nowrite progbits -%endif -%ifidn __OUTPUT_FORMAT__,elf32 -section .note.GNU-stack noalloc noexec nowrite progbits -%endif -%ifidn __OUTPUT_FORMAT__,elf64 -section .note.GNU-stack noalloc noexec nowrite progbits -%endif -%endmacro +;/**************************************************************************** +; * +; * XVID MPEG-4 VIDEO CODEC +; * - NASM common header - +; * +; * Copyright (C) 2008 Michael Militzer +; * +; * This program is free software ; you can redistribute it and/or modify +; * it under the terms of the GNU General Public License as published by +; * the Free Software Foundation ; either version 2 of the License, or +; * (at your option) any later version. +; * +; * This program is distributed in the hope that it will be useful, +; * but WITHOUT ANY WARRANTY ; without even the implied warranty of +; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; * GNU General Public License for more details. +; * +; * You should have received a copy of the GNU General Public License +; * along with this program ; if not, write to the Free Software +; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; * +; * $Id: nasm.inc,v 1.7.2.2 2011-02-25 12:40:25 Isibaar Exp $ +; * +; ***************************************************************************/ + +%ifdef ARCH_IS_X86_64 + +BITS 64 +DEFAULT REL + +%define SECTION_ALIGN 32 + +%ifdef WINDOWS + +%define prm1 rcx +%define prm2 rdx +%define prm3 r8 +%define prm4 r9 +%define prm5 [rsp+40] +%define prm6 [rsp+48] +%define prm7 [rsp+56] +%define prm8 [rsp+64] + +%define prm1d ecx +%define prm2d edx +%define prm3d r8d +%define prm4d r9d +%define prm5d dword prm5 +%define prm6d dword prm6 +%define prm7d dword prm7 +%define prm8d dword prm8 + +%macro PUSH_XMM6_XMM7 0 + movdqa [_ESP+PTR_SIZE], xmm6 + movdqa [_ESP+PTR_SIZE+16], xmm7 +%endmacro + +%macro POP_XMM6_XMM7 0 + movdqa xmm6, [_ESP+PTR_SIZE] + movdqa xmm7, [_ESP+PTR_SIZE+16] +%endmacro + +%else ; Linux + +%define prm1 rdi +%define prm2 rsi +%define prm3 rdx +%define prm4 rcx +%define prm5 r8 +%define prm6 r9 +%define prm7 [rsp+8] +%define prm8 [rsp+16] + +%define prm1d edi +%define prm2d esi +%define prm3d edx +%define prm4d ecx +%define prm5d r8d +%define prm6d r9d +%define prm7d dword prm7 +%define prm8d dword prm8 + +%define PUSH_XMM6_XMM7 +%define POP_XMM6_XMM7 + +%endif + +%define _EAX rax +%define _EBX rbx +%define _ECX rcx +%define _EDX rdx +%define _ESI rsi +%define _EDI rdi +%define _EBP rbp +%define _ESP rsp + +%define TMP0 r10 +%define TMP1 r11 + +%define TMP0d r10d +%define TMP1d r11d + +%define PTR_SIZE 8 +%define PTR_TYPE qword + +%ifdef __YASM_VERSION_ID__ +%define XVID_MOVSXD movsxd +%else +%define XVID_MOVSXD movsx +%endif + +%else + +%define SECTION_ALIGN 16 + +BITS 32 + +%define prm1 [esp + 4] +%define prm2 [esp + 8] +%define prm3 [esp + 12] +%define prm4 [esp + 16] +%define prm5 [esp + 20] +%define prm6 [esp + 24] +%define prm7 [esp + 28] +%define prm8 [esp + 32] + +%define prm1d dword prm1 +%define prm2d dword prm2 +%define prm3d dword prm3 +%define prm4d dword prm4 +%define prm5d dword prm5 +%define prm6d dword prm6 +%define prm7d dword prm7 +%define prm8d dword prm8 + +%define _EAX eax +%define _EBX ebx +%define _ECX ecx +%define _EDX edx +%define _ESI esi +%define _EDI edi +%define _EBP ebp +%define _ESP esp + +%define TMP0 ecx +%define TMP1 edx + +%define TMP0d ecx +%define TMP1d edx + +%define PTR_SIZE 4 +%define PTR_TYPE dword + +%define PUSH_XMM6_XMM7 +%define POP_XMM6_XMM7 + +%define XVID_MOVSXD movsx +%endif + + +%ifdef WINDOWS + %define PREFIX +%endif + +%ifdef NO_PREFIX + %undef PREFIX +%endif + +%macro DATA 0 + %ifdef FORMAT_COFF + SECTION .rodata + %else + SECTION .rodata align=SECTION_ALIGN + %endif +%endmacro + +%macro TEXT 0 + SECTION .text align=SECTION_ALIGN +%endmacro + +%macro cglobal 1 + %ifdef PREFIX + %ifdef MARK_FUNCS + global _%1:function %1.endfunc-%1 + %define %1 _%1:function %1.endfunc-%1 + %define ENDFUNC .endfunc: + %else + global _%1 + %define %1 _%1 + %define ENDFUNC + %endif + %else + %ifdef MARK_FUNCS + global %1:function %1.endfunc-%1 + %define ENDFUNC .endfunc: + %else + global %1 + %define ENDFUNC + %endif + %endif +%endmacro + +%macro NON_EXEC_STACK 0 +%ifidn __OUTPUT_FORMAT__,elf +section .note.GNU-stack noalloc noexec nowrite progbits +%endif +%ifidn __OUTPUT_FORMAT__,elf32 +section .note.GNU-stack noalloc noexec nowrite progbits +%endif +%ifidn __OUTPUT_FORMAT__,elf64 +section .note.GNU-stack noalloc noexec nowrite progbits +%endif +%endmacro diff --git a/src/quant/quant_matrix.c b/src/quant/quant_matrix.c index 385858c5..74ef2208 100644 --- a/src/quant/quant_matrix.c +++ b/src/quant/quant_matrix.c @@ -24,6 +24,7 @@ * ****************************************************************************/ +#include "../global.h" #include "quant_matrix.h" #define FIX(X) (((X)==1) ? 0xFFFF : ((1UL << 16) / (X) + 1)) @@ -114,7 +115,7 @@ set_intra_matrix(uint16_t * mpeg_quant_matrices, const uint8_t * matrix) uint16_t *intra_matrix = mpeg_quant_matrices + 0*64; for (i = 0; i < 64; i++) { - intra_matrix[i] = (!i) ? (uint16_t)8: (uint16_t)matrix[i]; + intra_matrix[i] = (!i) ? (uint16_t)8: (uint16_t)MAX(1, matrix[i]); } } @@ -141,7 +142,7 @@ set_inter_matrix(uint16_t * mpeg_quant_matrices, const uint8_t * matrix) uint16_t *inter_matrix_fixl = mpeg_quant_matrices + 7*64; for (i = 0; i < 64; i++) { - inter_matrix1[i] = ((inter_matrix[i] = (int16_t) matrix[i])>>1); + inter_matrix1[i] = ((inter_matrix[i] = (int16_t)MAX(1, (matrix[i])>>1))); inter_matrix1[i] += ((inter_matrix[i] == 1) ? 1: 0); inter_matrix_fix[i] = (uint16_t) FIX(inter_matrix[i]); inter_matrix_fixl[i] = (uint16_t) FIXL(inter_matrix[i]); diff --git a/src/xvid.c b/src/xvid.c index ba31c465..9dee35ab 100644 --- a/src/xvid.c +++ b/src/xvid.c @@ -699,7 +699,7 @@ xvid_gbl_info(xvid_gbl_info_t * info) return XVID_ERR_VERSION; info->actual_version = XVID_VERSION; - info->build = "xvid-1.3.5"; + info->build = "xvid-1.3.6"; info->cpu_flags = detect_cpu_flags(); info->num_threads = 0; /* single-thread */ diff --git a/src/xvid.h b/src/xvid.h index 2165cf88..648de1b2 100644 --- a/src/xvid.h +++ b/src/xvid.h @@ -57,7 +57,7 @@ extern "C" { #define XVID_API_MAJOR(a) (((a)>>16) & 0xff) #define XVID_API_MINOR(a) (((a)>> 0) & 0xff) -#define XVID_VERSION XVID_MAKE_VERSION(1,3,5) +#define XVID_VERSION XVID_MAKE_VERSION(1,3,6) #define XVID_API XVID_MAKE_API(4, 3) /* Bitstream Version @@ -71,7 +71,7 @@ extern "C" { * doesnt hurt but not increasing it could cause difficulty for decoders in the * future */ -#define XVID_BS_VERSION 67 +#define XVID_BS_VERSION 68 /***************************************************************************** * error codes @@ -447,8 +447,8 @@ typedef struct int sse_v; /* [out] V plane's sse */ /* End of duplicated data, kept only for binary compatibility */ - int bquant_ratio; /* [in] */ - int bquant_offset; /* [in] */ + int bquant_ratio; /* [out] */ + int bquant_offset; /* [out] */ xvid_enc_stats_t stats; /* [out] frame statistics */ } xvid_plg_data_t;