Commit Graph

210 Commits

Author SHA1 Message Date
Andreas Rheinhardt
02220b88fc avcodec/thread: Don't use ThreadFrame when unnecessary
The majority of frame-threaded decoders (mainly the intra-only)
need exactly one part of ThreadFrame: The AVFrame. They don't
need the owners nor the progress, yet they had to use it because
ff_thread_(get|release)_buffer() requires it.

This commit changes this and makes these functions work with ordinary
AVFrames; the decoders that need the extra fields for progress
use ff_thread_(get|release)_ext_buffer() which work exactly
as ff_thread_(get|release)_buffer() used to do.

This also avoids some unnecessary allocations of progress AVBuffers,
namely for H.264 and HEVC film grain frames: These frames are not
used for synchronization and therefore don't need a ThreadFrame.

Also move the ThreadFrame structure as well as ff_thread_ref_frame()
to threadframe.h, the header for frame-threaded decoders with
inter-frame dependencies.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:22:35 +01:00
Andreas Rheinhardt
15d003a495 avcodec/flacdec: Mark decoder as init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-05-02 03:19:46 +02:00
Andreas Rheinhardt
a247ac640d avcodec: Constify AVCodecs
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>
2021-04-27 10:43:15 -03:00
Michael Niedermayer
bd525e2876 avcodec/flacdec: Avoid undefined shift in error case
Fixes: flac_1040988

Reported-by: Thomas Guilbert <tguilbert@google.com>
Reviewed-by: Thomas Guilbert <tguilbert@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-13 21:02:31 +01:00
Michael Niedermayer
34f5a59ad5 avcodec: Set AV_CODEC_CAP_CHANNEL_CONF in more decoders
Suggested-by: Paul B Mahol <onemda@gmail.com>
See: [FFmpeg-devel] [PATCH 1/3] avcodec/fastaudio: Check channels
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-11-28 00:41:51 +01:00
Paul B Mahol
ccc7120ee7 avcodec/flacdec: use designated initializers for AVClass 2020-08-28 01:16:55 +02:00
Anton Khirnov
1f4cf92cfb pthread_frame: merge the functionality for normal decoder init and init_thread_copy
The current design, where
- proper init is called for the first per-thread context
- first thread's private data is copied into private data for all the
  other threads
- a "fixup" function is called for all the other threads to e.g.
  allocate dynamically allocated data
is very fragile and hard to follow, so it is abandoned. Instead, the
same init function is used to init each per-thread context. Where
necessary, AVCodecInternal.is_copy can be used to differentiate between
the first thread and the other ones (e.g. for decoding the extradata
just once).
2020-04-10 15:24:54 +02:00
Michael Niedermayer
3d23f7a096 avcodec/flacdec: Fix overflow in multiplication in decode_subframe_fixed()
Fixes: signed integer overflow: 2 * 1629495328 cannot be represented in type 'int'
Fixes: 4716/clusterfuzz-testcase-minimized-5835915940331520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-28 20:13:59 +01:00
Michael Niedermayer
560daf8891 avcodec/flacdec: avoid undefined shift
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 4688/clusterfuzz-testcase-minimized-6572210748653568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-28 20:13:59 +01:00
James Almer
ec703910af Merge commit '0f5ad12ba2b538cb329c507ecc914e06bfa70194'
* commit '0f5ad12ba2b538cb329c507ecc914e06bfa70194':
  flac: Use a local cache for decode_residual()

Merged-by: James Almer <jamrial@gmail.com>
2017-11-07 19:08:46 -03:00
James Almer
ff55b62a65 Merge commit '15f1cc09a406cf6296818d475a256902235eefc4'
* commit '15f1cc09a406cf6296818d475a256902235eefc4':
  flac: Postpone unlikely condition checks

Merged-by: James Almer <jamrial@gmail.com>
2017-11-07 18:59:43 -03:00
Luca Barbato
0f5ad12ba2 flac: Use a local cache for decode_residual()
About an additional 4% speedup.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2017-07-09 20:51:24 +02:00
Luca Barbato
15f1cc09a4 flac: Postpone unlikely condition checks
About 2% speedup on gcc-6.3.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2017-07-09 20:49:57 +02:00
Alexandra Hájková
9c1e111406 flac: Convert to the new bitstream reader
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2017-07-09 20:47:53 +02:00
Michael Niedermayer
3f5a68533d avcodec/flacdec: Return error code instead of 0 for failures
Fixes: infinite loop
Fixes: 1418/clusterfuzz-testcase-minimized-5934472438480896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-09 16:50:18 +02:00
Michael Niedermayer
0a65dae9d0 avcodec/flacdec: reduce limit for golomb so that the max value does not overflow
Fixes: runtime error: left shift of 32 by 26 places cannot be represented in type 'int'

