]> git.sesse.net Git - ffmpeg/log
ffmpeg
4 years agolavf/dump: Fix vbv_delay type specifier.
Carl Eugen Hoyos [Sat, 10 Aug 2019 21:33:10 +0000 (23:33 +0200)]
lavf/dump: Fix vbv_delay type specifier.

Spotted-by: James Almer
4 years agolavc/libx264: Cast bit_rate to int64_t to avoid an integer overflow.
Carl Eugen Hoyos [Sat, 10 Aug 2019 15:10:58 +0000 (17:10 +0200)]
lavc/libx264: Cast bit_rate to int64_t to avoid an integer overflow.

Fixes ticket #8071.

4 years agolavc/libx264: bit_rates > INT_MAX are not supported.
Carl Eugen Hoyos [Sat, 10 Aug 2019 12:40:23 +0000 (14:40 +0200)]
lavc/libx264: bit_rates > INT_MAX are not supported.

4 years agoavformat/rtpdec_mpeg4: Fix integer parameters size check in SDP fmtp line
Olivier Maignial [Wed, 24 Jul 2019 08:20:14 +0000 (10:20 +0200)]
avformat/rtpdec_mpeg4: Fix integer parameters size check in SDP fmtp line

=== PROBLEM ===

I was trying to record h264 + aac streams from an RTSP server to mp4 file. using this command line:
    ffmpeg -v verbose -y -i "rtsp://<ip>/my_resources" -codec copy -bsf:a aac_adtstoasc test.mp4

FFmpeg then fail to record audio and output this logs:
    [rtsp @ 0xcda1f0] The profile-level-id field size is invalid (40)
    [rtsp @ 0xcda1f0] Error parsing AU headers
    ...
    [rtsp @ 0xcda1f0] Could not find codec parameters for stream 1 (Audio: aac, 48000 Hz, 1 channels): unspecified sample format

In SDP provided by my RTSP server I had this fmtp line:
    a=fmtp:98 streamType=5; profile-level-id=40; mode=AAC-hbr; config=1188; sizeLength=13; indexLength=3; indexDeltaLength=3;

In FFmpeg code, I found a check introduced by commit 24130234cd9dd733116d17b724ea4c8e12ce097a. It disallows values greater than 32 for fmtp line parameters.
RFC-4566 (SDP: Session Description Protocol) do not give any limit of size on interger parameters given in an fmtp line.

However, In RFC-6416 (RTP Payload Format for MPEG-4 Audio/Visual Streams) give examples of "profile-level-id" values for AAC, up to 55.

=== FIX ===

As each parameter may have its own min and max values
I propose to introduce a range for each parameter.
For this patch I used RFC-3640 and ISO/IEC 14496-1 as reference for validity ranges.

This patch fix my problem and I now can record my RTSP AAC stream to mp4.
It has passed the full fate tests suite sucessfully.

Signed-off-by: Olivier Maignial <olivier.maignial@smile.fr>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agotools/zmqsend: Avoid mem copy past the end of input buffer
Andriy Gelman [Thu, 8 Aug 2019 14:37:10 +0000 (10:37 -0400)]
tools/zmqsend: Avoid mem copy past the end of input buffer

This patch avoids a read past the end of the input buffer in memcpy since the size
of the received zmq message is recv_buf_size - 1.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agodoc/fate: Document how to request samples upload access
Michael Niedermayer [Wed, 7 Aug 2019 19:18:12 +0000 (21:18 +0200)]
doc/fate: Document how to request samples upload access

The awnser which most people will seek is put first

Reviewed-by: Thilo Borgmann <thilo.borgmann@mail.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agodoc/ffmpeg: Document dts_error_threshold option
Jun Zhao [Sun, 21 Jul 2019 04:36:21 +0000 (12:36 +0800)]
doc/ffmpeg: Document dts_error_threshold option

Document dts_error_threshold option.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 years agoexamples/encode_video: only add sequence end code for mpeg1/2 video
Jun Zhao [Mon, 5 Aug 2019 04:53:55 +0000 (12:53 +0800)]
examples/encode_video: only add sequence end code for mpeg1/2 video

Only add sequence end code for mpeg1/mpeg2 video, or else use the encoder
libx264 or libx265 in this sample, decoding the output file will get
unknow NALU type error.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 years agolavf/showinfo: use error level when get invalid sidedata
Jun Zhao [Mon, 5 Aug 2019 06:33:41 +0000 (14:33 +0800)]
lavf/showinfo: use error level when get invalid sidedata

Use error level when get invalid sidedata, and remove a unnecessary
newline in error message.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 years agolavf/showinfo: support mastering display sidedata
Jun Zhao [Sun, 4 Aug 2019 09:35:29 +0000 (17:35 +0800)]
lavf/showinfo: support mastering display sidedata

support mastering display sidedata.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 years agolavf/hls: add http_seekable option for HTTP partial requests
Jun Zhao [Wed, 7 Aug 2019 16:12:16 +0000 (00:12 +0800)]
lavf/hls: add http_seekable option for HTTP partial requests

Add http_seekable option for HTTP partial requests, when The
EXT-X-BYTERANGE tag indicates that a Media Segment is a sub-range
of the resource identified by its URI, we can use HTTP partial
requests to get the Media Segment.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
4 years agolavf/vf_vpp_qsv: add support for QSV transpose filter
Linjie Fu [Wed, 10 Jul 2019 17:57:46 +0000 (01:57 +0800)]
lavf/vf_vpp_qsv: add support for QSV transpose filter

