Commit Graph

164 Commits

Author SHA1 Message Date
Michael Niedermayer ba4beaf614 avcodec/apedec: Fix integer overflow
Fixes: out of array access
Fixes: PoC.ape and others

Found-by: Bingchang, Liu@VARAS of IIE
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-07-16 16:53:02 +02:00
Clément Bœsch 549045254c Fix all -Wformat warnings raised by DJGPP 2017-03-29 14:49:29 +02:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Luca Barbato dd4fb2339f ape: Unbreak adaptcoeffs computation
And simplify and explain the expression.

Fault introduced in f3fdef108e

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-12 14:32:16 +01:00
Derek Buitenhuis 22900770c5 Merge commit 'f3fdef108eb06b1e71b29152bf6822519e787efe'
* commit 'f3fdef108eb06b1e71b29152bf6822519e787efe':
  ape: Avoid undefined behaviour

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-12 14:20:51 +01:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Luca Barbato 4012fe1ee8 ape: Unbreak adaptcoeffs computation
And simplify and explain the expression.

Fault introduced in f3fdef108e
2016-04-24 10:18:25 +02:00
Luca Barbato f3fdef108e ape: Avoid undefined behaviour
Avoid the clang warning

"warning: shifting a negative signed value is undefined"
2016-04-19 20:22:31 +02:00
Paul B Mahol 9149e9c0ba avcodec/apedec: fix decoding of stereo files with one channel full of silence
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-04-12 11:03:48 +02:00
Carl Eugen Hoyos 9cf8c3e62c ape: Show more information for loglevel verbose.
Requested by Andy E, fixes bug 687.
2016-01-19 11:02:14 +01:00
Michael Niedermayer cd7524fdd1 avcodec/apedec: Check length in long_filter_high_3800()
Fixes out of array read
Fixes: 0a7ff0c1d93da9cef28a315ec91b692a/asan_heap-oob_4a52e5_3604_9c56dbb20e308f4faeef7b35f688521a.ape

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-02 21:38:11 +01:00
Ganesh Ajjanagadde c4c389aa14 avcodec/apedec: fix bug introduced in commit d3e5fbb140
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-03 23:04:23 +02:00
Ganesh Ajjanagadde d3e5fbb140 avcodec/apedec: fix undefined left shifts of negative numbers
This fixes -Wshift-negative-value reported with clang 3.7+, e.g
http://fate.ffmpeg.org/log.cgi?time=20150919172459&log=compile&slot=x86_64-darwin-clang-polly-notiling-3.7.
Note that the patch crucially depends on int >= 32 bits,
an assumption made in many places in the codebase.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-29 15:05:38 +02:00
Michael Niedermayer 444e9874a7 Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'
* commit 'def97856de6021965db86c25a732d78689bd6bb0':
  lavc: AV-prefix all codec capabilities

Conflicts:
	cmdutils.c
	ffmpeg.c
	ffplay.c
	libavcodec/8svx.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/adpcm.c
	libavcodec/alac.c
	libavcodec/atrac3plusdec.c
	libavcodec/bink.c
	libavcodec/dnxhddec.c
	libavcodec/dvdec.c
	libavcodec/dvenc.c
	libavcodec/ffv1dec.c
	libavcodec/ffv1enc.c
	libavcodec/fic.c
	libavcodec/flacdec.c
	libavcodec/flacenc.c
	libavcodec/flvdec.c
	libavcodec/fraps.c
	libavcodec/frwu.c
	libavcodec/gifdec.c
	libavcodec/h261dec.c
	libavcodec/hevc.c
	libavcodec/iff.c
	libavcodec/imc.c
	libavcodec/libopenjpegdec.c
	libavcodec/libvo-aacenc.c
	libavcodec/libvorbisenc.c
	libavcodec/libvpxdec.c
	libavcodec/libvpxenc.c
	libavcodec/libx264.c
	libavcodec/mjpegbdec.c
	libavcodec/mjpegdec.c
	libavcodec/mpegaudiodec_float.c
	libavcodec/msmpeg4dec.c
	libavcodec/mxpegdec.c
	libavcodec/nvenc_h264.c
	libavcodec/nvenc_hevc.c
	libavcodec/pngdec.c
	libavcodec/qpeg.c
	libavcodec/ra288.c
	libavcodec/rv10.c
	libavcodec/s302m.c
	libavcodec/sp5xdec.c
	libavcodec/takdec.c
	libavcodec/tiff.c
	libavcodec/tta.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/vp6.c
	libavcodec/vp9.c
	libavcodec/wavpack.c
	libavcodec/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:50:18 +02:00
