1
0
Fork 0
Commit Graph

76 Commits

Author SHA1 Message Date
Andreas Rheinhardt 05086a6c93 avcodec/mjpegdec: Only use receive_frame for SMVJPEG
Only one codec using mjpegdec.c actually creates multiple
frames from a single packet, namely SMVJPEG. The other can
use the ordinary decode callback just fine. This e.g. has
the advantage of confining the special SP5X/AMV code to sp5xdec.c.

This reverts most of commit e9a2a8777317d91af658f774c68442ac4aa726ec;
of course it is not a simple revert: Way too much has changed;
furthermore, outright reverting the sp5xdec.c changes would readd
a stack packet to sp5x_decode_frame() which is not desired.
In order to avoid this without modifying the given AVPacket,
a variant of ff_mjpeg_decode_frame() with explicit buf and size
parameters has been added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-10 21:15:27 +01:00
Andreas Rheinhardt 3cdfb146b2 avcodec/mjpegdec: Only keep what is used from ScanTable
Namely ScanTable.permutated.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-24 00:47:10 +02:00
Michael Niedermayer 7f6ada4eea avcodec/mjpegdec: Decode to PAL8 independant of the location of LSE
This simply performs a 2nd pass if a LSE is encountered with GRAY8

Fixes: tickets/3933/128.jls

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-03 21:34:22 +02:00
Michael Niedermayer 9fd06a3639 Revert "avcodec/mjpegdec: postpone calling ff_get_buffer() until the SOS marker"
This also temporary disables fate-jpegls which is re-enabled in the next commit

This reverts commit c8197f73e6.
2021-05-03 21:34:22 +02:00
James Almer c8197f73e6 avcodec/mjpegdec: postpone calling ff_get_buffer() until the SOS marker
With JPEG-LS PAL8 samples, the JPEG-LS extension parameters signaled with
the LSE marker show up after SOF but before SOS. For those, the pixel format
chosen by get_format() in SOF is GRAY8, and then replaced by PAL8 in LSE.
This has not been an issue given both pixel formats allocate the second data
plane for the palette, but after the upcoming soname bump, GRAY8 will no longer
do that. This will result in segfauls when ff_jpegls_decode_lse() attempts to
write the palette on a buffer originally allocated as a GRAY8 one.

Work around this by calling ff_get_buffer() after the actual pixel format is
known.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-25 10:57:29 -03:00
Andreas Rheinhardt 718e03e5f2 avcodec/jpeglsdec: Don't presume the context to contain a JLSState
Before 9b3c46a081 every call to
ff_jpegls_decode_picture() allocated and freed a JLSState. This commit
instead put said structure into the context of the JPEG-LS decoder to
avoid said allocation. But said function can also be called from other
MJPEG-based decoders and their contexts doesn't contain said structure,
leading to segfaults. This commit fixes this: The JLSState is now
allocated on the first call to ff_jpegls_decode_picture() and stored in
the context.

Found-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-20 21:19:29 +02:00
Andreas Rheinhardt a5b2f06b0c avcodec/mjpegdec: Fix leak in case ICC array allocations fail partially
If only one of the two arrays used for the ICC profile could be
successfully allocated, it might be overwritten and leak when
the next ICC entry is encountered. Fix this by using a common struct,
so that one has only one array to allocate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-03 22:26:51 +02:00
Andreas Rheinhardt d26198ada3 avcodec/g2meet, mjpegdec: Factor out common VLC initialization code
While just at it, remove the nb_codes parameter: It is redundant
(the number of codes is implicitly contained in the array containing how
many entries of a specific size there are) and for this reason it might
even be wrong, so it is better to check what is actually used instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-23 10:14:25 +01:00
Anton Khirnov 15baa0c1ac lavc/mjpegdec: cosmetics, org->orig 2021-01-01 14:33:47 +01:00
Anton Khirnov e15371061d lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
They are not properly namespaced and not intended for public use.
2021-01-01 14:14:57 +01:00
Anton Khirnov 19ce064239 smvjpegdec: merge into mjpegdec
SMVJPEG stores frames as slices of a big JPEG image. The decoder is
implemented as a wrapper that instantiates a full internal MJPEG
decoder, then forwards the decoded frames with offset data pointers.
This is unnecessarily complex and fragile, not supporting useful decoder
capabilities like direct rendering.

