summaryrefslogtreecommitdiff
path: root/libavcodec/sonic.c
Commit message (Collapse)AuthorAge
* avcodec/encode: Always use intermediate buffer in ff_alloc_packet2()Andreas Rheinhardt2021-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, ff_alloc_packet2() has a min_size parameter: It is supposed to be a lower bound on the final size of the packet to allocate. If it is not too far from the upper bound (namely, if it is at least half the upper bound), then ff_alloc_packet2() already allocates the final, already refcounted packet; if it is not, then the packet is not refcounted and its data only points to a buffer owned by the AVCodecContext (in this case, the packet will be made refcounted in encode_simple_internal() in libavcodec/encode.c). The goal of this was to avoid data copies and intermediate buffers if one has a precise lower bound. Yet those encoders for which precise lower bounds exist have recently been switched to ff_get_encode_buffer() (which automatically allocates final buffers), leaving only two encoders to actually set the min_size to something else than zero (namely aliaspixenc and hapenc). Both of these encoders use a very low lower bound that is not helpful in any nontrivial case. This commit therefore removes the min_size parameter as well as the codepath in ff_alloc_packet2() for the allocation of final buffers. Furthermore, the function has been renamed to ff_alloc_packet() and moved to encode.h alongside ff_get_encode_buffer(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/sonic: Mark decoder as init-threadsafeAndreas Rheinhardt2021-05-02
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Mark encoders as init-threadsafeAndreas Rheinhardt2021-05-02
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* Avoid intermediate bitcount for number of bytes in PutBitContextAndreas Rheinhardt2021-03-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Remove outdated outcommented lineAndreas Rheinhardt2021-03-30
| | | | | | | Compilation would fail if it were outcommented as it refers to a nonexistent PutBitContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Use unsigned temporary in predictor_calc_error()Michael Niedermayer2021-03-28
| | | | | | | | Fixes: signed integer overflow: -2147471366 - 18638 cannot be represented in type 'int' Fixes: 30157/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5171199746506752 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: set AV_CODEC_CAP_CHANNEL_CONF on decoders which set their own channelsHendrik Leppkes2020-12-10
| | | | | | | | | | | | The decoders in this set either have a fixed channel count, or read it from the bitstream, and thus do not require the channel count as external information. Fixes various regressions since 81503ac58a763a36b1f57264013b1e76acb62b68, which requires a valid channel count for decoders which do not set this capability. Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
* avcodec/sonic: Don't allocate a temporary buffer for every frameAndreas Rheinhardt2020-11-06
| | | | | | Instead allocate it together with the buffer that it mirrors. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Don't hardcode sizeof(int) == 4Andreas Rheinhardt2020-11-04
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Allocate several buffers togetherAndreas Rheinhardt2020-11-04
| | | | | | | It simplifies freeing them and reduces the amount of allocations. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Check for overreadMichael Niedermayer2020-10-15
| | | | | | | | Fixes: Timeout (too long -> 1.3 sec) Fixes: 24358/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5107284099989504 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/sonic: Check channels before deallocatingMichael Niedermayer2020-09-25
| | | | | | | | | Fixes: heap-buffer-overflow Fixes: 25744/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5172961169113088 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/sonic: Fix leaks upon allocation errorsAndreas Rheinhardt2020-09-17
| | | | | | | | | The Sonic decoder and encoders allocate several buffers in their init function and return immediately if one of these allocations fails; this will lead to leaks if there was an earlier successfull allocation. Fix this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/sonic: Fix several integer state overflowsMichael Niedermayer2020-06-14
| | | | | | | | | Fixes: signed integer overflow: -234 * -14797801 cannot be represented in type 'int' Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776 Fixes: 22275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5695924975435776 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/sonic: Fix several integer overflowsMichael Niedermayer2020-06-14
| | | | | | | | Fixes: signed integer overflow: 2129689466 + 2129689466 cannot be represented in type 'int' Fixes: 20715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5155263109922816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/sonic: Check e in get_symbol()Michael Niedermayer2019-12-31
| | | | | | | | | Fixes: signed integer overflow: 1721520852 + 1721520852 cannot be represented in type 'int' Fixes: 18346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5709623893426176 Fixes: 18753/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5663299131932672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/sonic: Fix integer overflow in predictor_calc_error()Michael Niedermayer2019-11-20
| | | | | | | | Fixes: signed integer overflow: 5 * -1094995529 cannot be represented in type 'int' Fixes: 18346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SONIC_fuzzer-5709623893426176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/rangecoder: factorize termination version codeMichael Niedermayer2018-12-31
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* sonic: make sure num_taps * channels is not larger than frame_sizeAndreas Cadhalpun2015-12-17
| | | | | | | | | If that is the case, the loop setting predictor_state in sonic_decode_frame causes out of bounds reads of int_samples, which has only frame_size number of elements. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* avcodec/sonic: Check init_get_bits8() for failureMichael Niedermayer2015-09-04
| | | | | | Fixes: CID1322310 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'Michael Niedermayer2015-07-27
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* | avcodec: Add a min size parameter to ff_alloc_packet2()Michael Niedermayer2015-07-27
| | | | | | | | | | | | | | | | This parameter can be used to inform the allocation code about how much downsizing might occur, and can be used to optimize how to allocate the packet Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | sonic: set avctx->channels in sonic_decode_initAndreas Cadhalpun2015-06-09
| | | | | | | | | | | | | | Otherwise it can be 0 in sonic_decode_frame, causing SIGFPE crashes. Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* | avcodec/sonic: More completely check sample_rate_index and channelsMichael Niedermayer2015-05-15
| | | | | | | | | | | | Fixes CID1271783 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/sonic: check memory allocationsMichael Niedermayer2015-05-15
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: Switch to rangecoderMichael Niedermayer2013-12-10
| | | | | | | | | | | | | | | | | | | | significantly improves compression rate This also bumps version to 2 and drops support for version 0/1 If someone used version 0/1 despite their experimental status then support for these can and should be added back Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/sonic: add larger version and minor_version fields with version >= 2Michael Niedermayer2013-12-10
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/sonic: move version to the contextMichael Niedermayer2013-12-10
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/sonic: fix memleaksMichael Niedermayer2013-12-10
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: use M_SQRT2Michael Niedermayer2013-12-10
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | cosmetics: group remaining .name and .long_name.Clément Bœsch2013-10-04
| | | | | | | | See b2bed9325.
* | avcodec/sonic: Fix usage of init_get_bits() and use init_get_bits8()Michael Niedermayer2013-07-04
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: use av_freep() as its safer than av_free()Michael Niedermayer2013-06-23
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: cleanup/simplify num_taps checkMichael Niedermayer2013-06-23
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: replace divide() by ROUNDED_DIV()Michael Niedermayer2013-06-23
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: avoid float sqrt() for integer input & outputMichael Niedermayer2013-06-23
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: simplify quant clipingMichael Niedermayer2013-06-23
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: use av_calloc()Michael Niedermayer2013-06-23
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: replace literal numbers by sizeof()Michael Niedermayer2013-06-22
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: replace some float by integers to improve platform independanceMichael Niedermayer2013-06-22
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: Improve error codesMichael Niedermayer2013-06-22
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonic: simplify shift_down()Michael Niedermayer2013-06-22
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonicenc: fix off by 1 errorMichael Niedermayer2013-06-19
| | | | | | | | | | | | Fixes out of array accesses Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonicenc: dont put multiple assignments per lineMichael Niedermayer2013-06-19
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonicenc: set supported samples formats arrayMichael Niedermayer2013-06-19
| | | | | | | | | | | | This ensures that only supported formats are input Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonicenc: don't allocate unused avctx->coded_framePaul B Mahol2013-06-07
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | sonicdec: update to new buffer APIMichael Niedermayer2013-03-21
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonicenc: fix mono decorrelationMichael Niedermayer2013-03-21
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | sonicdec: fix frame sizeMichael Niedermayer2013-03-21
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>