summaryrefslogtreecommitdiff
path: root/libavcodec/pngdec.c
Commit message (Collapse)AuthorAgeFilesLines
* png: set AVFrame flags/fields before calling setup_finished().Ronald S. Bultje2017-04-031-2/+2
| | | | | | | | | | | Fixes tsan warnings in fate-apng: WARNING: ThreadSanitizer: data race (pid=51230) Read of size 4 at 0x7d50000042fc by main thread (mutexes: write M1000): #0 frame_copy_props frame.c:302 (ffmpeg:x86_64+0x1019a35d6) [..] Previous write of size 4 at 0x7d50000042fc by thread T1 (mutexes: write M997): #0 decode_idat_chunk pngdec.c:708 (ffmpeg:x86_64+0x100f5562a)
* png: split header state and data state in two separate variables.Ronald S. Bultje2017-04-031-26/+39
| | | | | | | | | | | Fixes a reported (but false) race condition in tsan for fate-apng: WARNING: ThreadSanitizer: data race (pid=6274) Read of size 4 at 0x7d680001ec78 by main thread (mutexes: write M1338): #0 update_thread_context src/libavcodec/pngdec.c:1456 (ffmpeg+0x000000dacf0c) [..] Previous write of size 4 at 0x7d680001ec78 by thread T1 (mutexes: write M1335): #0 decode_idat_chunk src/libavcodec/pngdec.c:737 (ffmpeg+0x000000dae951)
* lavc: use av_fourcc2str() where appropriateClément Bœsch2017-03-291-5/+2
|
* avcodec/pngdec: Fix runtime error: left shift of 152 by 24 places cannot be ↵Michael Niedermayer2017-02-251-1/+1
| | | | | | | | | represented in type 'int' Fixes: 666/clusterfuzz-testcase-6581447227867136 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pngdec: Check bit depth for validityMichael Niedermayer2017-02-191-0/+9
| | | | | | | | | | Fixes: runtime error: shift exponent 132 is too large for 32-bit type 'int' Fixes: 609/clusterfuzz-testcase-4825202619842560 See 11.2.2 IHDR Image header Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pngdec: Store metadata directly into AVFrameMichael Niedermayer2017-02-191-8/+5
| | | | | | | | Fixes memleak Fixes: 500/clusterfuzz-testcase-6315221727576064 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Mark some codecs with threadsafe init as suchDerek Buitenhuis2017-02-071-1/+2
| | | | | Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pngdec: Check trns more completelyMichael Niedermayer2017-02-041-1/+14
| | | | | | | | Fixes out of array access Fixes: 546/clusterfuzz-testcase-4809433909559296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pngdec: Fix off by 1 size in decode_zbuf()Michael Niedermayer2017-01-231-3/+3
| | | | | | | | Fixes out of array access Fixes: 444/fuzz-2-ffmpeg_VIDEO_AV_CODEC_ID_PNG_fuzzer Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* pngdec: check if previous frame exists instead of trusting sequence_numberAndreas Cadhalpun2016-11-271-1/+2
| | | | | | | | This fixes a segmentation fault caused by calling memcpy with NULL as second argument in handle_p_frame_apng. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* Revert "apngdec: use side data to pass extradata to the decoder"James Almer2016-11-181-21/+2
| | | | | | | | | | | | | This reverts commit e0c6b32046f4bab7d34be77dd2f03b2a80c86d39. Said commit changed the behavior of the demuxer and decoder in a non backwards compatible way. Demuxers should make extradata available at init if possible, and send new extradata as side data within a packet if needed. A better fix for the remuxing crash will follow. Signed-off-by: James Almer <jamrial@gmail.com>
* apngdec: use side data to pass extradata to the decoderAndreas Cadhalpun2016-11-011-2/+21
| | | | | | | | | Fixes remuxing apng streams coming from the apng demuxer. This is a regression since 940b8908b94404a65f9f55e33efb4ccc6c81383c. Found-by: James Almer <jamrial@gmail.com> Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'Clément Bœsch2016-06-211-1/+1
|\ | | | | | | | | | | | | * commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb': cosmetics: Fix spelling mistakes Merged-by: Clément Bœsch <u@pkh.me>
| * cosmetics: Fix spelling mistakesVittorio Giovara2016-05-041-1/+1
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | avcodec/pngdec: Fix alpha detection with skip_frameMichael Niedermayer2016-04-091-0/+1
| | | | | | | | | | | | Fixes Ticket4816 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/pngdec: use av_mod_uintp2James Almer2016-01-291-1/+1
| | | | | | | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* | avcodec/pngdec: Replace assert by request for sample for unsupported TRNS casesMichael Niedermayer2015-11-161-1/+4
| | | | | | | | | | | | | | | | Fixes assertion failure Fixes: 7f646252a30ee28b583aac1f82e7985e/signal_sigabrt_7ffff6ae7cc9_7353_62fc077bf2f454d39e188c69807193a6.png Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavc/pngdec: set FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM capabilityMatthieu Bouron2015-11-151-0/+1
| |
* | apng: use correct size for output bufferAndreas Cadhalpun2015-11-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | The buffer needs s->bpp bytes, at maximum currently 10. Assert that s->bpp is not larger. This fixes a stack buffer overflow. Reviewed-by: wm4 <nfxjfg@googlemail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* | Merge commit '1720791e36f9cc24c05efea5bb275ab52156ce50'Hendrik Leppkes2015-11-021-7/+9
|\ \ | |/ | | | | | | | | | | * commit '1720791e36f9cc24c05efea5bb275ab52156ce50': png: read and write stereo3d frame side data information Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * png: read and write stereo3d frame side data informationKirill Gavrilov2015-10-301-0/+18
| | | | | | | | | | | | | | Use optional sTER chunk defining side-by-side stereo pair within "Extensions to the PNG 1.2 Specification", version 1.3.0. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | lavc/pngdec: honor skip_frame optionMatthieu Bouron2015-10-291-0/+32
| |
* | avcodec/png: read and write stereo3d frame side data informationKirill Gavrilov2015-10-281-0/+16
| | | | | | | | | | | | | | Use optional sTER chunk defining side-by-side stereo pair within "Extensions to the PNG 1.2 Specification", version 1.3.0. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/pngdec: Use av_malloc_array()Michael Niedermayer2015-10-111-1/+1
| | | | | | | | | | Suggested-by: ubitux Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/pngdec: Alloc buffer after blend_op check in handle_p_frame_apng()Michael Niedermayer2015-10-111-4/+6
| | | | | | | | | | | | | | Avoids memleak on error Fixes CID1322342 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/pngdec: Check blend_op.Michael Niedermayer2015-10-111-0/+5
| | | | | | | | | | | | Fixes CID1322359, CID1322358 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec: use HAVE_THREADS header guards to silence -Wunused-functionGanesh Ajjanagadde2015-10-041-0/+2
| | | | | | | | | | | | | | | | | | | | 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>
* | avcodec/pngdec: mark previous_picture as done on end of decode_frame_common()Michael Niedermayer2015-10-011-0/+2
| | | | | | | | | | | | | | | | Fixes deadlock with threads Found-by: Paul B Mahol Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/pngdec: reset has_trns after every decode_frame_png()Paul B Mahol2015-09-281-1/+1
| | | | | | | | | | | | Fixes #4887. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avcodec/pngdec: fully support the tRNS chunkDonny Yang2015-08-311-9/+89
| | | | | | | | Signed-off-by: Donny Yang <work@kota.moe>
* | Merge commit '4fee11ab05fc8569ef35c0ce86a60375c903eefb'Hendrik Leppkes2015-08-051-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | * commit '4fee11ab05fc8569ef35c0ce86a60375c903eefb': png: Be more informative regarding signature errors Conflicts: libavcodec/pngdec.c Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * png: Be more informative regarding signature errorsLuca Barbato2015-08-021-3/+17
| | | | | | | | Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'Michael Niedermayer2015-07-271-2/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * lavc: AV-prefix all codec capabilitiesVittorio Giovara2015-07-271-1/+1
| | | | | | | | | | | | Express bitfields more simply. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | apng: Fix decoding images with the PREVIOUS dispose opDonny Yang2015-07-221-20/+27
| |
* | avcodec/apngdec: Fix typos in decoder causing incorrect resultsDonny Yang2015-07-201-5/+6
| | | | | | | | Signed-off-by: Donny Yang <work@kota.moe>
* | avcodec/pngdec: Check values before updating context in decode_fctl_chunk()Michael Niedermayer2015-06-291-13/+21
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pngdec: Copy IHDR & plte state from last threadMichael Niedermayer2015-06-291-8/+15
| | | | | | | | | | | | | | | | | | | | Previously these chunks where parsed again for each frame with threads but not without leading to a different path and the potential for inconsistencies This also removes a related special case from decode_ihdr_chunk() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pngdec: Require a IHDR chunk before fctlMichael Niedermayer2015-06-291-0/+5
| | | | | | | | | | | | This is required by the APNG spec Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pngdec: Only allow one IHDR chunkMichael Niedermayer2015-06-291-0/+5
| | | | | | | | | | | | | | | | | | | | Multiple IHDR chunks are forbidden in PNG Fixes inconsistency and out of array accesses Fixes: asan_heap-oob_4d5c5a_1738_cov_2638287726_c-m2-8f2b481b7fd9bd745e620b7c01a18df2.png Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/apng: Add partial support for blending with PAL8 pixel formatDonny Yang2015-06-081-1/+14
| | | | | | | | | | | | | | | | | | Currently restricted to blending pixels that only contain either 0 or 255 in their alpha components Signed-off-by: Donny Yang <work@kota.moe> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/apng: Add support for blending with GRAY8A pixel formatDonny Yang2015-06-081-1/+7
| | | | | | | | | | | | Signed-off-by: Donny Yang <work@kota.moe> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/apng: Add blending support for non-alpha pixel formatsDonny Yang2015-06-081-0/+15
| | | | | | | | | | | | Signed-off-by: Donny Yang <work@kota.moe> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/apng: Dispose previous frame properlyDonny Yang2015-06-081-87/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec specifies the dispose operation as how the current (i.e., currently being rendered) frame should be disposed when the next frame is blended onto it This is contrary to ffmpeg's current behaviour of interpreting the dispose operation as how the previous (i.e., already rendered) frame should be disposed This patch fixes ffmpeg's behaviour to match those of the spec, which involved a rewrite of the blending function Signed-off-by: Donny Yang <work@kota.moe> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/apng: Remove blending support for AV_PIX_FMT_ARGBDonny Yang2015-06-031-6/+1
| | | | | | | | | | | | | | | | ARGB is not a supported PNG pixel format Signed-off-by: Donny Yang <work@kota.moe> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'b9f7a677083647d85e583d6d7384938766a293d7'Michael Niedermayer2015-05-101-2/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit 'b9f7a677083647d85e583d6d7384938766a293d7': png: Set the color range as full range Conflicts: libavcodec/pngdec.c See: 72e7553125e61847d9cab77fb7de62440dca746b Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * png: Set the color range as full rangewm42015-05-091-0/+2
| | | | | | | | | | | | The format uses full range for the gray formats. CC: libav-stable@libav.org
* | pngdec: set correct rangewm42015-05-081-0/+2
| | | | | | | | | | | | | | | | | | | | AV_PIX_FMT_GRAY8/16 are considered YUV formats, and the color_range is not set - so the API user will have to assume limitted range. (Unless the API user adds a special-case for the PNG decoder.) Just export the correct range - full range. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | pngdec: don't use AV_PIX_FMT_MONOBLACK for apngAndreas Cadhalpun2015-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | AV_PIX_FMT_MONOBLACK has the AV_PIX_FMT_FLAG_BITSTREAM flag, i.e. linesize can be smaller than width. Since x_offset is only check against the width, this can lead to x_offset * bpp >= image_linesize. In this case ptr could be set to a position outside the image_buf in png_handle_row, leading to memory corruption and thus crashes. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | pngdec: return correct error code from decode_frame_commonAndreas Cadhalpun2015-05-031-5/+10
| | | | | | | | | | | | | | | | During the loop ret can get changed. Since it is not set on all failure paths, decode_frame_common can return 0 even though an error occurred. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>