Compare commits
107 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b769df8ff2 | ||
![]() |
cc2580e6e9 | ||
![]() |
4b0f8aed13 | ||
![]() |
2c8ac66456 | ||
![]() |
4f209fe960 | ||
![]() |
037b1142cd | ||
![]() |
37cc48861d | ||
![]() |
0cd61bfa6d | ||
![]() |
16ea6af381 | ||
![]() |
8bd374858f | ||
![]() |
d39cc3c092 | ||
![]() |
e124c3c298 | ||
![]() |
8acc0546bb | ||
![]() |
36e4be0a0a | ||
![]() |
c603cf5170 | ||
![]() |
e1a46eff7a | ||
![]() |
23aaa82b1d | ||
![]() |
58087a4e64 | ||
![]() |
8d1fa1c97e | ||
![]() |
2eb5f77bc8 | ||
![]() |
ddbbe500b0 | ||
![]() |
d1a5b53ede | ||
![]() |
8e6173c76a | ||
![]() |
1a6f024520 | ||
![]() |
3699a46ed7 | ||
![]() |
62da9203fd | ||
![]() |
2e1e3c1e41 | ||
![]() |
635256a324 | ||
![]() |
240546a185 | ||
![]() |
07df40db6e | ||
![]() |
b24c2e59fe | ||
![]() |
25bc1108c2 | ||
![]() |
8ef917c033 | ||
![]() |
1883249be3 | ||
![]() |
648dc68098 | ||
![]() |
10da0edddc | ||
![]() |
d6bf79993f | ||
![]() |
0f2735e839 | ||
![]() |
9463a28792 | ||
![]() |
1330a8a1cb | ||
![]() |
8135c35528 | ||
![]() |
38423fe0b7 | ||
![]() |
71132596ae | ||
![]() |
d6f8b65417 | ||
![]() |
d8439f0452 | ||
![]() |
eb6b0ed8be | ||
![]() |
6108f04d4f | ||
![]() |
b261ebfd22 | ||
![]() |
03db051b43 | ||
![]() |
cc885682e3 | ||
![]() |
1415ebf031 | ||
![]() |
4e0315b30e | ||
![]() |
a9ded3d272 | ||
![]() |
ef93642aac | ||
![]() |
9cda3d7915 | ||
![]() |
52b8edc94c | ||
![]() |
f936799f0b | ||
![]() |
f6d3dfe78b | ||
![]() |
2e17744a90 | ||
![]() |
19431d4d4e | ||
![]() |
ecd6fa11c2 | ||
![]() |
7cb35d4954 | ||
![]() |
457f869b73 | ||
![]() |
70f01f1262 | ||
![]() |
80fb9f2c57 | ||
![]() |
46f9a6203a | ||
![]() |
e9210b4e17 | ||
![]() |
4f07a3aa2c | ||
![]() |
04888edef3 | ||
![]() |
24cd7c5df7 | ||
![]() |
8210ee22e2 | ||
![]() |
eed5697f99 | ||
![]() |
52ee20f2aa | ||
![]() |
f17b892787 | ||
![]() |
18c5fe919f | ||
![]() |
c5898d7c1d | ||
![]() |
2c4d6aeabc | ||
![]() |
31c8dcedb2 | ||
![]() |
2adad90ae7 | ||
![]() |
808f9ce727 | ||
![]() |
8069e2f6fb | ||
![]() |
f7494394ee | ||
![]() |
04847a06c2 | ||
![]() |
329e816ed7 | ||
![]() |
d6860fb653 | ||
![]() |
e332c41670 | ||
![]() |
11f6eebdd3 | ||
![]() |
9109a58867 | ||
![]() |
44511b17cb | ||
![]() |
48b086b0ef | ||
![]() |
c9864adf34 | ||
![]() |
7d10059aeb | ||
![]() |
69e8b43812 | ||
![]() |
2f504d7a90 | ||
![]() |
2dea9a1266 | ||
![]() |
84e6629de3 | ||
![]() |
fc038df32e | ||
![]() |
021054a196 | ||
![]() |
ee20f19b20 | ||
![]() |
2fcb56dab9 | ||
![]() |
96ca078b22 | ||
![]() |
7fd4cbb519 | ||
![]() |
557e065d5f | ||
![]() |
461243731d | ||
![]() |
fe95afe1e2 | ||
![]() |
775aa5f38c | ||
![]() |
578c32814c |
46
.gitignore
vendored
Normal file
46
.gitignore
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
.config
|
||||
.version
|
||||
*.o
|
||||
*.so
|
||||
*.d
|
||||
*.exe
|
||||
*.ho
|
||||
*-example
|
||||
*-test
|
||||
*_g
|
||||
config.*
|
||||
doc/*.1
|
||||
doc/*.html
|
||||
doc/*.pod
|
||||
doxy
|
||||
ffmpeg
|
||||
ffplay
|
||||
ffprobe
|
||||
ffserver
|
||||
libavcodec/libavcodec*
|
||||
libavcore/libavcore*
|
||||
libavdevice/libavdevice*
|
||||
libavfilter/libavfilter*
|
||||
libavformat/libavformat*
|
||||
libavutil/avconfig.h
|
||||
libavutil/libavutil*
|
||||
libpostproc/libpostproc*
|
||||
libswscale/libswscale*
|
||||
tests/audiogen
|
||||
tests/base64
|
||||
tests/data
|
||||
tests/rotozoom
|
||||
tests/seek_test
|
||||
tests/tiny_psnr
|
||||
tests/videogen
|
||||
tests/vsynth1
|
||||
tests/vsynth2
|
||||
tools/cws2fws
|
||||
tools/graph2dot
|
||||
tools/lavfi-showfiltfmts
|
||||
tools/pktdumper
|
||||
tools/probetest
|
||||
tools/qt-faststart
|
||||
tools/trasher
|
||||
tools/trasher*.d
|
||||
version.h
|
41
Changelog
41
Changelog
@@ -2,10 +2,51 @@ Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
|
||||
version 0.5.5:
|
||||
|
||||
- Fix memory (re)allocation in matroskadec.c (MSVR11-011/CVE-2011-3504)
|
||||
- Fix some crashes with invalid bitstreams in the CAVS decoder
|
||||
(CVE-2011-3362, CVE-2011-3973, CVE-2011-3974)
|
||||
- Compilation fixes for gcc-4.6, testsuite now passes again
|
||||
- Detect and handle overreads in the MJPEG decoder.
|
||||
- multiple other security fixes.
|
||||
|
||||
|
||||
|
||||
version 0.5.4:
|
||||
|
||||
- Fix memory corruption in WMV parsing (addresses CVE-2010-3908)
|
||||
- Fix heap corruption crashes (addresses CVE-2011-0722)
|
||||
- Fix crashes in Vorbis decoding found by zzuf (addresses CVE-2010-4704)
|
||||
- Fix another crash in Vorbis decoding (addresses CVE-2011-0480, Chrome issue 68115)
|
||||
- Fix invalid reads in VC-1 decoding (related to CVE-2011-0723)
|
||||
- Do not attempt to decode APE file with no frames
|
||||
(adresses http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt)
|
||||
|
||||
|
||||
|
||||
version 0.5.3:
|
||||
|
||||
- build system improvements
|
||||
- performance fix for seekable HTTP
|
||||
- fix several potentially exploitable issues in the FLIC decoder
|
||||
(addresses CVE-2010-3429)
|
||||
|
||||
|
||||
|
||||
version 0.5.2:
|
||||
|
||||
- Hurd support
|
||||
- PowerPC without AltiVec compilation issues
|
||||
- validate channels and samplerate in the Vorbis decoder
|
||||
|
||||
|
||||
|
||||
version 0.5.1:
|
||||
|
||||
- build system updates
|
||||
- documentation updates
|
||||
- libswscale now is LGPL except for x86 optimizations
|
||||
- fix for GPL code in libswscale that was erroneously activated
|
||||
- AltiVec code in libswscale is now LGPL
|
||||
- remaining GPL parts in AC-3 decoder converted to LGPL
|
||||
|
64
RELEASE
64
RELEASE
@@ -40,7 +40,7 @@ should appear in doc/APIchanges.
|
||||
|
||||
|
||||
|
||||
* 0.5.1
|
||||
* 0.5.1 March 2, 2010
|
||||
|
||||
General notes
|
||||
-------------
|
||||
@@ -101,3 +101,65 @@ claimed. We have changed configure to reflect this. You now have to pass the
|
||||
Furthermore the non-free bits in libavcodec/fdctref.c have been rewritten. Note
|
||||
well that they were only used in a test program and never compiled into any
|
||||
FFmpeg library.
|
||||
|
||||
|
||||
|
||||
* 0.5.2 May 25, 2010
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This is a maintenance-only release that addresses a small number of security
|
||||
and portability issues. Distributors and system integrators are encouraged
|
||||
to update and share their patches against this branch.
|
||||
|
||||
|
||||
|
||||
* 0.5.3 Oct 18, 2010
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This is (again) another maintenance-only release that addresses a fix
|
||||
for seekable HTTP and an exploitable bug in the FLIC decoder
|
||||
(cf. CVE-2010-3429 for details). Distributors and system integrators are
|
||||
encouraged to update and share their patches against this branch.
|
||||
|
||||
|
||||
|
||||
* 0.5.4 Mar 17, 2011
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This is the first release that we cut after git migration. It is another
|
||||
maintenance-only release that addresses several security issues that were
|
||||
brought to our attention. In detail, fixes for RV30/40, WMV, Vorbis and
|
||||
VC-1 have been backported from trunk. Distributors and system integrators
|
||||
are encouraged to update and share their patches against this branch.
|
||||
|
||||
|
||||
|
||||
* 0.5.5 Nov 6, 2011
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This maintenance-only release addresses several security issues that
|
||||
were brought to our attention. In detail, fixes for the MJPEG decoder,
|
||||
the CAVS decoder (CVE-2011-3362, CVE-2011-3973, CVE-2011-3974), and the
|
||||
Matroska decoder (MSVR11-011/CVE-2011-3504) and many others have been
|
||||
corrected. Additional, this release contains fixes for compilation with
|
||||
gcc-4.6. Distributors and system integrators are encouraged to update
|
||||
and share their patches against this branch.
|
||||
|
||||
|
||||
|
||||
* 0.5.6 Nov 21, 2011
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This maintenance-only release addresses several security issues that
|
||||
were brought to our attention.
|
||||
|
||||
|
46
configure
vendored
46
configure
vendored
@@ -82,7 +82,7 @@ show_help(){
|
||||
echo " --disable-ffplay disable ffplay build"
|
||||
echo " --disable-ffserver disable ffserver build"
|
||||
echo " --enable-postproc enable GPLed postprocessing support [no]"
|
||||
echo " --enable-swscale enable GPLed software scaler support [no]"
|
||||
echo " --enable-swscale enable software scaler support [no]"
|
||||
echo " --enable-avfilter video filter support (replaces vhook) [no]"
|
||||
echo " --enable-avfilter-lavf video filters dependent on avformat [no]"
|
||||
echo " --disable-vhook disable video hooking support"
|
||||
@@ -261,7 +261,6 @@ Include the log file "$logfile" produced by configure as this will help
|
||||
solving the problem.
|
||||
EOF
|
||||
fi
|
||||
rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -1358,13 +1357,36 @@ esac
|
||||
: ${TMPDIR:=$TMP}
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
TMPC="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
|
||||
TMPE="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
|
||||
TMPH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
|
||||
TMPO="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
|
||||
TMPS="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
|
||||
TMPV="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.ver"
|
||||
TMPSH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
|
||||
|
||||
if ! check_cmd type mktemp; then
|
||||
# simple replacement for missing mktemp
|
||||
# NOT SAFE FOR GENERAL USE
|
||||
mktemp(){
|
||||
echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
tmpfile(){
|
||||
tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
|
||||
(set -C; exec > $tmp) 2>/dev/null ||
|
||||
die "Unable to create temoporary file in $TMPDIR."
|
||||
append TMPFILES $tmp
|
||||
eval $1=$tmp
|
||||
}
|
||||
|
||||
trap 'rm -f -- $TMPFILES' EXIT
|
||||
trap exit HUP INT TERM
|
||||
|
||||
tmpfile TMPC .c
|
||||
tmpfile TMPE $EXESUF
|
||||
tmpfile TMPH .h
|
||||
tmpfile TMPO .o
|
||||
tmpfile TMPS .S
|
||||
tmpfile TMPV .ver
|
||||
tmpfile TMPSH .sh
|
||||
|
||||
unset -f mktemp
|
||||
|
||||
# make sure we can execute files in $TMPDIR
|
||||
cat > $TMPSH 2>> $logfile <<EOF
|
||||
@@ -1378,7 +1400,6 @@ variable to another directory and make sure that it is not mounted noexec.
|
||||
EOF
|
||||
die "Sanity test failed."
|
||||
fi
|
||||
rm $TMPSH
|
||||
|
||||
if $cc --version 2>/dev/null | grep -qi gcc; then
|
||||
cc_type=gcc
|
||||
@@ -1659,6 +1680,9 @@ case $target_os in
|
||||
;;
|
||||
gnu/kfreebsd)
|
||||
;;
|
||||
gnu)
|
||||
disable dv1394
|
||||
;;
|
||||
|
||||
*)
|
||||
die "Unknown OS '$target_os'."
|
||||
@@ -2519,8 +2543,6 @@ cmp -s $TMPH config.h &&
|
||||
echo "config.h is unchanged" ||
|
||||
mv -f $TMPH config.h
|
||||
|
||||
rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
|
||||
|
||||
# build tree in object directory if source path is different from current one
|
||||
if enabled source_path_used; then
|
||||
DIRS="\
|
||||
|
@@ -133,7 +133,9 @@ typedef struct FourXContext{
|
||||
GetBitContext pre_gb; ///< ac/dc prefix
|
||||
GetBitContext gb;
|
||||
const uint8_t *bytestream;
|
||||
const uint8_t *bytestream_end;
|
||||
const uint16_t *wordstream;
|
||||
const uint16_t *wordstream_end;
|
||||
int mv[256];
|
||||
VLC pre_vlc;
|
||||
int last_dc;
|
||||
@@ -308,6 +310,8 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int lo
|
||||
assert(code>=0 && code<=6);
|
||||
|
||||
if(code == 0){
|
||||
if (f->bytestream_end - f->bytestream < 1)
|
||||
return;
|
||||
src += f->mv[ *f->bytestream++ ];
|
||||
if(start > src || src > end){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||
@@ -325,15 +329,23 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int lo
|
||||
}else if(code == 3 && f->version<2){
|
||||
mcdc(dst, src, log2w, h, stride, 1, 0);
|
||||
}else if(code == 4){
|
||||
if (f->bytestream_end - f->bytestream < 1)
|
||||
return;
|
||||
src += f->mv[ *f->bytestream++ ];
|
||||
if(start > src || src > end){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
|
||||
return;
|
||||
}
|
||||
if (f->wordstream_end - f->wordstream < 1)
|
||||
return;
|
||||
mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++));
|
||||
}else if(code == 5){
|
||||
if (f->wordstream_end - f->wordstream < 1)
|
||||
return;
|
||||
mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++));
|
||||
}else if(code == 6){
|
||||
if (f->wordstream_end - f->wordstream < 2)
|
||||
return;
|
||||
if(log2w){
|
||||
dst[0] = le2me_16(*f->wordstream++);
|
||||
dst[1] = le2me_16(*f->wordstream++);
|
||||
@@ -355,6 +367,8 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
|
||||
if(f->version>1){
|
||||
extra=20;
|
||||
if (length < extra)
|
||||
return -1;
|
||||
bitstream_size= AV_RL32(buf+8);
|
||||
wordstream_size= AV_RL32(buf+12);
|
||||
bytestream_size= AV_RL32(buf+16);
|
||||
@@ -365,11 +379,10 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
bytestream_size= FFMAX(length - bitstream_size - wordstream_size, 0);
|
||||
}
|
||||
|
||||
if(bitstream_size+ bytestream_size+ wordstream_size + extra != length
|
||||
|| bitstream_size > (1<<26)
|
||||
|| bytestream_size > (1<<26)
|
||||
|| wordstream_size > (1<<26)
|
||||
){
|
||||
if (bitstream_size > length ||
|
||||
bytestream_size > length - bitstream_size ||
|
||||
wordstream_size > length - bytestream_size - bitstream_size ||
|
||||
extra > length - bytestream_size - bitstream_size - wordstream_size){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size,
|
||||
bitstream_size+ bytestream_size+ wordstream_size - length);
|
||||
return -1;
|
||||
@@ -380,7 +393,9 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size);
|
||||
|
||||
f->wordstream= (const uint16_t*)(buf + extra + bitstream_size);
|
||||
f->wordstream_end= f->wordstream + wordstream_size/2;
|
||||
f->bytestream= buf + extra + bitstream_size + wordstream_size;
|
||||
f->bytestream_end = f->bytestream + bytestream_size;
|
||||
|
||||
init_mv(f);
|
||||
|
||||
@@ -509,7 +524,7 @@ static int decode_i_mb(FourXContext *f){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf){
|
||||
static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf, int buf_size){
|
||||
int frequency[512];
|
||||
uint8_t flag[512];
|
||||
int up[512];
|
||||
@@ -517,6 +532,7 @@ static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const
|
||||
int bits_tab[257];
|
||||
int start, end;
|
||||
const uint8_t *ptr= buf;
|
||||
const uint8_t *ptr_end = buf + buf_size;
|
||||
int j;
|
||||
|
||||
memset(frequency, 0, sizeof(frequency));
|
||||
@@ -527,6 +543,8 @@ static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const
|
||||
for(;;){
|
||||
int i;
|
||||
|
||||
if (start <= end && ptr_end - ptr < end - start + 1 + 1)
|
||||
return NULL;
|
||||
for(i=start; i<=end; i++){
|
||||
frequency[i]= *ptr++;
|
||||
}
|
||||
@@ -599,10 +617,13 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
const int height= f->avctx->height;
|
||||
uint16_t *dst= (uint16_t*)f->current_picture.data[0];
|
||||
const int stride= f->current_picture.linesize[0]>>1;
|
||||
const uint8_t *buf_end = buf + length;
|
||||
|
||||
for(y=0; y<height; y+=16){
|
||||
for(x=0; x<width; x+=16){
|
||||
unsigned int color[4], bits;
|
||||
if (buf_end - buf < 8)
|
||||
return -1;
|
||||
memset(color, 0, sizeof(color));
|
||||
//warning following is purely guessed ...
|
||||
color[0]= bytestream_get_le16(&buf);
|
||||
@@ -636,18 +657,23 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
uint16_t *dst= (uint16_t*)f->current_picture.data[0];
|
||||
const int stride= f->current_picture.linesize[0]>>1;
|
||||
const unsigned int bitstream_size= AV_RL32(buf);
|
||||
const int token_count av_unused = AV_RL32(buf + bitstream_size + 8);
|
||||
unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4);
|
||||
const uint8_t *prestream= buf + bitstream_size + 12;
|
||||
unsigned int prestream_size;
|
||||
const uint8_t *prestream;
|
||||
|
||||
if(prestream_size + bitstream_size + 12 != length
|
||||
|| bitstream_size > (1<<26)
|
||||
|| prestream_size > (1<<26)){
|
||||
if (bitstream_size > (1<<26) || length < bitstream_size + 12)
|
||||
return -1;
|
||||
prestream_size = 4*AV_RL32(buf + bitstream_size + 4);
|
||||
prestream = buf + bitstream_size + 12;
|
||||
|
||||
if (prestream_size > (1<<26) ||
|
||||
prestream_size != length - (bitstream_size + 12)){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
prestream= read_huffman_tables(f, prestream);
|
||||
prestream= read_huffman_tables(f, prestream, buf + length - prestream);
|
||||
if (!prestream)
|
||||
return -1;
|
||||
|
||||
init_get_bits(&f->gb, buf + 4, 8*bitstream_size);
|
||||
|
||||
@@ -684,6 +710,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
AVFrame *p, temp;
|
||||
int i, frame_4cc, frame_size;
|
||||
|
||||
if (buf_size < 12)
|
||||
return AVERROR_INVALIDDATA;
|
||||
frame_4cc= AV_RL32(buf);
|
||||
if(buf_size != AV_RL32(buf+4)+8 || buf_size < 20){
|
||||
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, AV_RL32(buf+4));
|
||||
@@ -696,6 +724,9 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
const int whole_size= AV_RL32(buf+16);
|
||||
CFrameBuffer *cfrm;
|
||||
|
||||
if (data_size < 0 || whole_size < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
for(i=0; i<CFRAME_BUFFER_COUNT; i++){
|
||||
if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
|
||||
av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n", f->cfrm[i].id);
|
||||
@@ -712,6 +743,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
cfrm= &f->cfrm[i];
|
||||
|
||||
if (data_size > UINT_MAX - cfrm->size - FF_INPUT_BUFFER_PADDING_SIZE)
|
||||
return AVERROR_INVALIDDATA;
|
||||
cfrm->data= av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if(!cfrm->data){ //explicit check needed as memcpy below might not catch a NULL
|
||||
av_log(f->avctx, AV_LOG_ERROR, "realloc falure");
|
||||
|
@@ -946,4 +946,9 @@ static inline int decode210(GetBitContext *gb){
|
||||
return 2 - get_bits1(gb);
|
||||
}
|
||||
|
||||
static inline int get_bits_left(GetBitContext *gb)
|
||||
{
|
||||
return gb->size_in_bits - get_bits_count(gb);
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_BITSTREAM_H */
|
||||
|
@@ -130,12 +130,14 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
|
||||
r++;
|
||||
mask = -(level_code & 1);
|
||||
level = (level^mask) - mask;
|
||||
} else {
|
||||
} else if (level_code >= 0) {
|
||||
level = r->rltab[level_code][0];
|
||||
if(!level) //end of block signal
|
||||
break;
|
||||
run = r->rltab[level_code][1];
|
||||
r += r->rltab[level_code][2];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
level_buf[i] = level;
|
||||
run_buf[i] = run;
|
||||
@@ -163,7 +165,7 @@ static inline int decode_residual_inter(AVSContext *h) {
|
||||
|
||||
/* get coded block pattern */
|
||||
int cbp= get_ue_golomb(&h->s.gb);
|
||||
if(cbp > 63){
|
||||
if(cbp > 63U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal inter cbp\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -189,7 +191,8 @@ static inline int decode_residual_inter(AVSContext *h) {
|
||||
|
||||
static int decode_mb_i(AVSContext *h, int cbp_code) {
|
||||
GetBitContext *gb = &h->s.gb;
|
||||
int block, pred_mode_uv;
|
||||
unsigned pred_mode_uv;
|
||||
int block;
|
||||
uint8_t top[18];
|
||||
uint8_t *left = NULL;
|
||||
uint8_t *d;
|
||||
@@ -222,7 +225,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code) {
|
||||
/* get coded block pattern */
|
||||
if(h->pic_type == FF_I_TYPE)
|
||||
cbp_code = get_ue_golomb(gb);
|
||||
if(cbp_code > 63){
|
||||
if(cbp_code > 63U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal intra cbp\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -445,6 +448,8 @@ static inline int check_for_slice(AVSContext *h) {
|
||||
if((show_bits_long(gb,24+align) & 0xFFFFFF) == 0x000001) {
|
||||
skip_bits_long(gb,24+align);
|
||||
h->stc = get_bits(gb,8);
|
||||
if (h->stc >= h->mb_height)
|
||||
return 0;
|
||||
decode_slice_header(h,gb);
|
||||
return 1;
|
||||
}
|
||||
@@ -648,7 +653,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
|
||||
buf_end = buf + buf_size;
|
||||
for(;;) {
|
||||
buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc);
|
||||
if(stc & 0xFFFFFE00)
|
||||
if((stc & 0xFFFFFE00) || buf_ptr == buf_end)
|
||||
return FFMAX(0, buf_ptr - buf - s->parse_context.last_index);
|
||||
input_size = (buf_end - buf_ptr)*8;
|
||||
switch(stc) {
|
||||
|
@@ -336,7 +336,8 @@ static int cinepak_decode (CinepakContext *s)
|
||||
* If the frame header is followed by the bytes FE 00 00 06 00 00 then
|
||||
* this is probably one of the two known files that have 6 extra bytes
|
||||
* after the frame header. Else, assume 2 extra bytes. */
|
||||
if ((s->data[10] == 0xFE) &&
|
||||
if (s->size >= 16 &&
|
||||
(s->data[10] == 0xFE) &&
|
||||
(s->data[11] == 0x00) &&
|
||||
(s->data[12] == 0x00) &&
|
||||
(s->data[13] == 0x06) &&
|
||||
@@ -365,6 +366,8 @@ static int cinepak_decode (CinepakContext *s)
|
||||
s->strips[i].x2 = s->avctx->width;
|
||||
|
||||
strip_size = AV_RB24 (&s->data[1]) - 12;
|
||||
if(strip_size < 0)
|
||||
return -1;
|
||||
s->data += 12;
|
||||
strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
|
||||
|
||||
|
@@ -60,7 +60,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
p->pict_type= FF_I_TYPE;
|
||||
p->key_frame= 1;
|
||||
|
||||
init_get_bits(&a->gb, buf, buf_size);
|
||||
init_get_bits(&a->gb, buf, buf_size * 8);
|
||||
|
||||
for(y=0; y<avctx->height; y++){
|
||||
uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ];
|
||||
|
@@ -215,6 +215,8 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
/* handle palette */
|
||||
if (palette_type == 0) {
|
||||
if (palette_colors_count > 256)
|
||||
return AVERROR_INVALIDDATA;
|
||||
for (i = 0; i < palette_colors_count; ++i) {
|
||||
cin->palette[i] = bytestream_get_le24(&buf);
|
||||
bitmap_frame_size -= 3;
|
||||
|
@@ -414,11 +414,6 @@ static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5;
|
||||
/* see dv_88_areas and dv_248_areas for details */
|
||||
static const int mb_area_start[5] = { 1, 6, 21, 43, 64 };
|
||||
|
||||
static inline int get_bits_left(GetBitContext *s)
|
||||
{
|
||||
return s->size_in_bits - get_bits_count(s);
|
||||
}
|
||||
|
||||
static inline int put_bits_left(PutBitContext* s)
|
||||
{
|
||||
return (s->buf_end - s->buf) * 8 - put_bits_count(s);
|
||||
|
@@ -160,7 +160,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
||||
int pixel_skip;
|
||||
int pixel_countdown;
|
||||
unsigned char *pixels;
|
||||
int pixel_limit;
|
||||
unsigned int pixel_limit;
|
||||
|
||||
s->frame.reference = 1;
|
||||
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||
@@ -254,10 +254,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
||||
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
|
||||
} else if ((line_packets & 0xC000) == 0x8000) {
|
||||
// "last byte" opcode
|
||||
pixels[y_ptr + s->frame.linesize[0] - 1] = line_packets & 0xff;
|
||||
pixel_ptr= y_ptr + s->frame.linesize[0] - 1;
|
||||
CHECK_PIXEL_PTR(0);
|
||||
pixels[pixel_ptr] = line_packets & 0xff;
|
||||
} else {
|
||||
compressed_lines--;
|
||||
pixel_ptr = y_ptr;
|
||||
CHECK_PIXEL_PTR(0);
|
||||
pixel_countdown = s->avctx->width;
|
||||
for (i = 0; i < line_packets; i++) {
|
||||
/* account for the skip bytes */
|
||||
@@ -269,7 +272,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
||||
byte_run = -byte_run;
|
||||
palette_idx1 = buf[stream_ptr++];
|
||||
palette_idx2 = buf[stream_ptr++];
|
||||
CHECK_PIXEL_PTR(byte_run);
|
||||
CHECK_PIXEL_PTR(byte_run * 2);
|
||||
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
|
||||
pixels[pixel_ptr++] = palette_idx1;
|
||||
pixels[pixel_ptr++] = palette_idx2;
|
||||
@@ -299,6 +302,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
|
||||
stream_ptr += 2;
|
||||
while (compressed_lines > 0) {
|
||||
pixel_ptr = y_ptr;
|
||||
CHECK_PIXEL_PTR(0);
|
||||
pixel_countdown = s->avctx->width;
|
||||
line_packets = buf[stream_ptr++];
|
||||
if (line_packets > 0) {
|
||||
@@ -454,7 +458,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
||||
int pixel_countdown;
|
||||
unsigned char *pixels;
|
||||
int pixel;
|
||||
int pixel_limit;
|
||||
unsigned int pixel_limit;
|
||||
|
||||
s->frame.reference = 1;
|
||||
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||
@@ -504,6 +508,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
||||
} else {
|
||||
compressed_lines--;
|
||||
pixel_ptr = y_ptr;
|
||||
CHECK_PIXEL_PTR(0);
|
||||
pixel_countdown = s->avctx->width;
|
||||
for (i = 0; i < line_packets; i++) {
|
||||
/* account for the skip bytes */
|
||||
@@ -515,13 +520,13 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
||||
byte_run = -byte_run;
|
||||
pixel = AV_RL16(&buf[stream_ptr]);
|
||||
stream_ptr += 2;
|
||||
CHECK_PIXEL_PTR(byte_run);
|
||||
CHECK_PIXEL_PTR(2 * byte_run);
|
||||
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
|
||||
*((signed short*)(&pixels[pixel_ptr])) = pixel;
|
||||
pixel_ptr += 2;
|
||||
}
|
||||
} else {
|
||||
CHECK_PIXEL_PTR(byte_run);
|
||||
CHECK_PIXEL_PTR(2 * byte_run);
|
||||
for (j = 0; j < byte_run; j++, pixel_countdown--) {
|
||||
*((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
|
||||
stream_ptr += 2;
|
||||
@@ -612,7 +617,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
||||
if (byte_run > 0) {
|
||||
pixel = AV_RL16(&buf[stream_ptr]);
|
||||
stream_ptr += 2;
|
||||
CHECK_PIXEL_PTR(byte_run);
|
||||
CHECK_PIXEL_PTR(2 * byte_run);
|
||||
for (j = 0; j < byte_run; j++) {
|
||||
*((signed short*)(&pixels[pixel_ptr])) = pixel;
|
||||
pixel_ptr += 2;
|
||||
@@ -623,7 +628,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
|
||||
}
|
||||
} else { /* copy pixels if byte_run < 0 */
|
||||
byte_run = -byte_run;
|
||||
CHECK_PIXEL_PTR(byte_run);
|
||||
CHECK_PIXEL_PTR(2 * byte_run);
|
||||
for (j = 0; j < byte_run; j++) {
|
||||
*((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
|
||||
stream_ptr += 2;
|
||||
|
@@ -3743,6 +3743,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
free_tables(h);
|
||||
flush_dpb(s->avctx);
|
||||
MPV_common_end(s);
|
||||
h->list_count = 0;
|
||||
}
|
||||
if (!s->context_initialized) {
|
||||
if(h != h0)
|
||||
@@ -3940,8 +3941,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
fill_default_ref_list(h);
|
||||
}
|
||||
|
||||
if(h->slice_type_nos!=FF_I_TYPE && decode_ref_pic_list_reordering(h) < 0)
|
||||
if(h->slice_type_nos!=FF_I_TYPE && decode_ref_pic_list_reordering(h) < 0) {
|
||||
h->ref_count[1]= h->ref_count[0]= 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(h->slice_type_nos!=FF_I_TYPE){
|
||||
s->last_picture_ptr= &h->ref_list[0][0];
|
||||
@@ -7165,7 +7168,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
|
||||
}
|
||||
|
||||
sps->ref_frame_count= get_ue_golomb_31(&s->gb);
|
||||
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count >= 32U){
|
||||
if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count > 16U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
|
||||
goto fail;
|
||||
}
|
||||
|
@@ -153,6 +153,13 @@ static int ir2_decode_frame(AVCodecContext *avctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
start = 48; /* hardcoded for now */
|
||||
|
||||
if (start >= buf_size) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "input buffer size too small (%d)\n", buf_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
s->decode_delta = buf[18];
|
||||
|
||||
/* decide whether frame uses deltas or not */
|
||||
@@ -160,9 +167,8 @@ static int ir2_decode_frame(AVCodecContext *avctx,
|
||||
for (i = 0; i < buf_size; i++)
|
||||
buf[i] = ff_reverse[buf[i]];
|
||||
#endif
|
||||
start = 48; /* hardcoded for now */
|
||||
|
||||
init_get_bits(&s->gb, buf + start, buf_size - start);
|
||||
init_get_bits(&s->gb, buf + start, (buf_size - start) * 8);
|
||||
|
||||
if (s->decode_delta) { /* intraframe */
|
||||
ir2_decode_plane(s, avctx->width, avctx->height,
|
||||
|
@@ -485,6 +485,7 @@ av_cold int ff_xvid_encode_close(AVCodecContext *avctx) {
|
||||
if( x->twopassbuffer != NULL ) {
|
||||
av_free(x->twopassbuffer);
|
||||
av_free(x->old_twopassbuffer);
|
||||
avctx->stats_out = NULL;
|
||||
}
|
||||
if( x->twopassfile != NULL )
|
||||
av_free(x->twopassfile);
|
||||
|
@@ -784,6 +784,10 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i
|
||||
if (s->restart_interval && !s->restart_count)
|
||||
s->restart_count = s->restart_interval;
|
||||
|
||||
if(get_bits_count(&s->gb)>s->gb.size_in_bits){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "overread %d\n", get_bits_count(&s->gb) - s->gb.size_in_bits);
|
||||
return -1;
|
||||
}
|
||||
for(i=0;i<nb_components;i++) {
|
||||
uint8_t *ptr;
|
||||
int n, h, v, x, y, c, j;
|
||||
|
@@ -325,7 +325,8 @@ static int mp_decode_frame(AVCodecContext *avctx,
|
||||
if (sz == 0)
|
||||
goto end;
|
||||
|
||||
init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);
|
||||
if (init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0))
|
||||
goto end;
|
||||
mp_decode_frame_helper(mp, &gb);
|
||||
free_vlc(&mp->vlc);
|
||||
|
||||
|
@@ -164,12 +164,19 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
|
||||
int i, ch, t;
|
||||
int mb = -1;
|
||||
Band *bands = c->bands;
|
||||
int off;
|
||||
int off, out_size;
|
||||
int bits_used, bits_avail;
|
||||
|
||||
memset(bands, 0, sizeof(bands));
|
||||
if(buf_size <= 4){
|
||||
av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
out_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
|
||||
if (*data_size < out_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
@@ -248,7 +255,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
|
||||
*data_size = 0;
|
||||
return buf_size;
|
||||
}
|
||||
*data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
|
||||
*data_size = out_size;
|
||||
|
||||
return buf_size;
|
||||
}
|
||||
|
@@ -154,6 +154,7 @@ static int decode_tag(AVCodecContext * avctx,
|
||||
void *data, int *data_size,
|
||||
const uint8_t * buf, int buf_size) {
|
||||
NellyMoserDecodeContext *s = avctx->priv_data;
|
||||
int data_max = *data_size;
|
||||
int blocks, i;
|
||||
int16_t* samples;
|
||||
*data_size = 0;
|
||||
@@ -177,6 +178,8 @@ static int decode_tag(AVCodecContext * avctx,
|
||||
}
|
||||
|
||||
for (i=0 ; i<blocks ; i++) {
|
||||
if ((i + 1) * NELLY_SAMPLES * sizeof(int16_t) > data_max)
|
||||
return i > 0 ? i * NELLY_BLOCK_LEN : -1;
|
||||
nelly_decode_block(s, &buf[i*NELLY_BLOCK_LEN], s->float_buf);
|
||||
s->dsp.float_to_int16(&samples[i*NELLY_SAMPLES], s->float_buf, NELLY_SAMPLES);
|
||||
*data_size += NELLY_SAMPLES*sizeof(int16_t);
|
||||
|
@@ -802,7 +802,7 @@ erasure:
|
||||
|
||||
*data_size = 160 * sizeof(*outbuffer);
|
||||
|
||||
return *data_size;
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
AVCodec qcelp_decoder =
|
||||
|
@@ -77,6 +77,7 @@ do { \
|
||||
#define SAMPLES_NEEDED_2(why) \
|
||||
av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
|
||||
|
||||
#define QDM2_MAX_FRAME_SIZE 512
|
||||
|
||||
typedef int8_t sb_int8_array[2][30][64];
|
||||
|
||||
@@ -169,7 +170,7 @@ typedef struct {
|
||||
/// I/O data
|
||||
const uint8_t *compressed_data;
|
||||
int compressed_size;
|
||||
float output_buffer[1024];
|
||||
float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
|
||||
|
||||
/// Synthesis filter
|
||||
DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]);
|
||||
@@ -1351,7 +1352,7 @@ static void qdm2_fft_decode_tones (QDM2Context *q, int duration, GetBitContext *
|
||||
local_int_10 = 1 << (q->group_order - duration - 1);
|
||||
offset = 1;
|
||||
|
||||
while (1) {
|
||||
while (get_bits_left(gb)>0) {
|
||||
if (q->superblocktype_2_3) {
|
||||
while ((n = qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2)) < 2) {
|
||||
offset = 1;
|
||||
@@ -1821,6 +1822,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
|
||||
|
||||
avctx->channels = s->nb_channels = s->channels = AV_RB32(extradata);
|
||||
extradata += 4;
|
||||
if (s->channels > MPA_MAX_CHANNELS)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
avctx->sample_rate = AV_RB32(extradata);
|
||||
extradata += 4;
|
||||
@@ -1844,6 +1847,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
|
||||
s->group_order = av_log2(s->group_size) + 1;
|
||||
s->frame_size = s->group_size / 16; // 16 iterations per super block
|
||||
|
||||
if (s->frame_size > QDM2_MAX_FRAME_SIZE)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
s->sub_sampling = s->fft_order - 7;
|
||||
s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
|
||||
|
||||
@@ -1911,6 +1917,9 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
|
||||
int ch, i;
|
||||
const int frame_size = (q->frame_size * q->channels);
|
||||
|
||||
if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
|
||||
return -1;
|
||||
|
||||
/* select input buffer */
|
||||
q->compressed_data = in;
|
||||
q->compressed_size = q->checksum_size;
|
||||
|
@@ -127,6 +127,7 @@ static inline void qtrle_decode_2n4bpp(QtrleContext *s, int stream_ptr,
|
||||
while (lines_to_change--) {
|
||||
CHECK_STREAM_PTR(2);
|
||||
pixel_ptr = row_ptr + (num_pixels * (s->buf[stream_ptr++] - 1));
|
||||
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
|
||||
|
||||
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
|
||||
if (rle_code == 0) {
|
||||
@@ -183,6 +184,7 @@ static void qtrle_decode_8bpp(QtrleContext *s, int stream_ptr, int row_ptr, int
|
||||
while (lines_to_change--) {
|
||||
CHECK_STREAM_PTR(2);
|
||||
pixel_ptr = row_ptr + (4 * (s->buf[stream_ptr++] - 1));
|
||||
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
|
||||
|
||||
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
|
||||
if (rle_code == 0) {
|
||||
@@ -236,6 +238,7 @@ static void qtrle_decode_16bpp(QtrleContext *s, int stream_ptr, int row_ptr, int
|
||||
while (lines_to_change--) {
|
||||
CHECK_STREAM_PTR(2);
|
||||
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 2;
|
||||
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
|
||||
|
||||
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
|
||||
if (rle_code == 0) {
|
||||
@@ -285,6 +288,7 @@ static void qtrle_decode_24bpp(QtrleContext *s, int stream_ptr, int row_ptr, int
|
||||
while (lines_to_change--) {
|
||||
CHECK_STREAM_PTR(2);
|
||||
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3;
|
||||
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
|
||||
|
||||
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
|
||||
if (rle_code == 0) {
|
||||
@@ -336,6 +340,7 @@ static void qtrle_decode_32bpp(QtrleContext *s, int stream_ptr, int row_ptr, int
|
||||
while (lines_to_change--) {
|
||||
CHECK_STREAM_PTR(2);
|
||||
pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 4;
|
||||
CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
|
||||
|
||||
while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) {
|
||||
if (rle_code == 0) {
|
||||
@@ -461,6 +466,8 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
|
||||
stream_ptr += 4;
|
||||
height = AV_RB16(&s->buf[stream_ptr]);
|
||||
stream_ptr += 4;
|
||||
if (height > s->avctx->height - start_line)
|
||||
goto done;
|
||||
} else {
|
||||
start_line = 0;
|
||||
height = s->avctx->height;
|
||||
|
@@ -279,9 +279,9 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
|
||||
if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
|
||||
output_bak = output;
|
||||
|
||||
if (!s->buffer_size[1] || s->buffer_size[1] < lenout) {
|
||||
if (!s->buffer_size[1] || s->buffer_size[1] < 2*lenout) {
|
||||
av_free(s->buffer[1]);
|
||||
s->buffer_size[1] = lenout;
|
||||
s->buffer_size[1] = 2*lenout;
|
||||
s->buffer[1] = av_malloc(s->buffer_size[1]);
|
||||
if (!s->buffer[1]) {
|
||||
av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n");
|
||||
|
@@ -190,8 +190,10 @@ AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size,
|
||||
memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
|
||||
c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
|
||||
|
||||
c->src_incr= out_rate;
|
||||
c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;
|
||||
if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2))
|
||||
return NULL;
|
||||
c->ideal_dst_incr= c->dst_incr;
|
||||
|
||||
c->index= -phase_count*((c->filter_length-1)/2);
|
||||
|
||||
return c;
|
||||
@@ -225,10 +227,9 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
|
||||
dst[dst_index] = src[index2>>32];
|
||||
index2 += incr;
|
||||
}
|
||||
frac += dst_index * dst_incr_frac;
|
||||
index += dst_index * dst_incr;
|
||||
index += frac / c->src_incr;
|
||||
frac %= c->src_incr;
|
||||
index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
|
||||
frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
|
||||
}else{
|
||||
for(dst_index=0; dst_index < dst_size; dst_index++){
|
||||
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
|
||||
|
@@ -642,6 +642,11 @@ static int rv10_decode_packet(AVCodecContext *avctx,
|
||||
if(MPV_frame_start(s, avctx) < 0)
|
||||
return -1;
|
||||
ff_er_frame_start(s);
|
||||
} else {
|
||||
if (s->current_picture_ptr->pict_type != s->pict_type) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@@ -51,6 +51,11 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
|
||||
skip_bits1(gb);
|
||||
si->pts = get_bits(gb, 13);
|
||||
rpr = get_bits(gb, r->rpr);
|
||||
if (r->s.avctx->extradata_size < 8 + rpr*2) {
|
||||
av_log(r->s.avctx, AV_LOG_WARNING,
|
||||
"Extradata does not contain selected resolution\n");
|
||||
rpr = 0;
|
||||
}
|
||||
if(rpr){
|
||||
w = r->s.avctx->extradata[6 + rpr*2] << 2;
|
||||
h = r->s.avctx->extradata[7 + rpr*2] << 2;
|
||||
@@ -74,7 +79,7 @@ static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t
|
||||
for(i = 0; i < 4; i++, dst += r->s.b4_stride - 4){
|
||||
for(j = 0; j < 4; j+= 2){
|
||||
int code = svq3_get_ue_golomb(gb) << 1;
|
||||
if(code >= 81*2){
|
||||
if(code >= 81U*2U){
|
||||
av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -103,7 +108,7 @@ static int rv30_decode_mb_info(RV34DecContext *r)
|
||||
GetBitContext *gb = &s->gb;
|
||||
int code = svq3_get_ue_golomb(gb);
|
||||
|
||||
if(code > 11){
|
||||
if(code > 11U){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
|
||||
return -1;
|
||||
}
|
||||
|
@@ -1249,6 +1249,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
|
||||
MPV_common_end(s);
|
||||
s->width = r->si.width;
|
||||
s->height = r->si.height;
|
||||
avcodec_set_dimensions(s->avctx, s->width, s->height);
|
||||
if(MPV_common_init(s) < 0)
|
||||
return -1;
|
||||
r->intra_types_hist = av_realloc(r->intra_types_hist, s->b4_stride * 4 * 2 * sizeof(*r->intra_types_hist));
|
||||
@@ -1268,6 +1269,17 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
|
||||
r->next_pts = r->cur_pts;
|
||||
}
|
||||
s->mb_x = s->mb_y = 0;
|
||||
} else {
|
||||
int slice_type = r->si.type ? r->si.type : FF_I_TYPE;
|
||||
|
||||
if (slice_type != s->pict_type) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (s->width != r->si.width || s->height != r->si.height) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
r->si.end = end;
|
||||
@@ -1400,8 +1412,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
slice_count = avctx->slice_count;
|
||||
|
||||
//parse first slice header to check whether this frame can be decoded
|
||||
if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){
|
||||
av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n");
|
||||
if(get_slice_offset(avctx, slices_hdr, 0) < 0 ||
|
||||
get_slice_offset(avctx, slices_hdr, 0) > buf_size){
|
||||
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
|
||||
return -1;
|
||||
}
|
||||
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), buf_size-get_slice_offset(avctx, slices_hdr, 0));
|
||||
@@ -1429,8 +1442,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
else
|
||||
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
|
||||
|
||||
if(offset > buf_size){
|
||||
av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n");
|
||||
if(offset < 0 || offset > buf_size || size < 0){
|
||||
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1451,7 +1464,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
|
||||
break;
|
||||
}
|
||||
|
||||
if(last){
|
||||
if(last && s->current_picture_ptr){
|
||||
if(r->loop_filter)
|
||||
r->loop_filter(r, s->mb_height - 1);
|
||||
ff_er_frame_end(s);
|
||||
|
@@ -207,8 +207,11 @@ static int rv40_decode_mb_info(RV34DecContext *r)
|
||||
int blocks[RV34_MB_TYPES] = {0};
|
||||
int count = 0;
|
||||
|
||||
if(!r->s.mb_skip_run)
|
||||
if(!r->s.mb_skip_run) {
|
||||
r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;
|
||||
if(r->s.mb_skip_run > (unsigned)s->mb_num)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(--r->s.mb_skip_run)
|
||||
return RV34_MB_SKIP;
|
||||
|
@@ -147,7 +147,7 @@ static void fix_bitshift(ShortenContext *s, int32_t *buffer)
|
||||
|
||||
if (s->bitshift != 0)
|
||||
for (i = 0; i < s->blocksize; i++)
|
||||
buffer[s->nwrap + i] <<= s->bitshift;
|
||||
buffer[i] <<= s->bitshift;
|
||||
}
|
||||
|
||||
|
||||
@@ -469,9 +469,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
|
||||
case FN_BITSHIFT:
|
||||
s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
|
||||
break;
|
||||
case FN_BLOCKSIZE:
|
||||
s->blocksize = get_uint(s, av_log2(s->blocksize));
|
||||
case FN_BLOCKSIZE: {
|
||||
int blocksize = get_uint(s, av_log2(s->blocksize));
|
||||
if (blocksize > s->blocksize) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
s->blocksize = blocksize;
|
||||
break;
|
||||
}
|
||||
case FN_QUIT:
|
||||
*data_size = 0;
|
||||
return buf_size;
|
||||
|
@@ -133,11 +133,13 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx
|
||||
return -1;
|
||||
}
|
||||
b1 = get_bits_count(gb);
|
||||
i1 = get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3);
|
||||
i1 = ctx->v1->table ? get_vlc2(gb, ctx->v1->table, SMKTREE_BITS, 3) : 0;
|
||||
b1 = get_bits_count(gb) - b1;
|
||||
b2 = get_bits_count(gb);
|
||||
i2 = get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3);
|
||||
i2 = ctx->v2->table ? get_vlc2(gb, ctx->v2->table, SMKTREE_BITS, 3) : 0;
|
||||
b2 = get_bits_count(gb) - b2;
|
||||
if (i1 < 0 || i2 < 0)
|
||||
return -1;
|
||||
val = ctx->recode1[i1] | (ctx->recode2[i2] << 8);
|
||||
if(val == ctx->escapes[0]) {
|
||||
ctx->last[0] = hc->current;
|
||||
@@ -289,7 +291,8 @@ static int decode_header_trees(SmackVContext *smk) {
|
||||
smk->mmap_tbl[0] = 0;
|
||||
smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;
|
||||
} else {
|
||||
smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);
|
||||
if (smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size))
|
||||
return -1;
|
||||
}
|
||||
if(!get_bits1(&gb)) {
|
||||
av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
|
||||
@@ -297,7 +300,8 @@ static int decode_header_trees(SmackVContext *smk) {
|
||||
smk->mclr_tbl[0] = 0;
|
||||
smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;
|
||||
} else {
|
||||
smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size);
|
||||
if (smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size))
|
||||
return -1;
|
||||
}
|
||||
if(!get_bits1(&gb)) {
|
||||
av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\n");
|
||||
@@ -305,7 +309,8 @@ static int decode_header_trees(SmackVContext *smk) {
|
||||
smk->full_tbl[0] = 0;
|
||||
smk->full_last[0] = smk->full_last[1] = smk->full_last[2] = 1;
|
||||
} else {
|
||||
smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size);
|
||||
if (smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size))
|
||||
return -1;
|
||||
}
|
||||
if(!get_bits1(&gb)) {
|
||||
av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\n");
|
||||
@@ -313,7 +318,8 @@ static int decode_header_trees(SmackVContext *smk) {
|
||||
smk->type_tbl[0] = 0;
|
||||
smk->type_last[0] = smk->type_last[1] = smk->type_last[2] = 1;
|
||||
} else {
|
||||
smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size);
|
||||
if (smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -527,8 +533,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
decode_header_trees(c);
|
||||
|
||||
if (decode_header_trees(c))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -654,6 +660,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
} else { //8-bit data
|
||||
for(i = stereo; i >= 0; i--)
|
||||
pred[i] = get_bits(&gb, 8);
|
||||
if (stereo + unp_size > *data_size)
|
||||
return -1;
|
||||
for(i = 0; i < stereo; i++)
|
||||
*samples++ = (pred[i] - 0x80) << 8;
|
||||
for(i = 0; i < unp_size; i++) {
|
||||
|
@@ -88,7 +88,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
|
||||
recoded[j++] = 0xFF;
|
||||
recoded[j++] = 0xD9;
|
||||
|
||||
avctx->flags &= ~CODEC_FLAG_EMU_EDGE;
|
||||
i = ff_mjpeg_decode_frame(avctx, data, data_size, recoded, j);
|
||||
|
||||
av_free(recoded);
|
||||
|
@@ -676,6 +676,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
avcodec_set_dimensions(avctx, s->width, s->height);
|
||||
|
||||
//FIXME this avoids some confusion for "B frames" without 2 references
|
||||
//this should be removed after libavcodec can handle more flexible picture types & ordering
|
||||
|
@@ -202,7 +202,7 @@ static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,
|
||||
for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {
|
||||
for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {
|
||||
|
||||
if (vlc == INVALID_VLC)
|
||||
if (vlc < 0)
|
||||
return -1;
|
||||
|
||||
sign = (vlc & 0x1) - 1;
|
||||
@@ -220,7 +220,7 @@ static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,
|
||||
level = ((vlc + 9) >> 2) - run;
|
||||
}
|
||||
} else {
|
||||
if (vlc < 16) {
|
||||
if (vlc < 16U) {
|
||||
run = svq3_dct_tables[intra][vlc].run;
|
||||
level = svq3_dct_tables[intra][vlc].level;
|
||||
} else if (intra) {
|
||||
@@ -549,7 +549,7 @@ static int svq3_decode_mb(H264Context *h, unsigned int mb_type)
|
||||
for (i = 0; i < 16; i+=2) {
|
||||
vlc = svq3_get_ue_golomb(&s->gb);
|
||||
|
||||
if (vlc >= 25){
|
||||
if (vlc >= 25U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc);
|
||||
return -1;
|
||||
}
|
||||
@@ -620,7 +620,7 @@ static int svq3_decode_mb(H264Context *h, unsigned int mb_type)
|
||||
}
|
||||
|
||||
if (!IS_INTRA16x16(mb_type) && (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE)) {
|
||||
if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48){
|
||||
if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc);
|
||||
return -1;
|
||||
}
|
||||
@@ -630,7 +630,7 @@ static int svq3_decode_mb(H264Context *h, unsigned int mb_type)
|
||||
if (IS_INTRA16x16(mb_type) || (s->pict_type != FF_I_TYPE && s->adaptive_quant && cbp)) {
|
||||
s->qscale += svq3_get_se_golomb(&s->gb);
|
||||
|
||||
if (s->qscale > 31){
|
||||
if (s->qscale > 31U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "qscale:%d\n", s->qscale);
|
||||
return -1;
|
||||
}
|
||||
@@ -727,7 +727,7 @@ static int svq3_decode_slice_header(H264Context *h)
|
||||
skip_bits_long(&s->gb, 0);
|
||||
}
|
||||
|
||||
if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3){
|
||||
if ((i = svq3_get_ue_golomb(&s->gb)) >= 3U){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i);
|
||||
return -1;
|
||||
}
|
||||
|
@@ -189,7 +189,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
|
||||
}
|
||||
|
||||
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
|
||||
if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/4)
|
||||
if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
|
||||
return 0;
|
||||
|
||||
av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
|
||||
|
@@ -2366,7 +2366,7 @@ static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value,
|
||||
if (index != vc1_ac_sizes[codingset] - 1) {
|
||||
run = vc1_index_decode_table[codingset][index][0];
|
||||
level = vc1_index_decode_table[codingset][index][1];
|
||||
lst = index >= vc1_last_decode_table[codingset];
|
||||
lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0;
|
||||
if(get_bits1(gb))
|
||||
level = -level;
|
||||
} else {
|
||||
|
@@ -206,6 +206,16 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
frame_y = AV_RL16(&s->buf[8]);
|
||||
frame_width = AV_RL16(&s->buf[10]) - frame_x + 1;
|
||||
frame_height = AV_RL16(&s->buf[12]) - frame_y + 1;
|
||||
if (frame_x < 0 || frame_width < 0 ||
|
||||
frame_x >= s->avctx->width ||
|
||||
frame_width > s->avctx->width ||
|
||||
frame_x + frame_width > s->avctx->width)
|
||||
return;
|
||||
if (frame_y < 0 || frame_height < 0 ||
|
||||
frame_y >= s->avctx->height ||
|
||||
frame_height > s->avctx->height ||
|
||||
frame_y + frame_height > s->avctx->height)
|
||||
return;
|
||||
|
||||
if ((frame_width == s->avctx->width && frame_height == s->avctx->height) &&
|
||||
(frame_x || frame_y)) {
|
||||
|
@@ -60,8 +60,8 @@ typedef struct vorbis_floor0_s vorbis_floor0;
|
||||
typedef struct vorbis_floor1_s vorbis_floor1;
|
||||
struct vorbis_context_s;
|
||||
typedef
|
||||
uint_fast8_t (* vorbis_floor_decode_func)
|
||||
(struct vorbis_context_s *, vorbis_floor_data *, float *);
|
||||
int (* vorbis_floor_decode_func)
|
||||
(struct vorbis_context_s *, vorbis_floor_data *, float *);
|
||||
typedef struct {
|
||||
uint_fast8_t floor_type;
|
||||
vorbis_floor_decode_func decode;
|
||||
@@ -443,14 +443,14 @@ static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc) {
|
||||
|
||||
// Process floors part
|
||||
|
||||
static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
|
||||
static int vorbis_floor0_decode(vorbis_context *vc,
|
||||
vorbis_floor_data *vfu, float *vec);
|
||||
static void create_map( vorbis_context * vc, uint_fast8_t floor_number );
|
||||
static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
|
||||
static int vorbis_floor1_decode(vorbis_context *vc,
|
||||
vorbis_floor_data *vfu, float *vec);
|
||||
static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
|
||||
GetBitContext *gb=&vc->gb;
|
||||
uint_fast16_t i,j,k;
|
||||
int i,j,k;
|
||||
|
||||
vc->floor_count=get_bits(gb, 6)+1;
|
||||
|
||||
@@ -466,6 +466,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
|
||||
if (floor_setup->floor_type==1) {
|
||||
uint_fast8_t maximum_class=0;
|
||||
uint_fast8_t rangebits;
|
||||
uint_fast32_t rangemax;
|
||||
uint_fast16_t floor1_values=2;
|
||||
|
||||
floor_setup->decode=vorbis_floor1_decode;
|
||||
@@ -526,8 +527,15 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) {
|
||||
|
||||
|
||||
rangebits=get_bits(gb, 4);
|
||||
rangemax = (1 << rangebits);
|
||||
if (rangemax > vc->blocksize[1] / 2) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR,
|
||||
"Floor value is too large for blocksize: %d (%d)\n",
|
||||
rangemax, vc->blocksize[1] / 2);
|
||||
return -1;
|
||||
}
|
||||
floor_setup->data.t1.list[0].x = 0;
|
||||
floor_setup->data.t1.list[1].x = (1<<rangebits);
|
||||
floor_setup->data.t1.list[1].x = rangemax;
|
||||
|
||||
for(j=0;j<floor_setup->data.t1.partitions;++j) {
|
||||
for(k=0;k<floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]];++k,++floor1_values) {
|
||||
@@ -902,8 +910,16 @@ static int vorbis_parse_id_hdr(vorbis_context *vc){
|
||||
}
|
||||
|
||||
vc->version=get_bits_long(gb, 32); //FIXME check 0
|
||||
vc->audio_channels=get_bits(gb, 8); //FIXME check >0
|
||||
vc->audio_samplerate=get_bits_long(gb, 32); //FIXME check >0
|
||||
vc->audio_channels=get_bits(gb, 8);
|
||||
if(vc->audio_channels <= 0){
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid number of channels\n");
|
||||
return -1;
|
||||
}
|
||||
vc->audio_samplerate=get_bits_long(gb, 32);
|
||||
if(vc->audio_samplerate <= 0){
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid samplerate\n");
|
||||
return -1;
|
||||
}
|
||||
vc->bitrate_maximum=get_bits_long(gb, 32);
|
||||
vc->bitrate_nominal=get_bits_long(gb, 32);
|
||||
vc->bitrate_minimum=get_bits_long(gb, 32);
|
||||
@@ -1030,7 +1046,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) {
|
||||
|
||||
// Read and decode floor
|
||||
|
||||
static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
|
||||
static int vorbis_floor0_decode(vorbis_context *vc,
|
||||
vorbis_floor_data *vfu, float *vec) {
|
||||
vorbis_floor0 * vf=&vfu->t0;
|
||||
float * lsp=vf->lsp;
|
||||
@@ -1054,6 +1070,9 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
|
||||
}
|
||||
AV_DEBUG( "floor0 dec: booknumber: %u\n", book_idx );
|
||||
codebook=vc->codebooks[vf->book_list[book_idx]];
|
||||
/* Invalid codebook! */
|
||||
if (!codebook.codevectors)
|
||||
return -1;
|
||||
|
||||
while (lsp_len<vf->order) {
|
||||
int vec_off;
|
||||
@@ -1143,7 +1162,7 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) {
|
||||
static int vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) {
|
||||
vorbis_floor1 * vf=&vfu->t1;
|
||||
GetBitContext *gb=&vc->gb;
|
||||
uint_fast16_t range_v[4]={ 256, 128, 86, 64 };
|
||||
@@ -1519,14 +1538,21 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
|
||||
for(i=0;i<vc->audio_channels;++i) {
|
||||
vorbis_floor *floor;
|
||||
int ret;
|
||||
if (mapping->submaps>1) {
|
||||
floor=&vc->floors[mapping->submap_floor[mapping->mux[i]]];
|
||||
} else {
|
||||
floor=&vc->floors[mapping->submap_floor[0]];
|
||||
}
|
||||
|
||||
no_residue[i]=floor->decode(vc, &floor->data, ch_floor_ptr);
|
||||
ch_floor_ptr+=blocksize/2;
|
||||
ret = floor->decode(vc, &floor->data, ch_floor_ptr);
|
||||
|
||||
if (ret < 0) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n");
|
||||
return -1;
|
||||
}
|
||||
no_residue[i] = ret;
|
||||
ch_floor_ptr += blocksize / 2;
|
||||
}
|
||||
|
||||
// Nonzero vector propagate
|
||||
|
@@ -199,7 +199,8 @@ static void vp5_parse_coeff(VP56Context *s)
|
||||
model1 = model->coeff_dccv[pt];
|
||||
model2 = model->coeff_dcct[pt][ctx];
|
||||
|
||||
for (coeff_idx=0; coeff_idx<64; ) {
|
||||
coeff_idx = 0;
|
||||
for (;;) {
|
||||
if (vp56_rac_get_prob(c, model2[0])) {
|
||||
if (vp56_rac_get_prob(c, model2[2])) {
|
||||
if (vp56_rac_get_prob(c, model2[3])) {
|
||||
@@ -236,8 +237,11 @@ static void vp5_parse_coeff(VP56Context *s)
|
||||
ct = 0;
|
||||
s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 0;
|
||||
}
|
||||
coeff_idx++;
|
||||
if (coeff_idx >= 64)
|
||||
break;
|
||||
|
||||
cg = vp5_coeff_groups[++coeff_idx];
|
||||
cg = vp5_coeff_groups[coeff_idx];
|
||||
ctx = s->coeff_ctx[vp56_b6to4[b]][coeff_idx];
|
||||
model1 = model->coeff_ract[pt][ct][cg];
|
||||
model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];
|
||||
|
@@ -519,6 +519,16 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
if (!res)
|
||||
return -1;
|
||||
|
||||
if (res == 2) {
|
||||
int i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (s->frames[i].data[0])
|
||||
avctx->release_buffer(avctx, &s->frames[i]);
|
||||
}
|
||||
if (is_alpha)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!is_alpha) {
|
||||
p->reference = 1;
|
||||
if (avctx->get_buffer(avctx, p) < 0) {
|
||||
|
@@ -427,7 +427,8 @@ static void vp6_parse_coeff(VP56Context *s)
|
||||
model1 = model->coeff_dccv[pt];
|
||||
model2 = model->coeff_dcct[pt][ctx];
|
||||
|
||||
for (coeff_idx=0; coeff_idx<64; ) {
|
||||
coeff_idx = 0;
|
||||
for (;;) {
|
||||
if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) {
|
||||
/* parse a coeff */
|
||||
if (vp56_rac_get_prob(c, model2[2])) {
|
||||
@@ -468,8 +469,10 @@ static void vp6_parse_coeff(VP56Context *s)
|
||||
run += vp56_rac_get_prob(c, model3[i+8]) << i;
|
||||
}
|
||||
}
|
||||
|
||||
cg = vp6_coeff_groups[coeff_idx+=run];
|
||||
coeff_idx += run;
|
||||
if (coeff_idx >= 64)
|
||||
break;
|
||||
cg = vp6_coeff_groups[coeff_idx];
|
||||
model1 = model2 = model->coeff_ract[pt][ct][cg];
|
||||
}
|
||||
|
||||
|
@@ -536,12 +536,13 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
switch(id & WP_IDF_MASK){
|
||||
case WP_ID_DECTERMS:
|
||||
s->terms = size;
|
||||
if(s->terms > MAX_TERMS){
|
||||
if(size > MAX_TERMS){
|
||||
av_log(avctx, AV_LOG_ERROR, "Too many decorrelation terms\n");
|
||||
s->terms = 0;
|
||||
buf += ssize;
|
||||
continue;
|
||||
}
|
||||
s->terms = size;
|
||||
for(i = 0; i < s->terms; i++) {
|
||||
s->decorr[s->terms - i - 1].value = (*buf & 0x1F) - 5;
|
||||
s->decorr[s->terms - i - 1].delta = *buf >> 5;
|
||||
|
@@ -105,6 +105,11 @@ static int wma_decode_init(AVCodecContext * avctx)
|
||||
s->use_bit_reservoir = flags2 & 0x0002;
|
||||
s->use_variable_block_len = flags2 & 0x0004;
|
||||
|
||||
if(avctx->channels > MAX_CHANNELS){
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels (%d)\n", avctx->channels);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ff_wma_init(avctx, flags2)<0)
|
||||
return -1;
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include "libavutil/x86_cpu.h"
|
||||
#include "libavcodec/dsputil.h"
|
||||
|
||||
static const int m1m1m1m1[4] __attribute__((aligned(16))) =
|
||||
DECLARE_ASM_CONST(16, int, m1m1m1m1)[4] =
|
||||
{ 1 << 31, 1 << 31, 1 << 31, 1 << 31 };
|
||||
|
||||
void ff_fft_dispatch_sse(FFTComplex *z, int nbits);
|
||||
@@ -182,7 +182,7 @@ void ff_imdct_calc_sse(MDCTContext *s, FFTSample *output, const FFTSample *input
|
||||
j = -n;
|
||||
k = n-16;
|
||||
__asm__ volatile(
|
||||
"movaps %4, %%xmm7 \n"
|
||||
"movaps "MANGLE(m1m1m1m1)", %%xmm7 \n"
|
||||
"1: \n"
|
||||
"movaps (%2,%1), %%xmm0 \n"
|
||||
"movaps (%3,%0), %%xmm1 \n"
|
||||
@@ -195,8 +195,7 @@ void ff_imdct_calc_sse(MDCTContext *s, FFTSample *output, const FFTSample *input
|
||||
"add $16, %0 \n"
|
||||
"jl 1b \n"
|
||||
:"+r"(j), "+r"(k)
|
||||
:"r"(output+n4), "r"(output+n4*3),
|
||||
"m"(*m1m1m1m1)
|
||||
:"r"(output+n4), "r"(output+n4*3)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -335,6 +335,10 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
|
||||
url_fskip(pb, ape->wavheaderlength);
|
||||
}
|
||||
|
||||
if(!ape->totalframes){
|
||||
av_log(s, AV_LOG_ERROR, "No frames in the file!\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
|
||||
av_log(s, AV_LOG_ERROR, "Too many frames: %d\n", ape->totalframes);
|
||||
return -1;
|
||||
@@ -352,6 +356,8 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
|
||||
|
||||
if (ape->seektablelength > 0) {
|
||||
ape->seektable = av_malloc(ape->seektablelength);
|
||||
if (!ape->seektable)
|
||||
return AVERROR(ENOMEM);
|
||||
for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
|
||||
ape->seektable[i] = get_le32(pb);
|
||||
}
|
||||
|
@@ -27,6 +27,13 @@
|
||||
|
||||
#define IO_BUFFER_SIZE 32768
|
||||
|
||||
/**
|
||||
* Do seeks within this distance ahead of the current buffer by skipping
|
||||
* data instead of calling the protocol seek function, for seekable
|
||||
* protocols.
|
||||
*/
|
||||
#define SHORT_SEEK_THRESHOLD 4096
|
||||
|
||||
static void fill_buffer(ByteIOContext *s);
|
||||
|
||||
int init_put_byte(ByteIOContext *s,
|
||||
@@ -151,8 +158,9 @@ int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence)
|
||||
offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
|
||||
/* can do the seek inside the buffer */
|
||||
s->buf_ptr = s->buffer + offset1;
|
||||
} else if(s->is_streamed && !s->write_flag &&
|
||||
offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){
|
||||
} else if ((s->is_streamed ||
|
||||
offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
|
||||
!s->write_flag && offset1 >= 0) {
|
||||
while(s->pos < offset && !s->eof_reached)
|
||||
fill_buffer(s);
|
||||
if (s->eof_reached)
|
||||
|
@@ -163,10 +163,14 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||
sub_type = get_byte(s->pb);
|
||||
type = get_byte(s->pb);
|
||||
size = get_le16(s->pb);
|
||||
if (size < 4)
|
||||
return AVERROR_INVALIDDATA;
|
||||
avs->remaining_frame_size -= size;
|
||||
|
||||
switch (type) {
|
||||
case AVS_PALETTE:
|
||||
if (size - 4 > sizeof(palette))
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = get_buffer(s->pb, palette, size - 4);
|
||||
if (ret < size - 4)
|
||||
return AVERROR(EIO);
|
||||
|
@@ -752,11 +752,15 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
|
||||
uint32_t id = syntax->id;
|
||||
uint64_t length;
|
||||
int res;
|
||||
void *newelem;
|
||||
|
||||
data = (char *)data + syntax->data_offset;
|
||||
if (syntax->list_elem_size) {
|
||||
EbmlList *list = data;
|
||||
list->elem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size);
|
||||
newelem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size);
|
||||
if (!newelem)
|
||||
return AVERROR(ENOMEM);
|
||||
list->elem = newelem;
|
||||
data = (char*)list->elem + list->nb_elem*syntax->list_elem_size;
|
||||
memset(data, 0, syntax->list_elem_size);
|
||||
list->nb_elem++;
|
||||
@@ -873,6 +877,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
|
||||
uint8_t* data = *buf;
|
||||
int isize = *buf_size;
|
||||
uint8_t* pkt_data = NULL;
|
||||
uint8_t* newpktdata;
|
||||
int pkt_size = isize;
|
||||
int result = 0;
|
||||
int olen;
|
||||
@@ -899,7 +904,12 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
|
||||
zstream.avail_in = isize;
|
||||
do {
|
||||
pkt_size *= 3;
|
||||
pkt_data = av_realloc(pkt_data, pkt_size);
|
||||
newpktdata = av_realloc(pkt_data, pkt_size);
|
||||
if (!newpktdata) {
|
||||
inflateEnd(&zstream);
|
||||
goto failed;
|
||||
}
|
||||
pkt_data = newpktdata;
|
||||
zstream.avail_out = pkt_size - zstream.total_out;
|
||||
zstream.next_out = pkt_data + zstream.total_out;
|
||||
result = inflate(&zstream, Z_NO_FLUSH);
|
||||
@@ -920,7 +930,12 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
|
||||
bzstream.avail_in = isize;
|
||||
do {
|
||||
pkt_size *= 3;
|
||||
pkt_data = av_realloc(pkt_data, pkt_size);
|
||||
newpktdata = av_realloc(pkt_data, pkt_size);
|
||||
if (!newpktdata) {
|
||||
BZ2_bzDecompressEnd(&bzstream);
|
||||
goto failed;
|
||||
}
|
||||
pkt_data = newpktdata;
|
||||
bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
|
||||
bzstream.next_out = pkt_data + bzstream.total_out_lo32;
|
||||
result = BZ2_bzDecompress(&bzstream);
|
||||
@@ -975,13 +990,17 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska,
|
||||
}
|
||||
}
|
||||
|
||||
static void matroska_merge_packets(AVPacket *out, AVPacket *in)
|
||||
static int matroska_merge_packets(AVPacket *out, AVPacket *in)
|
||||
{
|
||||
out->data = av_realloc(out->data, out->size+in->size);
|
||||
void *newdata = av_realloc(out->data, out->size+in->size);
|
||||
if (!newdata)
|
||||
return AVERROR(ENOMEM);
|
||||
out->data = newdata;
|
||||
memcpy(out->data+out->size, in->data, in->size);
|
||||
out->size += in->size;
|
||||
av_destruct_packet(in);
|
||||
av_free(in);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
|
||||
@@ -1462,11 +1481,13 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
|
||||
memcpy(pkt, matroska->packets[0], sizeof(AVPacket));
|
||||
av_free(matroska->packets[0]);
|
||||
if (matroska->num_packets > 1) {
|
||||
void *newpackets;
|
||||
memmove(&matroska->packets[0], &matroska->packets[1],
|
||||
(matroska->num_packets - 1) * sizeof(AVPacket *));
|
||||
matroska->packets =
|
||||
av_realloc(matroska->packets, (matroska->num_packets - 1) *
|
||||
sizeof(AVPacket *));
|
||||
newpackets = av_realloc(matroska->packets,
|
||||
(matroska->num_packets - 1) * sizeof(AVPacket *));
|
||||
if (newpackets)
|
||||
matroska->packets = newpackets;
|
||||
} else {
|
||||
av_freep(&matroska->packets);
|
||||
}
|
||||
@@ -1620,7 +1641,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
|
||||
lace_size[n] = lace_size[n - 1] + snum;
|
||||
total += lace_size[n];
|
||||
}
|
||||
lace_size[n] = size - total;
|
||||
lace_size[laces - 1] = size - total;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -90,14 +90,24 @@ ogg_restore (AVFormatContext * s, int discard)
|
||||
ogg->state = ost->next;
|
||||
|
||||
if (!discard){
|
||||
struct ogg_stream *old_streams = ogg->streams;
|
||||
|
||||
for (i = 0; i < ogg->nstreams; i++)
|
||||
av_free (ogg->streams[i].buf);
|
||||
|
||||
url_fseek (bc, ost->pos, SEEK_SET);
|
||||
ogg->curidx = ost->curidx;
|
||||
ogg->nstreams = ost->nstreams;
|
||||
memcpy(ogg->streams, ost->streams,
|
||||
ost->nstreams * sizeof(*ogg->streams));
|
||||
ogg->streams = av_realloc (ogg->streams,
|
||||
ogg->nstreams * sizeof (*ogg->streams));
|
||||
|
||||
if (ogg->streams) {
|
||||
memcpy(ogg->streams, ost->streams,
|
||||
ost->nstreams * sizeof(*ogg->streams));
|
||||
} else {
|
||||
av_free(old_streams);
|
||||
ogg->nstreams = 0;
|
||||
}
|
||||
}
|
||||
|
||||
av_free (ost);
|
||||
|
@@ -154,8 +154,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
|
||||
ast->audio_framesize = st->codec->block_align;
|
||||
st->codec->block_align = coded_framesize;
|
||||
|
||||
if(ast->audio_framesize >= UINT_MAX / sub_packet_h){
|
||||
av_log(s, AV_LOG_ERROR, "ast->audio_framesize * sub_packet_h too large\n");
|
||||
if (ast->audio_framesize <= 0 || sub_packet_h <= 0 ||
|
||||
ast->audio_framesize >= UINT_MAX / sub_packet_h){
|
||||
av_log(s, AV_LOG_ERROR, "ast->audio_framesize * sub_packet_h is invalid\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -185,8 +186,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
|
||||
ast->audio_framesize = st->codec->block_align;
|
||||
st->codec->block_align = ast->sub_packet_size;
|
||||
|
||||
if(ast->audio_framesize >= UINT_MAX / sub_packet_h){
|
||||
av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n");
|
||||
if (ast->audio_framesize <= 0 || sub_packet_h <= 0 ||
|
||||
ast->audio_framesize >= UINT_MAX / sub_packet_h){
|
||||
av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h is invalid\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@@ -111,11 +111,16 @@ static int film_read_header(AVFormatContext *s,
|
||||
film->audio_samplerate = AV_RB16(&scratch[24]);
|
||||
film->audio_channels = scratch[21];
|
||||
film->audio_bits = scratch[22];
|
||||
if (film->audio_bits == 8)
|
||||
film->audio_type = CODEC_ID_PCM_S8;
|
||||
else if (film->audio_bits == 16)
|
||||
film->audio_type = CODEC_ID_PCM_S16BE;
|
||||
else
|
||||
if (scratch[23] == 2)
|
||||
film->audio_type = CODEC_ID_ADPCM_ADX;
|
||||
else if (film->audio_channels > 0) {
|
||||
if (film->audio_bits == 8)
|
||||
film->audio_type = CODEC_ID_PCM_S8;
|
||||
else if (film->audio_bits == 16)
|
||||
film->audio_type = CODEC_ID_PCM_S16BE;
|
||||
else
|
||||
film->audio_type = CODEC_ID_NONE;
|
||||
} else
|
||||
film->audio_type = CODEC_ID_NONE;
|
||||
}
|
||||
|
||||
@@ -167,6 +172,8 @@ static int film_read_header(AVFormatContext *s,
|
||||
if(film->sample_count >= UINT_MAX / sizeof(film_sample))
|
||||
return -1;
|
||||
film->sample_table = av_malloc(film->sample_count * sizeof(film_sample));
|
||||
if (!film->sample_table)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
for(i=0; i<s->nb_streams; i++)
|
||||
av_set_pts_info(s->streams[i], 33, 1, film->base_clock);
|
||||
@@ -187,8 +194,12 @@ static int film_read_header(AVFormatContext *s,
|
||||
film->sample_table[i].pts *= film->base_clock;
|
||||
film->sample_table[i].pts /= film->audio_samplerate;
|
||||
|
||||
audio_frame_counter += (film->sample_table[i].sample_size /
|
||||
(film->audio_channels * film->audio_bits / 8));
|
||||
if (film->audio_type == CODEC_ID_ADPCM_ADX)
|
||||
audio_frame_counter += (film->sample_table[i].sample_size * 32 /
|
||||
(18 * film->audio_channels));
|
||||
else if (film->audio_type != CODEC_ID_NONE)
|
||||
audio_frame_counter += (film->sample_table[i].sample_size /
|
||||
(film->audio_channels * film->audio_bits / 8));
|
||||
} else {
|
||||
film->sample_table[i].stream = film->video_stream_index;
|
||||
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
|
||||
@@ -238,6 +249,10 @@ static int film_read_packet(AVFormatContext *s,
|
||||
av_free(film->stereo_buffer);
|
||||
film->stereo_buffer_size = sample->sample_size;
|
||||
film->stereo_buffer = av_malloc(film->stereo_buffer_size);
|
||||
if (!film->stereo_buffer) {
|
||||
film->stereo_buffer_size = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
pkt->pos= url_ftell(pb);
|
||||
|
@@ -284,6 +284,10 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
frame_size -= 4;
|
||||
smk->curstream++;
|
||||
smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size);
|
||||
if (!smk->bufs[smk->curstream]) {
|
||||
smk->buf_sizes[smk->curstream] = 0;
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
smk->buf_sizes[smk->curstream] = size;
|
||||
ret = get_buffer(s->pb, smk->bufs[smk->curstream], size);
|
||||
if(ret != size)
|
||||
@@ -292,7 +296,9 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
flags >>= 1;
|
||||
}
|
||||
if (av_new_packet(pkt, frame_size + 768))
|
||||
if (frame_size < 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (av_new_packet(pkt, frame_size + 769))
|
||||
return AVERROR(ENOMEM);
|
||||
if(smk->frm_size[smk->cur_frame] & 1)
|
||||
palchange |= 2;
|
||||
|
@@ -279,10 +279,8 @@ static int wsvqa_read_header(AVFormatContext *s,
|
||||
/* there are 0 or more chunks before the FINF chunk; iterate until
|
||||
* FINF has been skipped and the file will be ready to be demuxed */
|
||||
do {
|
||||
if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
|
||||
av_free(st->codec->extradata);
|
||||
if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
chunk_tag = AV_RB32(&scratch[0]);
|
||||
chunk_size = AV_RB32(&scratch[4]);
|
||||
|
||||
|
@@ -256,11 +256,11 @@ if((y)<(x)){\
|
||||
}
|
||||
|
||||
#if defined(__ICC) || defined(__SUNPRO_C)
|
||||
#define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
|
||||
#elif defined(__GNUC__)
|
||||
#define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n)))
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
|
||||
|
@@ -33,7 +33,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
||||
{
|
||||
static int print_prefix=1;
|
||||
static int count;
|
||||
static char line[1024], prev[1024];
|
||||
static char prev[1024];
|
||||
char line[1024];
|
||||
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
|
||||
if(level>av_log_level)
|
||||
return;
|
||||
|
@@ -113,7 +113,9 @@ void *av_realloc(void *ptr, unsigned int size)
|
||||
//FIXME this isn't aligned correctly, though it probably isn't needed
|
||||
if(!ptr) return av_malloc(size);
|
||||
diff= ((char*)ptr)[-1];
|
||||
return (char*)realloc((char*)ptr - diff, size + diff) + diff;
|
||||
ptr= realloc((char*)ptr - diff, size + diff);
|
||||
if(ptr) ptr = (char*)ptr + diff;
|
||||
return ptr;
|
||||
#else
|
||||
return realloc(ptr, size);
|
||||
#endif
|
||||
|
@@ -960,7 +960,7 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
|
||||
#endif
|
||||
|
||||
#if ARCH_PPC
|
||||
#if HAVE_ALTIVEC || CONFIG_RUNTIME_CPUDETECT
|
||||
#if HAVE_ALTIVEC
|
||||
#define COMPILE_ALTIVEC
|
||||
#endif
|
||||
#endif //ARCH_PPC
|
||||
@@ -1649,7 +1649,7 @@ static SwsFunc getSwsFunc(int flags){
|
||||
return swScale_C;
|
||||
|
||||
#else
|
||||
#if ARCH_PPC
|
||||
#if ARCH_PPC && defined COMPILE_ALTIVEC
|
||||
if (flags & SWS_CPU_CAPS_ALTIVEC)
|
||||
return swScale_altivec;
|
||||
else
|
||||
|
@@ -1739,7 +1739,7 @@ static inline void RENAME(bgr24ToY_mmx)(uint8_t *dst, uint8_t *src, long width,
|
||||
static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *src, long width, int srcFormat)
|
||||
{
|
||||
__asm__ volatile(
|
||||
"movq 24+%4, %%mm6 \n\t"
|
||||
"movq 24(%4), %%mm6 \n\t"
|
||||
"mov %3, %%"REG_a" \n\t"
|
||||
"pxor %%mm7, %%mm7 \n\t"
|
||||
"1: \n\t"
|
||||
@@ -1750,9 +1750,9 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *
|
||||
"punpcklbw %%mm7, %%mm1 \n\t"
|
||||
"movq %%mm0, %%mm2 \n\t"
|
||||
"movq %%mm1, %%mm3 \n\t"
|
||||
"pmaddwd %4, %%mm0 \n\t"
|
||||
"pmaddwd 8+%4, %%mm1 \n\t"
|
||||
"pmaddwd 16+%4, %%mm2 \n\t"
|
||||
"pmaddwd (%4), %%mm0 \n\t"
|
||||
"pmaddwd 8(%4), %%mm1 \n\t"
|
||||
"pmaddwd 16(%4), %%mm2 \n\t"
|
||||
"pmaddwd %%mm6, %%mm3 \n\t"
|
||||
"paddd %%mm1, %%mm0 \n\t"
|
||||
"paddd %%mm3, %%mm2 \n\t"
|
||||
@@ -1764,9 +1764,9 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *
|
||||
"punpcklbw %%mm7, %%mm3 \n\t"
|
||||
"movq %%mm1, %%mm4 \n\t"
|
||||
"movq %%mm3, %%mm5 \n\t"
|
||||
"pmaddwd %4, %%mm1 \n\t"
|
||||
"pmaddwd 8+%4, %%mm3 \n\t"
|
||||
"pmaddwd 16+%4, %%mm4 \n\t"
|
||||
"pmaddwd (%4), %%mm1 \n\t"
|
||||
"pmaddwd 8(%4), %%mm3 \n\t"
|
||||
"pmaddwd 16(%4), %%mm4 \n\t"
|
||||
"pmaddwd %%mm6, %%mm5 \n\t"
|
||||
"paddd %%mm3, %%mm1 \n\t"
|
||||
"paddd %%mm5, %%mm4 \n\t"
|
||||
@@ -1789,7 +1789,7 @@ static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *
|
||||
"add $4, %%"REG_a" \n\t"
|
||||
" js 1b \n\t"
|
||||
: "+r" (src)
|
||||
: "r" (dstU+width), "r" (dstV+width), "g" (-width), "m"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24][0])
|
||||
: "r" (dstU+width), "r" (dstV+width), "g" (-width), "r"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24])
|
||||
: "%"REG_a
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user