Add transpose support for qsv_vpp with rotate and hflip:
    - rotate: [0, 3] support clockwise rotation of 0, 90, 180, 270;
    - hflip:  [0, 1] support horizontal flip;

Configure with:
{"cclock_hflip","clock","cclock","clock_hflip","reversal","hflip","vflip"}

CMD:
ffmpeg -hwaccel qsv -c:v h264_qsv -i input.h264
    -vf 'format=qsv,vpp_qsv=transpose=clock' -c:v h264_qsv output.h264

ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv -i input.h264
    -vf 'hwupload=extra_hw_frames=64,format=qsv,vpp_qsv=transpose=cclock_hflip'
                            -f rawvideo -pix_fmt nv12 ./transpose.yuv

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
4 years agoavfilter/vf_convolution: add x86 SIMD for filter_3x3()
Ruiling Song [Thu, 27 Jun 2019 02:07:21 +0000 (10:07 +0800)]
avfilter/vf_convolution: add x86 SIMD for filter_3x3()

Tested using a simple command (apply edge enhance):
./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
 -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128" \
 -an -vframes 1000 -f null /dev/null

The fps increase from 151 to 270 on my local machine.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
4 years agoRevert "avformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation"
Michael Niedermayer [Tue, 6 Aug 2019 08:35:38 +0000 (10:35 +0200)]
Revert "avformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation"

Reverted at the request of the Author due to potential regression with SMPTE 2110-20

This reverts commit 9051092e73666e95986eb2d596cc0867aea05c3d.

4 years agoconfigure: cuda_llvm: fix include path for MSYS2
Ricardo Constantino [Mon, 5 Aug 2019 19:47:03 +0000 (20:47 +0100)]
configure: cuda_llvm: fix include path for MSYS2

MSYS2 converts paths to MinGW-based applications from unix to
pseudo-windows paths on execution time.
Since there was no space between '-include' and the path, MSYS2 doesn't
detect the path properly.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agoavcodec/alsdec: Check for block_length <= 0 in read_var_block_data()
Michael Niedermayer [Fri, 26 Jul 2019 13:26:08 +0000 (15:26 +0200)]
avcodec/alsdec: Check for block_length <= 0 in read_var_block_data()

Fixes: left shift of negative value -1
Fixes: 15719/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5685731105701888
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vqavideo: Set video size
Michael Niedermayer [Thu, 25 Jul 2019 22:35:32 +0000 (00:35 +0200)]
avcodec/vqavideo: Set video size

Fixes: out of array access
Fixes: 15919/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQA_fuzzer-5657368257363968
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/sanm: Check extradata_size before allocations
Michael Niedermayer [Mon, 15 Jul 2019 21:26:05 +0000 (23:26 +0200)]
avcodec/sanm: Check extradata_size before allocations

Fixes: Leaks
Fixes: 15349/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5102530557640704
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation
Jacob Siddall [Thu, 27 Jun 2019 06:06:22 +0000 (06:06 +0000)]
avformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation

The previous calculation code did not account for the fact that the
copy_offset for the start of the frame array is at index 0, yet the
scan line number from the rfc4175 RTP header starts at 1.
This caused 2 issues to appear:
- The first scan line was being copied into the array where the second
  scan line should be. This caused the resulting video to have a green
  line at the top of it.
- Since the packet containing the last scan line would fail the
  calculation, the packet with the RTP marker would not be processed
  which caused a log message saying "Missed previous RTP marker" to be
  outputted for each frame.

Signed-off-by: Jacob Siddall <kobe@live.com.au>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agolibavcodec/iff: Use unsigned to avoid undefined behaviour
Andreas Rheinhardt [Fri, 2 Aug 2019 20:29:16 +0000 (22:29 +0200)]
libavcodec/iff: Use unsigned to avoid undefined behaviour

The initialization of the uint32_t plane32_lut matrix uses left shifts
of the form 1 << plane; plane can be as big as 31 which means that this
is undefined behaviour as 1 will be simply an int. So make it unsigned
to avoid this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/mss1: check for overread and forward errors
Michael Niedermayer [Fri, 2 Aug 2019 22:29:48 +0000 (00:29 +0200)]
avcodec/mss1: check for overread and forward errors

Fixes: Timeout (106sec -> 14ms)
Fixes: 15576/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS1_fuzzer-5688080461201408
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>
4 years agoavcodec/loco: Check for end of input in pixel decode
Michael Niedermayer [Fri, 2 Aug 2019 20:14:22 +0000 (22:14 +0200)]
avcodec/loco: Check for end of input in pixel decode

Fixes: Timeout (100sec -> 5sec)
Fixes: 15509/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LOCO_fuzzer-5724297261219840
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>
4 years agoavcodec/dirac_parser: Fix overflow in dts
Michael Niedermayer [Thu, 11 Jul 2019 21:23:07 +0000 (23:23 +0200)]
avcodec/dirac_parser: Fix overflow in dts

Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 15568/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5634719611355136
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>
4 years agoavcodec/ralf: Fix undefined pointer in decode_channel()
Michael Niedermayer [Sun, 4 Aug 2019 15:25:55 +0000 (17:25 +0200)]
avcodec/ralf: Fix undefined pointer in decode_channel()

Fixes: 16203/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5086088934195200
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/ralf: Fix integer overflow in apply_lpc()
Michael Niedermayer [Sun, 4 Aug 2019 15:20:45 +0000 (17:20 +0200)]
avcodec/ralf: Fix integer overflow in apply_lpc()

