Compare commits

...

99 Commits

Author SHA1 Message Date
Michael Niedermayer
74700e50bf Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-09 18:33:21 +01:00
chcunningham
00cdf4e4e5 avformat/mov: validate chunk_count vs stsc_data
Bad content may contain stsc boxes with a first_chunk index that
exceeds stco.entries (chunk_count). This ammends the existing check to
include cases where chunk_count == 0. It also patches up the case
when stsc refers to unknown chunks, but stts has no samples (so we
can simply ignore stsc).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1c15449ca9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-08 12:22:37 +01:00
chcunningham
bcc71f30ad avformat/mov.c: require tfhd to begin parsing trun
Detecting missing tfhd avoids re-using tfhd track info from the previous
moof. For files with multiple tracks, this may make a mess of the
avindex and fragindex, which can later trigger av_assert0 in
mov_read_trun().

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3ea87e5d9e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-08 12:22:13 +01:00
Michael Niedermayer
31a1d2aa83 Changelog: update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-04 00:51:42 +01:00
Michael Niedermayer
7816497ba0 avcodec/pgssubdec: Check for duplicate display segments
In such a duplication the previous gets overwritten and leaks

Fixes: memleak
Fixes: 12510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGSSUB_fuzzer-5694439226343424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e35c3d887b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-04 00:32:09 +01:00
Michael Niedermayer
953f97979f avformat/rtsp: Check number of streams in sdp_parse_line()
Fixes: OOM

Found-by: Michael Hanselmann <public@hansmi.ch>
Reviewed-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 497c9b0cce)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 18:03:35 +01:00
Michael Niedermayer
e75a73d629 avformat/rtsp: Clear reply in every iteration in ff_rtsp_connect()
Fixes: Infinite loop

Found-by: Michael Hanselmann <public@hansmi.ch>
Reviewed-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0b50f27635)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:29:41 +01:00
Michael Niedermayer
b482e94e59 avcodec/rasc: Move ff_get_buffer() after frame checks
If the frame1/2 checks fail this avoids doing the allocation of a new frame

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9f4af97aff)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:29:05 +01:00
Michael Niedermayer
0f1332309a avcodec/rasc: Check uncompressed dlta size
We assume that if the compressed size is bigger than if each byte is encoded in a single raw packet
that the data is invalid.

Fixes: Out of memory
Fixes: 12208/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5648916473708544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f4079d5174)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:28:23 +01:00
Michael Niedermayer
f5c9753bfd avcodec/fic: Check that there is input left in fic_decode_block()
Fixes: Timeout
Fixes: 12450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FIC_fuzzer-5661984622641152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit db1c4acd02)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:23:01 +01:00
Michael Niedermayer
d8b8b27dc3 avcodec/ilbcdec: Fix undefined integer overflow lsf2poly()
The addition is moved up into the context where the variable is unsigned avoiding
the undefined behavior

Fixes: runtime error: signed integer overflow: 2147481972 + 4096 cannot be represented in type 'int'
Fixes: 12444/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5755706244857856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4523cc5e75)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:20:38 +01:00
Michael Niedermayer
62f5325ca3 avcodec/ilbcdec: Fix integer overflow in construct_vector()
webrtc contains explicit code to ignore the undefined behavior (RTC_NO_SANITIZE / OverflowingAddS32S32ToS32())

Probably fixes: Integer overflow (unreproducable here)
Probably fixes: 12215/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5767142427852800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c95d0fb239)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:20:24 +01:00
Michael Niedermayer
bcfd82b0be Update for 4.1.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 08:34:57 +01:00
Michael Niedermayer
31fa50f3d9 avcodec/prosumer: Error out if decompress() stops reading data
if 0 is encountered in the LUT then decompress() will continue to output 0 bytes but never read more data.
Without a specification it is impossible to say if this is invalid or a feature.
None of the valid prosumer files tested cause a 0 to be read, so it is likely
not a intended feature.

Fixes: Timeout
Fixes: 11266/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PROSUMER_fuzzer-5681827423977472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 62f8d27ef1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
552733d48b avcodec/tiff: Check for 12bit gray fax
Fixes: Assertion failure
Fixes: 11898/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5759794191794176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ec28a85107)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
a8b5990f45 avutil/imgutils: Optimize memset_bytes() by using av_memcpy_backptr()
This is strongly based on code by Marton Balint, and depends on the previous commit

Fixes: Timeout
Fixes: 11502/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920
Before: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920 in 11209 ms
After:  Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920 in  4104 ms

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f64c0dffa1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
cb6af7dfa1 avutil/mem: Optimize fill32() by unrolling and using 64bit
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 12b1338be3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
James Almer
29d978c91e configure: bump year
Happy new year!

(cherry picked from commit 3209d7b393)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
3a52cae2c7 avcodec/tests/rangecoder: initialize array to avoid valgrind warning
Found-by: jamrial
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c15972f0af)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
792df36f42 avcodec/gdv: Optimize and factorize scaling loops
Fixes: Timeout
Fixes: 11067/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5686623711264768

Before change: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5686623711264768 in 34386 ms
After  change: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5686623711264768 in 24327 ms

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6e23736aef)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
c694273feb avcodec/h264_slice: Fix integer overflow in implicit_weight_table()
Fixes: signed integer overflow: 2 * 2132811760 cannot be represented in type 'int'
Fixes: 11156/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6237685933408256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 77e56d74f9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
9239d58b36 avcodec/exr: set layer_match in all branches
Otherwise it is left to the value from the previous iteration

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 433d2ae435)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
1623f42d99 avcodec/exr: Check for duplicate channel index
Fixes: Out of memory
Fixes: 11582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5730204559867904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f9728feaf9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
99576bf034 avfilter/vf_tonemap_opencl: Make static tables const
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 47c3a10b16)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
e385fc45dd doc/indevs: fix upto typo
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b33de55747)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
15857674c5 avcodec/4xm: Fix returned error codes
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 07607a1db8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
6b6c854658 avformat/libopenmpt: Fix successfull typo
Reviewed-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 571af98a59)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
41ee513c81 avcodec/v4l2_m2m: fix cant typo
Reviewed-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 062bf56393)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
33b4aba5bd avcodec/mjpegbdec: Fix some misplaced {} and spaces
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 11a8d2ccab)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
David Bryant
ea279bd160 avformat/wvdec: detect and error out on WavPack DSD files
Not currently supported.

(cherry picked from commit db109373d8)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
gxw
929b5519d8 avcodec/mips: Fix failed case: hevc-conformance-AMP_A_Samsung_* when enable msa
The AV_INPUT_BUFFER_PADDING_SIZE has been increased to 64, but the value is still 32
in function ff_hevc_sao_edge_filter_8_msa. So, use AV_INPUT_BUFFER_PADDING_SIZE directly.
Also, use MAX_PB_SIZE directly instead of 64. Fate tests passed.

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f652c7a45c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
5ed024e40b avcodec/fic: Fail on invalid slice size/off
Fixes: Timeout
Fixes: 11486/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FIC_fuzzer-5677133863583744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 30a7a81cdc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
5550946ff4 avcodec/ilbcdec: fix integer overflow in energy
webrtc uses a int32_t like the existing code in ilbcdec

Fixes: signed integer overflow: 2080245063 + 257939661 cannot be represented in type 'int'
Fixes: 11037/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5682976612941824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit fbf409cd91)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
daef9d4382 postproc/postprocess_template: remove FF_REG_sp from clobber list
Future gcc may no longer support this

Tested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c1cbeb87db)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
69f50eb915 postproc/postprocess_template: Avoid using %4 for the threshold compare
This avoids problems if %4 is the stack pointer
the constraints do not allow %4 to be the stack pointer but gcc 9 may
no longer support specifying such constraints

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4325527e1c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Jacob Trimble
73c90818b1 libavformat/mov: Fix NULL-dereference read for some encrypted content.
When reading frames, we need to use the fragment for the correct
stream.  Sometimes the "current" fragment is not the same as the one
the frame is for.

Found by Chromium's ClusterFuzz:
https://crbug.com/906392 and https://crbug.com/915524

Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 555f332e7a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
c22b67feaa avcodec/rpza: Check that there is enough data for all the blocks
Fixes: Timeout
Fixes: 11547/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RPZA_fuzzer-5678435842654208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e63517e00a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
4c0be3a60c avcodec/rpza: Move frame allocation to a later point
This will allow performing some fast checks before the slow allocation

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8a708aa99c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
42357b37cb avcodec/avcodec: Document the data type for AV_PKT_DATA_MPEGTS_STREAM_ID
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 68e011e410)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
e3fbbb7d18 avformat/mpegts: Fix side data type for stream id
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ab1319d82f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
2f75965c47 tests/fate/filter-video: increase fuzz for fate-filter-refcmp-psnr-rgb
Fixes: test failure on powerpc

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f8f762c300)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
e1f40f0dae avcodec/mjpegdec: Fix indention of ljpeg_decode_yuv_scan()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ea30ac1e40)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
chcunningham
45f5f2086e lavf/id3v2: fail read_apic on EOF reading mimetype
avio_read may return EOF, leaving the mimetype array unitialized. fail
early when this occurs to avoid using the array in an unitialized state.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ee1e39a576)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
321c418b87 avcodec/rasc: Check that the number of moves is less than or equal the number of pixels
Fixes: OOM
Fixes: 10307/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5393974559244288

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 092cb17983)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
f5859d4a8e avformat/nutenc: Document trailer index assert better
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3a95b73abc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
chcunningham
54fbdacc37 lavf/mov: ensure only one tkhd per trak
Chromium fuzzing produced a whacky file with extra tkhds. This caused
an AVStream that was already in use to be corrupted by assigning it a
new id, which blows up later in mov_read_trun because the
MOVFragmentStreamInfo.index_entry now points OOB.

Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c9f7b6f7a9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
228f17ced3 avcodec/clearvideo: Check remaining input bits in P macro block loop
Fixes: Timeout
Fixes: 11083/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5657180351496192

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7aaab127be)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
9b5a6bb67b avcodec/rasc: Check input space before reading chunk
Fixes: Timeout
Fixes: 11118/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5652564066959360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 52ba824c65)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
219cbc5527 avcodec/dxv: Check that there is enough data to decompress
Fixes: Timeout
Fixes: 10979/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_fuzzer-6178582203203584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2bc3811c0d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
55c36d2498 avcodec/ppc/hevcdsp: Fix build failures with powerpc-linux-gnu-gcc-4.8 with --disable-optimizations
The affected functions could also be changed into macros, this is the
smaller change to fix it though. And avoids (probably) less readable macros
The extra code should be optimized out when optimizations are done as all values
are known at build after inlining.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2c64a6bcd2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
558ba71de5 avcodec/msvideo1: Check for too small dimensions
Such low resolution would result in empty output as a minimum of 4x4 is needed
We could also check for multiple of 4 dimensions but that is not needed

Fixes: Timeout
Fixes: 11191/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSVIDEO1_fuzzer-5739529588178944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 953bd58861)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
1a5db666ac avcodec/wmv2dec: Skip I frame if its smaller than 1/8 of the minimal size
Frames that small are not valid and of limited use for error concealment, while
being very computationally intensive to process.

Fixes: Timeout
Fixes: 11168/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV2_fuzzer-5733782032744448

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d6f4341522)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
eee0cf487a avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size
Frames that small are not valid and of limited use for error concealment, while
being very computationally intensive to process.

Fixes: Timeout
Fixes: 11318/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSMPEG4V1_fuzzer-5710884555456512

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 09ec182864)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
90db1e441f avcodec/truemotion2rt: Fix rounding in input size check
Fixes: Timeout
Fixes: 11332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2RT_fuzzer-5678456612847616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7f22a4ebc9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
4fe90900d8 avcodec/diracdec: Check component quant
Fixes: Timeout
Fixes: 10708/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5730140957442048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 28c96c2ce2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:26 +01:00
Michael Niedermayer
ee349bd0fd avcodec/tiff: Limit filtering to decoded data
Fixes: Timeout
Fixes: 11068/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5698456681709568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 90ac0e5f29)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Michael Niedermayer
ab744447e1 avcodec/truemotion2: fix integer overflows in tm2_low_chroma()
Fixes: 11295/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-4888953459572736

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2ae39d7956)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Michael Niedermayer
89d65915cf avcodec/pngdec: Check compression method
method 0 (inflate/deflate) is the only specified in the specification and the only supported

Fixes: Timeout
Fixes: 10976/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-5729372588736512

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1f99674ddd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Michael Niedermayer
e69bb0fb05 fftools/ffmpeg: Repair reinit_filter feature
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3504004879)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Michael Niedermayer
98a9d868d1 avcodec/shorten: Fix integer overflow with offset
Fixes: signed integer overflow: -1625810908 - 582229060 cannot be represented in type 'int'
Fixes: 10977/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5732602018267136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2f888771cd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Michael Niedermayer
b66152a4e5 avcodec/imm4: Use ff_set_dimensions()
Fixes: Out of memory
Fixes: 10970/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM4_fuzzer-5698750043914240

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c305e134ce)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Andreas Rheinhardt
ac50246cc4 h264_redundant_pps: Fix logging context
The first element of H264RedundantPPSContext is not a pointer to an
AVClass as required.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6dafcb6fdb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-21 07:53:25 +01:00
Marton Balint
ddc284300e avfilter/af_asetnsamples: fix last frame props
Frame properties were not copied, so e.g. PTS was not set for the last frame.

Regression since ef3babb2c7.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit f9e947845f)
2019-01-01 20:39:44 +01:00
Mark Thompson
b420f23566 cbs_av1: Fix reading of overlong uvlc codes
The specification allows 2^32-1 to be encoded as any number of zeroes
greater than 31, followed by a one.  This previously failed because the
trace code would overflow the array containing the string representation
of the bits if there were more than 63 zeroes.  Fix that by splitting the
trace output into batches, and at the same time move it out of the default
path.

(While this seems likely to be a specification error, libaom does support
it so we probably should as well.)

From a test case by keval shah <skeval65@gmail.com>.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b97a4b6588)
2018-12-22 18:28:41 +00:00
James Almer
5356e61001 avcodec/cbs_av1: fix parsing delta_frame_id_minus1
delta_frame_id_minus1 is not a single value in the bitstream, and can
store values up to 17 bits wide.

Fixes parsing files with frame ids.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 064f9505f4)
2018-12-20 18:29:42 -03:00
Paul B Mahol
a4ddc3c9fc avfilter/vf_overlay: fix filtering with negative y
(cherry picked from commit 8440835dbe)
2018-12-14 23:56:21 +01:00
Paul B Mahol
59e30c05d7 avformat/movenc: get number of written bytes from bitstream writer
Update fate test.

(cherry picked from commit 97d1ee437b)
2018-11-26 15:36:12 +01:00
Paul B Mahol
fcffed470a avformat/movenc: fix size calculation in mov_write_eac3_tag()
Otherwise it would assert when flushing bits.

(cherry picked from commit 027f032bbc)
2018-11-26 15:36:05 +01:00
Paul B Mahol
9efc591cb7 avfilter/vf_overlay: fix crash with negative y
(cherry picked from commit 57815cfad5)
2018-11-25 12:46:56 +01:00
Marton Balint
d4c5f515f0 avcodec/mpeg_er: fix clearing chroma blocks for 422 and 444
Fixes ticket #7494.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit e3a9630982)
2018-11-19 23:29:30 +01:00
Marton Balint
bb01cd3cc0 avfilter/af_afade: fix duration maximum
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit aecd63b926)
2018-11-15 22:34:53 +01:00
Mark Harris
fed94c2f22 avfilter/vf_fade: fix start/duration max value
A fade out (usually at the end of a video) can easily start beyond
INT32_MAX (about 36 minutes).  Regression since d40dc64173.

(cherry picked from commit ae4323548a)
2018-11-15 22:34:34 +01:00
James Almer
a9e9303f26 avcodec/cbs_av1: fix parsing signed integer values
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit f0f2832a5c)
2018-11-14 20:53:44 -03:00
James Almer
49bc641e89 avcodec/cbs_av1: fix storage size for segmentation_params feature_value fields
The valid range is -255 to 255.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 79831f4531)
2018-11-14 20:53:40 -03:00
Mark Thompson
4f1e07090a configure: Add missing xlib dependency for VAAPI X11 code
Fixes #7538.

(cherry picked from commit 2ce3a48f30)
2018-11-14 23:24:51 +00:00
Mark Wu
11dff170ef avcodec/hevcdec: fix non-ref frame judgement
After inspecting the source code of x265, mpv and ffmpeg, I've found that
ffmpeg mistakenly regards EVC_NAL_BLA_N_LP and HEVC_NAL_IDR_N_LP as non-
reference frames, which are acutally reference frames according to the
specification in x265, and drops them.

This patch should address the problem. I have tested it with mpv.

