Compare commits
166 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9eaec5b8f0 | ||
![]() |
48ef116631 | ||
![]() |
cc511b36f3 | ||
![]() |
85b22a8924 | ||
![]() |
6ec1d3b3ba | ||
![]() |
d843e7dc94 | ||
![]() |
acc665f22c | ||
![]() |
4c223fe519 | ||
![]() |
5a9588b088 | ||
![]() |
02cd93f4ad | ||
![]() |
f8a31e2113 | ||
![]() |
8ba939fcda | ||
![]() |
79674d27d9 | ||
![]() |
b061ee9a5d | ||
![]() |
baba561c0b | ||
![]() |
f6147effd2 | ||
![]() |
b990187f99 | ||
![]() |
ae6c57859c | ||
![]() |
5629c39101 | ||
![]() |
7867cbaf6c | ||
![]() |
0bf8e22cdb | ||
![]() |
7944a87ba8 | ||
![]() |
a55db1fc49 | ||
![]() |
123e925956 | ||
![]() |
96c6b3a11c | ||
![]() |
5e3cd42b6d | ||
![]() |
f73106256d | ||
![]() |
782c3ab777 | ||
![]() |
4b2e02a4c4 | ||
![]() |
79fbcd9f03 | ||
![]() |
468cc41d6d | ||
![]() |
6c9b404dba | ||
![]() |
b2ac7e585e | ||
![]() |
8bb3ba5541 | ||
![]() |
5a92aa378d | ||
![]() |
c4e8c99507 | ||
![]() |
479869c499 | ||
![]() |
ec4979e16e | ||
![]() |
056c909d9d | ||
![]() |
bde4b66063 | ||
![]() |
0fda37cff9 | ||
![]() |
2e693be7e9 | ||
![]() |
8e101086eb | ||
![]() |
f13de3c653 | ||
![]() |
1eb7872238 | ||
![]() |
15df4428d2 | ||
![]() |
ec0124203c | ||
![]() |
6b01bcebb9 | ||
![]() |
efd453d82d | ||
![]() |
7209c2b13f | ||
![]() |
7ee536e87a | ||
![]() |
665421f3b1 | ||
![]() |
3eb6983dbc | ||
![]() |
e75056bc54 | ||
![]() |
8755a7890e | ||
![]() |
d0688fdd31 | ||
![]() |
0e05292a6c | ||
![]() |
23f228a0d0 | ||
![]() |
110aff4b24 | ||
![]() |
4a1c3df592 | ||
![]() |
185abfb218 | ||
![]() |
280590e338 | ||
![]() |
9767ea7aa7 | ||
![]() |
771ceb19f2 | ||
![]() |
7739947671 | ||
![]() |
8abf1d882e | ||
![]() |
1a53095406 | ||
![]() |
60eebf5c12 | ||
![]() |
30ee6c1995 | ||
![]() |
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 |
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
|
91
Changelog
91
Changelog
@@ -2,10 +2,99 @@ Entries are sorted chronologically from oldest to youngest within each release,
|
||||
releases are sorted from youngest to oldest.
|
||||
|
||||
|
||||
version 0.5.9:
|
||||
- dpcm: ignore extra unpaired bytes in stereo streams (CVE-2011-3951)
|
||||
- h264: Add check for invalid chroma_format_idc (CVE-2012-0851)
|
||||
- adpcm: ADPCM Electronic Arts has always two channels (CVE-2012-0852)
|
||||
- kmvc: Check palsize (CVE-2011-3952)
|
||||
- qdm2: clip array indices returned by qdm2_get_vlc()
|
||||
- configure: properly check for mingw-w64 through installed headers
|
||||
- Replace every usage of -lvfw32 with what is particularly necessary for that case
|
||||
- mingw32: properly check if vfw capture is supported by the system headers
|
||||
- mingw32: merge checks for mingw-w64 and mingw32-runtime >= 3.15 into one
|
||||
- vfwcap: Include windows.h before vfw.h since the latter requires defines from the former
|
||||
- ea: check chunk_size for validity
|
||||
- eatqi: move "block" variable into context to ensure sufficient alignment for idct_put
|
||||
- tqi: Pass errors from the MB decoder
|
||||
- png: check bit depth for PAL8/Y400A pixel formats.
|
||||
|
||||
|
||||
version 0.5.8:
|
||||
|
||||
- id3v2: fix skipping extended header in id3v2.4
|
||||
- nsvdec: Several bugfixes related to CVE-2011-3940
|
||||
- dv: check stype
|
||||
- dv: Fix null pointer dereference due to ach=0
|
||||
- dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936.
|
||||
- atrac3: Fix crash in tonal component decoding, fixes CVE-2012-0853
|
||||
- mjpegbdec: Fix overflow in SOS, fixes CVE-2011-3947
|
||||
- motionpixels: Clip YUV values after applying a gradient.
|
||||
- vqavideo: return error if image size is not a multiple of block size,
|
||||
fixes CVE-2012-0947.
|
||||
|
||||
|
||||
version 0.5.7:
|
||||
- vorbis: An additional defense in the Vorbis codec. (CVE-2011-3895)
|
||||
- vorbisdec: Fix decoding bug with channel handling.
|
||||
- matroskadec: Fix a bug where a pointer was cached to an array that might
|
||||
later move due to a realloc(). (CVE-2011-3893)
|
||||
- vorbis: Avoid some out-of-bounds reads. (CVE-2011-3893)
|
||||
- vp3: fix oob read for negative tokens and memleaks on error, (CVE-2011-3892)
|
||||
- vp3: fix streams with non-zero last coefficient.
|
||||
|
||||
|
||||
version 0.5.6:
|
||||
- svq1dec: call avcodec_set_dimensions() after dimensions changed. (NGS00148, CVE-2011-4579)
|
||||
- vmd: fix segfaults on corruped streams (CVE-2011-4364)
|
||||
- commits related to CVE-2011-4353:
|
||||
- vp6: partially propagate huffman tree building errors during coeff model parsing and fix misspelling
|
||||
- Plug some memory leaks in the VP6 decoder
|
||||
- vp6: Reset the internal state when aborting key frames header parsing
|
||||
- vp6: Fix illegal read.
|
||||
- vp6: Fix illegal read.
|
||||
- Fix out of bound reads in the QDM2 decoder.
|
||||
- commits related to CVE-2011-4351:
|
||||
- Check for out of bound writes in the QDM2 decoder.
|
||||
- qdm2: check output buffer size before decoding
|
||||
- Fix qdm2 decoder packet handling to match the api
|
||||
|
||||
|
||||
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
|
||||
- PowerPC without AltiVec compilation issues
|
||||
- validate channels and samplerate in the Vorbis decoder
|
||||
|
||||
|
||||
|
122
RELEASE
122
RELEASE
@@ -109,6 +109,126 @@ FFmpeg library.
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This is a maintenance only release that addresses a small number of security
|
||||
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.
|
||||
|
||||
|
||||
|
||||
* 0.5.7 Dec 25, 2011
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This maintenance-only release addresses several security issues that
|
||||
were brought to our attention. In details, it features fixes for the
|
||||
QDM2 decoder (CVE-2011-4351), DoS in the VP5/VP6 decoders
|
||||
(CVE-2011-4353), and a buffer overflow in the Sierra VMD decoder
|
||||
CVE-2011-4364, and a safety fix in the SVQ1 decoder (CVE-2011-4579).
|
||||
CVE-2011-4352, a bug in the VP3 decoder, is not known to affect this
|
||||
release.
|
||||
|
||||
Distributors and system integrators are encouraged to update and share
|
||||
their patches against this branch.
|
||||
|
||||
|
||||
|
||||
* 0.5.8 Jan 12, 2012
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This mostly maintenance-only release that addresses a number a number of
|
||||
bugs such as security and compilation issues that have been brought to
|
||||
our attention. Among other (rather minor) fixes, this release features
|
||||
fixes for the VP3 decoder (CVE-2011-3892), vorbis decoder, and matroska
|
||||
demuxer (CVE-2011-3893 and CVE-2011-3895).
|
||||
|
||||
Distributors and system integrators are encouraged
|
||||
to update and share their patches against this branch. For a full list
|
||||
of changes please see the Changelog file.
|
||||
|
||||
|
||||
|
||||
* 0.5.9 May 11, 2012
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This maintenance-only release that addresses a number a number of
|
||||
security issues that have been brought to our attention. Among other
|
||||
(rather minor) fixes, this release features fixes for the DV decoder
|
||||
(CVE-2011-3929 and CVE-2011-3936), nsvdec (CVE-2011-3940), Atrac3
|
||||
(CVE-2012-0853), mjpegdec (CVE-2011-3947) and the VQA video decoder
|
||||
(CVE-2012-0947).
|
||||
|
||||
Distributors and system integrators are encouraged
|
||||
to update and share their patches against this branch. For a full list
|
||||
of changes please see the Changelog file.
|
||||
|
||||
|
||||
|
||||
* 0.5.10 Jun 09, 2012
|
||||
|
||||
General notes
|
||||
-------------
|
||||
|
||||
This mostly maintenance-only release addresses a number a number of bugs
|
||||
such as security and compilation issues that have been brought to our
|
||||
attention. Among other fixes, this release features includes security
|
||||
updates for the DPCM codecs (CVE-2011-3951), H.264 (CVE-2012-0851),
|
||||
ADPCM (CVE-2012-0852), and the KMVC decoder (CVE-2011-3952).
|
||||
|
||||
Distributors and system integrators are encouraged
|
||||
to update and share their patches against this branch. For a full list
|
||||
of changes please see the Changelog file or the git commit history.
|
||||
|
@@ -50,7 +50,7 @@ AVCodecContext *avctx_opts[CODEC_TYPE_NB];
|
||||
AVFormatContext *avformat_opts;
|
||||
struct SwsContext *sws_opts;
|
||||
|
||||
const int this_year = 2009;
|
||||
const int this_year = 2012;
|
||||
|
||||
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
|
||||
{
|
||||
|
60
configure
vendored
60
configure
vendored
@@ -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
|
||||
}
|
||||
|
||||
@@ -1132,8 +1131,8 @@ rtsp_demuxer_deps="sdp_demuxer"
|
||||
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
|
||||
v4l_demuxer_deps="linux_videodev_h"
|
||||
v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
|
||||
vfwcap_demuxer_deps="capCreateCaptureWindow"
|
||||
vfwcap_demuxer_extralibs="-lvfw32"
|
||||
vfwcap_demuxer_deps="capCreateCaptureWindow vfwcap_defines"
|
||||
vfwcap_demuxer_extralibs="-lavicap32"
|
||||
x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
|
||||
x11_grab_device_demuxer_extralibs="-lX11 -lXext"
|
||||
|
||||
@@ -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
|
||||
@@ -1590,13 +1611,9 @@ case $target_os in
|
||||
objformat="win32"
|
||||
enable dos_paths
|
||||
check_cflags -fno-common
|
||||
if ! enabled x86_64; then
|
||||
check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
|
||||
check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
|
||||
|| (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
|
||||
die "ERROR: MinGW runtime version must be >= 3.15."
|
||||
enabled_any avisynth vfwcap_demuxer &&
|
||||
{ check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
|
||||
die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
|
||||
fi
|
||||
;;
|
||||
cygwin*)
|
||||
target_os=cygwin
|
||||
@@ -2001,7 +2018,7 @@ EOF
|
||||
done
|
||||
|
||||
# these are off by default, so fail if requested and not available
|
||||
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
|
||||
enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
|
||||
enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
|
||||
enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
|
||||
enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
|
||||
@@ -2128,7 +2145,10 @@ check_header linux/videodev.h
|
||||
check_header linux/videodev2.h
|
||||
check_header sys/videoio.h
|
||||
|
||||
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
|
||||
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lavicap32
|
||||
# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
|
||||
# w32api 3.12 had it defined wrong
|
||||
check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
|
||||
|
||||
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
|
||||
{ check_header dev/bktr/ioctl_meteor.h &&
|
||||
@@ -2522,8 +2542,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");
|
||||
|
@@ -667,17 +667,23 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
|
||||
static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
ADPCMContext *c = avctx->priv_data;
|
||||
unsigned int min_channels = 1;
|
||||
unsigned int max_channels = 2;
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
case CODEC_ID_ADPCM_EA:
|
||||
min_channels = 2;
|
||||
break;
|
||||
case CODEC_ID_ADPCM_EA_R1:
|
||||
case CODEC_ID_ADPCM_EA_R2:
|
||||
case CODEC_ID_ADPCM_EA_R3:
|
||||
max_channels = 6;
|
||||
break;
|
||||
}
|
||||
if(avctx->channels > max_channels){
|
||||
return -1;
|
||||
|
||||
if (avctx->channels < min_channels || avctx->channels > max_channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
|
@@ -454,6 +454,8 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
|
||||
|
||||
for (k=0; k<coded_components; k++) {
|
||||
sfIndx = get_bits(gb,6);
|
||||
if(component_count>=64)
|
||||
return AVERROR_INVALIDDATA;
|
||||
pComponent[component_count].pos = j * 64 + (get_bits(gb,6));
|
||||
max_coded_values = 1024 - pComponent[component_count].pos;
|
||||
coded_values = coded_values_per_component + 1;
|
||||
|
@@ -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] ];
|
||||
|
@@ -167,6 +167,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
int in, out = 0;
|
||||
int predictor[2];
|
||||
int channel_number = 0;
|
||||
int stereo = s->channels - 1;
|
||||
short *output_samples = data;
|
||||
int shift[2];
|
||||
unsigned char byte;
|
||||
@@ -175,6 +176,9 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
if (!buf_size)
|
||||
return 0;
|
||||
|
||||
if (stereo && (buf_size & 1))
|
||||
buf_size--;
|
||||
|
||||
// almost every DPCM variant expands one byte of data into two
|
||||
if(*data_size/2 < buf_size)
|
||||
return -1;
|
||||
|
@@ -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);
|
||||
|
@@ -40,6 +40,7 @@ typedef struct TqiContext {
|
||||
AVFrame frame;
|
||||
uint8_t *bitstream_buf;
|
||||
unsigned int bitstream_buf_size;
|
||||
DECLARE_ALIGNED_16(DCTELEM, block[6][64]);
|
||||
} TqiContext;
|
||||
|
||||
static av_cold int tqi_decode_init(AVCodecContext *avctx)
|
||||
@@ -58,12 +59,15 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64])
|
||||
static int tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64])
|
||||
{
|
||||
int n;
|
||||
s->dsp.clear_blocks(block[0]);
|
||||
for (n=0; n<6; n++)
|
||||
ff_mpeg1_decode_block_intra(s, block[n], n);
|
||||
if (ff_mpeg1_decode_block_intra(s, block[n], n) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void tqi_idct_put(TqiContext *t, DCTELEM (*block)[64])
|
||||
@@ -106,7 +110,6 @@ static int tqi_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf_end = buf+buf_size;
|
||||
TqiContext *t = avctx->priv_data;
|
||||
MpegEncContext *s = &t->s;
|
||||
DECLARE_ALIGNED_16(DCTELEM, block[6][64]);
|
||||
|
||||
s->width = AV_RL16(&buf[0]);
|
||||
s->height = AV_RL16(&buf[2]);
|
||||
@@ -134,8 +137,9 @@ static int tqi_decode_frame(AVCodecContext *avctx,
|
||||
for (s->mb_y=0; s->mb_y<(avctx->height+15)/16; s->mb_y++)
|
||||
for (s->mb_x=0; s->mb_x<(avctx->width+15)/16; s->mb_x++)
|
||||
{
|
||||
tqi_decode_mb(s, block);
|
||||
tqi_idct_put(t, block);
|
||||
if (tqi_decode_mb(s, t->block) < 0)
|
||||
break;
|
||||
tqi_idct_put(t, t->block);
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
|
@@ -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;
|
||||
|
@@ -285,6 +285,10 @@ static int h261_decode_mb(H261Context *h){
|
||||
|
||||
// Read mtype
|
||||
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
|
||||
if (h->mtype < 0) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "illegal mtype %d\n", h->mtype);
|
||||
return SLICE_ERROR;
|
||||
}
|
||||
h->mtype = h261_mtype_map[h->mtype];
|
||||
|
||||
// Read mquant
|
||||
|
@@ -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];
|
||||
@@ -7131,8 +7134,12 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
|
||||
|
||||
if(sps->profile_idc >= 100){ //high profile
|
||||
sps->chroma_format_idc= get_ue_golomb_31(&s->gb);
|
||||
if(sps->chroma_format_idc == 3)
|
||||
if(sps->chroma_format_idc > 3) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc (%u) out of range\n", sps->chroma_format_idc);
|
||||
return -1;
|
||||
} else if(sps->chroma_format_idc == 3) {
|
||||
sps->residual_color_transform_flag = get_bits1(&s->gb);
|
||||
}
|
||||
sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8;
|
||||
sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8;
|
||||
sps->transform_bypass = get_bits1(&s->gb);
|
||||
@@ -7165,7 +7172,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,
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#define KMVC_KEYFRAME 0x80
|
||||
#define KMVC_PALETTE 0x40
|
||||
#define KMVC_METHOD 0x0F
|
||||
#define MAX_PALSIZE 256
|
||||
|
||||
/*
|
||||
* Decoder context
|
||||
@@ -43,7 +44,7 @@ typedef struct KmvcContext {
|
||||
|
||||
int setpal;
|
||||
int palsize;
|
||||
uint32_t pal[256];
|
||||
uint32_t pal[MAX_PALSIZE];
|
||||
uint8_t *cur, *prev;
|
||||
uint8_t *frm0, *frm1;
|
||||
} KmvcContext;
|
||||
@@ -366,6 +367,10 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
c->palsize = 127;
|
||||
} else {
|
||||
c->palsize = AV_RL16(avctx->extradata + 10);
|
||||
if (c->palsize >= MAX_PALSIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->extradata_size == 1036) { // palette in extradata
|
||||
|
@@ -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);
|
||||
|
@@ -49,6 +49,9 @@ read_header:
|
||||
s->restart_count = 0;
|
||||
s->mjpb_skiptosod = 0;
|
||||
|
||||
if (buf_end - buf_ptr >= 1 << 28)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
|
||||
|
||||
skip_bits(&hgb, 32); /* reserved zeros */
|
||||
@@ -99,8 +102,8 @@ read_header:
|
||||
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
|
||||
if (sos_offs)
|
||||
{
|
||||
// init_get_bits(&s->gb, buf+sos_offs, (buf_end - (buf+sos_offs))*8);
|
||||
init_get_bits(&s->gb, buf_ptr+sos_offs, field_size*8);
|
||||
init_get_bits(&s->gb, buf_ptr + sos_offs,
|
||||
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
|
||||
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
|
||||
s->start_code = SOS;
|
||||
ff_mjpeg_decode_sos(s);
|
||||
|
@@ -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;
|
||||
|
@@ -239,10 +239,13 @@ static void mp_decode_line(MotionPixelsContext *mp, GetBitContext *gb, int y)
|
||||
p = mp_get_yuv_from_rgb(mp, x - 1, y);
|
||||
} else {
|
||||
p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb));
|
||||
p.y = av_clip(p.y, 0, 31);
|
||||
if ((x & 3) == 0) {
|
||||
if ((y & 3) == 0) {
|
||||
p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb));
|
||||
p.v = av_clip(p.v, -32, 31);
|
||||
p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb));
|
||||
p.u = av_clip(p.u, -32, 31);
|
||||
mp->hpt[((y / 4) * mp->avctx->width + x) / 4] = p;
|
||||
} else {
|
||||
p.v = mp->hpt[((y / 4) * mp->avctx->width + x) / 4].v;
|
||||
@@ -266,9 +269,12 @@ static void mp_decode_frame_helper(MotionPixelsContext *mp, GetBitContext *gb)
|
||||
p = mp_get_yuv_from_rgb(mp, 0, y);
|
||||
} else {
|
||||
p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb));
|
||||
p.y = av_clip(p.y, 0, 31);
|
||||
if ((y & 3) == 0) {
|
||||
p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb));
|
||||
p.v = av_clip(p.v, -32, 31);
|
||||
p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb));
|
||||
p.u = av_clip(p.u, -32, 31);
|
||||
}
|
||||
mp->vpt[y] = p;
|
||||
mp_set_rgb_from_yuv(mp, 0, y, &p);
|
||||
@@ -325,7 +331,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);
|
||||
|
@@ -473,7 +473,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
} else if (s->bit_depth == 1 &&
|
||||
s->color_type == PNG_COLOR_TYPE_GRAY) {
|
||||
avctx->pix_fmt = PIX_FMT_MONOBLACK;
|
||||
} else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
} else if (s->bit_depth == 8 &&
|
||||
s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
} else {
|
||||
goto fail;
|
||||
|
@@ -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]);
|
||||
@@ -904,9 +905,13 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l
|
||||
break;
|
||||
|
||||
case 30:
|
||||
if (BITS_LEFT(length,gb) >= 4)
|
||||
samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)];
|
||||
else
|
||||
if (BITS_LEFT(length,gb) >= 4) {
|
||||
unsigned index = qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1);
|
||||
if (index < FF_ARRAY_ELEMS(type30_dequant)) {
|
||||
samples[0] = type30_dequant[index];
|
||||
} else
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
} else
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
|
||||
run = 1;
|
||||
@@ -920,8 +925,12 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l
|
||||
type34_predictor = samples[0];
|
||||
type34_first = 0;
|
||||
} else {
|
||||
samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor;
|
||||
type34_predictor = samples[0];
|
||||
unsigned index = qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1);
|
||||
if (index < FF_ARRAY_ELEMS(type34_delta)) {
|
||||
samples[0] = type34_delta[index] / type34_div + type34_predictor;
|
||||
type34_predictor = samples[0];
|
||||
} else
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
}
|
||||
} else {
|
||||
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
|
||||
@@ -1351,7 +1360,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;
|
||||
@@ -1377,6 +1386,8 @@ static void qdm2_fft_decode_tones (QDM2Context *q, int duration, GetBitContext *
|
||||
return;
|
||||
|
||||
local_int_14 = (offset >> local_int_8);
|
||||
if (local_int_14 >= FF_ARRAY_ELEMS(fft_level_index_table))
|
||||
return;
|
||||
|
||||
if (q->nb_channels > 1) {
|
||||
channel = get_bits1(gb);
|
||||
@@ -1821,6 +1832,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 +1857,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));
|
||||
|
||||
@@ -1906,11 +1922,14 @@ static av_cold int qdm2_decode_close(AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
|
||||
static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
|
||||
static int 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;
|
||||
@@ -1942,7 +1961,7 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
|
||||
|
||||
if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {
|
||||
SAMPLES_NEEDED_2("has errors, and C list is not empty")
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1963,6 +1982,8 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
|
||||
|
||||
out[i] = value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1971,25 +1992,33 @@ static int qdm2_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf, int buf_size)
|
||||
{
|
||||
QDM2Context *s = avctx->priv_data;
|
||||
int16_t *out = data;
|
||||
int i, out_size;
|
||||
|
||||
if(!buf)
|
||||
return 0;
|
||||
if(buf_size < s->checksum_size)
|
||||
return -1;
|
||||
|
||||
*data_size = s->channels * s->frame_size * sizeof(int16_t);
|
||||
out_size = 16 * s->channels * s->frame_size *
|
||||
av_get_bits_per_sample_format(avctx->sample_fmt)/8;
|
||||
if (*data_size < out_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n",
|
||||
buf_size, buf, s->checksum_size, data, *data_size);
|
||||
|
||||
qdm2_decode(s, buf, data);
|
||||
|
||||
// reading only when next superblock found
|
||||
if (s->sub_packet == 0) {
|
||||
return s->checksum_size;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (qdm2_decode(s, buf, out) < 0)
|
||||
return -1;
|
||||
out += s->channels * s->frame_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
*data_size = out_size;
|
||||
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
AVCodec qdm2_decoder =
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -519,6 +519,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
}
|
||||
|
||||
#define APPLY_C_PREDICTOR() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->c_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
@@ -536,6 +540,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
index++;
|
||||
|
||||
#define APPLY_C_PREDICTOR_24() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->c_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
@@ -554,6 +562,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
|
||||
|
||||
#define APPLY_Y_PREDICTOR() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->y_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 1) { \
|
||||
@@ -571,6 +583,10 @@ hres,vres,i,i%vres (0 < i < 4)
|
||||
index++;
|
||||
|
||||
#define APPLY_Y_PREDICTOR_24() \
|
||||
if(index > 1023){\
|
||||
av_log(s->avctx, AV_LOG_ERROR, " index %d went out of bounds\n", index); \
|
||||
return; \
|
||||
}\
|
||||
predictor_pair = s->y_predictor_table[index]; \
|
||||
horiz_pred += (predictor_pair >> 1); \
|
||||
if (predictor_pair & 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 {
|
||||
|
@@ -73,9 +73,11 @@ typedef struct VmdVideoContext {
|
||||
#define QUEUE_SIZE 0x1000
|
||||
#define QUEUE_MASK 0x0FFF
|
||||
|
||||
static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_len)
|
||||
static void lz_unpack(const unsigned char *src, int src_len,
|
||||
unsigned char *dest, int dest_len)
|
||||
{
|
||||
const unsigned char *s;
|
||||
unsigned int s_len;
|
||||
unsigned char *d;
|
||||
unsigned char *d_end;
|
||||
unsigned char queue[QUEUE_SIZE];
|
||||
@@ -88,13 +90,16 @@ static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_le
|
||||
unsigned int i, j;
|
||||
|
||||
s = src;
|
||||
s_len = src_len;
|
||||
d = dest;
|
||||
d_end = d + dest_len;
|
||||
dataleft = AV_RL32(s);
|
||||
s += 4;
|
||||
s += 4; s_len -= 4;
|
||||
memset(queue, 0x20, QUEUE_SIZE);
|
||||
if (s_len < 4)
|
||||
return;
|
||||
if (AV_RL32(s) == 0x56781234) {
|
||||
s += 4;
|
||||
s += 4; s_len -= 4;
|
||||
qpos = 0x111;
|
||||
speclen = 0xF + 3;
|
||||
} else {
|
||||
@@ -102,32 +107,41 @@ static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_le
|
||||
speclen = 100; /* no speclen */
|
||||
}
|
||||
|
||||
while (dataleft > 0) {
|
||||
tag = *s++;
|
||||
while (dataleft > 0 && s_len > 0) {
|
||||
tag = *s++; s_len--;
|
||||
if ((tag == 0xFF) && (dataleft > 8)) {
|
||||
if (d + 8 > d_end)
|
||||
if (d + 8 > d_end || s_len < 8)
|
||||
return;
|
||||
for (i = 0; i < 8; i++) {
|
||||
queue[qpos++] = *d++ = *s++;
|
||||
qpos &= QUEUE_MASK;
|
||||
}
|
||||
s_len -= 8;
|
||||
dataleft -= 8;
|
||||
} else {
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (dataleft == 0)
|
||||
break;
|
||||
if (tag & 0x01) {
|
||||
if (d + 1 > d_end)
|
||||
if (d + 1 > d_end || s_len < 1)
|
||||
return;
|
||||
queue[qpos++] = *d++ = *s++;
|
||||
qpos &= QUEUE_MASK;
|
||||
dataleft--;
|
||||
s_len--;
|
||||
} else {
|
||||
if (s_len < 2)
|
||||
return;
|
||||
chainofs = *s++;
|
||||
chainofs |= ((*s & 0xF0) << 4);
|
||||
chainlen = (*s++ & 0x0F) + 3;
|
||||
if (chainlen == speclen)
|
||||
s_len -= 2;
|
||||
if (chainlen == speclen) {
|
||||
if (s_len < 1)
|
||||
return;
|
||||
chainlen = *s++ + 0xF + 3;
|
||||
s_len--;
|
||||
}
|
||||
if (d + chainlen > d_end)
|
||||
return;
|
||||
for (j = 0; j < chainlen; j++) {
|
||||
@@ -144,7 +158,7 @@ static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_le
|
||||
}
|
||||
|
||||
static int rle_unpack(const unsigned char *src, unsigned char *dest,
|
||||
int src_len, int dest_len)
|
||||
int src_count, int src_size, int dest_len)
|
||||
{
|
||||
const unsigned char *ps;
|
||||
unsigned char *pd;
|
||||
@@ -153,31 +167,40 @@ static int rle_unpack(const unsigned char *src, unsigned char *dest,
|
||||
|
||||
ps = src;
|
||||
pd = dest;
|
||||
if (src_len & 1)
|
||||
if (src_count & 1) {
|
||||
if (src_size < 1)
|
||||
return 0;
|
||||
*pd++ = *ps++;
|
||||
src_size--;
|
||||
}
|
||||
|
||||
src_len >>= 1;
|
||||
src_count >>= 1;
|
||||
i = 0;
|
||||
do {
|
||||
if (src_size < 1)
|
||||
break;
|
||||
l = *ps++;
|
||||
src_size--;
|
||||
if (l & 0x80) {
|
||||
l = (l & 0x7F) * 2;
|
||||
if (pd + l > dest_end)
|
||||
if (pd + l > dest_end || src_size < l)
|
||||
return ps - src;
|
||||
memcpy(pd, ps, l);
|
||||
ps += l;
|
||||
src_size -= l;
|
||||
pd += l;
|
||||
} else {
|
||||
if (pd + i > dest_end)
|
||||
if (pd + i > dest_end || src_size < 2)
|
||||
return ps - src;
|
||||
for (i = 0; i < l; i++) {
|
||||
*pd++ = ps[0];
|
||||
*pd++ = ps[1];
|
||||
}
|
||||
ps += 2;
|
||||
src_size -= 2;
|
||||
}
|
||||
i += l;
|
||||
} while (i < src_len);
|
||||
} while (i < src_count);
|
||||
|
||||
return ps - src;
|
||||
}
|
||||
@@ -192,6 +215,7 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
const unsigned char *p = s->buf + 16;
|
||||
|
||||
const unsigned char *pb;
|
||||
unsigned int pb_size;
|
||||
unsigned char meth;
|
||||
unsigned char *dp; /* pointer to current frame */
|
||||
unsigned char *pp; /* pointer to previous frame */
|
||||
@@ -206,6 +230,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)) {
|
||||
@@ -218,8 +252,9 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
|
||||
/* if only a certain region will be updated, copy the entire previous
|
||||
* frame before the decode */
|
||||
if (frame_x || frame_y || (frame_width != s->avctx->width) ||
|
||||
(frame_height != s->avctx->height)) {
|
||||
if (s->prev_frame.data[0] &&
|
||||
(frame_x || frame_y || (frame_width != s->avctx->width) ||
|
||||
(frame_height != s->avctx->height))) {
|
||||
|
||||
memcpy(s->frame.data[0], s->prev_frame.data[0],
|
||||
s->avctx->height * s->frame.linesize[0]);
|
||||
@@ -237,14 +272,19 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
}
|
||||
s->size -= (256 * 3 + 2);
|
||||
}
|
||||
if (s->size >= 0) {
|
||||
if (s->size > 0) {
|
||||
/* originally UnpackFrame in VAG's code */
|
||||
pb = p;
|
||||
meth = *pb++;
|
||||
pb_size = s->buf + s->size - pb;
|
||||
if (pb_size < 1)
|
||||
return;
|
||||
meth = *pb++; pb_size--;
|
||||
if (meth & 0x80) {
|
||||
lz_unpack(pb, s->unpack_buffer, s->unpack_buffer_size);
|
||||
lz_unpack(pb, pb_size,
|
||||
s->unpack_buffer, s->unpack_buffer_size);
|
||||
meth &= 0x7F;
|
||||
pb = s->unpack_buffer;
|
||||
pb_size = s->unpack_buffer_size;
|
||||
}
|
||||
|
||||
dp = &s->frame.data[0][frame_y * s->frame.linesize[0] + frame_x];
|
||||
@@ -255,17 +295,21 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
for (i = 0; i < frame_height; i++) {
|
||||
ofs = 0;
|
||||
do {
|
||||
if (pb_size < 1)
|
||||
return;
|
||||
len = *pb++;
|
||||
pb_size--;
|
||||
if (len & 0x80) {
|
||||
len = (len & 0x7F) + 1;
|
||||
if (ofs + len > frame_width)
|
||||
if (ofs + len > frame_width || pb_size < len)
|
||||
return;
|
||||
memcpy(&dp[ofs], pb, len);
|
||||
pb += len;
|
||||
pb_size -= len;
|
||||
ofs += len;
|
||||
} else {
|
||||
/* interframe pixel copy */
|
||||
if (ofs + len + 1 > frame_width)
|
||||
if (ofs + len + 1 > frame_width || !s->prev_frame.data[0])
|
||||
return;
|
||||
memcpy(&dp[ofs], &pp[ofs], len + 1);
|
||||
ofs += len + 1;
|
||||
@@ -283,8 +327,11 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
|
||||
case 2:
|
||||
for (i = 0; i < frame_height; i++) {
|
||||
if (pb_size < frame_width)
|
||||
return;
|
||||
memcpy(dp, pb, frame_width);
|
||||
pb += frame_width;
|
||||
pb_size -= frame_width;
|
||||
dp += s->frame.linesize[0];
|
||||
pp += s->prev_frame.linesize[0];
|
||||
}
|
||||
@@ -294,18 +341,27 @@ static void vmd_decode(VmdVideoContext *s)
|
||||
for (i = 0; i < frame_height; i++) {
|
||||
ofs = 0;
|
||||
do {
|
||||
if (pb_size < 1)
|
||||
return;
|
||||
len = *pb++;
|
||||
pb_size--;
|
||||
if (len & 0x80) {
|
||||
len = (len & 0x7F) + 1;
|
||||
if (pb_size < 1)
|
||||
return;
|
||||
if (*pb++ == 0xFF)
|
||||
len = rle_unpack(pb, &dp[ofs], len, frame_width - ofs);
|
||||
else
|
||||
len = rle_unpack(pb, &dp[ofs], len, pb_size, frame_width - ofs);
|
||||
else {
|
||||
if (pb_size < len)
|
||||
return;
|
||||
memcpy(&dp[ofs], pb, len);
|
||||
}
|
||||
pb += len;
|
||||
pb_size -= 1 + len;
|
||||
ofs += len;
|
||||
} else {
|
||||
/* interframe pixel copy */
|
||||
if (ofs + len + 1 > frame_width)
|
||||
if (ofs + len + 1 > frame_width || !s->prev_frame.data[0])
|
||||
return;
|
||||
memcpy(&dp[ofs], &pp[ofs], len + 1);
|
||||
ofs += len + 1;
|
||||
|
@@ -146,13 +146,13 @@ void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values) {
|
||||
}
|
||||
}
|
||||
|
||||
static void render_line(int x0, int y0, int x1, int y1, float * buf) {
|
||||
static void render_line(int x0, uint8_t y0, int x1, int y1, float * buf) {
|
||||
int dy = y1 - y0;
|
||||
int adx = x1 - x0;
|
||||
int base = dy / adx;
|
||||
int ady = FFABS(dy) - FFABS(base) * adx;
|
||||
int x = x0;
|
||||
int y = y0;
|
||||
uint8_t y = y0;
|
||||
int err = 0;
|
||||
int sy = dy<0 ? -1 : 1;
|
||||
buf[x] = ff_vorbis_floor1_inverse_db_table[y];
|
||||
@@ -168,7 +168,8 @@ static void render_line(int x0, int y0, int x1, int y1, float * buf) {
|
||||
}
|
||||
|
||||
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint_fast16_t * y_list, int * flag, int multiplier, float * out, int samples) {
|
||||
int lx, ly, i;
|
||||
int lx, i;
|
||||
uint8_t ly;
|
||||
lx = 0;
|
||||
ly = y_list[0] * multiplier;
|
||||
for (i = 1; i < values; i++) {
|
||||
|
@@ -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) {
|
||||
@@ -646,7 +654,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){
|
||||
res_setup->partition_size=get_bits(gb, 24)+1;
|
||||
/* Validations to prevent a buffer overflow later. */
|
||||
if (res_setup->begin>res_setup->end
|
||||
|| res_setup->end>vc->blocksize[1]/(res_setup->type==2?1:2)
|
||||
|| res_setup->end > (res_setup->type == 2 ? vc->avccontext->channels : 1) * vc->blocksize[1] / 2
|
||||
|| (res_setup->end-res_setup->begin)/res_setup->partition_size>V_MAX_PARTITIONS) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %d, %d, %d, %d, %d\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1]/2);
|
||||
return 1;
|
||||
@@ -1038,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;
|
||||
@@ -1062,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;
|
||||
@@ -1151,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 };
|
||||
@@ -1282,7 +1293,7 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, vorbis_floor_data *
|
||||
|
||||
// Read and decode residue
|
||||
|
||||
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, int vr_type) {
|
||||
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, unsigned ch_left, int vr_type) {
|
||||
GetBitContext *gb=&vc->gb;
|
||||
uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions;
|
||||
uint_fast16_t n_to_read=vr->end-vr->begin;
|
||||
@@ -1292,6 +1303,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, v
|
||||
uint_fast8_t ch_used;
|
||||
uint_fast8_t i,j,l;
|
||||
uint_fast16_t k;
|
||||
unsigned max_output = (ch - 1) * vlen;
|
||||
|
||||
if (vr_type==2) {
|
||||
for(j=1;j<ch;++j) {
|
||||
@@ -1299,8 +1311,15 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, v
|
||||
}
|
||||
if (do_not_decode[0]) return 0;
|
||||
ch_used=1;
|
||||
max_output += vr->end / ch;
|
||||
} else {
|
||||
ch_used=ch;
|
||||
max_output += vr->end;
|
||||
}
|
||||
|
||||
if (max_output > ch_left * vlen) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Insufficient output buffer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
|
||||
@@ -1424,14 +1443,14 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, v
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen)
|
||||
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen, unsigned ch_left)
|
||||
{
|
||||
if (vr->type==2)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 2);
|
||||
else if (vr->type==1)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 1);
|
||||
else if (vr->type==0)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, 0);
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 2);
|
||||
else if (vr->type == 1)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 1);
|
||||
else if (vr->type == 0)
|
||||
return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 0);
|
||||
else {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
|
||||
return 1;
|
||||
@@ -1494,6 +1513,8 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
uint_fast8_t res_num=0;
|
||||
int_fast16_t retlen=0;
|
||||
float fadd_bias = vc->add_bias;
|
||||
unsigned ch_left = vc->audio_channels;
|
||||
unsigned vlen;
|
||||
|
||||
if (get_bits1(gb)) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
|
||||
@@ -1516,25 +1537,33 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
|
||||
blockflag=vc->modes[mode_number].blockflag;
|
||||
blocksize=vc->blocksize[blockflag];
|
||||
vlen = blocksize / 2;
|
||||
if (blockflag) {
|
||||
skip_bits(gb, 2); // previous_window, next_window
|
||||
}
|
||||
|
||||
memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
|
||||
memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*blocksize/2); //FIXME can this be removed ?
|
||||
memset(ch_res_ptr, 0, sizeof(float)*vc->audio_channels*vlen); //FIXME can this be removed ?
|
||||
memset(ch_floor_ptr, 0, sizeof(float)*vc->audio_channels*vlen); //FIXME can this be removed ?
|
||||
|
||||
// Decode floor
|
||||
|
||||
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 += vlen;
|
||||
}
|
||||
|
||||
// Nonzero vector propagate
|
||||
@@ -1551,6 +1580,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
for(i=0;i<mapping->submaps;++i) {
|
||||
vorbis_residue *residue;
|
||||
uint_fast8_t ch=0;
|
||||
int ret;
|
||||
|
||||
for(j=0;j<vc->audio_channels;++j) {
|
||||
if ((mapping->submaps==1) || (i==mapping->mux[j])) {
|
||||
@@ -1565,9 +1595,18 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) {
|
||||
}
|
||||
}
|
||||
residue=&vc->residues[mapping->submap_residue[i]];
|
||||
vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2);
|
||||
if (ch_left < ch) {
|
||||
av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
|
||||
return -1;
|
||||
}
|
||||
if (ch) {
|
||||
ret = vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, vlen, ch_left);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ch_res_ptr+=ch*blocksize/2;
|
||||
ch_res_ptr += ch * vlen;
|
||||
ch_left -= ch;
|
||||
}
|
||||
|
||||
// Inverse coupling
|
||||
|
@@ -1011,12 +1011,12 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
/* decode a VLC into a token */
|
||||
token = get_vlc2(gb, table->table, 5, 3);
|
||||
/* use the token to get a zero run, a coefficient, and an eob run */
|
||||
if (token <= 6) {
|
||||
if ((unsigned) token <= 6U) {
|
||||
eob_run = eob_run_base[token];
|
||||
if (eob_run_get_bits[token])
|
||||
eob_run += get_bits(gb, eob_run_get_bits[token]);
|
||||
coeff = zero_run = 0;
|
||||
} else {
|
||||
} else if (token >= 0) {
|
||||
bits_to_get = coeff_get_bits[token];
|
||||
if (!bits_to_get)
|
||||
coeff = coeff_tables[token][0];
|
||||
@@ -1026,6 +1026,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
|
||||
zero_run = zero_run_base[token];
|
||||
if (zero_run_get_bits[token])
|
||||
zero_run += get_bits(gb, zero_run_get_bits[token]);
|
||||
} else {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Invalid token %d\n", token);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,6 +1075,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
||||
/* unpack the C plane DC coefficients */
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
/* fetch the AC table indexes */
|
||||
ac_y_table = get_bits(gb, 4);
|
||||
@@ -1080,36 +1086,52 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
|
||||
for (i = 1; i <= 5; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
/* unpack the group 2 AC coefficients (coeffs 6-14) */
|
||||
for (i = 6; i <= 14; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
/* unpack the group 3 AC coefficients (coeffs 15-27) */
|
||||
for (i = 15; i <= 27; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
/* unpack the group 4 AC coefficients (coeffs 28-63) */
|
||||
for (i = 28; i <= 63; i++) {
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_y_table], i,
|
||||
s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
|
||||
residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_c_table], i,
|
||||
s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
|
||||
if (residual_eob_run < 0)
|
||||
return residual_eob_run;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -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) {
|
||||
@@ -685,6 +695,7 @@ av_cold void vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
|
||||
av_cold int vp56_free(AVCodecContext *avctx)
|
||||
{
|
||||
VP56Context *s = avctx->priv_data;
|
||||
int pt;
|
||||
|
||||
av_free(s->above_blocks);
|
||||
av_free(s->macroblocks);
|
||||
@@ -695,5 +706,15 @@ av_cold int vp56_free(AVCodecContext *avctx)
|
||||
avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN2]);
|
||||
if (s->framep[VP56_FRAME_PREVIOUS]->data[0])
|
||||
avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);
|
||||
|
||||
for (pt=0; pt < 2; pt++) {
|
||||
int ct, cg;
|
||||
free_vlc(&s->dccv_vlc[pt]);
|
||||
free_vlc(&s->runv_vlc[pt]);
|
||||
for (ct=0; ct<3; ct++)
|
||||
for (cg = 0; cg < 6; cg++)
|
||||
free_vlc(&s->ract_vlc[pt][ct][cg]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -136,8 +136,11 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
|
||||
if (coeff_offset) {
|
||||
buf += coeff_offset;
|
||||
buf_size -= coeff_offset;
|
||||
if (buf_size < 0)
|
||||
if (buf_size < 0) {
|
||||
if (s->framep[VP56_FRAME_CURRENT]->key_frame)
|
||||
avcodec_set_dimensions(s->avctx, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
if (s->use_huffman) {
|
||||
s->parse_coeff = vp6_parse_coeff_huffman;
|
||||
init_get_bits(&s->gb, buf, buf_size<<3);
|
||||
@@ -212,8 +215,8 @@ static int vp6_huff_cmp(const void *va, const void *vb)
|
||||
return (a->count - b->count)*16 + (b->sym - a->sym);
|
||||
}
|
||||
|
||||
static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
|
||||
const uint8_t *map, unsigned size, VLC *vlc)
|
||||
static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
|
||||
const uint8_t *map, unsigned size, VLC *vlc)
|
||||
{
|
||||
Node nodes[2*size], *tmp = &nodes[size];
|
||||
int a, b, i;
|
||||
@@ -227,9 +230,10 @@ static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
|
||||
nodes[map[2*i+1]].count = b + !b;
|
||||
}
|
||||
|
||||
/* then build the huffman tree accodring to probabilities */
|
||||
ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
|
||||
FF_HUFFMAN_FLAG_HNODE_FIRST);
|
||||
free_vlc(vlc);
|
||||
/* then build the huffman tree according to probabilities */
|
||||
return ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
|
||||
FF_HUFFMAN_FLAG_HNODE_FIRST);
|
||||
}
|
||||
|
||||
static void vp6_parse_coeff_models(VP56Context *s)
|
||||
@@ -365,7 +369,7 @@ static void vp6_parse_coeff_huffman(VP56Context *s)
|
||||
if (b > 3) pt = 1;
|
||||
vlc_coeff = &s->dccv_vlc[pt];
|
||||
|
||||
for (coeff_idx=0; coeff_idx<64; ) {
|
||||
for (coeff_idx = 0;;) {
|
||||
int run = 1;
|
||||
if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) {
|
||||
s->nb_null[coeff_idx][pt]--;
|
||||
@@ -400,6 +404,8 @@ static void vp6_parse_coeff_huffman(VP56Context *s)
|
||||
}
|
||||
}
|
||||
coeff_idx+=run;
|
||||
if (coeff_idx >= 64)
|
||||
break;
|
||||
cg = FFMIN(vp6_coeff_groups[coeff_idx], 3);
|
||||
vlc_coeff = &s->ract_vlc[pt][ct][cg];
|
||||
}
|
||||
@@ -427,7 +433,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 +475,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];
|
||||
}
|
||||
|
||||
|
@@ -163,6 +163,12 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (s->width & (s->vector_width - 1) ||
|
||||
s->height & (s->vector_height - 1)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Image size not multiple of block size\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* allocate codebooks */
|
||||
s->codebook_size = MAX_CODEBOOK_SIZE;
|
||||
s->codebook = av_malloc(s->codebook_size);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -67,6 +67,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
int prev_y = 0, prev_u = 0, prev_v = 0;
|
||||
uint8_t *rbuf;
|
||||
|
||||
if(buf_size<=8) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buf_size %d is too small\n", buf_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if(!rbuf){
|
||||
av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
|
||||
|
@@ -882,6 +882,7 @@ static int vsad16_mmx2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, i
|
||||
|
||||
static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
|
||||
x86_reg i=0;
|
||||
if(w>=16)
|
||||
__asm__ volatile(
|
||||
"1: \n\t"
|
||||
"movq (%2, %0), %%mm0 \n\t"
|
||||
|
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include <vfw.h>
|
||||
#include <windows.h>
|
||||
#include <vfw.h>
|
||||
|
||||
//#define DEBUG_VFW
|
||||
|
||||
|
@@ -127,6 +127,10 @@ static int fourxm_read_header(AVFormatContext *s,
|
||||
for (i = 0; i < header_size - 8; i++) {
|
||||
fourcc_tag = AV_RL32(&header[i]);
|
||||
size = AV_RL32(&header[i + 4]);
|
||||
if (size > header_size - i - 8 && (fourcc_tag == vtrk_TAG || fourcc_tag == strk_TAG)) {
|
||||
av_log(s, AV_LOG_ERROR, "chunk larger than array %d>%d\n", size, header_size - i - 8);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (fourcc_tag == std__TAG) {
|
||||
fourxm->fps = av_int2flt(AV_RL32(&header[i + 12]));
|
||||
|
@@ -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);
|
||||
|
@@ -125,10 +125,14 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
|
||||
/* We work with 720p frames split in half, thus even frames have
|
||||
* channels 0,1 and odd 2,3. */
|
||||
ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
|
||||
pcm = ppcm[ipcm++];
|
||||
|
||||
/* for each DIF channel */
|
||||
for (chan = 0; chan < sys->n_difchan; chan++) {
|
||||
/* next stereo channel (50Mbps and 100Mbps only) */
|
||||
pcm = ppcm[ipcm++];
|
||||
if (!pcm)
|
||||
break;
|
||||
|
||||
/* for each DIF segment */
|
||||
for (i = 0; i < sys->difseg_size; i++) {
|
||||
frame += 6 * 80; /* skip DIF segment header */
|
||||
@@ -176,11 +180,6 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
|
||||
frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
|
||||
}
|
||||
}
|
||||
|
||||
/* next stereo channel (50Mbps and 100Mbps only) */
|
||||
pcm = ppcm[ipcm++];
|
||||
if (!pcm)
|
||||
break;
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -202,6 +201,12 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame)
|
||||
stype = (as_pack[3] & 0x1f); /* 0 - 2CH, 2 - 4CH, 3 - 8CH */
|
||||
quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */
|
||||
|
||||
if (stype > 3) {
|
||||
av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype);
|
||||
c->ach = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* note: ach counts PAIRS of channels (i.e. stereo channels) */
|
||||
ach = ((int[4]){ 1, 0, 2, 4})[stype];
|
||||
if (ach == 1 && quant && freq == 2)
|
||||
@@ -335,7 +340,8 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
|
||||
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
|
||||
ppcm[i] = c->audio_buf[i];
|
||||
}
|
||||
dv_extract_audio(buf, ppcm, c->sys);
|
||||
if (c->ach)
|
||||
dv_extract_audio(buf, ppcm, c->sys);
|
||||
c->abytes += size;
|
||||
|
||||
/* We work with 720p frames split in half, thus even frames have
|
||||
|
@@ -448,12 +448,17 @@ static int ea_read_packet(AVFormatContext *s,
|
||||
|
||||
while (!packet_read) {
|
||||
chunk_type = get_le32(pb);
|
||||
chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8;
|
||||
chunk_size = ea->big_endian ? get_be32(pb) : get_le32(pb);
|
||||
if (chunk_size <= 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
chunk_size -= 8;
|
||||
|
||||
switch (chunk_type) {
|
||||
/* audio data */
|
||||
case ISNh_TAG:
|
||||
/* header chunk also contains data; skip over the header portion*/
|
||||
if (chunk_size < 32)
|
||||
return AVERROR_INVALIDDATA;
|
||||
url_fskip(pb, 32);
|
||||
chunk_size -= 32;
|
||||
case ISNd_TAG:
|
||||
|
@@ -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,
|
||||
@@ -1044,13 +1063,13 @@ static void matroska_convert_tags(AVFormatContext *s)
|
||||
static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
|
||||
{
|
||||
EbmlList *seekhead_list = &matroska->seekhead;
|
||||
MatroskaSeekhead *seekhead = seekhead_list->elem;
|
||||
uint32_t level_up = matroska->level_up;
|
||||
int64_t before_pos = url_ftell(matroska->ctx->pb);
|
||||
MatroskaLevel level;
|
||||
int i;
|
||||
|
||||
for (i=0; i<seekhead_list->nb_elem; i++) {
|
||||
MatroskaSeekhead *seekhead = seekhead_list->elem;
|
||||
int64_t offset = seekhead[i].pos + matroska->segment_start;
|
||||
|
||||
if (seekhead[i].pos <= before_pos
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -162,7 +162,6 @@ static int mm_read_packet(AVFormatContext *s,
|
||||
case MM_TYPE_AUDIO :
|
||||
if (av_get_packet(s->pb, pkt, length)<0)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->size = length;
|
||||
pkt->stream_index = 1;
|
||||
pkt->pts = mm->audio_pts++;
|
||||
return 0;
|
||||
|
@@ -246,8 +246,17 @@ static void id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t fl
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(isv34 && flags & 0x40) /* Extended header present, just skip over it */
|
||||
url_fskip(s->pb, id3v2_get_size(s->pb, 4));
|
||||
if (isv34 && flags & 0x40) { /* Extended header present, just skip over it */
|
||||
int extlen = id3v2_get_size(s->pb, 4);
|
||||
if (version == 4)
|
||||
extlen -= 4; // in v2.4 the length includes the length field we just read
|
||||
|
||||
if (extlen < 0) {
|
||||
reason = "invalid extended header length";
|
||||
goto error;
|
||||
}
|
||||
url_fskip(s->pb, extlen);
|
||||
}
|
||||
|
||||
while(len >= taghdrlen) {
|
||||
if(isv34) {
|
||||
|
@@ -317,7 +317,9 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
char *token, *value;
|
||||
char quote;
|
||||
|
||||
p = strings = av_mallocz(strings_size + 1);
|
||||
p = strings = av_mallocz((size_t)strings_size + 1);
|
||||
if (!p)
|
||||
return AVERROR(ENOMEM);
|
||||
endp = strings + strings_size;
|
||||
get_buffer(pb, strings, strings_size);
|
||||
while (p < endp) {
|
||||
@@ -351,6 +353,8 @@ static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
if((unsigned)table_entries >= UINT_MAX / sizeof(uint32_t))
|
||||
return -1;
|
||||
nsv->nsvf_index_data = av_malloc(table_entries * sizeof(uint32_t));
|
||||
if (!nsv->nsvf_index_data)
|
||||
return AVERROR(ENOMEM);
|
||||
#warning "FIXME: Byteswap buffer as needed"
|
||||
get_buffer(pb, (unsigned char *)nsv->nsvf_index_data, table_entries * sizeof(uint32_t));
|
||||
}
|
||||
@@ -507,11 +511,16 @@ static int nsv_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
for (i = 0; i < NSV_MAX_RESYNC_TRIES; i++) {
|
||||
if (nsv_resync(s) < 0)
|
||||
return -1;
|
||||
if (nsv->state == NSV_FOUND_NSVF)
|
||||
if (nsv->state == NSV_FOUND_NSVF) {
|
||||
err = nsv_parse_NSVf_header(s, ap);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
/* we need the first NSVs also... */
|
||||
if (nsv->state == NSV_FOUND_NSVS) {
|
||||
err = nsv_parse_NSVs_header(s, ap);
|
||||
if (err < 0)
|
||||
return err;
|
||||
break; /* we just want the first one */
|
||||
}
|
||||
}
|
||||
@@ -586,12 +595,12 @@ null_chunk_retry:
|
||||
}
|
||||
|
||||
/* map back streams to v,a */
|
||||
if (s->streams[0])
|
||||
if (s->nb_streams > 0)
|
||||
st[s->streams[0]->id] = s->streams[0];
|
||||
if (s->streams[1])
|
||||
if (s->nb_streams > 1)
|
||||
st[s->streams[1]->id] = s->streams[1];
|
||||
|
||||
if (vsize/* && st[NSV_ST_VIDEO]*/) {
|
||||
if (vsize && st[NSV_ST_VIDEO]) {
|
||||
nst = st[NSV_ST_VIDEO]->priv_data;
|
||||
pkt = &nsv->ahead[NSV_ST_VIDEO];
|
||||
av_get_packet(pb, pkt, vsize);
|
||||
@@ -606,7 +615,7 @@ null_chunk_retry:
|
||||
if(st[NSV_ST_VIDEO])
|
||||
((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++;
|
||||
|
||||
if (asize/*st[NSV_ST_AUDIO]*/) {
|
||||
if (asize && st[NSV_ST_AUDIO]) {
|
||||
nst = st[NSV_ST_AUDIO]->priv_data;
|
||||
pkt = &nsv->ahead[NSV_ST_AUDIO];
|
||||
/* read raw audio specific header on the first audio chunk... */
|
||||
|
@@ -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
|
||||
|
@@ -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