Fixes: signed integer overflow: 1603085316 + 1238786562 cannot be represented in type 'int'
Fixes: 16203/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5086088934195200
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vorbisdec: Implement vr->classifications = 1
Michael Niedermayer [Sun, 4 Aug 2019 15:10:18 +0000 (17:10 +0200)]
avcodec/vorbisdec: Implement vr->classifications = 1

It appears no valid file uses this, so this is not testable with
a valid file.

Fixes: assertion failure
Fixes: 16187/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-5638880618872832
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vorbisdec: Check parameters in vorbis_floor0_decode() before divide
Michael Niedermayer [Sun, 4 Aug 2019 10:28:55 +0000 (12:28 +0200)]
avcodec/vorbisdec: Check parameters in vorbis_floor0_decode() before divide

Fixes: division by zero
Fixes: 16183/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-5688966782648320
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/realtextdec: Check for duplicate extradata in realtext_read_header()
Michael Niedermayer [Sun, 4 Aug 2019 10:21:51 +0000 (12:21 +0200)]
avformat/realtextdec: Check for duplicate extradata in realtext_read_header()

Fixes: memleak
Fixes: 16140/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5684008052064256
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/vividas: Fix memleak of AVIOContext in track_header()
Michael Niedermayer [Sun, 4 Aug 2019 10:13:21 +0000 (12:13 +0200)]
avformat/vividas: Fix memleak of AVIOContext in track_header()

Fixes: memleak
Fixes: 16127/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5649290914955264
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/cfhd: Check destination space for bayer before writing
Michael Niedermayer [Sun, 4 Aug 2019 10:03:35 +0000 (12:03 +0200)]
avcodec/cfhd: Check destination space for bayer before writing

Fixes: out of array write
Fixes: 16105/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5690817309573120
Fixes: 16119/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5099050675732480
Fixes: 16135/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5705501601431552
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/cfhd: Fix linesize type
Michael Niedermayer [Sun, 4 Aug 2019 10:02:33 +0000 (12:02 +0200)]
avcodec/cfhd: Fix linesize type

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/cbs_av1_syntax_template: Check ref_frame_idx before use
Michael Niedermayer [Sun, 4 Aug 2019 07:51:26 +0000 (09:51 +0200)]
avcodec/cbs_av1_syntax_template: Check ref_frame_idx before use

Fixes: index -1 out of bounds for type 'AV1ReferenceFrameState [8]'
Fixes: 16079/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5758807440883712
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
See: [FFmpeg-devel] [PATCH 05/13] avcodec/cbs_av1_syntax_template: Check ref_frame_idx before use
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/apedec: Fix 2 signed overflows
Michael Niedermayer [Sun, 4 Aug 2019 07:46:34 +0000 (09:46 +0200)]
avcodec/apedec: Fix 2 signed overflows

Fixes: left shift of 1073741824 by 1 places cannot be represented in type 'int'
Fixes: signed integer overflow: 2049431315 + 262759074 cannot be represented in type 'int'
Fixes: 16012/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5719016003338240
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/mss3: Check for the rac stream being invalid in rac_normalize()
Michael Niedermayer [Sun, 4 Aug 2019 07:33:45 +0000 (09:33 +0200)]
avcodec/mss3: Check for the rac stream being invalid in rac_normalize()

Fixes: out of array read
Fixes: 15982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSA1_fuzzer-5630676251967488
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vc1_block: Check get_vlc2() return before use
Michael Niedermayer [Sun, 4 Aug 2019 06:32:58 +0000 (08:32 +0200)]
avcodec/vc1_block: Check get_vlc2() return before use

Fixes: index -1 out of bounds for type 'const uint8_t [185][2]'
Fixes: 15720/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS2_fuzzer-5666071933091840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/apedec: Do not partially clear data array
Michael Niedermayer [Sun, 4 Aug 2019 06:26:40 +0000 (08:26 +0200)]
avcodec/apedec: Do not partially clear data array

Fixes: Assertion failure and memleak
Fixes: 15709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5182435093905408
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/atrac9dec: Check grad_range[1] more tightly
Michael Niedermayer [Sat, 3 Aug 2019 22:45:20 +0000 (00:45 +0200)]
avcodec/atrac9dec: Check grad_range[1] more tightly

Alternatively the array could be made bigger but the extra values
would not be read without other changes.

Fixes: Out of array access
Fixes: 15658/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5738260074070016
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/atrac9dec: Remove impossible condition
Michael Niedermayer [Sat, 3 Aug 2019 22:37:52 +0000 (00:37 +0200)]
avcodec/atrac9dec: Remove impossible condition

Suggested-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/bink: Add many end of input checks
Michael Niedermayer [Sat, 3 Aug 2019 22:09:32 +0000 (00:09 +0200)]
avcodec/bink: Add many end of input checks

Fixes: Timeout (83sec -> 15sec)
Fixes: 15595/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-5689153263501312
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agocompat/cuda: Change inclusion guards
Andreas Rheinhardt [Mon, 5 Aug 2019 01:09:41 +0000 (03:09 +0200)]
compat/cuda: Change inclusion guards

cuda_runtime.h as well as dynlink_loader.h used nonstandard inclusion
guards with an AV_ prefix, although these files are not in an libav*/
path. So change the inclusion guards and adapt the ref file of the
source fate test accordingly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agobuild: add support for building CUDA files with clang
Rodger Combs [Tue, 30 Jul 2019 07:51:42 +0000 (02:51 -0500)]
build: add support for building CUDA files with clang