Signed-off-by: Mark Wu <wfwf1997@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 10bc4c3a7d)
2018-11-10 14:38:25 -03:00
Mark Thompson
10506de9ad cbs_av1: Support redundant frame headers
(cherry picked from commit f5894178fb)
2018-11-05 23:11:03 +00:00
Mark Thompson
af3fccfeff cbs_av1: Fix header writing when already aligned
(cherry picked from commit 6bdb7712ae)
2018-11-05 23:10:57 +00:00
Mark Thompson
ec1b5216fc configure: Add missing V4L2 M2M decoder BSF dependencies
(cherry picked from commit e9d2e3fdaa)
2018-11-05 23:10:49 +00:00
Mark Thompson
066ff02621 configure: Add missing IVF muxer BSF dependency
(cherry picked from commit a4fb2b1150)
2018-11-05 23:10:41 +00:00
James Almer
398a70309e avcodec/cbs_av1: fix decoder/encoder_buffer_delay variable types
buffer_delay_length_minus_1 is five bits long, meaning decode_buffer_delay and
encoder_buffer_delay can have values up to 32 bits long.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 89a0d33e3a)
2018-11-04 22:06:20 -03:00
Mark Thompson
acd13f1255 configure: Fix av1_metadata BSF dependency
(cherry picked from commit 34429182b9)
2018-11-04 22:06:11 -03:00
James Almer
1c98cf4ddd avformat/ivfenc: use the av1_metadata bsf to insert Temporal Delimiter OBUs if needed
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 2d2af23349)
2018-11-04 22:06:08 -03:00
Marton Balint
63c1e291ef avformat/ftp: allow nonstandard 202 reply to OPTS UTF8
Fixes ticket #7481.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 8e5a2495a8)
2018-11-04 22:55:09 +01:00
Michael Niedermayer
7ebc27e1fa avcodec/cavsdec: Propagate error codes inside decode_mb_i()
Fixes: Timeout
Fixes: 10702/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CAVS_fuzzer-5669940938407936

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c1cee05656)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Michael Niedermayer
bc5777bdab avcodec/mpeg4videodec: Clear partitioned frame in decode_studio_vop_header()
partitioned_frame is also set/cleared in decode_vop_header()

Fixes: out of array read
Fixes: 9789/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5638681627983872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 074187d599)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Michael Niedermayer
7d23ccac8d avcodec/mpegaudio_parser: Consume more than 0 bytes in case of the unsupported mp3adu case
Fixes: Timeout
Fixes: 10966/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP3ADU_fuzzer-5348695024336896
Fixes: 10969/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MP3ADUFLOAT_fuzzer-5691669402877952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit df91af140c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Michael Niedermayer
2f04b78b95 avcodec/prosumer: Simplify bit juggling of the c variable in decompress()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 66425add27)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Michael Niedermayer
fd05e20650 avcodec/prosumer: Remove always true check in decompress()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1dfa0b6f36)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Michael Niedermayer
a163384467 avcodec/prosumer: Remove unneeded ()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 506839a3e9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Michael Niedermayer
b9875b7583 avcodec/prosumer: Check for bytestream eof in decompress()
Fixes: Infinite loop
Fixes: 10685/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PROSUMER_fuzzer-5652236881887232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9acdf17b2c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-04 20:26:49 +01:00
Philip Langdale
ebc1c49e41 avfilter/vf_cuda_yadif: Avoid new syntax for vector initialisation
This requires a newer version of CUDA than we want to require.

(cherry picked from commit 8e50215b5e)
2018-11-03 15:50:31 -07:00
Philip Langdale
6feec11e48 avcodec/nvdec: Increase frame pool size to help deinterlacing
With the cuda yadif filter in use, the number of mapped decoder
frames could increase by two, as the filter holds on to additional
frames.

(cherry picked from commit 1b41115ef7)
2018-11-03 15:50:25 -07:00
Philip Langdale
67126555fc avfilter/vf_yadif_cuda: CUDA accelerated yadif deinterlacer
This is a cuda implementation of yadif, which gives us a way to
do deinterlacing when using the nvdec hwaccel. In that scenario
we don't have access to the nvidia deinterlacer.

(cherry picked from commit d5272e94ab)
2018-11-03 15:50:12 -07:00
Philip Langdale
041231fcd6 libavfilter/vf_yadif: Make frame management logic and options shareable
I'm writing a cuda implementation of yadif, and while this
obviously has a very different implementation of the actual
filtering, all the frame management is unchanged. To avoid
duplicating that logic, let's make it shareable.

From the perspective of the existing filter, the only real change
is introducing a function pointer for the filter() function so it
can be specified for the specific filter.

(cherry picked from commit 598f0f3927)
2018-11-03 15:45:55 -07:00
Josh de Kock
765fb1f224 fate/api-h264-slice-test: use cleaner error handling
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1052578dad)
2018-11-03 12:57:51 -03:00
Josh de Kock
5060a615c7 fate/api-h264-slice-test: don't use ssize_t
Fixes ticket #7521

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 8096f52049)
2018-11-03 12:57:37 -03:00
Michael Niedermayer
1665ac6a44 RELEASE_NOTES: Based on the version from 4.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-02 01:36:21 +01:00
Michael Niedermayer
3c7e973430 Update for 4.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-11-02 01:33:08 +01:00
77 changed files with 1682 additions and 473 deletions

View File

@@ -1,6 +1,82 @@
Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest.
version 4.1.1:
- avformat/mov: validate chunk_count vs stsc_data
- avformat/mov: require tfhd to begin parsing trun
- avcodec/pgssubdec: Check for duplicate display segments
- avformat/rtsp: Check number of streams in sdp_parse_line()
- avformat/rtsp: Clear reply in every iteration in ff_rtsp_connect()
- avcodec/rasc: Move ff_get_buffer() after frame checks
- avcodec/rasc: Check uncompressed dlta size
- avcodec/fic: Check that there is input left in fic_decode_block()
- avcodec/ilbcdec: Fix undefined integer overflow lsf2poly()
- avcodec/ilbcdec: Fix integer overflow in construct_vector()
- avcodec/prosumer: Error out if decompress() stops reading data
- avcodec/tiff: Check for 12bit gray fax
- avutil/imgutils: Optimize memset_bytes() by using av_memcpy_backptr()
- avutil/mem: Optimize fill32() by unrolling and using 64bit
- configure: bump year
- avcodec/tests/rangecoder: initialize array to avoid valgrind warning
- avcodec/gdv: Optimize and factorize scaling loops
- avcodec/h264_slice: Fix integer overflow in implicit_weight_table()
- avcodec/exr: set layer_match in all branches
- avcodec/exr: Check for duplicate channel index
- avfilter/vf_tonemap_opencl: Make static tables const
- doc/indevs: fix upto typo
- avcodec/4xm: Fix returned error codes
- avformat/libopenmpt: Fix successfull typo
- avcodec/v4l2_m2m: fix cant typo
- avcodec/mjpegbdec: Fix some misplaced {} and spaces
- avformat/wvdec: detect and error out on WavPack DSD files
- avcodec/mips: Fix failed case: hevc-conformance-AMP_A_Samsung_* when enable msa
- avcodec/fic: Fail on invalid slice size/off
- avcodec/ilbcdec: fix integer overflow in energy
- postproc/postprocess_template: remove FF_REG_sp from clobber list
- postproc/postprocess_template: Avoid using %4 for the threshold compare
- libavformat/mov: Fix NULL-dereference read for some encrypted content.
- avcodec/rpza: Check that there is enough data for all the blocks
- avcodec/rpza: Move frame allocation to a later point
- avcodec/avcodec: Document the data type for AV_PKT_DATA_MPEGTS_STREAM_ID
- avformat/mpegts: Fix side data type for stream id
- tests/fate/filter-video: increase fuzz for fate-filter-refcmp-psnr-rgb
- avcodec/mjpegdec: Fix indention of ljpeg_decode_yuv_scan()
- lavf/id3v2: fail read_apic on EOF reading mimetype
- avcodec/rasc: Check that the number of moves is less than or equal the number of pixels
- avformat/nutenc: Document trailer index assert better
- lavf/mov: ensure only one tkhd per trak
- avcodec/clearvideo: Check remaining input bits in P macro block loop
- avcodec/rasc: Check input space before reading chunk
- avcodec/dxv: Check that there is enough data to decompress
- avcodec/ppc/hevcdsp: Fix build failures with powerpc-linux-gnu-gcc-4.8 with --disable-optimizations
- avcodec/msvideo1: Check for too small dimensions
- avcodec/wmv2dec: Skip I frame if its smaller than 1/8 of the minimal size
- avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size
- avcodec/truemotion2rt: Fix rounding in input size check
- avcodec/diracdec: Check component quant
- avcodec/tiff: Limit filtering to decoded data
- avcodec/truemotion2: fix integer overflows in tm2_low_chroma()
- avcodec/pngdec: Check compression method
- fftools/ffmpeg: Repair reinit_filter feature
- avcodec/shorten: Fix integer overflow with offset
- avcodec/imm4: Use ff_set_dimensions()
- h264_redundant_pps: Fix logging context
- avfilter/af_asetnsamples: fix last frame props
- cbs_av1: Fix reading of overlong uvlc codes
- avcodec/cbs_av1: fix parsing delta_frame_id_minus1
- avfilter/vf_overlay: fix filtering with negative y
- avformat/movenc: get number of written bytes from bitstream writer
- avformat/movenc: fix size calculation in mov_write_eac3_tag()
- avfilter/vf_overlay: fix crash with negative y
- avcodec/mpeg_er: fix clearing chroma blocks for 422 and 444
- avfilter/af_afade: fix duration maximum
- avfilter/vf_fade: fix start/duration max value
- avcodec/cbs_av1: fix parsing signed integer values
- avcodec/cbs_av1: fix storage size for segmentation_params feature_value fields
- configure: Add missing xlib dependency for VAAPI X11 code
- avcodec/hevcdec: fix non-ref frame judgement
version 4.1:
- deblock filter
- tmix filter
@@ -42,6 +118,7 @@ version 4.1:
- xstack filter
- pcm vidc decoder and encoder
- (a)graphmonitor filter
- yadif_cuda filter
version 4.0:

View File

@@ -1 +1 @@
4.0.git
4.1.1

15
RELEASE_NOTES Normal file
View File

@@ -0,0 +1,15 @@
┌─────────────────────────────────────────────┐
│ RELEASE NOTES for FFmpeg 4.1 "al-Khwarizmi" │
└─────────────────────────────────────────────┘
The FFmpeg Project proudly presents FFmpeg 4.1 "al-Khwarizmi", about 6
months after the release of FFmpeg 4.0.
A complete Changelog is available at the root of the project, and the
complete Git history on https://git.ffmpeg.org/gitweb/ffmpeg.git
We hope you will like this release as much as we enjoyed working on it, and
as usual, if you have any questions about it, or any FFmpeg related topic,
feel free to join us on the #ffmpeg IRC channel (on irc.freenode.net) or ask
on the mailing-lists.

7
configure vendored
View File

@@ -2812,6 +2812,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext"
dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32"
ffnvcodec_deps_any="libdl LoadLibrary"
nvdec_deps="ffnvcodec"
vaapi_x11_deps="xlib"
videotoolbox_hwaccel_deps="videotoolbox pthreads"
videotoolbox_hwaccel_extralibs="-framework QuartzCore"
xvmc_deps="X11_extensions_XvMClib_h"
@@ -2957,6 +2958,7 @@ h264_rkmpp_decoder_deps="rkmpp"
h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
h264_v4l2m2m_decoder_select="h264_mp4toannexb_bsf"
h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
hevc_amf_encoder_deps="amf"
hevc_cuvid_decoder_deps="cuvid"
@@ -2971,6 +2973,7 @@ hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
mjpeg_cuvid_decoder_deps="cuvid"
mjpeg_qsv_encoder_deps="libmfx"
@@ -3180,6 +3183,7 @@ image2_alias_pix_demuxer_select="image2_demuxer"
image2_brender_pix_demuxer_select="image2_demuxer"
ipod_muxer_select="mov_muxer"
ismv_muxer_select="mov_muxer"
ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
matroska_audio_muxer_select="matroska_muxer"
matroska_demuxer_select="iso_media riffdec"
matroska_demuxer_suggest="bzlib lzo zlib"
@@ -3481,6 +3485,7 @@ zscale_filter_deps="libzimg const_nan"
scale_vaapi_filter_deps="vaapi"
vpp_qsv_filter_deps="libmfx"
vpp_qsv_filter_select="qsvvpp"
yadif_cuda_filter_deps="cuda_sdk"
# examples
avio_dir_cmd_deps="avformat avutil"
@@ -7238,7 +7243,7 @@ cat > $TMPH <<EOF
#define FFMPEG_CONFIG_H
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
#define FFMPEG_LICENSE "$(c_escape $license)"
#define CONFIG_THIS_YEAR 2018
#define CONFIG_THIS_YEAR 2019
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
#define AVCONV_DATADIR "$(eval c_escape $datadir)"
#define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"

View File

@@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = 4.1.1
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@@ -17943,6 +17943,64 @@ filter").
It accepts the following parameters:
@table @option
@item mode
The interlacing mode to adopt. It accepts one of the following values:
@table @option
@item 0, send_frame
Output one frame for each frame.
@item 1, send_field
Output one frame for each field.
@item 2, send_frame_nospatial
Like @code{send_frame}, but it skips the spatial interlacing check.
@item 3, send_field_nospatial
Like @code{send_field}, but it skips the spatial interlacing check.
@end table
The default value is @code{send_frame}.
@item parity
The picture field parity assumed for the input interlaced video. It accepts one
of the following values:
@table @option
@item 0, tff
Assume the top field is first.
@item 1, bff
Assume the bottom field is first.
@item -1, auto
Enable automatic detection of field parity.
@end table
The default value is @code{auto}.
If the interlacing is unknown or the decoder does not export this information,
top field first will be assumed.
@item deint
Specify which frames to deinterlace. Accept one of the following
values:
@table @option
@item 0, all
Deinterlace all frames.
@item 1, interlaced
Only deinterlace frames marked as interlaced.
@end table
The default value is @code{all}.
@end table
@section yadif_cuda
Deinterlace the input video using the @ref{yadif} algorithm, but implemented
in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
and/or nvenc.
It accepts the following parameters:
@table @option
@item mode

View File

@@ -374,7 +374,7 @@ Defaults to @option{false}.
@item timestamp_align
Capture start time alignment in seconds. If set to nonzero, input frames are
dropped till the system timestamp aligns with configured value.
Alignment difference of upto one frame duration is tolerated.
Alignment difference of up to one frame duration is tolerated.
This is useful for maintaining input synchronization across N different
hardware devices deployed for 'N-way' redundancy. The system time of different
hardware devices should be synchronized with protocols such as NTP or PTP,

View File