Re-implement the decoder inside the MJPEG decoder, which is accomplished
by returning each decoded frame multiple times, setting cropping
information appropriately on each instance.

One peculiar aspect of the previous design is that since
- the smvjpeg decoder returns one frame per input packet
- there are multiple frames in each packets (the aformentioned slices)
the demuxer needs to return each packet multiple times.
This is now also eliminated - the demuxer now returns each packet
exactly once, with the duration set to the number of frames it decodes
to.

This also removes one of the last remaining internal uses of the old
video decoding API.
2020-12-10 10:07:09 +01:00
Anton Khirnov e9a2a87773 mjpegdec: convert to receive_frame()
This will be useful in the following commit.
2020-12-10 10:03:58 +01:00
Nick Renieris 40abff05d2 lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs
Main image data in DNGs is usually comprised of tiles, each of which is a Huffman-encoded lossless JPEG.

Tested for ljpeg regressions with:
`ffmpeg -f lavfi -i testsrc=d=1 -vcodec ljpeg test.avi`
`ffmpeg test.avi out.avi`
The modified code in ljpeg_decode_rgb_scan runs without issues.

Signed-off-by: Nick Renieris <velocityra@gmail.com>
2019-09-02 09:26:52 +02:00
Michael Niedermayer 8d381b57fd avcodec/mjpegdec: Check input buffer size.
Fixes: Timeout
Fixes: 6381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5665032743419904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-04-12 23:52:59 +02:00
Mark Thompson 6c0bfa30c0 mjpegdec: Add hwaccel hooks
Also adds some extra fields to the main context structure that may
be needed by a hwaccel decoder.
2018-02-21 23:38:10 +00:00
Mateusz 149268b47c fix MSVC compilation errors
After commit 3701d49 'error_resilience: remove avpriv_atomic usage'
we have included windows.h in much more files and we should
avoid conflicts with defines/function declarations.

Signed-off-by: Mateusz Brzostek <mateuszb@poczta.onet.pl>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-12-10 14:43:01 +01:00
Martin Vignali cbbec68847 libavcodec/blockdsp : add AVX version
Also modify the required alignment, to 32 instead of 16
for several codecs

Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-03 19:47:37 -03:00
Derek Buitenhuis 9e02f35f6a mjpeg: Add support for ICC side data
JPEGs store embedded profiles under the APP2 marker, signified
with a "ICC_PROFILE" null-terminated string header, and can be
split across multiple APP2 markers, out of order.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-08-25 13:44:41 +01:00
Michael Niedermayer 23f3f92361 avcodec/mjpegdec: quant_matrixes can be up to 65535, use uint16_t
Fixes invalid shift
Fixes: 870/clusterfuzz-testcase-5649105424482304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-20 01:38:04 +01:00
Michael Niedermayer dde6b2a355 avcodec/mjpegdec: dont try to combine fields for decimated multiscope 2 material
Fixes Ticket4535

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-21 02:53:06 +02:00
Michael Niedermayer e15455891b avcodec/mjpegdec: Change upscale_* to an array instead of a bitmask
This allows storing integer factors instead of just 0 and 1

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-18 23:13:44 +01:00
Michael Niedermayer d5a3a20d1e avcodec/mjpegdec: simplify chroma_height calculation
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-21 21:36:17 +02:00
Michael Niedermayer 581b5f0b9b Merge commit 'e3fcb14347466095839c2a3c47ebecff02da891e'
* commit 'e3fcb14347466095839c2a3c47ebecff02da891e':
  dsputil: Split off IDCT bits into their own context

Conflicts:
	configure
	libavcodec/aic.c
	libavcodec/arm/Makefile
	libavcodec/arm/dsputil_init_arm.c
	libavcodec/arm/dsputil_init_armv6.c
	libavcodec/asvdec.c
	libavcodec/dnxhdenc.c
	libavcodec/dsputil.c
	libavcodec/dvdec.c
	libavcodec/dxva2_mpeg2.c
	libavcodec/intrax8.c
	libavcodec/mdec.c
	libavcodec/mjpegdec.c
	libavcodec/mjpegenc_common.h
	libavcodec/mpegvideo.c
	libavcodec/ppc/dsputil_altivec.h
	libavcodec/ppc/dsputil_ppc.c
	libavcodec/ppc/idctdsp.c
	libavcodec/x86/Makefile
	libavcodec/x86/dsputil_init.c
	libavcodec/x86/dsputil_mmx.c
	libavcodec/x86/dsputil_x86.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-01 15:22:11 +02:00