This avoids using the CUDA SDK at all; instead, we provide a minimal
reimplementation of the basic functionality that lavfi actually uses.
It generates very similar code to what NVCC produces.

The header contains no implementation code derived from the SDK.
The function and type declarations are derived from the SDK only to the
extent required to build a compatible implementation. This is generally
accepted to qualify as fair use.

Because this option does not require the proprietary SDK, it does not require
the "--enable-nonfree" flag in configure.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agoavcodec/h263dec: enable nvdec hwaccel
Stefan Schoenefeld [Fri, 2 Aug 2019 09:18:10 +0000 (09:18 +0000)]
avcodec/h263dec: enable nvdec hwaccel

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agoavcodec/h263dec: fix hwaccel decoding
Stefan Schoenefeld [Fri, 2 Aug 2019 09:18:10 +0000 (09:18 +0000)]
avcodec/h263dec: fix hwaccel decoding

Recently we encountered an issue when decoding a h.263 file:

FFmpeg will freeze when decoding h.263 video with NVDEC. Turns out this is not directly related to NVDEC but is a problem that shows with several other HW decoders like VDPAU, though the exact kind of error is different (either error messages or freezing[1]). The root cause is that ff_thread_finish_setup() is called twice per frame from ff_h263_decode_frame(). This is not supported by ff_thread_finish_setup() and specifically checked for and warned against in the functions code. The issue is also specific to hw accelerated decoding only as the second call to ff_thread_finish_setup() is only issued when hw acceleration is on. The fix is simple: add a check that the first call is only send when hw acceleration is off, and the second call only when hw acceleration is on (see attached patch). This works fine as far as I was able to test with vdpau and nvdec/nvcuvid hw decoding. The patch also adds NVDEC to the hw config list if available.

I also noticed a secondary issue when browsing through the code which is that, according to documentation, ff_thread_finish_setup() should only be called if the codec implements update_thread_context(), which h263dec does not. The patch does not address this and I'm not sure any action needs to be taken here at all.

[1] This is depending on whether or not the hw decoder sets the  HWACCEL_CAPS_ASYNC_SAFE flag

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agoavcodec/hnm4video: Forward errors of decode_interframe_v4()
Michael Niedermayer [Fri, 2 Aug 2019 21:54:49 +0000 (23:54 +0200)]
avcodec/hnm4video: Forward errors of decode_interframe_v4()

Fixes: Timeout (108sec -> 160ms)
Fixes: 15570/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HNM4_VIDEO_fuzzer-5085482213441536
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/interplayvideo: Avoid ff_get_buffer() during init
Michael Niedermayer [Thu, 11 Jul 2019 20:29:10 +0000 (22:29 +0200)]
avcodec/interplayvideo: Avoid ff_get_buffer() during init

This is unneeded for interplay video

Fixes: memleak
Fixes: 15562/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer-5162268645392384
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/vividas: Check that value from ffio_read_varlen() does not overflow
Michael Niedermayer [Sat, 20 Jul 2019 20:41:08 +0000 (22:41 +0200)]
avformat/vividas: Check that value from ffio_read_varlen() does not overflow

Fixes: signed integer overflow: -1241665686 + -1340629419 cannot be represented in type 'int'
Fixes: 15922/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5692826442006528
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/vividas: forward errors from track_header()
Michael Niedermayer [Sat, 20 Jul 2019 20:36:10 +0000 (22:36 +0200)]
avformat/vividas: forward errors from track_header()

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/clearvideo: fix invalid shift in tile size check
Michael Niedermayer [Sat, 13 Jul 2019 18:16:19 +0000 (20:16 +0200)]
avcodec/clearvideo: fix invalid shift in tile size check

Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 15631/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5690110605000704
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/vividas: Check buffer size before allocation
Michael Niedermayer [Sat, 13 Jul 2019 17:57:21 +0000 (19:57 +0200)]
avformat/vividas: Check buffer size before allocation

Fixes: out of array access
Fixes: 15365/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5716153105645568
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/vividas: Check if extradata was read successfully
Michael Niedermayer [Sat, 13 Jul 2019 18:08:03 +0000 (20:08 +0200)]
avformat/vividas: Check if extradata was read successfully

Fixes: OOM
Fixes: 15575/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5654666781655040
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/dashenc: fix writing the AV1 codec string in mp4 mode
James Almer [Tue, 30 Jul 2019 16:21:46 +0000 (13:21 -0300)]
avformat/dashenc: fix writing the AV1 codec string in mp4 mode

From https://aomediacodec.github.io/av1-isobmff/#codecsparam, the parameters
sample entry 4CC, profile, level, tier, and bitDepth are all mandatory fields.
All the other fields are optional, mutually inclusive (all or none).

Fixes ticket #8049

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/dashenc: update stream extradata from packet side data
James Almer [Tue, 30 Jul 2019 18:08:36 +0000 (15:08 -0300)]
avformat/dashenc: update stream extradata from packet side data

codecpar->extradata is not going to change between packets. New extradata
is instead propagated using packet side data.

Use ff_alloc_extradata() as well.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/av1: combine high_bitdepth and twelve_bit into a single bitdepth value
James Almer [Tue, 30 Jul 2019 14:55:26 +0000 (11:55 -0300)]
avformat/av1: combine high_bitdepth and twelve_bit into a single bitdepth value

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/av1: rename some AV1SequenceParameters fields
James Almer [Tue, 30 Jul 2019 14:48:38 +0000 (11:48 -0300)]
avformat/av1: rename some AV1SequenceParameters fields