@@ -2139,9 +2139,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
/* determine if the parameters for this input changed */
need_reinit = ifilter->format != frame->format;
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
need_reinit = 1;
switch (ifilter->ist->st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -2155,6 +2152,13 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
break;
}
if (!ifilter->ist->reinit_filters && fg->graph)
need_reinit = 0;
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
need_reinit = 1;
if (need_reinit) {
ret = ifilter_parameters_from_frame(ifilter, frame);
if (ret < 0)

View File

@@ -498,7 +498,7 @@ static int decode_i_block(FourXContext *f, int16_t *block)
if (get_bits_left(&f->gb) < 2){
av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->gb));
return -1;
return AVERROR_INVALIDDATA;
}
/* DC coef */
@@ -732,7 +732,7 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
for (x = 0; x < width; x += 16) {
unsigned int color[4] = { 0 }, bits;
if (buf_end - buf < 8)
return -1;
return AVERROR_INVALIDDATA;
// warning following is purely guessed ...
color[0] = bytestream2_get_le16u(&g3);
color[1] = bytestream2_get_le16u(&g3);

View File

@@ -1321,7 +1321,7 @@ enum AVPacketSideDataType {
AV_PKT_DATA_METADATA_UPDATE,
/**
* MPEGTS stream ID, this is required to pass the stream ID
* MPEGTS stream ID as uint8_t, this is required to pass the stream ID
* information from the demuxer to the corresponding muxer.
*/
AV_PKT_DATA_MPEGTS_STREAM_ID,

View File

@@ -591,14 +591,21 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
}
static inline void decode_residual_chroma(AVSContext *h)
static inline int decode_residual_chroma(AVSContext *h)
{
if (h->cbp & (1 << 4))
decode_residual_block(h, &h->gb, chroma_dec, 0,
if (h->cbp & (1 << 4)) {
int ret = decode_residual_block(h, &h->gb, chroma_dec, 0,
ff_cavs_chroma_qp[h->qp], h->cu, h->c_stride);
if (h->cbp & (1 << 5))
decode_residual_block(h, &h->gb, chroma_dec, 0,
if (ret < 0)
return ret;
}
if (h->cbp & (1 << 5)) {
int ret = decode_residual_block(h, &h->gb, chroma_dec, 0,
ff_cavs_chroma_qp[h->qp], h->cv, h->c_stride);
if (ret < 0)
return ret;
}
return 0;
}
static inline int decode_residual_inter(AVSContext *h)
@@ -649,6 +656,7 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
uint8_t top[18];
uint8_t *left = NULL;
uint8_t *d;
int ret;
ff_cavs_init_mb(h);
@@ -692,8 +700,11 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
ff_cavs_load_intra_pred_luma(h, top, &left, block);
h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]
(d, top, left, h->l_stride);
if (h->cbp & (1<<block))
decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
if (h->cbp & (1<<block)) {
ret = decode_residual_block(h, gb, intra_dec, 1, h->qp, d, h->l_stride);
if (ret < 0)
return ret;
}
}
/* chroma intra prediction */
@@ -703,7 +714,9 @@ static int decode_mb_i(AVSContext *h, int cbp_code)
h->intra_pred_c[pred_mode_uv](h->cv, &h->top_border_v[h->mbx * 10],
h->left_border_v, h->c_stride);
decode_residual_chroma(h);
ret = decode_residual_chroma(h);
if (ret < 0)
return ret;
ff_cavs_filter(h, I_8X8);
set_mv_intra(h);
return 0;

View File

@@ -29,45 +29,67 @@ static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc,
const char *name, uint32_t *write_to,
uint32_t range_min, uint32_t range_max)
{
uint32_t value;
int position, zeroes, i, j;
char bits[65];
uint32_t zeroes, bits_value, value;
int position;
if (ctx->trace_enable)
position = get_bits_count(gbc);
zeroes = i = 0;
zeroes = 0;
while (1) {
if (get_bits_left(gbc) < zeroes + 1) {
if (get_bits_left(gbc) < 1) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at "
"%s: bitstream ended.\n", name);
return AVERROR_INVALIDDATA;
}
if (get_bits1(gbc)) {
bits[i++] = '1';
if (get_bits1(gbc))
break;
} else {
bits[i++] = '0';
++zeroes;
}
++zeroes;
}
if (zeroes >= 32) {
value = MAX_UINT_BITS(32);
} else {
value = get_bits_long(gbc, zeroes);
if (get_bits_left(gbc) < zeroes) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid uvlc code at "
"%s: bitstream ended.\n", name);
return AVERROR_INVALIDDATA;
}
for (j = 0; j < zeroes; j++)
bits[i++] = (value >> (zeroes - j - 1) & 1) ? '1' : '0';
value += (1 << zeroes) - 1;
bits_value = get_bits_long(gbc, zeroes);
value = bits_value + (UINT32_C(1) << zeroes) - 1;
}
if (ctx->trace_enable) {
char bits[65];
int i, j, k;
if (zeroes >= 32) {
while (zeroes > 32) {
k = FFMIN(zeroes - 32, 32);
for (i = 0; i < k; i++)
bits[i] = '0';
bits[i] = 0;
ff_cbs_trace_syntax_element(ctx, position, name,
NULL, bits, 0);
zeroes -= k;
position += k;
}
}
for (i = 0; i < zeroes; i++)
bits[i] = '0';
bits[i++] = '1';
if (zeroes < 32) {
for (j = 0; j < zeroes; j++)
bits[i++] = (bits_value >> (zeroes - j - 1) & 1) ? '1' : '0';
}
bits[i] = 0;
ff_cbs_trace_syntax_element(ctx, position, name, NULL,
bits, value);
ff_cbs_trace_syntax_element(ctx, position, name,
NULL, bits, value);
}
if (value < range_min || value > range_max) {
@@ -189,30 +211,26 @@ static int cbs_av1_read_su(CodedBitstreamContext *ctx, GetBitContext *gbc,
int width, const char *name,
const int *subscripts, int32_t *write_to)
{
uint32_t magnitude;
int position, sign;
int position;
int32_t value;
if (ctx->trace_enable)
position = get_bits_count(gbc);
if (get_bits_left(gbc) < width + 1) {
if (get_bits_left(gbc) < width) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid signed value at "
"%s: bitstream ended.\n", name);
return AVERROR_INVALIDDATA;
}
magnitude = get_bits(gbc, width);
sign = get_bits1(gbc);
value = sign ? -(int32_t)magnitude : magnitude;
value = get_sbits(gbc, width);
if (ctx->trace_enable) {
char bits[33];
int i;
for (i = 0; i < width; i++)
bits[i] = magnitude >> (width - i - 1) & 1 ? '1' : '0';
bits[i] = sign ? '1' : '0';
bits[i + 1] = 0;
bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
bits[i] = 0;
ff_cbs_trace_syntax_element(ctx, position,
name, subscripts, bits, value);
@@ -226,29 +244,21 @@ static int cbs_av1_write_su(CodedBitstreamContext *ctx, PutBitContext *pbc,
int width, const char *name,
const int *subscripts, int32_t value)
{
uint32_t magnitude;
int sign;
if (put_bits_left(pbc) < width + 1)
if (put_bits_left(pbc) < width)
return AVERROR(ENOSPC);
sign = value < 0;
magnitude = sign ? -value : value;
if (ctx->trace_enable) {
char bits[33];
int i;
for (i = 0; i < width; i++)
bits[i] = magnitude >> (width - i - 1) & 1 ? '1' : '0';
bits[i] = sign ? '1' : '0';
bits[i + 1] = 0;
bits[i] = value & (1 << (width - i - 1)) ? '1' : '0';
bits[i] = 0;
ff_cbs_trace_syntax_element(ctx, put_bits_count(pbc),
name, subscripts, bits, value);
}
put_bits(pbc, width, magnitude);
put_bits(pbc, 1, sign);
put_sbits(pbc, width, value);
return 0;
}
@@ -996,7 +1006,10 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
case AV1_OBU_REDUNDANT_FRAME_HEADER:
{
err = cbs_av1_read_frame_header_obu(ctx, &gbc,
&obu->obu.frame_header);
&obu->obu.frame_header,
obu->header.obu_type ==
AV1_OBU_REDUNDANT_FRAME_HEADER,
unit->data_ref);
if (err < 0)
return err;
}
@@ -1016,7 +1029,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
break;
case AV1_OBU_FRAME:
{
err = cbs_av1_read_frame_obu(ctx, &gbc, &obu->obu.frame);
err = cbs_av1_read_frame_obu(ctx, &gbc, &obu->obu.frame,
unit->data_ref);
if (err < 0)
return err;
@@ -1124,7 +1138,10 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
case AV1_OBU_REDUNDANT_FRAME_HEADER:
{
err = cbs_av1_write_frame_header_obu(ctx, pbc,
&obu->obu.frame_header);
&obu->obu.frame_header,
obu->header.obu_type ==
AV1_OBU_REDUNDANT_FRAME_HEADER,
NULL);
if (err < 0)
return err;
}
@@ -1141,7 +1158,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
break;
case AV1_OBU_FRAME:
{
err = cbs_av1_write_frame_obu(ctx, pbc, &obu->obu.frame);
err = cbs_av1_write_frame_obu(ctx, pbc, &obu->obu.frame, NULL);
if (err < 0)
return err;
@@ -1179,7 +1196,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
if (err < 0)
return err;
end_pos = put_bits_count(pbc);
obu->obu_size = (end_pos - start_pos + 7) / 8;
obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
} else {
// Empty OBU.
obu->obu_size = 0;
@@ -1302,6 +1319,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
CodedBitstreamAV1Context *priv = ctx->priv_data;
av_buffer_unref(&priv->sequence_header_ref);
av_buffer_unref(&priv->frame_header_ref);
av_freep(&priv->write_buffer);
}

View File

@@ -87,8 +87,8 @@ typedef struct AV1RawSequenceHeader {
uint8_t seq_level_idx[AV1_MAX_OPERATING_POINTS];
uint8_t seq_tier[AV1_MAX_OPERATING_POINTS];
uint8_t decoder_model_present_for_this_op[AV1_MAX_OPERATING_POINTS];
uint8_t decoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
uint8_t encoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
uint32_t decoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
uint32_t encoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
uint8_t low_delay_mode_flag[AV1_MAX_OPERATING_POINTS];
uint8_t initial_display_delay_present_for_this_op[AV1_MAX_OPERATING_POINTS];
uint8_t initial_display_delay_minus_1[AV1_MAX_OPERATING_POINTS];
@@ -170,7 +170,7 @@ typedef struct AV1RawFrameHeader {
uint8_t last_frame_idx;
uint8_t golden_frame_idx;
int8_t ref_frame_idx[AV1_REFS_PER_FRAME];
uint8_t delta_frame_id_minus1;
uint32_t delta_frame_id_minus1[AV1_REFS_PER_FRAME];
uint8_t allow_high_precision_mv;
uint8_t is_filter_switchable;
@@ -210,7 +210,7 @@ typedef struct AV1RawFrameHeader {
uint8_t segmentation_temporal_update;
uint8_t segmentation_update_data;
uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
uint8_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
uint8_t delta_q_present;
uint8_t delta_q_res;
@@ -399,7 +399,10 @@ typedef struct CodedBitstreamAV1Context {
AV1RawSequenceHeader *sequence_header;
AVBufferRef *sequence_header_ref;
int seen_frame_header;
int seen_frame_header;
AVBufferRef *frame_header_ref;
uint8_t *frame_header;
size_t frame_header_size;
int temporal_id;
int spatial_id;

View File

@@ -1323,8 +1323,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
if (!current->frame_refs_short_signaling)
fbs(3, ref_frame_idx[i], 1, i);
if (seq->frame_id_numbers_present_flag) {
fb(seq->delta_frame_id_length_minus_2 + 2,
delta_frame_id_minus1);
fbs(seq->delta_frame_id_length_minus_2 + 2,
delta_frame_id_minus1[i], 1, i);
}
}
@@ -1463,24 +1463,90 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
}
static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawFrameHeader *current)
AV1RawFrameHeader *current, int redundant,
AVBufferRef *rw_buffer_ref)
{
CodedBitstreamAV1Context *priv = ctx->priv_data;
int err;
HEADER("Frame Header");
int start_pos, fh_bits, fh_bytes, err;
uint8_t *fh_start;
if (priv->seen_frame_header) {
// Nothing to do.
if (!redundant) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid repeated "
"frame header OBU.\n");
return AVERROR_INVALIDDATA;
} else {
GetBitContext fh;
size_t i, b;
uint32_t val;
HEADER("Redundant Frame Header");
av_assert0(priv->frame_header_ref && priv->frame_header);
init_get_bits(&fh, priv->frame_header,
priv->frame_header_size);
for (i = 0; i < priv->frame_header_size; i += 8) {
b = FFMIN(priv->frame_header_size - i, 8);
val = get_bits(&fh, b);
xf(b, frame_header_copy[i],
val, val, val, 1, i / 8);
}
}
} else {
if (redundant)
HEADER("Redundant Frame Header (used as Frame Header)");
else
HEADER("Frame Header");
priv->seen_frame_header = 1;
#ifdef READ
start_pos = get_bits_count(rw);
#else
start_pos = put_bits_count(rw);
#endif
CHECK(FUNC(uncompressed_header)(ctx, rw, current));
if (current->show_existing_frame) {
priv->seen_frame_header = 0;
} else {
priv->seen_frame_header = 1;
av_buffer_unref(&priv->frame_header_ref);
#ifdef READ
fh_bits = get_bits_count(rw) - start_pos;
fh_start = (uint8_t*)rw->buffer + start_pos / 8;
#else
// Need to flush the bitwriter so that we can copy its output,
// but use a copy so we don't affect the caller's structure.
{
PutBitContext tmp = *rw;
flush_put_bits(&tmp);
}
fh_bits = put_bits_count(rw) - start_pos;
fh_start = rw->buf + start_pos / 8;
#endif
fh_bytes = (fh_bits + 7) / 8;
priv->frame_header_size = fh_bits;
if (rw_buffer_ref) {
priv->frame_header_ref = av_buffer_ref(rw_buffer_ref);
if (!priv->frame_header_ref)
return AVERROR(ENOMEM);
priv->frame_header = fh_start;
} else {
priv->frame_header_ref =
av_buffer_alloc(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
if (!priv->frame_header_ref)
return AVERROR(ENOMEM);
priv->frame_header = priv->frame_header_ref->data;
memcpy(priv->frame_header, fh_start, fh_bytes);
}
}
}
@@ -1524,11 +1590,13 @@ static int FUNC(tile_group_obu)(CodedBitstreamContext *ctx, RWContext *rw,
}
static int FUNC(frame_obu)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawFrame *current)
AV1RawFrame *current,
AVBufferRef *rw_buffer_ref)
{
int err;
CHECK(FUNC(frame_header_obu)(ctx, rw, &current->header));
CHECK(FUNC(frame_header_obu)(ctx, rw, &current->header,
0, rw_buffer_ref));
CHECK(FUNC(byte_alignment)(ctx, rw));

View File

@@ -570,6 +570,8 @@ static int clv_decode_frame(AVCodecContext *avctx, void *data,
for (j = 0; j < c->pmb_height; j++) {
for (i = 0; i < c->pmb_width; i++) {
if (get_bits_left(&c->gb) <= 0)
return AVERROR_INVALIDDATA;
if (get_bits1(&c->gb)) {
MV mv = mvi_predict(&c->mvi, i, j, zero_mv);

View File

@@ -676,6 +676,11 @@ static int decode_component(DiracContext *s, int comp)
b->length = get_interleaved_ue_golomb(&s->gb);
if (b->length) {
b->quant = get_interleaved_ue_golomb(&s->gb);
if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
b->quant = 0;
return AVERROR_INVALIDDATA;
}
align_get_bits(&s->gb);
b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
b->length = FFMIN(b->length, FFMAX(get_bits_left(&s->gb)/8, 0));

View File

@@ -1192,6 +1192,12 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
ret = decompress_tex(avctx);
if (ret < 0)
return ret;
{
int w_block = avctx->coded_width / ctx->texture_block_w;
int h_block = avctx->coded_height / ctx->texture_block_h;
if (w_block * h_block * ctx->tex_step > ctx->tex_size * 8LL)
return AVERROR_INVALIDDATA;
}
tframe.f = data;
ret = ff_thread_get_buffer(avctx, &tframe, 0);

View File

@@ -1389,6 +1389,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
if (*ch_gb.buffer == '.')
ch_gb.buffer++; /* skip dot if not given */
} else {
layer_match = 0;
av_log(s->avctx, AV_LOG_INFO,
"Channel doesn't match layer : %s.\n", ch_gb.buffer);
}
@@ -1463,6 +1464,11 @@ static int decode_header(EXRContext *s, AVFrame *frame)
}
s->pixel_type = current_pixel_type;
s->channel_offsets[channel_index] = s->current_channel_offset;
} else if (channel_index >= 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Multiple channels with index %d.\n", channel_index);
ret = AVERROR_INVALIDDATA;
goto fail;
}
s->channels = av_realloc(s->channels,

View File

@@ -139,6 +139,9 @@ static int fic_decode_block(FICContext *ctx, GetBitContext *gb,
{
int i, num_coeff;
if (get_bits_left(gb) < 8)
return AVERROR_INVALIDDATA;
/* Is it a skip block? */
if (get_bits1(gb)) {
*is_p = 1;
@@ -380,6 +383,8 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data,
slice_h = FFALIGN(avctx->height - ctx->slice_h * (nslices - 1), 16);
} else {
slice_size = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4 + 4);
if (slice_size < slice_off)
return AVERROR_INVALIDDATA;
}
if (slice_size < slice_off || slice_size > msize)

View File

@@ -72,9 +72,64 @@ static av_cold int gdv_decode_init(AVCodecContext *avctx)
return 0;
}
static void scaleup(uint8_t *dst, const uint8_t *src, int w)
{
int x;
for (x = 0; x < w - 7; x+=8) {
dst[x + 0] =
dst[x + 1] = src[(x>>1) + 0];
dst[x + 2] =
dst[x + 3] = src[(x>>1) + 1];
dst[x + 4] =
dst[x + 5] = src[(x>>1) + 2];
dst[x + 6] =
dst[x + 7] = src[(x>>1) + 3];
}
for (; x < w; x++) {
dst[x] = src[(x>>1)];
}
}
static void scaleup_rev(uint8_t *dst, const uint8_t *src, int w)
{
int x;
for (x = w - 1; (x+1) & 7; x--) {
dst[x] = src[(x>>1)];
}
for (x -= 7; x >= 0; x -= 8) {
dst[x + 6] =
dst[x + 7] = src[(x>>1) + 3];
dst[x + 4] =
dst[x + 5] = src[(x>>1) + 2];
dst[x + 2] =
dst[x + 3] = src[(x>>1) + 1];
dst[x + 0] =
dst[x + 1] = src[(x>>1) + 0];
}
}
static void scaledown(uint8_t *dst, const uint8_t *src, int w)
{
int x;
for (x = 0; x < w - 7; x+=8) {
dst[x + 0] = src[2*x + 0];
dst[x + 1] = src[2*x + 2];
dst[x + 2] = src[2*x + 4];
dst[x + 3] = src[2*x + 6];
dst[x + 4] = src[2*x + 8];
dst[x + 5] = src[2*x +10];
dst[x + 6] = src[2*x +12];
dst[x + 7] = src[2*x +14];
}
for (; x < w; x++) {
dst[x] = src[2*x];
}
}
static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, int scale_h)
{
int j, y, x;
int j, y;
if ((gdv->scale_v == scale_v) && (gdv->scale_h == scale_h)) {
return;
@@ -86,14 +141,7 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
uint8_t *src1 = dst + PREAMBLE_SIZE + (y>>!!gdv->scale_h) * (w>>1);
for (x = w - 1; x >= 0 && !(x&1); x--) {
dst1[x] = src1[(x>>1)];
}
for (x--; x >= 0; x-=2) {
dst1[x ] =
dst1[x+1] = src1[(x>>1)];
}
scaleup_rev(dst1, src1, w);
}
} else if (gdv->scale_h) {
for (j = 0; j < h; j++) {
@@ -108,9 +156,7 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
for (y = 0; y < (h>>1); y++) {
uint8_t *dst1 = dst + PREAMBLE_SIZE + y * (w>>1);
uint8_t *src1 = dst + PREAMBLE_SIZE + y*2 * w;
for (x = 0; x < (w>>1); x++) {
dst1[x] = src1[x*2];
}
scaledown(dst1, src1, w>>1);
}
} else if (scale_h) {
for (y = 0; y < (h>>1); y++) {
@@ -121,9 +167,7 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
} else if (scale_v) {
for (y = 0; y < h; y++) {
uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
for (x = 0; x < (w>>1); x++) {
dst1[x] = dst1[x*2];
}
scaledown(dst1, dst1, w>>1);
}
}
@@ -481,19 +525,16 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data,
}
} else {
int sidx = PREAMBLE_SIZE, didx = 0;
int y, x;
int y;
for (y = 0; y < avctx->height; y++) {
if (!gdv->scale_v) {
memcpy(dst + didx, gdv->frame + sidx, avctx->width);
} else {
for (x = 0; x < avctx->width - 1; x+=2) {
dst[didx + x ] =
dst[didx + x + 1] = gdv->frame[sidx + (x>>1)];
}
for (; x < avctx->width; x++) {
dst[didx + x] = gdv->frame[sidx + (x>>1)];
}
uint8_t *dst2 = dst + didx;
uint8_t *src2 = gdv->frame + sidx;
scaleup(dst2, src2, avctx->width);
}
if (!gdv->scale_h || ((y & 1) == 1)) {
sidx += !gdv->scale_v ? avctx->width : avctx->width/2;

View File

@@ -91,7 +91,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *out)
if (nal->type == H264_NAL_PPS) {
h264_redundant_pps_fixup_pps(ctx, nal->content);
if (!au_has_sps) {
av_log(ctx, AV_LOG_VERBOSE, "Deleting redundant PPS "
av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
"at %"PRId64".\n", in->pts);
ff_cbs_delete_unit(ctx->input, au, i);
}

View File

@@ -678,7 +678,7 @@ static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, in
cur_poc = h->cur_pic_ptr->field_poc[h->picture_structure - 1];
}
if (sl->ref_count[0] == 1 && sl->ref_count[1] == 1 && !FRAME_MBAFF(h) &&
sl->ref_list[0][0].poc + (int64_t)sl->ref_list[1][0].poc == 2 * cur_poc) {
sl->ref_list[0][0].poc + (int64_t)sl->ref_list[1][0].poc == 2LL * cur_poc) {
sl->pwt.use_weight = 0;
sl->pwt.use_weight_chroma = 0;
return;

View File

@@ -559,8 +559,6 @@ static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
case HEVC_NAL_VCL_N10:
case HEVC_NAL_VCL_N12:
case HEVC_NAL_VCL_N14:
case HEVC_NAL_BLA_N_LP:
case HEVC_NAL_IDR_N_LP:
return 1;
break;
default: break;

View File

@@ -408,11 +408,11 @@ static void lsf2poly(int16_t *a, int16_t *lsf)
a[0] = 4096;
for (i = 5; i > 0; i--) {
tmp = f[0][6 - i] + (unsigned)f[1][6 - i];
a[6 - i] = (tmp + 4096) >> 13;
tmp = f[0][6 - i] + (unsigned)f[1][6 - i] + 4096;
a[6 - i] = tmp >> 13;
tmp = f[0][6 - i] - (unsigned)f[1][6 - i];
a[5 + i] = (tmp + 4096) >> 13;
tmp = f[0][6 - i] - (unsigned)f[1][6 - i] + 4096;
a[5 + i] = tmp >> 13;
}
}
@@ -745,7 +745,7 @@ static void construct_vector (
for (j = 0; j < veclen; j++) {
a32 = SPL_MUL_16_16(*gainPtr++, cbvec0[j]);
a32 += SPL_MUL_16_16(*gainPtr++, cbvec1[j]);
a32 += SPL_MUL_16_16(*gainPtr, cbvec2[j]);
a32 += (unsigned)SPL_MUL_16_16(*gainPtr, cbvec2[j]);
gainPtr -= 2;
decvector[j] = (a32 + 8192) >> 14;
}
@@ -1303,7 +1303,8 @@ static int xcorr_coeff(int16_t *target, int16_t *regressor,
pos += step;
/* Do a +/- to get the next energy */
energy += step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> shifts);
energy += (unsigned)step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> shifts);
rp_beg += step;
rp_end += step;
}

View File

@@ -428,8 +428,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
return AVERROR_INVALIDDATA;
}
avctx->width = width;
avctx->height = height;
ret = ff_set_dimensions(avctx, width, height);
if (ret < 0)
return ret;
}
s->changed_size = 1;

View File

@@ -2630,7 +2630,7 @@ void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, uint8_t *src,
int16_t *sao_offset_val,
int eo, int width, int height)
{
ptrdiff_t stride_src = (2 * 64 + 32) / sizeof(uint8_t);
ptrdiff_t stride_src = (2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(uint8_t);
switch (eo) {
case 0:

View File

@@ -70,8 +70,7 @@ read_header:
skip_bits(&hgb, 32); /* reserved zeros */
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
{
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g')) {
av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
return AVERROR_INVALIDDATA;
}
@@ -85,19 +84,17 @@ read_header:
dqt_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dqt is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%"PRIx32"\n", dqt_offs);
if (dqt_offs)
{
if (dqt_offs) {
init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
s->start_code = DQT;
if (ff_mjpeg_decode_dqt(s) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return AVERROR_INVALIDDATA;
}
dht_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "dht is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%"PRIx32"\n", dht_offs);
if (dht_offs)
{
if (dht_offs) {
init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
s->start_code = DHT;
ff_mjpeg_decode_dht(s);
@@ -105,8 +102,7 @@ read_header:
sof_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%"PRIx32"\n", sof_offs);
if (sof_offs)
{
if (sof_offs) {
init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
s->start_code = SOF0;
if (ff_mjpeg_decode_sof(s) < 0)
@@ -117,25 +113,23 @@ read_header:
av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%"PRIx32"\n", sos_offs);
sod_offs = read_offs(avctx, &hgb, buf_end - buf_ptr, "sof is %d and size is %d\n");
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%"PRIx32"\n", sod_offs);
if (sos_offs)
{
if (sos_offs) {
init_get_bits(&s->gb, buf_ptr + sos_offs,
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
s->start_code = SOS;
if (ff_mjpeg_decode_sos(s, NULL, 0, NULL) < 0 &&
(avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
return AVERROR_INVALIDDATA;
}
if (s->interlaced) {
s->bottom_field ^= 1;
/* if not bottom field, do not output image yet */
if (s->bottom_field != s->interlace_polarity && second_field_offs)
{
if (s->bottom_field != s->interlace_polarity && second_field_offs) {
buf_ptr = buf + second_field_offs;
goto read_header;
}
}
}
//XXX FIXME factorize, this looks very similar to the EOI code

View File

@@ -1206,25 +1206,25 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor,
|| v * mb_y + y >= s->height) {
// Nothing to do
} else if (bits<=8) {
ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
if(y==0 && toprow){
if(x==0 && leftcol){
pred= 1 << (bits - 1);
ptr = s->picture_ptr->data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
if(y==0 && toprow){
if(x==0 && leftcol){
pred= 1 << (bits - 1);
}else{
pred= ptr[-1];
}
}else{
pred= ptr[-1];
if(x==0 && leftcol){
pred= ptr[-linesize];
}else{
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
}
}
}else{
if(x==0 && leftcol){
pred= ptr[-linesize];
}else{
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
}
}
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
pred &= mask;
*ptr= pred + ((unsigned)dc << point_transform);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
pred &= mask;
*ptr= pred + ((unsigned)dc << point_transform);
}else{
ptr16 = (uint16_t*)(s->picture_ptr->data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x)); //FIXME optimize this crap
if(y==0 && toprow){

View File

@@ -3056,6 +3056,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
if (get_bits_left(gb) <= 32)
return 0;
s->partitioned_frame = 0;
s->decode_mb = mpeg4_decode_studio_mb;
decode_smpte_tc(ctx, gb);

View File

@@ -78,6 +78,8 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
ff_update_block_index(s);
s->bdsp.clear_blocks(s->block[0]);
if (!s->chroma_y_shift)
s->bdsp.clear_blocks(s->block[6]);
s->dest[0] = s->current_picture.f->data[0] +
s->mb_y * 16 * s->linesize +

View File

@@ -101,7 +101,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
"MP3ADU full parser");
*poutbuf = NULL;
*poutbuf_size = 0;
return 0; /* parsers must not return error codes */
return buf_size; /* parsers must not return error codes */
}
break;

View File

@@ -412,6 +412,14 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
{
int code;
// at minimum one bit per macroblock is required at least in a valid frame,
// we discard frames much smaller than this. Frames smaller than 1/8 of the
// smallest "black/skip" frame generally contain not much recoverable content
// while at the same time they have the highest computational requirements
// per byte
if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
return AVERROR_INVALIDDATA;
if(s->msmpeg4_version==1){
int start_code = get_bits_long(&s->gb, 32);
if(start_code!=0x00000100){

View File

@@ -62,6 +62,9 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
if (avctx->width < 4 || avctx->height < 4)
return AVERROR_INVALIDDATA;
/* figure out the colorspace based on the presence of a palette */
if (s->avctx->bits_per_coded_sample == 8) {
s->mode_8bit = 1;

View File

@@ -601,7 +601,11 @@ int ff_nvdec_frame_params(AVCodecContext *avctx,
frames_ctx->format = AV_PIX_FMT_CUDA;
frames_ctx->width = (avctx->coded_width + 1) & ~1;
frames_ctx->height = (avctx->coded_height + 1) & ~1;
frames_ctx->initial_pool_size = dpb_size;
/*
* We add two extra frames to the pool to account for deinterlacing filters
* holding onto their frames.
*/
frames_ctx->initial_pool_size = dpb_size + 2;
frames_ctx->free = nvdec_free_dummy;
frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy);

View File

@@ -676,6 +676,11 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
*/
break;
case DISPLAY_SEGMENT:
if (*data_size) {
av_log(avctx, AV_LOG_ERROR, "Duplicate display segment\n");
ret = AVERROR_INVALIDDATA;
break;
}
ret = display_end_segment(avctx, data, buf, segment_length);
if (ret >= 0)
*data_size = ret;

View File

@@ -578,6 +578,10 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, PNGDecContext *s,
}
s->color_type = bytestream2_get_byte(&s->gb);
s->compression_type = bytestream2_get_byte(&s->gb);
if (s->compression_type) {
av_log(avctx, AV_LOG_ERROR, "Invalid compression method %d\n", s->compression_type);
goto error;
}
s->filter_type = bytestream2_get_byte(&s->gb);
s->interlace_type = bytestream2_get_byte(&s->gb);
bytestream2_skip(&s->gb, 4); /* crc */

View File

@@ -58,7 +58,13 @@ static av_always_inline void transform4x4(vec_s16 src_01, vec_s16 src_23,
e1 = vec_msums(src_02, trans4[2], zero);
o1 = vec_msums(src_13, trans4[3], zero);
add = vec_sl(vec_splat_s32(1), vec_splat_u32(shift - 1));
switch(shift) {
case 7: add = vec_sl(vec_splat_s32(1), vec_splat_u32( 7 - 1)); break;
case 10: add = vec_sl(vec_splat_s32(1), vec_splat_u32(10 - 1)); break;
case 12: add = vec_sl(vec_splat_s32(1), vec_splat_u32(12 - 1)); break;
default: abort();
}
e0 = vec_add(e0, add);
e1 = vec_add(e1, add);
@@ -72,7 +78,14 @@ static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2],
const int shift)
{
int i;
vec_u32 v_shift = vec_splat_u32(shift);
vec_u32 v_shift;
switch(shift) {
case 7: v_shift = vec_splat_u32(7) ; break;
case 10: v_shift = vec_splat_u32(10); break;
case 12: v_shift = vec_splat_u32(12); break;
default: abort();
}
for (i = 0; i < 4; i++)
res[i] = vec_sra(res[i], v_shift);

View File

@@ -57,27 +57,25 @@ static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const ui
b = lut[2 * idx];
while (1) {
if (bytestream2_get_bytes_left_p(pb) <= 0)
if (bytestream2_get_bytes_left_p(pb) <= 0 || bytestream2_get_eof(pb))
return 0;
if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) {
if ((b & 0xFF00u) != 0x8000u || (b & 0xFFu)) {
if ((b & 0xFF00u) != 0x8000u) {
bytestream2_put_le16(pb, b);
} else if (b & 0xFFu) {
} else {
idx = 0;
for (int i = 0; i < (b & 0xFFu); i++)
bytestream2_put_le32(pb, 0);
}
c = b >> 16;
if (c & 0xFF00u) {
c = (((c >> 8) & 0xFFu) | (c & 0xFF00)) & 0xF00F;
fill = lut[2 * idx + 1];
if ((c & 0xFF00u) == 0x1000) {
if ((c & 0xF000u) == 0x1000) {
bytestream2_put_le16(pb, fill);
c &= 0xFFFF00FFu;
} else {
bytestream2_put_le32(pb, fill);
c &= 0xFFFF00FFu;
}
c = (c >> 8) & 0x0Fu;
}
while (c) {
a <<= 4;
@@ -101,6 +99,8 @@ static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const ui
}
idx = a >> 20;
b = lut[2 * idx];
if (!b)
return AVERROR_INVALIDDATA;
continue;
}
idx = 2;
@@ -161,8 +161,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
memset(s->decbuffer, 0, s->size);
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
bytestream2_init_writer(&s->pb, s->decbuffer, s->size);
decompress(&s->gb, AV_RL32(avpkt->data + 28) >> 1, &s->pb, s->lut);
ret = decompress(&s->gb, AV_RL32(avpkt->data + 28) >> 1, &s->pb, s->lut);
if (ret < 0)
return ret;
vertical_predict((uint32_t *)s->decbuffer, 0, (uint32_t *)s->initial_line, s->stride, 1);
vertical_predict((uint32_t *)s->decbuffer, s->stride, (uint32_t *)s->decbuffer, s->stride, avctx->height - 1);

View File

@@ -215,7 +215,7 @@ static int decode_move(AVCodecContext *avctx,
bytestream2_skip(gb, 8);
compression = bytestream2_get_le32(gb);
if (nb_moves > INT32_MAX / 16)
if (nb_moves > INT32_MAX / 16 || nb_moves > avctx->width * avctx->height)
return AVERROR_INVALIDDATA;
uncompressed_size = 16 * nb_moves;
@@ -353,6 +353,8 @@ static int decode_dlta(AVCodecContext *avctx,
compression = bytestream2_get_le32(gb);
if (compression == 1) {
if (w * h * s->bpp * 3 < uncompressed_size)
return AVERROR_INVALIDDATA;
ret = decode_zlib(avctx, avpkt, size, uncompressed_size);
if (ret < 0)
return ret;
@@ -680,6 +682,9 @@ static int decode_frame(AVCodecContext *avctx,
while (bytestream2_get_bytes_left(gb) > 0) {
unsigned type, size = 0;
if (bytestream2_get_bytes_left(gb) < 8)
return AVERROR_INVALIDDATA;
type = bytestream2_get_le32(gb);
if (type == KBND || type == BNDL) {
intra = type == KBND;
@@ -718,12 +723,12 @@ static int decode_frame(AVCodecContext *avctx,
return ret;
}
if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
return ret;
if (!s->frame2->data[0] || !s->frame1->data[0])
return AVERROR_INVALIDDATA;
if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
return ret;
copy_plane(avctx, s->frame2, s->frame);
if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
memcpy(s->frame->data[1], s->frame2->data[1], 1024);

View File

@@ -73,13 +73,12 @@ typedef struct RpzaContext {
static int rpza_decode_stream(RpzaContext *s)
{
int width = s->avctx->width;
int stride = s->frame->linesize[0] / 2;
int row_inc = stride - 4;
int stride, row_inc, ret;
int chunk_size;
uint16_t colorA = 0, colorB;
uint16_t color4[4];
uint16_t ta, tb;
uint16_t *pixels = (uint16_t *)s->frame->data[0];
uint16_t *pixels;
int row_ptr = 0;
int pixel_ptr = 0;
@@ -106,6 +105,15 @@ static int rpza_decode_stream(RpzaContext *s)
/* Number of 4x4 blocks in frame. */
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
if (total_blocks / 32 > bytestream2_get_bytes_left(&s->gb))
return AVERROR_INVALIDDATA;
if ((ret = ff_reget_buffer(s->avctx, s->frame)) < 0)
return ret;
pixels = (uint16_t *)s->frame->data[0];
stride = s->frame->linesize[0] / 2;
row_inc = stride - 4;
/* Process chunk data */
while (bytestream2_get_bytes_left(&s->gb)) {
uint8_t opcode = bytestream2_get_byte(&s->gb); /* Get opcode */
@@ -256,9 +264,6 @@ static int rpza_decode_frame(AVCodecContext *avctx,
bytestream2_init(&s->gb, avpkt->data, avpkt->size);
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
ret = rpza_decode_stream(s);
if (ret < 0)
return ret;

View File

@@ -382,7 +382,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
/* subtract offset from previous samples to use in prediction */
if (command == FN_QLPC && coffset)
for (i = -pred_order; i < 0; i++)
s->decoded[channel][i] -= coffset;
s->decoded[channel][i] -= (unsigned)coffset;
/* decode residual and do LPC prediction */
init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset;
@@ -397,7 +397,7 @@ static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
/* add offset to current samples */
if (command == FN_QLPC && coffset)
for (i = 0; i < s->blocksize; i++)
s->decoded[channel][i] += coffset;
s->decoded[channel][i] += (unsigned)coffset;
return 0;
}

View File

@@ -29,7 +29,7 @@
int main(void)
{
RangeCoder c;
uint8_t b[9 * SIZE];
uint8_t b[9 * SIZE] = {0};
uint8_t r[9 * SIZE];
int i;
uint8_t state[10];

View File

@@ -571,7 +571,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
if (s->compr == TIFF_CCITT_RLE ||
s->compr == TIFF_G3 ||
s->compr == TIFF_G4) {
if (is_yuv)
if (is_yuv || p->format == AV_PIX_FMT_GRAY12)
return AVERROR_INVALIDDATA;
return tiff_unpack_fax(s, dst, stride, src, size, width, lines);
@@ -1304,6 +1304,7 @@ static int decode_frame(AVCodecContext *avctx,
planes = s->planar ? s->bppcount : 1;
for (plane = 0; plane < planes; plane++) {
int remaining = avpkt->size;
int decoded_height;
stride = p->linesize[plane];
dst = p->data[plane];
for (i = 0; i < s->height; i += s->rps) {
@@ -1331,6 +1332,8 @@ static int decode_frame(AVCodecContext *avctx,
break;
}
}
decoded_height = FFMIN(i, s->height);
if (s->predictor == 2) {
if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
av_log(s->avctx, AV_LOG_ERROR, "predictor == 2 with YUV is unsupported");
@@ -1347,7 +1350,7 @@ static int decode_frame(AVCodecContext *avctx,
s->avctx->pix_fmt == AV_PIX_FMT_YA16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16LE) {
for (i = 0; i < s->height; i++) {
for (i = 0; i < decoded_height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WL16(dst + j, AV_RL16(dst + j) + AV_RL16(dst + j - soff));
dst += stride;
@@ -1358,13 +1361,13 @@ static int decode_frame(AVCodecContext *avctx,
s->avctx->pix_fmt == AV_PIX_FMT_YA16BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) {
for (i = 0; i < s->height; i++) {
for (i = 0; i < decoded_height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WB16(dst + j, AV_RB16(dst + j) + AV_RB16(dst + j - soff));
dst += stride;
}
} else {
for (i = 0; i < s->height; i++) {
for (i = 0; i < decoded_height; i++) {
for (j = soff; j < ssize; j++)
dst[j] += dst[j - soff];
dst += stride;

View File

@@ -484,7 +484,7 @@ static inline void tm2_high_chroma(int *data, int stride, int *last, unsigned *C
}
}
static inline void tm2_low_chroma(int *data, int stride, int *clast, int *CD, int *deltas, int bx)
static inline void tm2_low_chroma(int *data, int stride, int *clast, unsigned *CD, int *deltas, int bx)
{
int t;
int l;
@@ -494,8 +494,8 @@ static inline void tm2_low_chroma(int *data, int stride, int *clast, int *CD, in
prev = clast[-3];
else
prev = 0;
t = (CD[0] + CD[1]) >> 1;
l = (prev - CD[0] - CD[1] + clast[1]) >> 1;
t = (int)(CD[0] + CD[1]) >> 1;
l = (int)(prev - CD[0] - CD[1] + clast[1]) >> 1;
CD[1] = CD[0] + CD[1] - t;
CD[0] = t;
clast[0] = l;

View File

@@ -116,7 +116,7 @@ static int truemotion2rt_decode_frame(AVCodecContext *avctx, void *data,
if (ret < 0)
return ret;
if (avctx->width / s->hscale * avctx->height * s->delta_size > avpkt->size * 8LL * 4)
if ((avctx->width + s->hscale - 1)/ s->hscale * avctx->height * s->delta_size > avpkt->size * 8LL * 4)
return AVERROR_INVALIDDATA;
ret = init_get_bits8(gb, avpkt->data + ret, avpkt->size - ret);

View File

@@ -104,7 +104,7 @@ int ff_v4l2_m2m_codec_init(AVCodecContext *avctx);
int ff_v4l2_m2m_codec_end(AVCodecContext *avctx);
/**
* Reinitializes the V4L2m2mContext when the driver cant continue processing
* Reinitializes the V4L2m2mContext when the driver cannot continue processing
* with the capture parameters.
*
* @param[in] ctx The V4L2m2mContext instantiated by the encoder/decoder.
@@ -114,7 +114,7 @@ int ff_v4l2_m2m_codec_end(AVCodecContext *avctx);
int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx);
/**
* Reinitializes the V4L2m2mContext when the driver cant continue processing
* Reinitializes the V4L2m2mContext when the driver cannot continue processing
* with the any of the current V4L2Contexts (ie, changes in output and capture).
*
* @param[in] ctx The V4L2m2mContext instantiated by the encoder/decoder.

View File

@@ -181,6 +181,14 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext *s)
}
s->dc_table_index = get_bits1(&s->gb);
// at minimum one bit per macroblock is required at least in a valid frame,
// we discard frames much smaller than this. Frames smaller than 1/8 of the
// smallest "black/skip" frame generally contain not much recoverable content
// while at the same time they have the highest computational requirements
// per byte
if (get_bits_left(&s->gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
return AVERROR_INVALIDDATA;
}
s->inter_intra_pred = 0;
s->no_rounding = 1;

View File

@@ -407,7 +407,8 @@ OBJS-$(CONFIG_WAVEFORM_FILTER) += vf_waveform.o
OBJS-$(CONFIG_WEAVE_FILTER) += vf_weave.o
OBJS-$(CONFIG_XBR_FILTER) += vf_xbr.o
OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o yadif_common.o
OBJS-$(CONFIG_YADIF_CUDA_FILTER) += vf_yadif_cuda.o vf_yadif_cuda.ptx.o yadif_common.o
OBJS-$(CONFIG_ZMQ_FILTER) += f_zmq.o
OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o
OBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o

View File

@@ -245,8 +245,8 @@ static const AVOption afade_options[] = {
{ "ns", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT64, {.i64 = 44100}, 1, INT64_MAX, FLAGS },
{ "start_time", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "st", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
{ "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "curve", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" },
{ "c", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" },
{ "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve" },

View File

@@ -76,6 +76,13 @@ static int activate(AVFilterContext *ctx)
return AVERROR(ENOMEM);
}
ret = av_frame_copy_props(pad_frame, frame);
if (ret < 0) {
av_frame_free(&pad_frame);
av_frame_free(&frame);
return ret;
}
av_samples_copy(pad_frame->extended_data, frame->extended_data,
0, 0, frame->nb_samples, frame->channels, frame->format);
av_samples_set_silence(pad_frame->extended_data, frame->nb_samples,

View File

@@ -389,6 +389,7 @@ extern AVFilter ff_vf_weave;
extern AVFilter ff_vf_xbr;
extern AVFilter ff_vf_xstack;
extern AVFilter ff_vf_yadif;
extern AVFilter ff_vf_yadif_cuda;
extern AVFilter ff_vf_zmq;
extern AVFilter ff_vf_zoompan;
extern AVFilter ff_vf_zscale;

View File

@@ -31,7 +31,7 @@
#define LIBAVFILTER_VERSION_MAJOR 7
#define LIBAVFILTER_VERSION_MINOR 40
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_MICRO 101
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \

View File

@@ -386,13 +386,13 @@ static const AVOption fade_options[] = {
OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, FLAGS },
{ "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FLAGS },
{ "start_time", "Number of seconds of the beginning of the effect.",
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "st", "Number of seconds of the beginning of the effect.",
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "duration", "Duration of the effect in seconds.",
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "d", "Duration of the effect in seconds.",
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
{ "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ NULL }

View File

@@ -380,15 +380,15 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx,
uint8_t *S, *sp, *d, *dp;
i = FFMAX(-y, 0);
imax = FFMIN(-y + dst_h, src_h);
imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h);
slice_start = (imax * jobnr) / nb_jobs;
slice_end = (imax * (jobnr+1)) / nb_jobs;
slice_start = i + (imax * jobnr) / nb_jobs;
slice_end = i + (imax * (jobnr+1)) / nb_jobs;
sp = src->data[0] + (i + slice_start) * src->linesize[0];
dp = dst->data[0] + (y + i + slice_start) * dst->linesize[0];
sp = src->data[0] + (slice_start) * src->linesize[0];
dp = dst->data[0] + (y + slice_start) * dst->linesize[0];
for (i = i + slice_start; i < slice_end; i++) {
for (i = slice_start; i < slice_end; i++) {
j = FFMAX(-x, 0);
S = sp + j * sstep;
d = dp + (x+j) * dstep;
@@ -468,19 +468,19 @@ static av_always_inline void blend_plane(AVFilterContext *ctx,
int slice_start, slice_end;
j = FFMAX(-yp, 0);
jmax = FFMIN(-yp + dst_hp, src_hp);
jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp);
slice_start = (jmax * jobnr) / nb_jobs;
slice_end = (jmax * (jobnr+1)) / nb_jobs;
slice_start = j + (jmax * jobnr) / nb_jobs;
slice_end = j + (jmax * (jobnr+1)) / nb_jobs;
sp = src->data[i] + slice_start * src->linesize[i];
sp = src->data[i] + (slice_start) * src->linesize[i];
dp = dst->data[dst_plane]
+ (yp + slice_start) * dst->linesize[dst_plane]
+ dst_offset;
ap = src->data[3] + (slice_start << vsub) * src->linesize[3];
dap = dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3];
for (j = j + slice_start; j < slice_end; j++) {
for (j = slice_start; j < slice_end; j++) {
k = FFMAX(-xp, 0);
d = dp + (xp+k) * dst_step;
s = sp + k;
@@ -961,13 +961,13 @@ static int do_blend(FFFrameSync *fs)
s->var_values[VAR_Y], s->y);
}
if (s->x < mainpic->width && s->x + second->width >= 0 ||
if (s->x < mainpic->width && s->x + second->width >= 0 &&
s->y < mainpic->height && s->y + second->height >= 0) {
ThreadData td;
td.dst = mainpic;
td.src = second;
ctx->internal->execute(ctx, s->blend_slice, &td, NULL, FFMIN(FFMIN(mainpic->height - s->y, second->height),
ctx->internal->execute(ctx, s->blend_slice, &td, NULL, FFMIN(FFMAX(1, FFMIN3(s->y + second->height, FFMIN(second->height, mainpic->height), mainpic->height - s->y)),
ff_filter_get_nb_threads(ctx)));
}
return ff_filter_frame(ctx->outputs[0], mainpic);

View File

@@ -98,12 +98,12 @@ static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB] = {
[AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
};
static struct PrimaryCoefficients primaries_table[AVCOL_PRI_NB] = {
static const struct PrimaryCoefficients primaries_table[AVCOL_PRI_NB] = {
[AVCOL_PRI_BT709] = { 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 },
[AVCOL_PRI_BT2020] = { 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 },
};
static struct WhitepointCoefficients whitepoint_table[AVCOL_PRI_NB] = {
static const struct WhitepointCoefficients whitepoint_table[AVCOL_PRI_NB] = {
[AVCOL_PRI_BT709] = { 0.3127, 0.3290 },
[AVCOL_PRI_BT2020] = { 0.3127, 0.3290 },
};

View File

@@ -22,7 +22,6 @@
#include "libavutil/avassert.h"
#include "libavutil/cpu.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
@@ -254,166 +253,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
emms_c();
}
static int return_frame(AVFilterContext *ctx, int is_second)
{
YADIFContext *yadif = ctx->priv;
AVFilterLink *link = ctx->outputs[0];
int tff, ret;
if (yadif->parity == -1) {
tff = yadif->cur->interlaced_frame ?
yadif->cur->top_field_first : 1;
} else {
tff = yadif->parity ^ 1;
}
if (is_second) {
yadif->out = ff_get_video_buffer(link, link->w, link->h);
if (!yadif->out)
return AVERROR(ENOMEM);
av_frame_copy_props(yadif->out, yadif->cur);
yadif->out->interlaced_frame = 0;
}
filter(ctx, yadif->out, tff ^ !is_second, tff);
if (is_second) {
int64_t cur_pts = yadif->cur->pts;
int64_t next_pts = yadif->next->pts;
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
yadif->out->pts = cur_pts + next_pts;
} else {
yadif->out->pts = AV_NOPTS_VALUE;
}
}
ret = ff_filter_frame(ctx->outputs[0], yadif->out);
yadif->frame_pending = (yadif->mode&1) && !is_second;
return ret;
}
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
{
int i;
for (i = 0; i < yadif->csp->nb_components; i++)
if (a->linesize[i] != b->linesize[i])
return 1;
return 0;
}
static void fixstride(AVFilterLink *link, AVFrame *f)
{
AVFrame *dst = ff_default_get_video_buffer(link, f->width, f->height);
if(!dst)
return;
av_frame_copy_props(dst, f);
av_image_copy(dst->data, dst->linesize,
(const uint8_t **)f->data, f->linesize,
dst->format, dst->width, dst->height);
av_frame_unref(f);
av_frame_move_ref(f, dst);
av_frame_free(&dst);
}
static int filter_frame(AVFilterLink *link, AVFrame *frame)
{
AVFilterContext *ctx = link->dst;
YADIFContext *yadif = ctx->priv;
av_assert0(frame);
if (yadif->frame_pending)
return_frame(ctx, 1);
if (yadif->prev)
av_frame_free(&yadif->prev);
yadif->prev = yadif->cur;
yadif->cur = yadif->next;
yadif->next = frame;
if (!yadif->cur &&
!(yadif->cur = av_frame_clone(yadif->next)))
return AVERROR(ENOMEM);
if (checkstride(yadif, yadif->next, yadif->cur)) {
av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
fixstride(link, yadif->next);
}
if (checkstride(yadif, yadif->next, yadif->cur))
fixstride(link, yadif->cur);
if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
fixstride(link, yadif->prev);
if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
return -1;
}
if (!yadif->prev)
return 0;
if ((yadif->deint && !yadif->cur->interlaced_frame) ||
ctx->is_disabled ||
(yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
(yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
) {
yadif->out = av_frame_clone(yadif->cur);
if (!yadif->out)
return AVERROR(ENOMEM);
av_frame_free(&yadif->prev);
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
return ff_filter_frame(ctx->outputs[0], yadif->out);
}
yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
if (!yadif->out)
return AVERROR(ENOMEM);
av_frame_copy_props(yadif->out, yadif->cur);
yadif->out->interlaced_frame = 0;
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
return return_frame(ctx, 0);
}
static int request_frame(AVFilterLink *link)
{
AVFilterContext *ctx = link->src;
YADIFContext *yadif = ctx->priv;
int ret;
if (yadif->frame_pending) {
return_frame(ctx, 1);
return 0;
}
if (yadif->eof)
return AVERROR_EOF;
ret = ff_request_frame(ctx->inputs[0]);
if (ret == AVERROR_EOF && yadif->cur) {
AVFrame *next = av_frame_clone(yadif->next);
if (!next)
return AVERROR(ENOMEM);
next->pts = yadif->next->pts * 2 - yadif->cur->pts;
filter_frame(ctx->inputs[0], next);
yadif->eof = 1;
} else if (ret < 0) {
return ret;
}
return 0;
}
static av_cold void uninit(AVFilterContext *ctx)
{
YADIFContext *yadif = ctx->priv;
@@ -492,6 +331,7 @@ static int config_props(AVFilterLink *link)
}
s->csp = av_pix_fmt_desc_get(link->format);
s->filter = filter;
if (s->csp->comp[0].depth > 8) {
s->filter_line = filter_line_c_16bit;
s->filter_edges = filter_edges_16bit;
@@ -507,37 +347,19 @@ static int config_props(AVFilterLink *link)
}
#define OFFSET(x) offsetof(YADIFContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
static const AVOption yadif_options[] = {
{ "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
{ "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
{ NULL }
static const AVClass yadif_class = {
.class_name = "yadif",
.item_name = av_default_item_name,
.option = ff_yadif_options,
.version = LIBAVUTIL_VERSION_INT,
.category = AV_CLASS_CATEGORY_FILTER,
};
AVFILTER_DEFINE_CLASS(yadif);
static const AVFilterPad avfilter_vf_yadif_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = filter_frame,
.filter_frame = ff_yadif_filter_frame,
},
{ NULL }
};
@@ -546,7 +368,7 @@ static const AVFilterPad avfilter_vf_yadif_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.request_frame = request_frame,
.request_frame = ff_yadif_request_frame,
.config_props = config_props,
},
{ NULL }

426
libavfilter/vf_yadif_cuda.c Normal file
View File

@@ -0,0 +1,426 @@
/*
* Copyright (C) 2018 Philip Langdale <philipl@overt.org>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <cuda.h>
#include "libavutil/avassert.h"
#include "libavutil/hwcontext_cuda.h"
#include "internal.h"
#include "yadif.h"
extern char vf_yadif_cuda_ptx[];
typedef struct DeintCUDAContext {
YADIFContext yadif;
AVCUDADeviceContext *hwctx;
AVBufferRef *device_ref;
AVBufferRef *input_frames_ref;
AVHWFramesContext *input_frames;
CUcontext cu_ctx;
CUstream stream;
CUmodule cu_module;
CUfunction cu_func_uchar;
CUfunction cu_func_uchar2;
CUfunction cu_func_ushort;
CUfunction cu_func_ushort2;
} DeintCUDAContext;
#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
#define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1))
#define BLOCKX 32
#define BLOCKY 16
static int check_cu(AVFilterContext *avctx, CUresult err, const char *func)
{
const char *err_name;
const char *err_string;
av_log(avctx, AV_LOG_TRACE, "Calling %s\n", func);
if (err == CUDA_SUCCESS)
return 0;
cuGetErrorName(err, &err_name);
cuGetErrorString(err, &err_string);
av_log(avctx, AV_LOG_ERROR, "%s failed", func);
if (err_name && err_string)
av_log(avctx, AV_LOG_ERROR, " -> %s: %s", err_name, err_string);
av_log(avctx, AV_LOG_ERROR, "\n");
return AVERROR_EXTERNAL;
}
#define CHECK_CU(x) check_cu(ctx, (x), #x)
static CUresult call_kernel(AVFilterContext *ctx, CUfunction func,
CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next,
CUarray_format format, int channels,
int src_width, // Width is pixels per channel
int src_height, // Height is pixels per channel
int src_pitch, // Pitch is bytes
CUdeviceptr dst,
int dst_width, // Width is pixels per channel
int dst_height, // Height is pixels per channel
int dst_pitch, // Pitch is pixels per channel
int parity, int tff)
{
DeintCUDAContext *s = ctx->priv;
CUtexObject tex_prev = 0, tex_cur = 0, tex_next = 0;
CUresult err;
int skip_spatial_check = s->yadif.mode&2;
void *args[] = { &dst, &tex_prev, &tex_cur, &tex_next,
&dst_width, &dst_height, &dst_pitch,
&src_width, &src_height, &parity, &tff,
&skip_spatial_check };
CUDA_TEXTURE_DESC tex_desc = {
.filterMode = CU_TR_FILTER_MODE_POINT,
.flags = CU_TRSF_READ_AS_INTEGER,
};
CUDA_RESOURCE_DESC res_desc = {
.resType = CU_RESOURCE_TYPE_PITCH2D,
.res.pitch2D.format = format,
.res.pitch2D.numChannels = channels,
.res.pitch2D.width = src_width,
.res.pitch2D.height = src_height,
.res.pitch2D.pitchInBytes = src_pitch,
};
res_desc.res.pitch2D.devPtr = (CUdeviceptr)prev;
err = CHECK_CU(cuTexObjectCreate(&tex_prev, &res_desc, &tex_desc, NULL));
if (err != CUDA_SUCCESS) {
goto exit;
}
res_desc.res.pitch2D.devPtr = (CUdeviceptr)cur;
err = CHECK_CU(cuTexObjectCreate(&tex_cur, &res_desc, &tex_desc, NULL));
if (err != CUDA_SUCCESS) {
goto exit;
}
res_desc.res.pitch2D.devPtr = (CUdeviceptr)next;
err = CHECK_CU(cuTexObjectCreate(&tex_next, &res_desc, &tex_desc, NULL));
if (err != CUDA_SUCCESS) {
goto exit;
}
err = CHECK_CU(cuLaunchKernel(func,
DIV_UP(dst_width, BLOCKX), DIV_UP(dst_height, BLOCKY), 1,
BLOCKX, BLOCKY, 1,
0, s->stream, args, NULL));
exit:
if (tex_prev)
CHECK_CU(cuTexObjectDestroy(tex_prev));
if (tex_cur)
CHECK_CU(cuTexObjectDestroy(tex_cur));
if (tex_next)
CHECK_CU(cuTexObjectDestroy(tex_next));
return err;
}
static void filter(AVFilterContext *ctx, AVFrame *dst,
int parity, int tff)
{
DeintCUDAContext *s = ctx->priv;
YADIFContext *y = &s->yadif;
CUcontext dummy;
CUresult err;
int i;
err = CHECK_CU(cuCtxPushCurrent(s->cu_ctx));
if (err != CUDA_SUCCESS) {
goto exit;
}
for (i = 0; i < y->csp->nb_components; i++) {
CUfunction func;
CUarray_format format;
int pixel_size, channels;
const AVComponentDescriptor *comp = &y->csp->comp[i];
if (comp->plane < i) {
// We process planes as a whole, so don't reprocess
// them for additional components
continue;
}
pixel_size = (comp->depth + comp->shift) / 8;
channels = comp->step / pixel_size;
if (pixel_size > 2 || channels > 2) {
av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
goto exit;
}
switch (pixel_size) {
case 1:
func = channels == 1 ? s->cu_func_uchar : s->cu_func_uchar2;
format = CU_AD_FORMAT_UNSIGNED_INT8;
break;
case 2:
func = channels == 1 ? s->cu_func_ushort : s->cu_func_ushort2;
format = CU_AD_FORMAT_UNSIGNED_INT16;
break;
default:
av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", y->csp->name);
goto exit;
}
av_log(ctx, AV_LOG_TRACE,
"Deinterlacing plane %d: pixel_size: %d channels: %d\n",
comp->plane, pixel_size, channels);
call_kernel(ctx, func,
(CUdeviceptr)y->prev->data[i],
(CUdeviceptr)y->cur->data[i],
(CUdeviceptr)y->next->data[i],
format, channels,
AV_CEIL_RSHIFT(y->cur->width, i ? y->csp->log2_chroma_w : 0),
AV_CEIL_RSHIFT(y->cur->height, i ? y->csp->log2_chroma_h : 0),
y->cur->linesize[i],
(CUdeviceptr)dst->data[i],
AV_CEIL_RSHIFT(dst->width, i ? y->csp->log2_chroma_w : 0),
AV_CEIL_RSHIFT(dst->height, i ? y->csp->log2_chroma_h : 0),
dst->linesize[i] / comp->step,
parity, tff);
}
err = CHECK_CU(cuStreamSynchronize(s->stream));
if (err != CUDA_SUCCESS) {
goto exit;
}
exit:
CHECK_CU(cuCtxPopCurrent(&dummy));
return;
}
static av_cold void deint_cuda_uninit(AVFilterContext *ctx)
{
CUcontext dummy;
DeintCUDAContext *s = ctx->priv;
YADIFContext *y = &s->yadif;
if (s->cu_module) {
CHECK_CU(cuCtxPushCurrent(s->cu_ctx));
CHECK_CU(cuModuleUnload(s->cu_module));
CHECK_CU(cuCtxPopCurrent(&dummy));
}
av_frame_free(&y->prev);
av_frame_free(&y->cur);
av_frame_free(&y->next);
av_buffer_unref(&s->device_ref);
s->hwctx = NULL;
av_buffer_unref(&s->input_frames_ref);
s->input_frames = NULL;
}
static int deint_cuda_query_formats(AVFilterContext *ctx)
{
enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
};
int ret;
if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts),
&ctx->inputs[0]->out_formats)) < 0)
return ret;
if ((ret = ff_formats_ref(ff_make_format_list(pix_fmts),
&ctx->outputs[0]->in_formats)) < 0)
return ret;
return 0;
}
static int config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
DeintCUDAContext *s = ctx->priv;
if (!inlink->hw_frames_ctx) {
av_log(ctx, AV_LOG_ERROR, "A hardware frames reference is "
"required to associate the processing device.\n");
return AVERROR(EINVAL);
}
s->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
if (!s->input_frames_ref) {
av_log(ctx, AV_LOG_ERROR, "A input frames reference create "
"failed.\n");
return AVERROR(ENOMEM);
}
s->input_frames = (AVHWFramesContext*)s->input_frames_ref->data;
return 0;
}
static int config_output(AVFilterLink *link)
{
AVHWFramesContext *output_frames;
AVFilterContext *ctx = link->src;
DeintCUDAContext *s = ctx->priv;
YADIFContext *y = &s->yadif;
int ret = 0;
CUcontext dummy;
CUresult err;
av_assert0(s->input_frames);
s->device_ref = av_buffer_ref(s->input_frames->device_ref);
if (!s->device_ref) {
av_log(ctx, AV_LOG_ERROR, "A device reference create "
"failed.\n");
return AVERROR(ENOMEM);
}
s->hwctx = ((AVHWDeviceContext*)s->device_ref->data)->hwctx;
s->cu_ctx = s->hwctx->cuda_ctx;
s->stream = s->hwctx->stream;
link->hw_frames_ctx = av_hwframe_ctx_alloc(s->device_ref);
if (!link->hw_frames_ctx) {
av_log(ctx, AV_LOG_ERROR, "Failed to create HW frame context "
"for output.\n");
ret = AVERROR(ENOMEM);
goto exit;
}
output_frames = (AVHWFramesContext*)link->hw_frames_ctx->data;
output_frames->format = AV_PIX_FMT_CUDA;
output_frames->sw_format = s->input_frames->sw_format;
output_frames->width = ctx->inputs[0]->w;
output_frames->height = ctx->inputs[0]->h;
output_frames->initial_pool_size = 4;
ret = ff_filter_init_hw_frames(ctx, link, 10);
if (ret < 0)
goto exit;
ret = av_hwframe_ctx_init(link->hw_frames_ctx);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to initialise CUDA frame "
"context for output: %d\n", ret);
goto exit;
}
link->time_base.num = ctx->inputs[0]->time_base.num;
link->time_base.den = ctx->inputs[0]->time_base.den * 2;
link->w = ctx->inputs[0]->w;
link->h = ctx->inputs[0]->h;
if(y->mode & 1)
link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
(AVRational){2, 1});
if (link->w < 3 || link->h < 3) {
av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
ret = AVERROR(EINVAL);
goto exit;
}
y->csp = av_pix_fmt_desc_get(output_frames->sw_format);
y->filter = filter;
err = CHECK_CU(cuCtxPushCurrent(s->cu_ctx));
if (err != CUDA_SUCCESS) {
ret = AVERROR_EXTERNAL;
goto exit;
}
err = CHECK_CU(cuModuleLoadData(&s->cu_module, vf_yadif_cuda_ptx));
if (err != CUDA_SUCCESS) {
ret = AVERROR_INVALIDDATA;
goto exit;
}
err = CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar, s->cu_module, "yadif_uchar"));
if (err != CUDA_SUCCESS) {
ret = AVERROR_INVALIDDATA;
goto exit;
}
err = CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar2, s->cu_module, "yadif_uchar2"));
if (err != CUDA_SUCCESS) {
ret = AVERROR_INVALIDDATA;
goto exit;
}
err= CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort, s->cu_module, "yadif_ushort"));
if (err != CUDA_SUCCESS) {
ret = AVERROR_INVALIDDATA;
goto exit;
}
err = CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort2, s->cu_module, "yadif_ushort2"));
if (err != CUDA_SUCCESS) {
ret = AVERROR_INVALIDDATA;
goto exit;
}
exit:
CHECK_CU(cuCtxPopCurrent(&dummy));
return ret;
}
static const AVClass yadif_cuda_class = {
.class_name = "yadif_cuda",
.item_name = av_default_item_name,
.option = ff_yadif_options,
.version = LIBAVUTIL_VERSION_INT,
.category = AV_CLASS_CATEGORY_FILTER,
};
static const AVFilterPad deint_cuda_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = ff_yadif_filter_frame,
.config_props = config_input,
},
{ NULL }
};
static const AVFilterPad deint_cuda_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.request_frame = ff_yadif_request_frame,
.config_props = config_output,
},
{ NULL }
};
AVFilter ff_vf_yadif_cuda = {
.name = "yadif_cuda",
.description = NULL_IF_CONFIG_SMALL("Deinterlace CUDA frames"),
.priv_size = sizeof(DeintCUDAContext),
.priv_class = &yadif_cuda_class,
.uninit = deint_cuda_uninit,
.query_formats = deint_cuda_query_formats,
.inputs = deint_cuda_inputs,
.outputs = deint_cuda_outputs,
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};

View File

@@ -0,0 +1,299 @@
/*
* Copyright (C) 2018 Philip Langdale <philipl@overt.org>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
template<typename T>
__inline__ __device__ T spatial_predictor(T a, T b, T c, T d, T e, T f, T g,
T h, T i, T j, T k, T l, T m, T n)
{
int spatial_pred = (d + k)/2;
int spatial_score = abs(c - j) + abs(d - k) + abs(e - l);
int score = abs(b - k) + abs(c - l) + abs(d - m);
if (score < spatial_score) {
spatial_pred = (c + l)/2;
spatial_score = score;
score = abs(a - l) + abs(b - m) + abs(c - n);
if (score < spatial_score) {
spatial_pred = (b + m)/2;
spatial_score = score;
}
}
score = abs(d - i) + abs(e - j) + abs(f - k);
if (score < spatial_score) {
spatial_pred = (e + j)/2;
spatial_score = score;
score = abs(e - h) + abs(f - i) + abs(g - j);
if (score < spatial_score) {
spatial_pred = (f + i)/2;
spatial_score = score;
}
}
return spatial_pred;
}
__inline__ __device__ int max3(int a, int b, int c)
{
int x = max(a, b);
return max(x, c);
}
__inline__ __device__ int min3(int a, int b, int c)
{
int x = min(a, b);
return min(x, c);
}
template<typename T>
__inline__ __device__ T temporal_predictor(T A, T B, T C, T D, T E, T F,
T G, T H, T I, T J, T K, T L,
T spatial_pred, bool skip_check)
{
int p0 = (C + H) / 2;
int p1 = F;
int p2 = (D + I) / 2;
int p3 = G;
int p4 = (E + J) / 2;
int tdiff0 = abs(D - I);
int tdiff1 = (abs(A - F) + abs(B - G)) / 2;
int tdiff2 = (abs(K - F) + abs(G - L)) / 2;
int diff = max3(tdiff0, tdiff1, tdiff2);
if (!skip_check) {
int maxi = max3(p2 - p3, p2 - p1, min(p0 - p1, p4 - p3));
int mini = min3(p2 - p3, p2 - p1, max(p0 - p1, p4 - p3));
diff = max3(diff, mini, -maxi);
}
if (spatial_pred > p2 + diff) {
spatial_pred = p2 + diff;
}
if (spatial_pred < p2 - diff) {
spatial_pred = p2 - diff;
}
return spatial_pred;
}
template<typename T>
__inline__ __device__ void yadif_single(T *dst,
cudaTextureObject_t prev,
cudaTextureObject_t cur,
cudaTextureObject_t next,
int dst_width, int dst_height, int dst_pitch,
int src_width, int src_height,
int parity, int tff, bool skip_spatial_check)
{
// Identify location
int xo = blockIdx.x * blockDim.x + threadIdx.x;
int yo = blockIdx.y * blockDim.y + threadIdx.y;
if (xo >= dst_width || yo >= dst_height) {
return;
}
// Don't modify the primary field
if (yo % 2 == parity) {
dst[yo*dst_pitch+xo] = tex2D<T>(cur, xo, yo);
return;
}
// Calculate spatial prediction
T a = tex2D<T>(cur, xo - 3, yo - 1);
T b = tex2D<T>(cur, xo - 2, yo - 1);
T c = tex2D<T>(cur, xo - 1, yo - 1);
T d = tex2D<T>(cur, xo - 0, yo - 1);
T e = tex2D<T>(cur, xo + 1, yo - 1);
T f = tex2D<T>(cur, xo + 2, yo - 1);
T g = tex2D<T>(cur, xo + 3, yo - 1);
T h = tex2D<T>(cur, xo - 3, yo + 1);
T i = tex2D<T>(cur, xo - 2, yo + 1);
T j = tex2D<T>(cur, xo - 1, yo + 1);
T k = tex2D<T>(cur, xo - 0, yo + 1);
T l = tex2D<T>(cur, xo + 1, yo + 1);
T m = tex2D<T>(cur, xo + 2, yo + 1);
T n = tex2D<T>(cur, xo + 3, yo + 1);
T spatial_pred =
spatial_predictor(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
// Calculate temporal prediction
int is_second_field = !(parity ^ tff);
cudaTextureObject_t prev2 = prev;
cudaTextureObject_t prev1 = is_second_field ? cur : prev;
cudaTextureObject_t next1 = is_second_field ? next : cur;
cudaTextureObject_t next2 = next;
T A = tex2D<T>(prev2, xo, yo - 1);
T B = tex2D<T>(prev2, xo, yo + 1);
T C = tex2D<T>(prev1, xo, yo - 2);
T D = tex2D<T>(prev1, xo, yo + 0);
T E = tex2D<T>(prev1, xo, yo + 2);
T F = tex2D<T>(cur, xo, yo - 1);
T G = tex2D<T>(cur, xo, yo + 1);
T H = tex2D<T>(next1, xo, yo - 2);
T I = tex2D<T>(next1, xo, yo + 0);
T J = tex2D<T>(next1, xo, yo + 2);
T K = tex2D<T>(next2, xo, yo - 1);
T L = tex2D<T>(next2, xo, yo + 1);
spatial_pred = temporal_predictor(A, B, C, D, E, F, G, H, I, J, K, L,
spatial_pred, skip_spatial_check);
dst[yo*dst_pitch+xo] = spatial_pred;
}
template <typename T>
__inline__ __device__ void yadif_double(T *dst,
cudaTextureObject_t prev,
cudaTextureObject_t cur,
cudaTextureObject_t next,
int dst_width, int dst_height, int dst_pitch,
int src_width, int src_height,
int parity, int tff, bool skip_spatial_check)
{
int xo = blockIdx.x * blockDim.x + threadIdx.x;
int yo = blockIdx.y * blockDim.y + threadIdx.y;
if (xo >= dst_width || yo >= dst_height) {
return;
}
if (yo % 2 == parity) {
// Don't modify the primary field
dst[yo*dst_pitch+xo] = tex2D<T>(cur, xo, yo);
return;
}
T a = tex2D<T>(cur, xo - 3, yo - 1);
T b = tex2D<T>(cur, xo - 2, yo - 1);
T c = tex2D<T>(cur, xo - 1, yo - 1);
T d = tex2D<T>(cur, xo - 0, yo - 1);
T e = tex2D<T>(cur, xo + 1, yo - 1);
T f = tex2D<T>(cur, xo + 2, yo - 1);
T g = tex2D<T>(cur, xo + 3, yo - 1);
T h = tex2D<T>(cur, xo - 3, yo + 1);
T i = tex2D<T>(cur, xo - 2, yo + 1);
T j = tex2D<T>(cur, xo - 1, yo + 1);
T k = tex2D<T>(cur, xo - 0, yo + 1);
T l = tex2D<T>(cur, xo + 1, yo + 1);
T m = tex2D<T>(cur, xo + 2, yo + 1);
T n = tex2D<T>(cur, xo + 3, yo + 1);
T spatial_pred;
spatial_pred.x =
spatial_predictor(a.x, b.x, c.x, d.x, e.x, f.x, g.x, h.x, i.x, j.x, k.x, l.x, m.x, n.x);
spatial_pred.y =
spatial_predictor(a.y, b.y, c.y, d.y, e.y, f.y, g.y, h.y, i.y, j.y, k.y, l.y, m.y, n.y);
// Calculate temporal prediction
int is_second_field = !(parity ^ tff);
cudaTextureObject_t prev2 = prev;
cudaTextureObject_t prev1 = is_second_field ? cur : prev;
cudaTextureObject_t next1 = is_second_field ? next : cur;
cudaTextureObject_t next2 = next;
T A = tex2D<T>(prev2, xo, yo - 1);
T B = tex2D<T>(prev2, xo, yo + 1);
T C = tex2D<T>(prev1, xo, yo - 2);
T D = tex2D<T>(prev1, xo, yo + 0);
T E = tex2D<T>(prev1, xo, yo + 2);
T F = tex2D<T>(cur, xo, yo - 1);
T G = tex2D<T>(cur, xo, yo + 1);
T H = tex2D<T>(next1, xo, yo - 2);
T I = tex2D<T>(next1, xo, yo + 0);
T J = tex2D<T>(next1, xo, yo + 2);
T K = tex2D<T>(next2, xo, yo - 1);
T L = tex2D<T>(next2, xo, yo + 1);
spatial_pred.x =
temporal_predictor(A.x, B.x, C.x, D.x, E.x, F.x, G.x, H.x, I.x, J.x, K.x, L.x,
spatial_pred.x, skip_spatial_check);
spatial_pred.y =
temporal_predictor(A.y, B.y, C.y, D.y, E.y, F.y, G.y, H.y, I.y, J.y, K.y, L.y,
spatial_pred.y, skip_spatial_check);
dst[yo*dst_pitch+xo] = spatial_pred;
}
extern "C" {
__global__ void yadif_uchar(unsigned char *dst,
cudaTextureObject_t prev,
cudaTextureObject_t cur,
cudaTextureObject_t next,
int dst_width, int dst_height, int dst_pitch,
int src_width, int src_height,
int parity, int tff, bool skip_spatial_check)
{
yadif_single(dst, prev, cur, next,
dst_width, dst_height, dst_pitch,
src_width, src_height,
parity, tff, skip_spatial_check);
}
__global__ void yadif_ushort(unsigned short *dst,
cudaTextureObject_t prev,
cudaTextureObject_t cur,
cudaTextureObject_t next,
int dst_width, int dst_height, int dst_pitch,
int src_width, int src_height,
int parity, int tff, bool skip_spatial_check)
{
yadif_single(dst, prev, cur, next,
dst_width, dst_height, dst_pitch,
src_width, src_height,
parity, tff, skip_spatial_check);
}
__global__ void yadif_uchar2(uchar2 *dst,
cudaTextureObject_t prev,
cudaTextureObject_t cur,
cudaTextureObject_t next,
int dst_width, int dst_height, int dst_pitch,
int src_width, int src_height,
int parity, int tff, bool skip_spatial_check)
{
yadif_double(dst, prev, cur, next,
dst_width, dst_height, dst_pitch,
src_width, src_height,
parity, tff, skip_spatial_check);
}
__global__ void yadif_ushort2(ushort2 *dst,
cudaTextureObject_t prev,
cudaTextureObject_t cur,
cudaTextureObject_t next,
int dst_width, int dst_height, int dst_pitch,
int src_width, int src_height,
int parity, int tff, bool skip_spatial_check)
{
yadif_double(dst, prev, cur, next,
dst_width, dst_height, dst_pitch,
src_width, src_height,
parity, tff, skip_spatial_check);
}
} /* extern "C" */

View File

@@ -19,6 +19,7 @@
#ifndef AVFILTER_YADIF_H
#define AVFILTER_YADIF_H
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
@@ -54,6 +55,8 @@ typedef struct YADIFContext {
AVFrame *prev;
AVFrame *out;
void (*filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff);
/**
* Required alignment for filter_line
*/
@@ -71,4 +74,10 @@ typedef struct YADIFContext {
void ff_yadif_init_x86(YADIFContext *yadif);
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame);
int ff_yadif_request_frame(AVFilterLink *link);
extern const AVOption ff_yadif_options[];
#endif /* AVFILTER_YADIF_H */

209
libavfilter/yadif_common.c Normal file
View File

@@ -0,0 +1,209 @@
/*
* Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
* 2010 James Darnley <james.darnley@gmail.com>
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "internal.h"
#include "yadif.h"
static int return_frame(AVFilterContext *ctx, int is_second)
{
YADIFContext *yadif = ctx->priv;
AVFilterLink *link = ctx->outputs[0];
int tff, ret;
if (yadif->parity == -1) {
tff = yadif->cur->interlaced_frame ?
yadif->cur->top_field_first : 1;
} else {
tff = yadif->parity ^ 1;
}
if (is_second) {
yadif->out = ff_get_video_buffer(link, link->w, link->h);
if (!yadif->out)
return AVERROR(ENOMEM);
av_frame_copy_props(yadif->out, yadif->cur);
yadif->out->interlaced_frame = 0;
}
yadif->filter(ctx, yadif->out, tff ^ !is_second, tff);
if (is_second) {
int64_t cur_pts = yadif->cur->pts;
int64_t next_pts = yadif->next->pts;
if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) {
yadif->out->pts = cur_pts + next_pts;
} else {
yadif->out->pts = AV_NOPTS_VALUE;
}
}
ret = ff_filter_frame(ctx->outputs[0], yadif->out);
yadif->frame_pending = (yadif->mode&1) && !is_second;
return ret;
}
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
{
int i;
for (i = 0; i < yadif->csp->nb_components; i++)
if (a->linesize[i] != b->linesize[i])
return 1;
return 0;
}
static void fixstride(AVFilterLink *link, AVFrame *f)
{
AVFrame *dst = ff_default_get_video_buffer(link, f->width, f->height);
if(!dst)
return;
av_frame_copy_props(dst, f);
av_image_copy(dst->data, dst->linesize,
(const uint8_t **)f->data, f->linesize,
dst->format, dst->width, dst->height);
av_frame_unref(f);
av_frame_move_ref(f, dst);
av_frame_free(&dst);
}
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
{
AVFilterContext *ctx = link->dst;
YADIFContext *yadif = ctx->priv;
av_assert0(frame);
if (yadif->frame_pending)
return_frame(ctx, 1);
if (yadif->prev)
av_frame_free(&yadif->prev);
yadif->prev = yadif->cur;
yadif->cur = yadif->next;
yadif->next = frame;
if (!yadif->cur &&
!(yadif->cur = av_frame_clone(yadif->next)))
return AVERROR(ENOMEM);
if (checkstride(yadif, yadif->next, yadif->cur)) {
av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
fixstride(link, yadif->next);
}
if (checkstride(yadif, yadif->next, yadif->cur))
fixstride(link, yadif->cur);
if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))
fixstride(link, yadif->prev);
if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) {
av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n");
return -1;
}
if (!yadif->prev)
return 0;
if ((yadif->deint && !yadif->cur->interlaced_frame) ||
ctx->is_disabled ||
(yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) ||
(yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict)
) {
yadif->out = av_frame_clone(yadif->cur);
if (!yadif->out)
return AVERROR(ENOMEM);
av_frame_free(&yadif->prev);
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
return ff_filter_frame(ctx->outputs[0], yadif->out);
}
yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
if (!yadif->out)
return AVERROR(ENOMEM);
av_frame_copy_props(yadif->out, yadif->cur);
yadif->out->interlaced_frame = 0;
if (yadif->out->pts != AV_NOPTS_VALUE)
yadif->out->pts *= 2;
return return_frame(ctx, 0);
}
int ff_yadif_request_frame(AVFilterLink *link)
{
AVFilterContext *ctx = link->src;
YADIFContext *yadif = ctx->priv;
int ret;
if (yadif->frame_pending) {
return_frame(ctx, 1);
return 0;
}
if (yadif->eof)
return AVERROR_EOF;
ret = ff_request_frame(ctx->inputs[0]);
if (ret == AVERROR_EOF && yadif->cur) {
AVFrame *next = av_frame_clone(yadif->next);
if (!next)
return AVERROR(ENOMEM);
next->pts = yadif->next->pts * 2 - yadif->cur->pts;
ff_yadif_filter_frame(ctx->inputs[0], next);
yadif->eof = 1;
} else if (ret < 0) {
return ret;
}
return 0;
}
#define OFFSET(x) offsetof(YADIFContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
#define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
const AVOption ff_yadif_options[] = {
{ "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=YADIF_MODE_SEND_FRAME}, 0, 3, FLAGS, "mode"},
CONST("send_frame", "send one frame for each frame", YADIF_MODE_SEND_FRAME, "mode"),
CONST("send_field", "send one frame for each field", YADIF_MODE_SEND_FIELD, "mode"),
CONST("send_frame_nospatial", "send one frame for each frame, but skip spatial interlacing check", YADIF_MODE_SEND_FRAME_NOSPATIAL, "mode"),
CONST("send_field_nospatial", "send one frame for each field, but skip spatial interlacing check", YADIF_MODE_SEND_FIELD_NOSPATIAL, "mode"),
{ "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=YADIF_PARITY_AUTO}, -1, 1, FLAGS, "parity" },
CONST("tff", "assume top field first", YADIF_PARITY_TFF, "parity"),
CONST("bff", "assume bottom field first", YADIF_PARITY_BFF, "parity"),
CONST("auto", "auto detect parity", YADIF_PARITY_AUTO, "parity"),
{ "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=YADIF_DEINT_ALL}, 0, 1, FLAGS, "deint" },
CONST("all", "deinterlace all frames", YADIF_DEINT_ALL, "deint"),
CONST("interlaced", "only deinterlace frames marked as interlaced", YADIF_DEINT_INTERLACED, "deint"),
{ NULL }
};

View File

@@ -513,7 +513,7 @@ static int ftp_features(FTPContext *s)
static const char *feat_command = "FEAT\r\n";
static const char *enable_utf8_command = "OPTS UTF8 ON\r\n";
static const int feat_codes[] = {211, 0};
static const int opts_codes[] = {200, 451, 0};
static const int opts_codes[] = {200, 202, 451, 0};
av_freep(&s->features);
if (ftp_send_command(s, feat_command, feat_codes, &s->features) != 211) {
@@ -521,7 +521,8 @@ static int ftp_features(FTPContext *s)
}
if (ftp_has_feature(s, "UTF8")) {
if (ftp_send_command(s, enable_utf8_command, opts_codes, NULL) == 200)
int ret = ftp_send_command(s, enable_utf8_command, opts_codes, NULL);
if (ret == 200 || ret == 202)
s->utf8 = 1;
}

View File

@@ -590,7 +590,7 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
int isv34)
{
int enc, pic_type;
char mimetype[64];
char mimetype[64] = {0};
const CodecMime *mime = ff_id3v2_mime_tags;
enum AVCodecID id = AV_CODEC_ID_NONE;
ID3v2ExtraMetaAPIC *apic = NULL;
@@ -612,7 +612,9 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen,
if (isv34) {
taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype));
} else {
avio_read(pb, mimetype, 3);
if (avio_read(pb, mimetype, 3) < 0)
goto fail;
mimetype[3] = 0;
taglen -= 3;
}

View File

@@ -87,6 +87,7 @@ typedef struct MOVAtom {
struct MOVParseTableEntry;
typedef struct MOVFragment {
int found_tfhd;
unsigned track_id;
uint64_t base_data_offset;
uint64_t moof_offset;

View File

@@ -97,6 +97,8 @@ static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
if (st->codecpar->codec_id == AV_CODEC_ID_VP9)
ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
else if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
ret = ff_stream_add_bitstream_filter(st, "av1_metadata", "td=insert");
return ret;
}

View File

@@ -259,7 +259,7 @@ static int read_probe_openmpt(AVProbeData *p)
} else {
/* The file extension is unknown and we have very few data
* bytes available. libopenmpt cannot decide anything here,
* and returning any score > 0 would result in successfull
* and returning any score > 0 would result in successful
* probing of random data.
*/
return 0;

View File

@@ -1326,6 +1326,10 @@ static int update_frag_index(MOVContext *c, int64_t offset)
return -1;
for (i = 0; i < c->fc->nb_streams; i++) {
// Avoid building frag index if streams lack track id.
if (c->fc->streams[i]->id < 0)
return AVERROR_INVALIDDATA;
frag_stream_info[i].id = c->fc->streams[i]->id;
frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE;
frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE;
@@ -1366,6 +1370,9 @@ static void fix_frag_index_entries(MOVFragmentIndex *frag_index, int index,
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
// Set by mov_read_tfhd(). mov_read_trun() will reject files missing tfhd.
c->fragment.found_tfhd = 0;
if (!c->has_looked_for_mfra && c->use_mfra_for > 0) {
c->has_looked_for_mfra = 1;
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
@@ -2689,8 +2696,11 @@ static inline int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int in
if (mov_stsc_index_valid(index, sc->stsc_count))
chunk_count = sc->stsc_data[index + 1].first - sc->stsc_data[index].first;
else
else {
// Validation for stsc / stco happens earlier in mov_read_stsc + mov_read_trak.
av_assert0(sc->stsc_data[index].first <= sc->chunk_count);
chunk_count = sc->chunk_count - (sc->stsc_data[index].first - 1);
}
return sc->stsc_data[index].count * (int64_t)chunk_count;
}
@@ -4154,7 +4164,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = avformat_new_stream(c->fc, NULL);
if (!st) return AVERROR(ENOMEM);
st->id = c->fc->nb_streams;
st->id = -1;
sc = av_mallocz(sizeof(MOVStreamContext));
if (!sc) return AVERROR(ENOMEM);
@@ -4168,6 +4178,13 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
c->trak_index = -1;
// Here stsc refers to a chunk not described in stco. This is technically invalid,
// but we can overlook it (clearing stsc) whenever stts_count == 0 (indicating no samples).
if (!sc->chunk_count && !sc->stts_count && sc->stsc_count) {
sc->stsc_count = 0;
av_freep(&sc->stsc_data);
}
/* sanity checks */
if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
(!sc->sample_size && !sc->sample_count))) ||
@@ -4176,7 +4193,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st->index);
return 0;
}
if (sc->chunk_count && sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {
if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {
av_log(c->fc, AV_LOG_ERROR, "stream %d, contradictionary STSC and STCO\n",
st->index);
return AVERROR_INVALIDDATA;
@@ -4438,6 +4455,11 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
// Each stream (trak) should have exactly 1 tkhd. This catches bad files and
// avoids corrupting AVStreams mapped to an earlier tkhd.
if (st->id != -1)
return AVERROR_INVALIDDATA;
version = avio_r8(pb);
flags = avio_rb24(pb);
st->disposition |= (flags & MOV_TKHD_FLAG_ENABLED) ? AV_DISPOSITION_DEFAULT : 0;
@@ -4540,6 +4562,8 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVTrackExt *trex = NULL;
int flags, track_id, i;
c->fragment.found_tfhd = 1;
avio_r8(pb); /* version */
flags = avio_rb24(pb);
@@ -4675,6 +4699,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVIndexEntry *new_entries;
MOVFragmentStreamInfo * frag_stream_info;
if (!frag->found_tfhd) {
av_log(c->fc, AV_LOG_ERROR, "trun track id unknown, no tfhd was found\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < c->fc->nb_streams; i++) {
if (c->fc->streams[i]->id == frag->track_id) {
st = c->fc->streams[i];
@@ -4704,6 +4733,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
break;
}
}
av_assert0(index_entry_pos <= st->nb_index_entries);
avio_r8(pb); /* version */
flags = avio_rb24(pb);
@@ -6546,14 +6576,14 @@ static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *s
return 0;
}
static int cenc_filter(MOVContext *mov, MOVStreamContext *sc, AVPacket *pkt, int current_index)
static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPacket *pkt, int current_index)
{
MOVFragmentStreamInfo *frag_stream_info;
MOVEncryptionIndex *encryption_index;
AVEncryptionInfo *encrypted_sample;
int encrypted_index, ret;
frag_stream_info = get_current_frag_stream_info(&mov->frag_index);
frag_stream_info = get_frag_stream_info(&mov->frag_index, mov->frag_index.current, st->id);
encrypted_index = current_index;
encryption_index = NULL;
if (frag_stream_info) {
@@ -7783,7 +7813,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
if (mov->aax_mode)
aax_filter(pkt->data, pkt->size, mov);
ret = cenc_filter(mov, sc, pkt, current_index);
ret = cenc_filter(mov, st, sc, pkt, current_index);
if (ret < 0)
return ret;

View File

@@ -541,7 +541,7 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
return AVERROR(EINVAL);
info = track->eac3_priv;
size = 2 + 4 * (info->num_ind_sub + 1);
size = 2 + ((34 * (info->num_ind_sub + 1) + 7) >> 3);
buf = av_malloc(size);
if (!buf) {
size = AVERROR(ENOMEM);
@@ -563,12 +563,12 @@ static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
put_bits(&pbc, 4, info->substream[i].num_dep_sub);
if (!info->substream[i].num_dep_sub) {
put_bits(&pbc, 1, 0); /* reserved */
size--;
} else {
put_bits(&pbc, 9, info->substream[i].chan_loc);
}
}
flush_put_bits(&pbc);
size = put_bits_count(&pbc) >> 3;
avio_wb32(pb, size + 8);
ffio_wfourcc(pb, "dec3");

View File

@@ -918,7 +918,7 @@ static void new_data_packet(const uint8_t *buffer, int len, AVPacket *pkt)
static int new_pes_packet(PESContext *pes, AVPacket *pkt)
{
char *sd;
uint8_t *sd;
av_init_packet(pkt);

View File

@@ -1172,7 +1172,7 @@ static int nut_write_trailer(AVFormatContext *s)
ret = avio_open_dyn_buf(&dyn_bc);
if (ret >= 0 && nut->sp_count) {
av_assert1(nut->write_index);
av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written
write_index(nut, dyn_bc);
put_packet(nut, bc, dyn_bc, 1, INDEX_STARTCODE);
}

View File

@@ -454,7 +454,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
} else if (!strcmp(st_type, "text")) {
codec_type = AVMEDIA_TYPE_SUBTITLE;
}
if (codec_type == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << codec_type))) {
if (codec_type == AVMEDIA_TYPE_UNKNOWN ||
!(rt->media_type_mask & (1 << codec_type)) ||
rt->nb_rtsp_streams >= s->max_streams
) {
s1->skip_media = 1;
return;
}
@@ -1663,7 +1666,7 @@ int ff_rtsp_connect(AVFormatContext *s)
char tcpname[1024], cmd[2048], auth[128];
const char *lower_rtsp_proto = "tcp";
int port, err, tcp_fd;
RTSPMessageHeader reply1 = {0}, *reply = &reply1;
RTSPMessageHeader reply1, *reply = &reply1;
int lower_transport_mask = 0;
int default_port = RTSP_DEFAULT_PORT;
char real_challenge[64] = "";
@@ -1692,6 +1695,7 @@ int ff_rtsp_connect(AVFormatContext *s)
rt->lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
redirect:
memset(&reply1, 0, sizeof(reply1));
/* extract hostname and port */
av_url_split(proto, sizeof(proto), auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->url);

View File

@@ -40,6 +40,7 @@ enum WV_FLAGS {
WV_HBAL = 0x0400,
WV_MCINIT = 0x0800,
WV_MCEND = 0x1000,
WV_DSD = 0x80000000,
};
static const int wv_rates[16] = {
@@ -97,6 +98,11 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
return ret;
}
if (wc->header.flags & WV_DSD) {
avpriv_report_missing_feature(ctx, "WV DSD");
return AVERROR_PATCHWELCOME;
}
if (wc->header.version < 0x402 || wc->header.version > 0x410) {
avpriv_report_missing_feature(ctx, "WV version 0x%03X",
wc->header.version);

View File

@@ -501,7 +501,6 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
size_t clear_size)
{
size_t pos = 0;
int same = 1;
int i;
@@ -521,28 +520,12 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
if (clear_size == 1) {
memset(dst, clear[0], dst_size);
dst_size = 0;
} else if (clear_size == 2) {
uint16_t val = AV_RN16(clear);
for (; dst_size >= 2; dst_size -= 2) {
AV_WN16(dst, val);
dst += 2;
}
} else if (clear_size == 4) {
uint32_t val = AV_RN32(clear);
for (; dst_size >= 4; dst_size -= 4) {
AV_WN32(dst, val);
dst += 4;
}
} else if (clear_size == 8) {
uint32_t val = AV_RN64(clear);
for (; dst_size >= 8; dst_size -= 8) {
AV_WN64(dst, val);
dst += 8;
}
} else {
if (clear_size > dst_size)
clear_size = dst_size;
memcpy(dst, clear, clear_size);
av_memcpy_backptr(dst + clear_size, clear_size, dst_size - clear_size);
}
for (; dst_size; dst_size--)
*dst++ = clear[pos++ % clear_size];
}
// Maximum size in bytes of a plane element (usually a pixel, or multiple pixels

View File

@@ -399,6 +399,18 @@ static void fill32(uint8_t *dst, int len)
{
uint32_t v = AV_RN32(dst - 4);
#if HAVE_FAST_64BIT
uint64_t v2= v + ((uint64_t)v<<32);
while (len >= 32) {
AV_WN64(dst , v2);
AV_WN64(dst+ 8, v2);
AV_WN64(dst+16, v2);
AV_WN64(dst+24, v2);
dst += 32;
len -= 32;
}
#endif
while (len >= 4) {
AV_WN32(dst, v);
dst += 4;

View File

@@ -1184,10 +1184,10 @@ FIND_MIN_MAX((%0, %1, 8))
#endif
"movq %%mm6, %%mm0 \n\t" // max
"psubb %%mm7, %%mm6 \n\t" // max - min
"push %4 \n\t"
"movd %%mm6, %k4 \n\t"
"cmpb "MANGLE(deringThreshold)", %b4 \n\t"
"pop %4 \n\t"
"push %%"FF_REG_a" \n\t"
"movd %%mm6, %%eax \n\t"
"cmpb "MANGLE(deringThreshold)", %%al \n\t"
"pop %%"FF_REG_a" \n\t"
" jb 1f \n\t"
PAVGB(%%mm0, %%mm7) // a=(max + min)/2
"punpcklbw %%mm7, %%mm7 \n\t"
@@ -1317,7 +1317,7 @@ DERING_CORE((%0, %1, 8) ,(%%FF_REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,
"1: \n\t"
: : "r" (src), "r" ((x86_reg)stride), "m" (c->pQPb), "m"(c->pQPb2), "q"(tmp)
NAMED_CONSTRAINTS_ADD(deringThreshold,b00,b02,b08)
: "%"FF_REG_a, "%"FF_REG_d, "%"FF_REG_sp
: "%"FF_REG_a, "%"FF_REG_d
);
#else // HAVE_7REGS && (TEMPLATE_PP_MMXEXT || TEMPLATE_PP_3DNOW)
int y;

View File

@@ -48,7 +48,7 @@
static int header = 0;
static void decode(AVCodecContext *dec_ctx, AVFrame *frame,
static int decode(AVCodecContext *dec_ctx, AVFrame *frame,
AVPacket *pkt)
{
static uint64_t frame_cnt = 0;
@@ -57,20 +57,20 @@ static void decode(AVCodecContext *dec_ctx, AVFrame *frame,
ret = avcodec_send_packet(dec_ctx, pkt);
if (ret < 0) {
fprintf(stderr, "Error sending a packet for decoding: %s\n", av_err2str(ret));
exit(1);
return ret;
}
while (ret >= 0) {
const AVPixFmtDescriptor *desc;
char *sum;
char sum[AV_HASH_MAX_SIZE * 2 + 1];
struct AVHashContext *hash;
ret = avcodec_receive_frame(dec_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
return;
return 0;
} else if (ret < 0) {
fprintf(stderr, "Error during decoding: %s\n", av_err2str(ret));
exit(1);
return ret;
}
if (!header) {
@@ -87,9 +87,10 @@ static void decode(AVCodecContext *dec_ctx, AVFrame *frame,
header = 1;
}
desc = av_pix_fmt_desc_get(dec_ctx->pix_fmt);
av_hash_alloc(&hash, "md5");
if ((ret = av_hash_alloc(&hash, "md5")) < 0) {
return ret;
}
av_hash_init(hash);
sum = av_mallocz(av_hash_get_size(hash) * 2 + 1);
for (int i = 0; i < frame->height; i++)
av_hash_update(hash, &frame->data[0][i * frame->linesize[0]], frame->width);
@@ -104,25 +105,25 @@ static void decode(AVCodecContext *dec_ctx, AVFrame *frame,
(frame->width * frame->height + 2 * (frame->height >> desc->log2_chroma_h) * (frame->width >> desc->log2_chroma_w)), sum);
frame_cnt += 1;
av_hash_freep(&hash);
av_free(sum);
}
return 0;
}
int main(int argc, char **argv)
{
const AVCodec *codec;
const AVCodec *codec = NULL;
AVCodecContext *c = NULL;
AVFrame *frame;
AVFrame *frame = NULL;
unsigned int threads;
AVPacket *pkt;
FILE *fd;
FILE *file = NULL;
char nal[MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE];
int nals = 0;
int nals = 0, ret = 0;
char *p = nal;
if (argc < 4) {
fprintf(stderr, "Usage: %s <threads> <input file> <output file>\n", argv[0]);
exit(1);
return -1;
}
if (!(threads = strtoul(argv[1], NULL, 0)))
@@ -134,17 +135,20 @@ int main(int argc, char **argv)
setmode(fileno(stdout), O_BINARY);
#endif
if (!(pkt = av_packet_alloc()))
exit(1);
if (!(pkt = av_packet_alloc())) {
return -1;
}
if (!(codec = avcodec_find_decoder(AV_CODEC_ID_H264))) {
fprintf(stderr, "Codec not found\n");
exit(1);
ret = -1;
goto err;
}
if (!(c = avcodec_alloc_context3(codec))) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
ret = -1;
goto err;
}
c->width = 352;
@@ -154,15 +158,16 @@ int main(int argc, char **argv)
c->thread_type = FF_THREAD_SLICE;
c->thread_count = threads;
if (avcodec_open2(c, codec, NULL) < 0) {
if ((ret = avcodec_open2(c, codec, NULL)) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
goto err;
}
#if HAVE_THREADS
if (c->active_thread_type != FF_THREAD_SLICE) {
fprintf(stderr, "Couldn't activate slice threading: %d\n", c->active_thread_type);
exit(1);
ret = -1;
goto err;
}
#else
fprintf(stderr, "WARN: not using threads, only checking decoding slice NALUs\n");
@@ -170,34 +175,37 @@ int main(int argc, char **argv)
if (!(frame = av_frame_alloc())) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
ret = -1;
goto err;
}
if (!(fd = fopen(argv[2], "rb"))) {
if (!(file = fopen(argv[2], "rb"))) {
fprintf(stderr, "Couldn't open NALU file: %s\n", argv[2]);
exit(1);
ret = -1;
goto err;
}
while(1) {
uint16_t size = 0;
ssize_t ret = fread(&size, 1, sizeof(uint16_t), fd);
if (ret < 0) {
perror("Couldn't read size");
exit(1);
} else if (ret != sizeof(uint16_t))
size_t ret = fread(&size, 1, sizeof(uint16_t), file);
if (ret != sizeof(uint16_t))
break;
size = ntohs(size);
ret = fread(p, 1, size, fd);
if (ret < 0 || ret != size) {
ret = fread(p, 1, size, file);
if (ret != size) {
perror("Couldn't read data");
exit(1);
goto err;
}
p += ret;
if (++nals >= threads) {
int decret = 0;
pkt->data = nal;
pkt->size = p - nal;
decode(c, frame, pkt);
if ((decret = decode(c, frame, pkt)) < 0) {
goto err;
}
memset(nal, 0, MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE);
nals = 0;
p = nal;
@@ -207,15 +215,19 @@ int main(int argc, char **argv)
if (nals) {
pkt->data = nal;
pkt->size = p - nal;
decode(c, frame, pkt);
if ((ret = decode(c, frame, pkt)) < 0) {
goto err;
}
}
decode(c, frame, NULL);
ret = decode(c, frame, NULL);
fclose(fd);
avcodec_free_context(&c);
err:
if (file)
fclose(file);
av_frame_free(&frame);
avcodec_free_context(&c);
av_packet_free(&pkt);
return 0;
return ret;
}

View File

@@ -782,7 +782,7 @@ fate-filter-meta-4560-rotate0: CMD = framecrc -flags +bitexact -c:a aac_fixed -i
REFCMP_DEPS = FFMPEG LAVFI_INDEV TESTSRC2_FILTER AVGBLUR_FILTER METADATA_FILTER
FATE_FILTER_SAMPLES-$(call ALLYES, $(REFCMP_DEPS) PSNR_FILTER) += fate-filter-refcmp-psnr-rgb
fate-filter-refcmp-psnr-rgb: CMD = refcmp_metadata psnr rgb24 0.001
fate-filter-refcmp-psnr-rgb: CMD = refcmp_metadata psnr rgb24 0.002
FATE_FILTER_SAMPLES-$(call ALLYES, $(REFCMP_DEPS) PSNR_FILTER) += fate-filter-refcmp-psnr-yuv
fate-filter-refcmp-psnr-yuv: CMD = refcmp_metadata psnr yuv422p 0.0015

View File

@@ -1,5 +1,5 @@
39aef1afff761d673fd1be07182941d1 *tests/data/fate/copy-trac3074.mp4
333991 tests/data/fate/copy-trac3074.mp4
f92a201033712bda262f1e071e25544a *tests/data/fate/copy-trac3074.mp4
333992 tests/data/fate/copy-trac3074.mp4
#tb 0: 1/48000
#media_type 0: audio
#codec_id 0: eac3