Diego Biurrun e3fcb14347 dsputil: Split off IDCT bits into their own context 2014-06-30 07:58:46 -07:00
Michael Niedermayer 2b05db4f81 Merge commit 'e74433a8e6fc00c8dbde293c97a3e45384c2c1d9'
* commit 'e74433a8e6fc00c8dbde293c97a3e45384c2c1d9':
  dsputil: Split clear_block*/fill_block* off into a separate context

Conflicts:
	configure
	libavcodec/asvdec.c
	libavcodec/dnxhddec.c
	libavcodec/dnxhdenc.c
	libavcodec/dsputil.h
	libavcodec/eamad.c
	libavcodec/intrax8.c
	libavcodec/mjpegdec.c
	libavcodec/ppc/dsputil_ppc.c
	libavcodec/vc1dec.c
	libavcodec/x86/dsputil_init.c
	libavcodec/x86/dsputil_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-19 04:54:38 +02:00
Diego Biurrun e74433a8e6 dsputil: Split clear_block*/fill_block* off into a separate context 2014-06-18 14:07:23 -07:00
Michael Niedermayer 254f653b24 avcodec/jpeglsdec: add PAL8 support
Fixes Ticket3478

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-01 13:43:44 +02:00
Michael Niedermayer 681e72a668 avcodec/mjpegdec: parse adobe_transform
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-27 20:13:48 +01:00
Michael Niedermayer 2884688bd5 avcodec/mjpegdec: pass into ff_mjpeg_decode_sos() and check bitmask size
Fixes: heap array overread
Fixes: asan_heap-oob_149b2bc_6577_m1.mxg
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-31 18:34:08 +01:00
Kirill Gavrilov e9e7e68516 mjpegdec: parse JPS extension and save relevant stereo3d information
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-30 00:17:02 +01:00
Michael Niedermayer cab5315519 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  mjpegdec: apply flipping after decoding, not before

Conflicts:
	libavcodec/mjpegdec.c
	libavcodec/mjpegdec.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-09 15:46:31 +01:00
Anton Khirnov d48132b7de mjpegdec: apply flipping after decoding, not before
This is simpler and removes a silly restriction on edges being present.
2014-01-09 09:56:51 +01:00
Michael Niedermayer 6393038676 Merge commit 'e2274aa555f023e4f4e4819bf29b2d7e0adec7d5'
* commit 'e2274aa555f023e4f4e4819bf29b2d7e0adec7d5':
  mjpegdec: use the AVFrame API properly.

Conflicts:
	libavcodec/mjpegdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-09 12:42:10 +01:00
Anton Khirnov e2274aa555 mjpegdec: use the AVFrame API properly. 2013-12-09 08:40:29 +01:00
Thilo Borgmann bb4e1b4cf9 avcodec/mjpegdec: Read EXIF metadata in JPEG input.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-13 00:30:34 +02:00
Michael Niedermayer 96747e6cbe mjpegdec: parse app-xfrm
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-11 16:08:49 +02:00
Michael Niedermayer 7afa68d37d mjpegdec: parse app-colr
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-11 16:08:36 +02:00
Michael Niedermayer 15cee5e562 mjpegdec: Fix used quant index for gbr
Fixes Ticket1651

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-11 02:31:58 +02:00
Ronald S. Bultje 28bc406c84 mjpeg: Use hpeldsp instead of dsputil for half-pel functions
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-04-19 23:18:38 +03:00
Ronald S. Bultje e0a8f31591 mjpeg: use hpeldsp instead of dsputil for half-pel functions. 2013-03-13 03:59:10 +01:00
Michael Niedermayer ac8987591f Merge commit '88bd7fdc821aaa0cbcf44cf075c62aaa42121e3f'
* commit '88bd7fdc821aaa0cbcf44cf075c62aaa42121e3f':
  Drop DCTELEM typedef