Cosmetic change.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/av1: split off sequence header parsing from the av1C writing function
James Almer [Tue, 30 Jul 2019 15:08:44 +0000 (12:08 -0300)]
avformat/av1: split off sequence header parsing from the av1C writing function

It will be used by the dash muxer

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/av1: add color config values to AV1SequenceParameters
James Almer [Tue, 30 Jul 2019 14:43:02 +0000 (11:43 -0300)]
avformat/av1: add color config values to AV1SequenceParameters

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/vp8: do vp7_fade_frame() later
Michael Niedermayer [Thu, 1 Aug 2019 11:54:21 +0000 (13:54 +0200)]
avcodec/vp8: do vp7_fade_frame() later

Fixes: Timeout (100sec -> 5sec)
Fixes: 15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vp3: Check for end of input in vp4_unpack_vlcs()
Michael Niedermayer [Fri, 2 Aug 2019 19:23:18 +0000 (21:23 +0200)]
avcodec/vp3: Check for end of input in vp4_unpack_vlcs()

Fixes: Timeout (too long -> 1sec)
Fixes: 15232/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5769583086010368
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vp3: Check that theora is theora
Michael Niedermayer [Sun, 21 Jul 2019 22:41:06 +0000 (00:41 +0200)]
avcodec/vp3: Check that theora is theora

Theora is forced to be non zero if it is zero and a sample
is asked for, as suggested by reimar

Fixes: Timeout (2min -> 600ms)
Fixes: 15366/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5737849938247680
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavutil/mips: Avoid instruction exception caused by gssqc1/gslqc1.
Shiyou Yin [Wed, 31 Jul 2019 01:30:01 +0000 (09:30 +0800)]
avutil/mips: Avoid instruction exception caused by gssqc1/gslqc1.

Ensure the address accesed by gssqc1/gslqc1 are 16-byte aligned.

4 years agoavcodec/msrle: remove unused items
Paul B Mahol [Thu, 1 Aug 2019 14:02:18 +0000 (16:02 +0200)]
avcodec/msrle: remove unused items

4 years agolavu/tx: add support for double precision FFT and MDCT
Lynne [Sat, 27 Jul 2019 17:54:20 +0000 (18:54 +0100)]
lavu/tx: add support for double precision FFT and MDCT

Simply moves and templates the actual transforms to support an
additional data type.
Unlike the float version, which is equal or better than libfftw3f,
double precision output is bit identical with libfftw3.

4 years agolavfi/zmq: Avoid mem copy past the end of input buffer
Andriy Gelman [Tue, 30 Jul 2019 21:16:08 +0000 (17:16 -0400)]
lavfi/zmq: Avoid mem copy past the end of input buffer

4 years agoFATE: add hls single file mode test case
Steven Liu [Tue, 30 Jul 2019 09:05:36 +0000 (17:05 +0800)]
FATE: add hls single file mode test case

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
4 years agotools/target_dec_fuzzer: fix memleak of extradata
Michael Niedermayer [Wed, 10 Jul 2019 20:32:49 +0000 (22:32 +0200)]
tools/target_dec_fuzzer: fix memleak of extradata

Fixes: memleak
Fixes: 15535/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5692162424963072
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vc1_pred: Fix invalid shift in scaleforsame()
Michael Niedermayer [Wed, 10 Jul 2019 21:27:19 +0000 (23:27 +0200)]
avcodec/vc1_pred: Fix invalid shift in scaleforsame()

Fixes: left shift of negative value -1
Fixes: 15531/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5759556258365440
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/vc1_block: Fix integer overflow in ff_vc1_pred_dc()
Michael Niedermayer [Thu, 4 Jul 2019 21:13:13 +0000 (23:13 +0200)]
avcodec/vc1_block: Fix integer overflow in ff_vc1_pred_dc()

Fixes: signed integer overflow: 32796 * 65536 cannot be represented in type 'int'
Fixes: 15430/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5735424087031808
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/truemotion2: Fix several integer overflows in tm2_motion_block()
Michael Niedermayer [Mon, 8 Jul 2019 21:00:09 +0000 (23:00 +0200)]
avcodec/truemotion2: Fix several integer overflows in tm2_motion_block()

Fixes: 15524/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-5173148372172800
Fixes: signed integer overflow: 13701388 - -2134868270 cannot be represented in type 'int'
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/apedec: Make coeffsA/B uint32_t, this avoids several cases of undefined behavior
Michael Niedermayer [Tue, 2 Jul 2019 10:30:32 +0000 (12:30 +0200)]
avcodec/apedec: Make coeffsA/B uint32_t, this avoids several cases of undefined behavior

Changing the type to an unsigned one to avoid many casts was suggested
This may be inadequate for fixing the UB on ILP64

Fixes: signed integer overflow: -1418162611 * 383 cannot be represented in type 'int'
Fixes: 15547/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5691384901664768
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/apedec: make left/right unsigned to avoid undefined behavior
Michael Niedermayer [Tue, 2 Jul 2019 10:13:19 +0000 (12:13 +0200)]
avcodec/apedec: make left/right unsigned to avoid undefined behavior

Fixes: signed integer overflow: 755176387 + 1515360583 cannot be represented in type 'int'
Fixes: 15506/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5706859232624640
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/apedec: Fix multiple integer overflows and undefined behaviorin filter_3800()
Michael Niedermayer [Sun, 16 Jun 2019 09:39:15 +0000 (11:39 +0200)]
avcodec/apedec: Fix multiple integer overflows and undefined behaviorin filter_3800()