Vittorio Giovara def97856de lavc: AV-prefix all codec capabilities
Express bitfields more simply.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:58 +01:00
Andreas Cadhalpun 295e05a762 ape: Support _0000 files with nblock smaller than 64
The decode_array_0000 assumed that 64 is the minimal block size
while it is not.

CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-05-08 11:10:51 +02:00
Andreas Cadhalpun 699341d647 apedec: prevent out of array writes in decode_array_0000
s->decoded_buffer is allocated with a min_size of:
    2 * FFALIGN(blockstodecode, 8) * sizeof(*s->decoded_buffer)

Then it is assigned to s->decoded[0] (and s->decoded_buffer + FFALIGN(blockstodecode, 8)
to s->decoded[1]) and passed as out buffer to decode_array_0000.

In this function 64 elements of the out buffer are written
unconditionally and outside the array if blockstodecode is too small.

This causes memory corruption, leading to segmentation faults or other
crashes.

Thus change decode_array_0000 to write at most blockstodecode elements
of the out buffer.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-28 12:43:13 +02:00
Andreas Cadhalpun 464c49155c apedec: set s->samples only when init_frame_decoder succeeded
Otherwise range_start_decoding is not necessarily run and thus
ctx->rc.range still 0 in range_dec_normalize leading to an infinite
loop.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-28 03:21:12 +02:00
zhaoxiu.zeng ac7fc444ee avcodec/apedec: simplify sign conversion
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 01:09:44 +01:00
zhaoxiu.zeng 0073c8e345 avcodec/apedec: move 'coeffs[256] and delay[256]' into, long_filter_high_3800
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-13 23:23:27 +01:00
Michael Niedermayer 35bb74900b Merge commit 'c67b449bebbe0b35c73b203683e77a0a649bc765'
* commit 'c67b449bebbe0b35c73b203683e77a0a649bc765':
  dsputil: Split bswap*_buf() off into a separate context

Conflicts:
	configure
	libavcodec/4xm.c
	libavcodec/ac3dec.c
	libavcodec/ac3dec.h
	libavcodec/apedec.c
	libavcodec/eamad.c
	libavcodec/flacenc.c
	libavcodec/fraps.c
	libavcodec/huffyuv.c
	libavcodec/huffyuvdec.c
	libavcodec/motionpixels.c
	libavcodec/truemotion2.c
	libavcodec/x86/Makefile
	libavcodec/x86/dsputil_init.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-23 13:31:26 +02:00
Diego Biurrun c67b449beb dsputil: Split bswap*_buf() off into a separate context 2014-06-22 18:22:31 -07:00
Michael Niedermayer 42e6fc147b avcodec/apedec: optimize sign combination
48078630 -> 32533850 dezi cycles

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-23 02:15:06 +02:00
Michael Niedermayer efec730431 Merge commit 'f83896abda1e78ebbbda0f184b682b4fabadc682'
* commit 'f83896abda1e78ebbbda0f184b682b4fabadc682':
  ape: Replace memset(0) by zero initialization

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-23 01:03:30 +02:00
Diego Biurrun f83896abda ape: Replace memset(0) by zero initialization 2014-06-22 18:43:11 +02:00
Christophe Gisquet ccff45a0d3 apedsp: move to llauddsp
APE is not the sole codec using scalarproduct_and_madd_int16.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-05 20:31:59 +02:00
Michael Niedermayer 40f3a87c10 Merge commit '054013a0fc6f2b52c60cee3e051be8cc7f82cef3'
* commit '054013a0fc6f2b52c60cee3e051be8cc7f82cef3':
  dsputil: Move APE-specific bits into apedsp

Conflicts:
	libavcodec/arm/int_neon.S
	libavcodec/x86/dsputil.asm

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-30 00:59:15 +02:00
Diego Biurrun 054013a0fc dsputil: Move APE-specific bits into apedsp 2014-05-29 06:41:15 -07:00
Michael Niedermayer ebfe154bd5 avcodec/apedec: tmpk==32 is not supported, prevent undefined behavior
Fixes CID1206639
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-26 20:56:31 +02:00
Michael Niedermayer 8d024c5107 Merge commit 'cc8163e1a3601a56f722a4720516e860bf1c6198'
* commit 'cc8163e1a3601a56f722a4720516e860bf1c6198':
  avcodec: more correct printf specifiers