Conflicts:
	libavcodec/alpha/dsputil_alpha.h
	libavcodec/alpha/motion_est_alpha.c
	libavcodec/arm/dsputil_init_armv6.c
	libavcodec/bfin/dsputil_bfin.h
	libavcodec/bfin/pixels_bfin.S
	libavcodec/cavs.c
	libavcodec/cavsdec.c
	libavcodec/dct-test.c
	libavcodec/dnxhdenc.c
	libavcodec/dsputil.c
	libavcodec/dsputil.h
	libavcodec/dsputil_template.c
	libavcodec/eamad.c
	libavcodec/h264_cavlc.c
	libavcodec/h264idct_template.c
	libavcodec/mpeg12.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo.h
	libavcodec/mpegvideo_enc.c
	libavcodec/ppc/dsputil_altivec.c
	libavcodec/proresdsp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-23 17:44:56 +01:00
Diego Biurrun 88bd7fdc82 Drop DCTELEM typedef
It does not help as an abstraction and adds dsputil dependencies.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2013-01-22 18:32:56 -08:00
Michael Niedermayer fc1152de41 Merge commit 'df9b9567518f2840d79a4a96b447ebe1aa326408'
* commit 'df9b9567518f2840d79a4a96b447ebe1aa326408':
  lavc: fix decode_frame() third parameter semantics for video decoders

Conflicts:
	libavcodec/cscd.c
	libavcodec/eamad.c
	libavcodec/ffv1dec.c
	libavcodec/gifdec.c
	libavcodec/h264.c
	libavcodec/iff.c
	libavcodec/mjpegdec.c
	libavcodec/pcx.c
	libavcodec/vp56.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-05 17:20:19 +01:00
Anton Khirnov df9b956751 lavc: fix decode_frame() third parameter semantics for video decoders
It's got_frame, not data size
2012-12-04 21:45:36 +01:00
Lou Logan 6851130fd6 cosmetics: minor libavcodec spelling errors
Also update some common misspelled words in patcheck

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-29 14:54:15 +02:00
Carl Eugen Hoyos d185278c36 Support decoding of some unusual jpeg samples.
Avoid unsupported pix_fmts by upscaling chroma.

Fixes ticket #878.
2012-01-06 00:51:31 +01:00
Carl Eugen Hoyos 387d86077f Support decoding yuv442 and yuv421 jpeg images.
Fixes ticket #787.
2011-12-27 18:21:38 +01:00
Michael Niedermayer 0ed7bc49a3 Merge remote-tracking branch 'qatar/master'
* qatar/master: (31 commits)
  libx264: set default thread count to 0 (auto)
  lavc: cosmetics, group deprecated codec flags
  mpeg12: add 'scan_offset' private option.
  h263/p encoder: add 'structured_slices' private option.
  h263/p encoder: add 'obmc' private option.
  h263p encoder: add 'aiv' private option.
  h263p encoder: add 'umv' private option.
  mpeg12enc/mpeg4videoenc: add 'alternate_scan' private option.
  mjpegdec: add 'extern_huff' private option.
  mpeg4enc: add 'data_partitioning' private option.
  snow: add 'memc_only' private option.
  libx264: add 'mbtree' private option.
  libx264: add 'psy' private option.
  libmp3lame: add 'reservoir' private option.
  mpeg2enc: add 'non_linear_quant' private option
  mpeg12enc: add drop_frame_timecode private option.
  mpeg12enc: add intra_vlc private option.
  VC1: Support dynamic dimension changes
  mjpeg: treat external huffman table setup failure as codec init failure if external huffman table use requested
  lavc: deprecate CODEC_FLAG2_BRDO
  ...

Conflicts:
	avconv.c
	libavcodec/libmp3lame.c
	libavcodec/libx264.c
	libavcodec/mjpegdec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegvideo.h
	libavcodec/vc1.c
	libavcodec/vc1dec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-09-01 00:01:21 +02:00
Anton Khirnov 1f0c7020a1 mjpegdec: add 'extern_huff' private option.
Deprecate CODEC_FLAG_EXTERN_HUFF
2011-08-31 13:25:54 +02:00
anatoly dd1e5bfd5e Add support for picture_ptr field in MJpegDecodeContext
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-04-26 22:06:13 +02:00