Fixes: left shift of negative value -4
Fixes: signed integer overflow: -15091694 * 167 cannot be represented in type 'int'
Fixes: signed integer overflow: 1898547155 + 453967445 cannot be represented in type 'int'
Fixes: 15258/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5759095564402688
Fixes: signed integer overflow: 962196438 * 31 cannot be represented in type 'int'
Fixes: 15364/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5718799845687296
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/mpc: deallocate frames array on errors
Michael Niedermayer [Wed, 24 Jul 2019 21:11:50 +0000 (23:11 +0200)]
avformat/mpc: deallocate frames array on errors

Fixes: memleak on error path
Fixes: 15984/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5679918412726272
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agolavfi/vf_thumbnail_cuda: fix operator precedence bug
Rodger Combs [Tue, 30 Jul 2019 07:51:43 +0000 (02:51 -0500)]
lavfi/vf_thumbnail_cuda: fix operator precedence bug

Discovered via a warning when building with clang

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agolavd/v4l2: produce a 0 byte packet when a dequeued buffer's size is unexpected
Stephan Hilb [Wed, 5 Jun 2019 20:04:38 +0000 (22:04 +0200)]
lavd/v4l2: produce a 0 byte packet when a dequeued buffer's size is unexpected

Behave like we do for V4L2_BUF_FLAG_ERROR, implemented in commit 28f20d2ff4 .

For some devices (probably also related to the V4L driver implementation)
it happens that when invoking the ioctl DQBUF, the returned buffer is not
of the expected size. Here are two examples for such occurrences:

    [video4linux2,v4l2 @ 0x258b440] Dequeued v4l2 buffer contains 609596 bytes, but 614400 were expected. Flags: 0x00000001.
    /dev/video1: Invalid data found when processing input

    [video4linux2,v4l2 @ 0x225f440] Dequeued v4l2 buffer contains 609508 bytes, but 614400 were expected. Flags: 0x00000001.
    /dev/video1: Invalid data found when processing input

For the ffmpeg CLI tool this means it will stop capturing and exit.

The described behaviour was observed at least with one OmniVision USB
web cam and with some stk1160 devices.

If you search the web for the error message, you will find quite a few
instances of this problem. Some of them experienced on other devices.

Probably fixes ticket #4795

Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
4 years agolavu/hwcontext_qsv: fix the memory leak
Linjie Fu [Fri, 26 Jul 2019 08:00:24 +0000 (16:00 +0800)]
lavu/hwcontext_qsv: fix the memory leak

av_dict_free child_device_opts to fix the memory leak.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
4 years agoavformat/av1: fix AV1CodecConfigurationBox name in doxy
James Almer [Tue, 30 Jul 2019 03:33:47 +0000 (00:33 -0300)]
avformat/av1: fix AV1CodecConfigurationBox name in doxy

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agocbs_mpeg2: Fix parsing the last unit
Andreas Rheinhardt [Mon, 29 Jul 2019 19:56:56 +0000 (21:56 +0200)]
cbs_mpeg2: Fix parsing the last unit

There is one way to find out if avpriv_find_start_code has found a start
code or not: One has to check whether the state variable contains a
start code, i.e. whether the three most significant bytes are 0x00 00 01.
Checking for whether the return value is the end of the designated
buffer is not enough: If the last four bytes constitute a start code,
the return value is also the end of the buffer. This happens with
sequence_end_codes which have been ignored for exactly this reason,
although e.g. all three files used for fate tests of cbs_mpeg2 contain
sequence_end_codes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agocbs_mpeg2: Rearrange start code search
Andreas Rheinhardt [Mon, 29 Jul 2019 19:56:55 +0000 (21:56 +0200)]
cbs_mpeg2: Rearrange start code search