Conflicts:
	libavcodec/4xm.c
	libavcodec/alsdec.c
	libavcodec/dfa.c
	libavcodec/h264_ps.c
	libavcodec/jpeg2000dec.c
	libavcodec/lagarith.c
	libavcodec/mpeg12dec.c
	libavcodec/rv10.c
	libavcodec/svq3.c
	libavcodec/wmaprodec.c
	libavcodec/xwddec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-22 18:43:40 +01:00
Diego Biurrun cc8163e1a3 avcodec: more correct printf specifiers 2014-03-22 14:08:20 +01:00
Michael Niedermayer 99978320c0 avcodec/apedec: use av_fast_padded_malloc()
Fixes use of uninitialized memory
Fixes part of msan_uninit-mem_7fa0d8c8bd58_8417_sh3.ape
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-23 18:11:35 +01:00
Michael Niedermayer d5128fce38 avcodec/apedec: more checks for k
Fixes assertion failure
Fixes part of msan_uninit-mem_7fa0d8c8bd58_8417_sh3.ape
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-23 18:10:44 +01:00
Paul B Mahol 49c6f0ae15 avcodec/apedec: use init_get_bits8()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-10-30 11:04:06 +00:00
Michael Niedermayer ee77140afa Merge commit 'b2bed9325dbd6be0da1d91ffed3f513c40274fd2'
* commit 'b2bed9325dbd6be0da1d91ffed3f513c40274fd2':
  cosmetics: Group .name and .long_name together in codec/format declarations

Conflicts:
	libavcodec/8svx.c
	libavcodec/alac.c
	libavcodec/cljr.c
	libavcodec/dnxhddec.c
	libavcodec/dnxhdenc.c
	libavcodec/dpxenc.c
	libavcodec/dvdec.c
	libavcodec/dvdsubdec.c
	libavcodec/dvdsubenc.c
	libavcodec/ffv1dec.c
	libavcodec/flacdec.c
	libavcodec/flvdec.c
	libavcodec/fraps.c
	libavcodec/frwu.c
	libavcodec/g726.c
	libavcodec/gif.c
	libavcodec/gifdec.c
	libavcodec/h261dec.c
	libavcodec/h263dec.c
	libavcodec/iff.c
	libavcodec/imc.c
	libavcodec/libopencore-amr.c
	libavcodec/libopenjpegdec.c
	libavcodec/libopenjpegenc.c
	libavcodec/libspeexenc.c
	libavcodec/libvo-amrwbenc.c
	libavcodec/libvorbisenc.c
	libavcodec/libvpxenc.c
	libavcodec/libx264.c
	libavcodec/libxavs.c
	libavcodec/libxvid.c
	libavcodec/ljpegenc.c
	libavcodec/mjpegbdec.c
	libavcodec/mjpegdec.c
	libavcodec/mpeg12dec.c
	libavcodec/mpeg4videodec.c
	libavcodec/msmpeg4dec.c
	libavcodec/pgssubdec.c
	libavcodec/pngdec.c
	libavcodec/pngenc.c
	libavcodec/proresdec_lgpl.c
	libavcodec/proresenc_kostya.c
	libavcodec/ra144enc.c
	libavcodec/rawdec.c
	libavcodec/rv10.c
	libavcodec/sp5xdec.c
	libavcodec/takdec.c
	libavcodec/tta.c
	libavcodec/v210dec.c
	libavcodec/vp6.c
	libavcodec/wavpack.c
	libavcodec/xbmenc.c
	libavcodec/yop.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 12:34:23 +02:00
Diego Biurrun b2bed9325d cosmetics: Group .name and .long_name together in codec/format declarations 2013-10-03 23:32:01 +02:00
Rafaël Carré 91d4cfb812 apedec: do not buffer decoded samples over AVPackets
Only consume an AVPacket when all the samples have been read.

When the rate of samples output is limited (by the default value
of max_samples), consuming the first packet immediately will cause
timing problems:

- The first packet with PTS 0 will output 4608 samples and be
consumed entirely
- The second packet with PTS 64 will output the remaining samples
(typically, a lot, that's why max_samples exist) until the decoded
samples of the first packet have been exhausted, at which point the
samples of the second packet will be decoded and output when
av_decode_frame is called with the next packet).

That means there's a PTS jump since the first packet is 'decoded'
immediately, which can be seen with avplay or mplayer: the timing
jumps immediately to 6.2s (which is the size of a packet).