Fixes: 628/clusterfuzz-testcase-6187747641393152
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-02-21 00:40:20 +01:00
Michael Niedermayer
3e1028c625 avcodec/flac: Fix several integer overflows
Fixes: 686513-media
Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-02-19 15:58:30 +01:00
Michael Niedermayer
fd00203554 avcodec/flacdec: Check for invalid vlcs
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-02-04 02:26:37 +01:00
Diego Biurrun
d4c2103bd3 golomb: Convert to the new bitstream reader 2017-01-31 17:46:19 +01:00
Michael Niedermayer
1f5630af51 avcodec/flacdec: Fix undefined shift in decode_subframe()
Fixes undefined behavior
Fixes: 639961-media

Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-04 00:12:06 +01:00
Michael Niedermayer
6567c59c49 avcodec/flac: forward errors from ff_flac_parse_streaminfo()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 23:39:11 +01:00
Michael Niedermayer
83a75bf6c3 avcodec/flacdec: Fix signed integer overflow in decode_subframe_fixed()
Fixes undefined behavior
Fixes: 640912-media

Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 17:26:39 +01:00
Clément Bœsch
fb99ef0bd3 avcodec: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:37:05 +01:00
Ganesh Ajjanagadde
2cbaa078d1 avcodec: use HAVE_THREADS header guards to silence -Wunused-function
When compiled with --disable-pthreads, e.g
http://fate.ffmpeg.org/report.cgi?time=20150917015044&slot=alpha-debian-qemu-gcc-4.7,
a bunch of -Wunused-functions are reported due to missing header guards
around threading related functions.
This patch should silence such warnings.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-04 12:47:34 -04: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
Michael Niedermayer
b6fcb2bb6d avcodec/flacdec: Attempt to auto-detect old buggy flac
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-17 13:42:32 +02:00
Carl Eugen Hoyos
e609cfd697 lavc/flac: Fix encoding and decoding with high lpc.
Based on an analysis by trac user lvqcl.

Fixes ticket #4421, reported by Chase Walker.
2015-05-17 02:08:58 +02:00
Carl Eugen Hoyos
38f5a266ee lavc/flacdec: Sanitize FLACSTREAMINFO usage. 2015-05-17 02:08:58 +02:00
Michael Niedermayer
5f30522894 avcodec/flacdec: fix off by 1 error
Fixes assertion failure
Fixes: signal_sigsegv_324b284_1980_dilvie___the_dragonfly.flac
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-26 04:11:16 +01:00
Michael Niedermayer
e5c01ccdf5 avcodec/flacdec: Call ff_flacdsp_init() unconditionally
Fixes out of array access
Fixes: signal_sigsegv_324b135_3398_cov_246853371_short.flac
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-26 04:11:08 +01:00
James Almer
3cec54b7d7 x86/flacdsp: add SSE2 and AVX decorrelate functions
Two to four times faster depending on instruction set, block size and channel count.
2014-11-13 13:47:55 -03:00
Michael Niedermayer
cffd2713e9 Merge commit 'acc897e6b15776ed438b88ffe330ec48f6b50e48'
* commit 'acc897e6b15776ed438b88ffe330ec48f6b50e48':
  lavc: make avpriv_flac_is_extradata_valid() private on the next bump

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-06 14:17:46 +01:00
Michael Niedermayer
cfef947f7f Merge commit 'c070a8751597e3aa1b443e88464da785d8966b14'
* commit 'c070a8751597e3aa1b443e88464da785d8966b14':
  lavc: make avpriv_flac_parse_streaminfo() private on the next bump

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-06 13:54:11 +01:00
Anton Khirnov
acc897e6b1 lavc: make avpriv_flac_is_extradata_valid() private on the next bump 2014-11-06 09:04:56 +01:00
Anton Khirnov
c070a87515 lavc: make avpriv_flac_parse_streaminfo() private on the next bump 2014-11-06 09:04:12 +01:00
Michael Niedermayer
7618d360ca Merge commit '7703995a2e8760e66ff35148bf029e0f9e30dbe6'
* commit '7703995a2e8760e66ff35148bf029e0f9e30dbe6':
  flac: Remove unused headers

Conflicts:
	libavcodec/flacdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-26 22:33:28 +02:00
Tristan Matthews
7703995a2e flac: Remove unused headers
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-09-26 10:33:01 -07:00
Michael Niedermayer
6fac482624 avcodec/flacdec: fix handling of av_samples_fill_arrays() return value
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-10 00:21:55 +02:00
Michael Niedermayer
40beec6a43 Merge commit '5fdaf312c5541b77b6364db8b49d6abb416a25c0'
* commit '5fdaf312c5541b77b6364db8b49d6abb416a25c0':
  flac: make avpriv_flac_parse_block_header() inline

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-28 12:33:49 +02:00
Anton Khirnov
5fdaf312c5 flac: make avpriv_flac_parse_block_header() inline
This avoids all the ABI troubles associated with avpriv_.
Since this function is very small and does not depend on any tables,
making it inline should have no adverse effects.
2014-05-28 07:48:30 +02:00
Michael Niedermayer
e9ad121ba5 Fix skiping typos
Found-by: Alessandro Ghedini <alessandro@ghedini.me>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-27 14:50:14 +02:00
Michael Niedermayer
8ca9a68f19 avcodec/flacdec: check rice_order against blocksize
Fixes use of uninitialized memory
Fixes: msan_uninit-mem_7f6e13c220d0_8489_short.flac
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-07 14:02:53 +01:00
Michael Niedermayer
4b12930f79 avcodec/flacdec: use get_unary() simplify code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-30 14:58:04 +01:00
Michael Niedermayer
9f5b75f241 avcodec/flacdec: make while get_bits loop more robust by checking bits left
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-30 14:39:31 +01:00
Michael Niedermayer
3b56f665b1 avcodec/flacdec: also do crc check when er compliant is set
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-27 09:51:21 +01: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
Michael Niedermayer
5f312139df Merge commit '45ee556d51ef04d79d52bf6b0b7f28a4d231cb0c'
* commit '45ee556d51ef04d79d52bf6b0b7f28a4d231cb0c':
  qdm2: Whitespace cosmetics
  flac: use meaningful return values

Conflicts:
	libavcodec/flacdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-29 11:34:07 +02:00
Luca Barbato
0e78ef0f94 flac: use meaningful return values 2013-07-28 14:58:18 +02:00