1. Currently, cbs_mpeg2_split_fragment uses essentially three variables
to hold the start code values found by avpriv_find_start_code. By
rearranging the code, one of them can be omitted.
2. The return value of avpriv_find_start_code points to the byte after
the byte containing the start code identifier (or to the byte after the
last byte of the fragment's data if no start code was found), but
cbs_mpeg2_split_fragment needs to work with the pointer to the byte
containing the start code identifier; it already did this, but in a
clumsy way. This has been changed.
3. Also use the correct type for the variable holding the
CodedBitstreamUnitType.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agocbs_mpeg2: Decompose Sequence End
Andreas Rheinhardt [Mon, 29 Jul 2019 19:56:54 +0000 (21:56 +0200)]
cbs_mpeg2: Decompose Sequence End

Sequence End units (or actually, sequence_end_codes) have up until now
not been decomposed; in fact due to a bug in cbs_mpeg2_split_fragment they
have mostly been treated as part of the preceding unit. So implement
decomposing them as preparation for fixing said bug.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agocbs_h264: Improve adding SEI messages
Andreas Rheinhardt [Mon, 29 Jul 2019 19:56:53 +0000 (21:56 +0200)]
cbs_h264: Improve adding SEI messages

Up until now, if an SEI messages was to be added to a fragment, it was
tried to add said SEI message to the first SEI NAL unit of the fragment
and if this SEI NAL unit already contained H264_NAL_SEI SEI messages (an
arbitrary limit imposed by cbs_h264), adding failed; if there was no SEI
NAL unit, a new one has been added.
With this commit, the fragment is searched for further NAL units to add
the SEI messages to. If all of them are full, a new SEI NAL unit is added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agocbs: Don't set AVBuffer's opaque
Andreas Rheinhardt [Mon, 29 Jul 2019 19:56:52 +0000 (21:56 +0200)]
cbs: Don't set AVBuffer's opaque

cbs is currently inconsistent regarding the opaque field that can be
used as a special argument to av_buffer_create in order to be used
during freeing the buffer: ff_cbs_alloc_unit_content and all the free
functions used name this parameter as if it should contain a pointer to
the unit whose content is about to be created; but both
ff_cbs_alloc_unit_content as well as ff_cbs_h264_add_sei_message
actually use a pointer to the CodedBitstreamContext as opaque. It should
actually be neither, because it is unneeded (as is evidenced by the fact
that none of the free functions use this pointer at all) and because it
ties the unit's content to the lifetime of other objects, although a
refcounted buffer is supposed to have its own lifetime that only ends
when its reference count reaches zero. This problem manifests itself in
the pointer becoming dangling.
The pointer to the unit can become dangling if another unit is added to
the fragment later as happens in the bitstream filters; in this case,
the pointer can point to the wrong unit (if the fragment's unit array
needn't be relocated) or it can point to where the array was earlier.
It can also become dangling if the unit's content is meant to survive
the resetting of the fragment it was originally read with. This applies
to the extradata of H.264 and HEVC.
The pointer to the context can become dangling if the context is closed
before the content is freed. Although this doesn't seem to happen right
now, it could happen, in particular if one uses different
CodedBitstreamContexts for in- and output.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/eatqi: Check for minimum frame size
Michael Niedermayer [Sun, 28 Jul 2019 20:29:57 +0000 (22:29 +0200)]
avcodec/eatqi: Check for minimum frame size

The minimum header is 8 bytes, the smallest bitstream that is passed to
the MB decode code is 4 bytes

Fixes: Timeout (35sec -> 18sec)
Fixes: 15800/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATQI_fuzzer-5684154517159936
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>
4 years agoavcodec/eatgv: Check remaining size after the keyframe header
Michael Niedermayer [Sun, 28 Jul 2019 19:09:14 +0000 (21:09 +0200)]
avcodec/eatgv: Check remaining size after the keyframe header

The minimal size which unpack() will not fail on is 5 bytes
Fixes: Timeout (14sec -> 77ms) (testcase 15508)
Fixes: 15508/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5700053513011200
Fixes: 15996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5751353223151616
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoh264_metadata: Support overscan_appropriate_flag
Mark Thompson [Sun, 28 Jul 2019 18:23:16 +0000 (19:23 +0100)]
h264_metadata: Support overscan_appropriate_flag

Fixes #8041.

4 years agocbs_h264: Fix missing inferred colour description fields
Mark Thompson [Sun, 28 Jul 2019 18:23:15 +0000 (19:23 +0100)]
cbs_h264: Fix missing inferred colour description fields

With video_signal_type_present_flag set but colour_description_present_flag
unset the colour fields would not have had their correct values inferred.

4 years agodnn: convert tf.pad to native model in python script, and load/execute it in the...
Guo, Yejun [Mon, 29 Jul 2019 01:56:54 +0000 (09:56 +0800)]
dnn: convert tf.pad to native model in python script, and load/execute it in the c code.

since tf.pad is enabled, the conv2d(valid) changes back to its original behavior.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
4 years agofate: add unit test for dnn-layer-pad
Guo, Yejun [Mon, 29 Jul 2019 01:56:40 +0000 (09:56 +0800)]
fate: add unit test for dnn-layer-pad

'make fate-dnn-layer-pad' to run the test

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
4 years agodnn: add layer pad which is equivalent to tf.pad
Guo, Yejun [Mon, 29 Jul 2019 01:56:33 +0000 (09:56 +0800)]
dnn: add layer pad which is equivalent to tf.pad

the reason to add this layer first is that vf_sr uses it in its
tensorflow model, and the next plan is to update the python script
to convert tf.pad into native model.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
4 years agoavcodec/cfhd: add bayer support
Paul B Mahol [Sat, 27 Jul 2019 11:09:20 +0000 (13:09 +0200)]
avcodec/cfhd: add bayer support

4 years agoavformat/hlsenc: Fix overflow of int for durations compute
Steven Liu [Mon, 29 Jul 2019 11:48:06 +0000 (19:48 +0800)]
avformat/hlsenc: Fix overflow of int for durations compute

Fix ticket: 8037

Reported-by: DusanBrejka
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
4 years agoavfilter/fade: don't allow nb_frames == 0
Gyan Doshi [Mon, 29 Jul 2019 05:23:12 +0000 (10:53 +0530)]
avfilter/fade: don't allow nb_frames == 0

In filter init, there's a division by nb_frames but value isn't checked.

4 years agolavfi: addroi filter
Mark Thompson [Sun, 7 Jul 2019 19:26:50 +0000 (20:26 +0100)]
lavfi: addroi filter

This can be used to add region of interest side data to video frames.

4 years agovaapi_encode: Add ROI support
Mark Thompson [Sun, 7 Jul 2019 19:26:49 +0000 (20:26 +0100)]
vaapi_encode: Add ROI support

4 years agoavcodec/mips: [loongson] refine process of setting block as 0 in h264dsp_mmi.
Shiyou Yin [Sun, 28 Jul 2019 04:42:09 +0000 (12:42 +0800)]
avcodec/mips: [loongson] refine process of setting block as 0 in h264dsp_mmi.

In function ff_h264_add_pixels4_8_mmi, there is no need to reset '%[ftmp0]'
to 0, because it's value has never changed since the start of the asm block.
This patch remove the redundant 'xor' and set src to zero once it was loaded.

In function ff_h264_idct_add_8_mmi, 'block' is seted to zero twice.
This patch removed the first setting zero operation and move the second one
after the load operation of block.

In function ff_h264_idct8_add_8_mmi, 'block' is seted to zero twice too.
This patch just removed the second setting zero operation.

This patch mainly simplifies the implementation of functions above,
the effect on the performance of whole h264 decoding process is not obvious.
According to the perf data, proportion of ff_h264_idct_add_8_mmi decreased from
0.29% to 0.26% and ff_h264_idct8_add_8_mmi decreased from 0.62% to 0.59% when decoding
H264 format on loongson 3A3000(For reference only , not very stable.).

Reviewed-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agovp9_metadata: Improve spec-compliance and warnings
Andreas Rheinhardt [Tue, 9 Jul 2019 01:10:45 +0000 (03:10 +0200)]
vp9_metadata: Improve spec-compliance and warnings

The earlier version had three deficits:
1. It allowed to set the stream to RGB although this is not allowed when
the profile is 0 or 2.
2. If it set the stream to RGB, then it did not automatically set the
range to full range; the result was that one got a warning every time a
frame with color_config element was processed if the frame originally
had TV range and the user didn't explicitly choose PC range. Now one
gets only one warning in such a situation.
3. Intra-only frames in profile 0 are automatically BT.601, but if the
user wished another color space, he was not informed about his wishes
being unfulfillable.

The commit also improves the documentation about this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoav1/h264_metadata: Don't reinitialize data
Andreas Rheinhardt [Wed, 19 Jun 2019 23:45:14 +0000 (01:45 +0200)]
av1/h264_metadata: Don't reinitialize data

If the relevant elements (the color description elements for AV1 and the
VUI elements in general for H.264 (since 1156b507)) are absent, then their
correct values (usually meaning unknown) have already been inferred by
the reading process, so that it is unnecessary to initialize them again
in the av1/h264_metadata filters even when they were initially absent.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agocbs_mpeg2: Fix parsing of picture and slice headers
Andreas Rheinhardt [Wed, 19 Jun 2019 23:45:12 +0000 (01:45 +0200)]
cbs_mpeg2: Fix parsing of picture and slice headers

1. The extra information in slice headers was parsed incorrectly:
In the first reading pass to derive the length of the extra information,
one should look at bits n, n + 9, n + 18, ... and check whether they
equal one (further extra information) or zero (end of extra information),
but instead bits n, n + 8, n + 16, ... were inspected. The second pass
of reading (where the length is already known and the bytes between the
length-determining bits are copied into a buffer) did not record what
was in bits n, n + 9, n + 18, ..., presuming they equal one. And during
writing, the bytes in the buffer are interleaved with set bits and
written. This means that if the detected length of the extra information
was greater than the real length, the output was corrupted. Fortunately
no sample is known that made use of this mechanism: The extra information
in slices is still marked as reserved in the specifications. cbs_mpeg2
is now ready in case this changes.

2. Furthermore, the buffer is now padded and slightly different, but
very similar code for reading resp. writing has been replaced by code
used for both. This was made possible by a new macro, the equivalent
to cbs_h2645's fixed().

3. These changes also made it possible to remove the extra_bit_slice
element from the MPEG2RawSliceHeader structure. Said element was always
zero except when the detected length of the extra information was less
than the real length.

4. The extra information in picture headers (which uses essentially the
same syntax as the extra information in slice headers) has simply been
forgotten. This meant that if this extra information was present, it was
discarded during reading; and unfortunately writing created invalid
bitstreams in this case (an extra_bit_picture - the last set bit of the
whole unit - indicated that there would be a further byte of data,
although the output didn't contain said data).

This has been fixed; both types of extra information are now parsed via
the same code and essentially passed through.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agocbs: Remove useless initializations
Andreas Rheinhardt [Wed, 19 Jun 2019 23:45:11 +0000 (01:45 +0200)]
cbs: Remove useless initializations

Up until now, a temporary variable was used and initialized every time a
value was read in CBS; if reading turned out to be successfull, this
value was overwritten (without having ever been looked at) with the
value read if reading was successfull; on failure the variable wasn't
touched either. Therefore these initializations can be and have been
removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agompeg2_metadata, cbs_mpeg2: Fix handling of colour_description
Andreas Rheinhardt [Wed, 19 Jun 2019 23:45:10 +0000 (01:45 +0200)]
mpeg2_metadata, cbs_mpeg2: Fix handling of colour_description

If a sequence display extension is read with colour_description equal to
zero, but a user wants to add one or more of the colour_description
elements, then the colour_description elements the user did not explicitly
request to be set are set to zero and not to the value equal to
unknown/unspecified (namely 2). A value of zero is not only inappropriate,
but explicitly forbidden. This is fixed by inferring the right default
values during the reading process if the elements are absent; moreover,
changing any of the colour_description elements to zero is now no longer
possible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/assdec: undefined use of memcpy()
Michael Niedermayer [Wed, 24 Jul 2019 20:55:15 +0000 (22:55 +0200)]
avcodec/assdec: undefined use of memcpy()

Fixes: null pointer passed as argument 2, which is declared to never be null
Fixes: 16008/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SSA_fuzzer-5650582821404672 (this is a separate issue found in this testcase)
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>