Sample: http://streams.videolan.org/issues/6348/Goldwave-MAClib.ape
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
2013-08-28 15:00:34 -04:00
Michael Niedermayer 60ab448042 ape_decode_value_3860: check k before using it in get_bits()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-02 17:24:02 +02:00
Michael Niedermayer 8937230719 ape_decode_value_3900: check tmpk
Fixes division by 0

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-02 16:45:32 +02:00
Michael Niedermayer 795b911bd8 Merge commit '613a37eca4c7b8eefceaa3e0231c23ad090ca94f'
* commit '613a37eca4c7b8eefceaa3e0231c23ad090ca94f':
  ape: 3.80-3.92 decoding support
  h264: Remove an unused variable

Conflicts:
	libavcodec/apedec.c
	libavformat/ape.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-26 13:14:16 +01:00
Kostya Shishkov 613a37eca4 ape: 3.80-3.92 decoding support 2013-03-25 18:40:56 +01:00
Michael Niedermayer 2265bb93ff Merge remote-tracking branch 'qatar/master'
* qatar/master:
  add support for Monkey's Audio versions from 3.93

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-15 13:43:01 +01:00
Michael Niedermayer 5be70f5826 Merge commit '9652d4fcfc9c07a726b35efc4ac644d9751b36d7'
* commit '9652d4fcfc9c07a726b35efc4ac644d9751b36d7':
  ape: provide two additional bytes in buffer for old MAC versions

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-15 13:34:20 +01:00
Michael Niedermayer 231795270b Merge commit 'b164d66e35d349de414e2f0d7365a147aba8a620'
* commit 'b164d66e35d349de414e2f0d7365a147aba8a620':
  ape: make version-dependent decoding functions called via pointers
  mpegts: add support for stream_type 0x42, which is CAVS

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-15 13:28:38 +01:00
Kostya Shishkov c42e262513 add support for Monkey's Audio versions from 3.93 2013-03-15 09:50:42 +01:00
Kostya Shishkov 9652d4fcfc ape: provide two additional bytes in buffer for old MAC versions
Range coder in 3.90-3.95 overread two bytes in the final normalize.
2013-03-15 09:50:42 +01:00
Kostya Shishkov b164d66e35 ape: make version-dependent decoding functions called via pointers
This will help in supporting old versions, e.g. version 3.93 uses the same
range coder but different predictor and version 3.82 uses different range
coder and predictor. Also this should not make decoding newer versions slower
by introducing additional checks on versions.
2013-03-15 09:50:42 +01:00
Michael Niedermayer 13795dbb64 Merge commit '6d97484d72e33f7dde9493a9ead1a72e2f029605'
* commit '6d97484d72e33f7dde9493a9ead1a72e2f029605':
  avcodec: av_log_ask_for_sample() ---> avpriv_request_sample()
  rsodec: Use avpriv_report_missing_feature() where appropriate

Conflicts:
	libavcodec/anm.c
	libavcodec/mlpdec.c
	libavcodec/pictordec.c
	libavcodec/sunrast.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-14 12:52:12 +01:00
Diego Biurrun 6d97484d72 avcodec: av_log_ask_for_sample() ---> avpriv_request_sample() 2013-03-13 21:20:12 +01:00
Clément Bœsch 1ec94b0f06 lavc: factorize ff_{thread_,re,}get_buffer error messages.
Coccinelle profile used:

  @@
  expression r, ctx, f, loglevel, str, flags;
  @@

  -if ((r = ff_get_buffer(ctx, f, flags)) < 0) {
  -    av_log(ctx, loglevel, str);
  -    return r;
  -}
  +if ((r = ff_get_buffer(ctx, f, flags)) < 0)
  +    return r;

  @@
  expression r, ctx, f, loglevel, str;
  @@

  -if ((r = ff_reget_buffer(ctx, f)) < 0) {
  -    av_log(ctx, loglevel, str);
  -    return r;
  -}
  +if ((r = ff_reget_buffer(ctx, f)) < 0)
  +    return r;

  @@
  expression r, ctx, f, loglevel, str, flags;
  @@

  -if ((r = ff_thread_get_buffer(ctx, f, flags)) < 0) {
  -    av_log(ctx, loglevel, str);
  -    return r;
  -}
  +if ((r = ff_thread_get_buffer(ctx, f, flags)) < 0)
  +    return r;

...along with some manual patches for the remaining ones.
2013-03-13 19:00:10 +01:00