ffmpeg.git
5 months agolavc/tiff: Enable decoding of LinearRaw images
Nick Renieris [Thu, 29 Aug 2019 13:10:54 +0000 (16:10 +0300)]
lavc/tiff: Enable decoding of LinearRaw images

"LinearRaw" is a value that the PhotometricInterpretation tag can be set
to on DNG images that contain color information for all channels instead
of being bayer-encoded ("CFA" value).

The DNG decoder is complete enough that we can enable this now.

Sample:
- http://www.rawsamples.ch/raws/nikon/SCANNER_NIKON_LS5000.DNG

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Default-initialize WhiteLevel DNG tag value
Nick Renieris [Thu, 29 Aug 2019 13:10:53 +0000 (16:10 +0300)]
lavc/tiff: Default-initialize WhiteLevel DNG tag value

Initialized to `(2 ^ BitsPerSample) - 1` as per the DNG Specification.

Also make sure that `BlackLevel < WhiteLevel`.

This fixes decoding for "X7 CinemaDNG" samples here:
- https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Support DNGs with striped (non-tiled) JPEGs images
Nick Renieris [Thu, 29 Aug 2019 13:10:52 +0000 (16:10 +0300)]
lavc/tiff: Support DNGs with striped (non-tiled) JPEGs images

DNG samples here can now be decoded:
- https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/mjpegdec: Skip unknown APPx marker on bayer images
Nick Renieris [Thu, 29 Aug 2019 13:10:51 +0000 (16:10 +0300)]
lavc/mjpegdec: Skip unknown APPx marker on bayer images

Samples:
- Embedded JPEG images in the DNG images here:
  https://www.photographyblog.com/previews/pentax_k1_photos

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Decode 10-bit and 14-bit DNG images
Nick Renieris [Thu, 29 Aug 2019 13:10:50 +0000 (16:10 +0300)]
lavc/tiff: Decode 10-bit and 14-bit DNG images

10-bit sample: http://www.rawsamples.ch/raws/phones/RAW_ONEPLUS_ONE-A0001.DNG
14-bit sample: https://drive.google.com/open?id=0B4JyRT3Lth5HVndyOTVOdWktM3J4TFEydTk1MnY3RWlpSzVB

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Support decoding of DNGs with single-component JPEGs
Nick Renieris [Thu, 29 Aug 2019 13:10:49 +0000 (16:10 +0300)]
lavc/tiff: Support decoding of DNGs with single-component JPEGs

This enables decoding of DNG images generated by the 'DJI Zenmuse X7'
digital camera
Samples: https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/mjpegdec: Enable decoding of single-component bayer images
Nick Renieris [Thu, 29 Aug 2019 13:10:48 +0000 (16:10 +0300)]
lavc/mjpegdec: Enable decoding of single-component bayer images

Also, ensure no false positives when determining DNG bayer images, by
setting them in tiff.c instead of relying on a heuristic.  There's no
way to determine this just from the JPEG data, so we have to pass this
information from outside the MJPEG decoder.

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Force DNG pixel data endianness on an edge case
Nick Renieris [Thu, 29 Aug 2019 13:10:47 +0000 (16:10 +0300)]
lavc/tiff: Force DNG pixel data endianness on an edge case

This fixes "X7 RAW" and "X7 CinemaDNG" samples here:
- https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Don't apply strips-related logic to tiled images
Nick Renieris [Thu, 29 Aug 2019 13:10:46 +0000 (16:10 +0300)]
lavc/tiff: Don't apply strips-related logic to tiled images

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Fix edge case with full-length/width tiles
Nick Renieris [Thu, 29 Aug 2019 13:10:45 +0000 (16:10 +0300)]
lavc/tiff: Fix edge case with full-length/width tiles

When the height is equal to the tile length (full-height tile)
after `height % tile_length` is applied with the current code,
it results in the operating tile_length to be 0.  This commit
makes this leftover logic only applies if it's necessary.

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/jpegtables: Handle multiple mappings to the same value
Nick Renieris [Thu, 29 Aug 2019 13:10:44 +0000 (16:10 +0300)]
lavc/jpegtables: Handle multiple mappings to the same value

Some JPEGs [1] have incorrect DHT entries that map 2 codes to
the same value.

The second (last) mapping does not ever actually appear in the
code stream, therefore ignoring any mappings after the first one
fixes this.

Without this, an "mjpeg_decode_dc: bad vlc: 0:0" error is thrown.

In all known files, the 2 codes are mapped to symbol 0 so only
that case is checked.

[1]: Embedded JPEGs in "X7 RAW" and "X7 CinemaDNG" samples here:
     https://www.dji.com/gr/zenmuse-x7/info#downloads

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Apply color scaling to uncompressed DNGs
Nick Renieris [Thu, 29 Aug 2019 13:10:43 +0000 (16:10 +0300)]
lavc/tiff: Apply color scaling to uncompressed DNGs

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Convert DNGs to sRGB color space
Nick Renieris [Thu, 29 Aug 2019 13:10:42 +0000 (16:10 +0300)]
lavc/tiff: Convert DNGs to sRGB color space

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/tiff: Decode embedded JPEGs in DNG images
Nick Renieris [Thu, 29 Aug 2019 13:10:41 +0000 (16:10 +0300)]
lavc/tiff: Decode embedded JPEGs in DNG images

Used a technique similar to lavc/tdsc.c for invoking the MJPEG decoder.

This commit adds support for:
- DNG tiles
- DNG tile huffman lossless JPEG decoding
- DNG 8-bpp ("packed" as dcraw calls it) decoding
- DNG color scaling [1]
  - LinearizationTable tag
  - BlackLevel tag

[1]: As specified in the DNG Specification - Chapter 5

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agolavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs
Nick Renieris [Thu, 29 Aug 2019 13:10:40 +0000 (16:10 +0300)]
lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs

Main image data in DNGs is usually comprised of tiles, each of which is a Huffman-encoded lossless JPEG.

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

Signed-off-by: Nick Renieris <velocityra@gmail.com>
5 months agoavformat/dashdec: start from the root uri when baseURL is start with '/'
Steven Liu [Thu, 29 Aug 2019 09:33:34 +0000 (17:33 +0800)]
avformat/dashdec: start from the root uri when baseURL is start with '/'

fix ticket: 8097

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agoavfilter/vf_delogo: support expr in delogo filter
Steven Liu [Tue, 27 Aug 2019 21:39:32 +0000 (05:39 +0800)]
avfilter/vf_delogo: support expr in delogo filter

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agolavf/hlsenc: refine the get_relative_url function to avoid extra malloc for relation...
Limin Wang [Fri, 30 Aug 2019 03:45:39 +0000 (11:45 +0800)]
lavf/hlsenc: refine the get_relative_url function to avoid extra malloc for relation path

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
5 months agoavcodec: Support EBU Tech. 3213-E primaries values
Raphaël Zumer [Sun, 11 Aug 2019 13:54:58 +0000 (09:54 -0400)]
avcodec: Support EBU Tech. 3213-E primaries values

Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavfilter: Support EBU Tech. 3213-E primaries values
Raphaël Zumer [Sun, 11 Aug 2019 13:54:57 +0000 (09:54 -0400)]
avfilter: Support EBU Tech. 3213-E primaries values

Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries value
Raphaël Zumer [Sun, 11 Aug 2019 13:54:56 +0000 (09:54 -0400)]
avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries value

This is an alias for JEDEC P22.

The name associated with the value is also changed
from jedec-p22 to ebu3213 to match ITU-T H.273.

Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/truemotion2: Fix multiple integer overflows in tm2_null_res_block()
Michael Niedermayer [Thu, 15 Aug 2019 21:22:50 +0000 (23:22 +0200)]
avcodec/truemotion2: Fix multiple integer overflows in tm2_null_res_block()

Fixes: signed integer overflow: 1795032576 + 598344192 cannot be represented in type 'int'
Fixes: 16196/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-5636723419119616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agotools/target_dec_fuzzer: adjust pixel threshold for TRUEMOTION2, as it allows coding...
Michael Niedermayer [Thu, 15 Aug 2019 20:26:14 +0000 (22:26 +0200)]
tools/target_dec_fuzzer: adjust pixel threshold for TRUEMOTION2, as it allows coding gigantic images on tiny input

Fixes: Timeout (137sec -> 6sec)
Fixes: 16090/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-5674245178261504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/vc1_block: Check the return code from vc1_decode_p_block()
Michael Niedermayer [Thu, 15 Aug 2019 18:15:20 +0000 (20:15 +0200)]
avcodec/vc1_block: Check the return code from vc1_decode_p_block()

Fixes: left shift of negative value -1
Fixes: 16424/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-5656579055026176
Fixes: 16358/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5714436358144000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/vc1dec: Require res_sprite for wmv3images
Michael Niedermayer [Thu, 15 Aug 2019 18:04:35 +0000 (20:04 +0200)]
avcodec/vc1dec: Require res_sprite for wmv3images

non res_sprite leads to decoder delay which leads to assertion failure
Fixes: Assertion failure
Fixes: 16402/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5704510034411520
Fixes: left shift of 1073741824 by 1 places cannot be represented in type 'int'
Fixes: 16425/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5692858838810624

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/vc1_block: Check for double escapes
Michael Niedermayer [Thu, 15 Aug 2019 16:47:54 +0000 (18:47 +0200)]
avcodec/vc1_block: Check for double escapes

Fixes: out of array read
Fixes: 16331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5672735195267072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavutil/mathematics: Fix 2 overflows in av_add_stable()
Michael Niedermayer [Sat, 10 Aug 2019 19:09:03 +0000 (21:09 +0200)]
avutil/mathematics: Fix 2 overflows in av_add_stable()

Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long'
Fixes: 16022/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5759796759756800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavformat/utils: return pending IO error on EOF in av_read_frame()
Marton Balint [Sat, 24 Aug 2019 20:00:12 +0000 (22:00 +0200)]
avformat/utils: return pending IO error on EOF in av_read_frame()

avio_feof() returns true both in case of actual EOF and in case of IO errors.
Some demuxers (matroska) have special handling to be able to return the proper
error for this exact reason, e.g.:

if (avio_feof(pb)) {
     if (pb->error) {
         return pb->error;
     } else {
         return AVERROR_EOF;
     }
}

However, most of the demuxers do not, and they simply return AVERROR_EOF if
avio_feof() is true, so there is a real chance that IO errors are mistaken for
EOF.

We might just say that the API user should always check the IO context error
attribute on EOF to make sure no IO errors happened, but not even ffmpeg.c does
this. It should be more intuitive to the API user if we simply return the IO
error as the return value of av_read_frame() instead of AVERROR_EOF.

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agoavformat/avidec: add support for recognizing HEVC fourcc when demuxing
Marton Balint [Fri, 23 Aug 2019 23:39:33 +0000 (01:39 +0200)]
avformat/avidec: add support for recognizing HEVC fourcc when demuxing

Some security cams generate this, as well as some versions of VirtualDub and
VLC so support for _reading_ such files is justified.

Fixes ticket #7110.

See also this discussion: https://patchwork.ffmpeg.org/patch/8744/

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agoavformat/mpegts: fix teletext PTS when selecting teletext streams only
Marton Balint [Fri, 23 Aug 2019 22:27:41 +0000 (00:27 +0200)]
avformat/mpegts: fix teletext PTS when selecting teletext streams only

After a1b4f120c031e6697bac9fd8c725d9c37ee36d13 the teletext PTS values were set
to AV_NOPTS_VALUE if the stream of the PCR pid was discarded.

What actually matters is that if we parse the PCR of the PCR PID or not, so
let's use the cached discard value of the actual PCR PID instead of the stream
discard value, which may be different.

Also fixes ticket #7567, which was caused by the fact that teletext PTS values
were not touched if the PCR pid was discarded even before
a1b4f120c031e6697bac9fd8c725d9c37ee36d13.

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agotools/target_dec_fuzzer: Init parsepkt
Michael Niedermayer [Fri, 30 Aug 2019 22:03:57 +0000 (00:03 +0200)]
tools/target_dec_fuzzer: Init parsepkt

Fixes: memory corruption
Fixes: 16702/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-5768418552184832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavfilter/vf_v360: add cubemap 1x6 layout
Paul B Mahol [Sat, 31 Aug 2019 12:52:32 +0000 (14:52 +0200)]
avfilter/vf_v360: add cubemap 1x6 layout

5 months agoavcodec/vorbisdec: Check get_vlc2() failure
Michael Niedermayer [Sun, 7 Jul 2019 23:18:05 +0000 (01:18 +0200)]
avcodec/vorbisdec: Check get_vlc2() failure

Fixes: out of array read
Fixes: 16510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VORBIS_fuzzer-5754510382727168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavfilter/vf_stereo3d: improve dubois anaglyphs
Paul B Mahol [Fri, 30 Aug 2019 20:35:51 +0000 (22:35 +0200)]
avfilter/vf_stereo3d: improve dubois anaglyphs

5 months agoavcodec/vaapi_encode: Simplify code with av_clip_int8()
Michael Niedermayer [Wed, 28 Aug 2019 17:26:49 +0000 (19:26 +0200)]
avcodec/vaapi_encode: Simplify code with av_clip_int8()

Reviewed-by: "Li, Zhong" <zhong.li@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agodnn: export operand info in python script and load in c code
Guo, Yejun [Tue, 20 Aug 2019 08:50:34 +0000 (16:50 +0800)]
dnn: export operand info in python script and load in c code

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
5 months agodnn: change .model file format to put layer number at the end of file
Guo, Yejun [Thu, 29 Aug 2019 05:53:41 +0000 (13:53 +0800)]
dnn: change .model file format to put layer number at the end of file

currently, the layer number is at the beginning of the .model file,
so we have to scan twice in python script, the first scan to get the
layer number. Only one scan needed after put the layer number at the
end of .model file.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
5 months agodnn: introduce dnn operand (in c code) to hold operand infos within network
Guo, Yejun [Thu, 29 Aug 2019 05:53:33 +0000 (13:53 +0800)]
dnn: introduce dnn operand (in c code) to hold operand infos within network

the info can be saved in dnn operand object without regenerating again and again,
and it is also needed for layer split/merge, and for memory reuse.

to make things step by step, this patch just focuses on c code,
the change within python script will be added later.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
5 months agoavfilter/vf_v360: add facebook's format
Eugene Lyapustin [Sun, 18 Aug 2019 17:26:36 +0000 (20:26 +0300)]
avfilter/vf_v360: add facebook's format

5 months agoavutil/file: add more check befor destory the buffer
Jun Zhao [Fri, 30 Aug 2019 01:09:16 +0000 (09:09 +0800)]
avutil/file: add more check befor destory the buffer

add more check befor destory the buffer

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
5 months agoavutil/file: always set *size to zero if *bufptr is NULL
Jun Zhao [Wed, 28 Aug 2019 16:15:52 +0000 (00:15 +0800)]
avutil/file: always set *size to zero if *bufptr is NULL

Always set *size to zero if *bufptr is NULL, it's more make sence.

fix #8095

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
5 months agoavcodec: add IMM5 decoder
Paul B Mahol [Fri, 14 Sep 2018 09:14:15 +0000 (11:14 +0200)]
avcodec: add IMM5 decoder

5 months agoavcodec/msrle: add a flush() callback
Paul B Mahol [Thu, 29 Aug 2019 16:28:49 +0000 (18:28 +0200)]
avcodec/msrle: add a flush() callback

The reference frame isn't valid after seeking.

5 months agoconfigure: fix --enable-omx compile on raspberry pi
Aman Gupta [Thu, 29 Aug 2019 15:44:45 +0000 (08:44 -0700)]
configure: fix --enable-omx compile on raspberry pi

Many ffmpeg + rpi compilation guides on the internet recommend
using `./configure --enable-omx --enable-omx-rpi`. This fails
to find the IL OMX headers on device because the omx require_headers
check happens first before the add_cflags in omx_rpi.

A workaround is to use `./configure --enable-omx-rpi` only, since
omx_rpi already implies omx. But because many users expect to use
existing scripts and commands, we swap the order here so omx_rpi
special cases are applied first.

In the past this wasn't an issue because users noticed the OMX_Core.h
missing error and installed libomxil-bellagio-dev. But since
76c82843ccad1, the rpi specific headers from /opt/vc/include/IL
are required.

Signed-off-by: Aman Gupta <aman@tmm1.net>
5 months agoavcodec/ivi: Allocate bufs later
Michael Niedermayer [Tue, 13 Aug 2019 23:28:09 +0000 (01:28 +0200)]
avcodec/ivi: Allocate bufs later

Fixes: Timeout (24sec->2sec)
Fixes: 15951/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO5_fuzzer-5095433266790400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agotools/target_dec_fuzzer: Adjust maxpixels for indeo4
Michael Niedermayer [Tue, 13 Aug 2019 21:42:09 +0000 (23:42 +0200)]
tools/target_dec_fuzzer: Adjust maxpixels for indeo4

Fixes: Timeout (131sec -> 4sec)
Fixes: 15581/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO4_fuzzer-5651105515569152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agotools/target_dec_fuzzer: Adjust GDV pixel threshold down by a factor of 2
Michael Niedermayer [Tue, 13 Aug 2019 20:06:12 +0000 (22:06 +0200)]
tools/target_dec_fuzzer: Adjust GDV pixel threshold down by a factor of 2

Fixes: Timeout (7sec -> 1sec)
Fixes: 14709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5704215281795072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agotools/target_dec_fuzzer: adjust pixel threshold for SANM, as it allows coding giganti...
Michael Niedermayer [Mon, 12 Aug 2019 08:40:30 +0000 (10:40 +0200)]
tools/target_dec_fuzzer: adjust pixel threshold for SANM, as it allows coding gigantic images on tiny input

Fixes: Timeout (13sec ->1sec)
Fixes: 16122/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5724944247291904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/tta: Fix integer overflow in prediction
Michael Niedermayer [Sun, 11 Aug 2019 18:56:44 +0000 (20:56 +0200)]
avcodec/tta: Fix integer overflow in prediction

Fixes: signed integer overflow: -395281576 + -1827578048 cannot be represented in type 'int'
Fixes: 16038/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5646109705240576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/vb: Check input packet size to be large enough to contain flags
Michael Niedermayer [Sun, 11 Aug 2019 22:21:49 +0000 (00:21 +0200)]
avcodec/vb: Check input packet size to be large enough to contain flags

Fixes: Timeout (->9sec)
Fixes: 16292/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VB_fuzzer-5747063496638464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/cavsdec: Limit the number of access units per packet to 2
Michael Niedermayer [Sat, 10 Aug 2019 15:34:37 +0000 (17:34 +0200)]
avcodec/cavsdec: Limit the number of access units per packet to 2

Fixes: Timeout (122sec -> 13ms)
Fixes: 15978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CAVS_fuzzer-5148925004087296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavformat/mpsubdec: Remove floating point usage
Michael Niedermayer [Tue, 30 Jul 2019 17:11:27 +0000 (19:11 +0200)]
avformat/mpsubdec: Remove floating point usage

This makes the code bitexact between platforms.
Intermediate timestamps between frames are preserved.
The timebase is simplified.
Rounding differs from doubles in cases where timestamps/durations
are "funny"

Suggested-by: jb
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agolavc/cbs_h2645: Use av_realloc instead of av_malloc
Thierry Foucu [Mon, 26 Aug 2019 20:50:40 +0000 (13:50 -0700)]
lavc/cbs_h2645: Use av_realloc instead of av_malloc

Follow the description of av_realloc, the memory needs to be allocated
by av_realloc.

5 months agolavf/dump: dump the vbv_delay with N/A instead of 18446744073709551615
Limin Wang [Tue, 27 Aug 2019 14:34:54 +0000 (22:34 +0800)]
lavf/dump: dump the vbv_delay with N/A instead of 18446744073709551615

How to check it:
./ffmpeg -f lavfi -i testsrc  -c:v mpeg2video  -f null  -
master:
  Side data:
        cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay:
        18446744073709551615
patch applied:
Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/dsd: use uint8_t instead of unsigned char
Paul B Mahol [Wed, 28 Aug 2019 15:30:55 +0000 (17:30 +0200)]
avcodec/dsd: use uint8_t instead of unsigned char

5 months agoavcodec/dsddec: add slice threading support
Paul B Mahol [Wed, 28 Aug 2019 15:28:16 +0000 (17:28 +0200)]
avcodec/dsddec: add slice threading support

5 months agoavformat/dsfdec: set packet pts/duration/pos correctly
Paul B Mahol [Tue, 30 Jul 2019 11:16:33 +0000 (13:16 +0200)]
avformat/dsfdec: set packet pts/duration/pos correctly

5 months agoavcodec/h264_refs: do not use invalid mmco values in case of error
Paul B Mahol [Wed, 7 Aug 2019 16:49:08 +0000 (18:49 +0200)]
avcodec/h264_refs: do not use invalid mmco values in case of error

Change one relevant assert to av_assert0 while here.

5 months agoavformat/mov: improve timecode calculation
Paul B Mahol [Thu, 22 Aug 2019 16:14:15 +0000 (18:14 +0200)]
avformat/mov: improve timecode calculation

Fixes timecode calculation for NTSC frame rates.
Fixes ticket #5978.

5 months agoavcodec/tiff: add missing break in tiff_decode_tag()
Paul B Mahol [Wed, 28 Aug 2019 13:46:40 +0000 (15:46 +0200)]
avcodec/tiff: add missing break in tiff_decode_tag()

5 months agoavformat/dhav: always initializer ret
Paul B Mahol [Wed, 28 Aug 2019 13:44:36 +0000 (15:44 +0200)]
avformat/dhav: always initializer ret

5 months agoavfilter/af_compand: change error condition into warning
Paul B Mahol [Tue, 6 Aug 2019 11:37:58 +0000 (13:37 +0200)]
avfilter/af_compand: change error condition into warning

5 months agolibavcodec/amfenc: Vulkan initialization support for encoder.
OvchinnikovDmitrii [Thu, 8 Aug 2019 18:33:25 +0000 (21:33 +0300)]
libavcodec/amfenc: Vulkan initialization support for encoder.

Added linux support for amf encoder through vulkan.

To use h.264(AMD VCE) encoder on linux amdgru-pro version 19.20+ and
amf-amdgpu-pro package(amdgru-pro contains, but does not install
automatically) are required.

This driver can be installed using amdgpu-pro-install script in
official amd driver archive.

Initialization of amf encoder occurs in this order:
1) trying to initialize through dx11(only windows)
2) trying to initialize through dx9(only windows)
3) trying to initialize through vulkan

Only Vulkan initialization available on linux.

5 months agoavcodec/qtrle: don't clear the palette when flushing
James Almer [Tue, 27 Aug 2019 18:24:01 +0000 (15:24 -0300)]
avcodec/qtrle: don't clear the palette when flushing

It may be propagated only once for the entire stream.

Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/qtrle: call ff_reget_buffer() only when the picture data is going to change
James Almer [Mon, 26 Aug 2019 17:29:59 +0000 (14:29 -0300)]
avcodec/qtrle: call ff_reget_buffer() only when the picture data is going to change

ff_reget_buffer() will attempt to create a writable copy of the frame,
which is not needed when the decoder intends to return a reference to
the same buffer as the previous frame.

Should reduce data copy, hopefully achieving a similar speed up as
a9dacdeea6168787a142209bd19fdd74aefc9dd6 without dropping frames.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoRevert "avcodec/qtrle: Do not output duplicated frames on insufficient input"
James Almer [Mon, 26 Aug 2019 02:10:41 +0000 (23:10 -0300)]
Revert "avcodec/qtrle: Do not output duplicated frames on insufficient input"

This reverts commit a9dacdeea6168787a142209bd19fdd74aefc9dd6.

This patch effectively made the decoder output vfr content out of samples
where cfr is expected.

Addresses ticket #7880.

Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/atrac9dec: Check block_align
Michael Niedermayer [Sun, 18 Aug 2019 23:03:59 +0000 (01:03 +0200)]
avcodec/atrac9dec: Check block_align

Fixes: Infinite loop
Fixes: 16260/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5676365617037312
Fixes: 16260/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5768093879500800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/qtrle: add a flush() callback
James Almer [Mon, 26 Aug 2019 18:27:55 +0000 (15:27 -0300)]
avcodec/qtrle: add a flush() callback

The reference frame isn't valid after seeking

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/h2645_parse: zero initialize the rbsp buffer
James Almer [Mon, 26 Aug 2019 03:54:20 +0000 (00:54 -0300)]
avcodec/h2645_parse: zero initialize the rbsp buffer

Fixes ticket #8093

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/vaapi_encode: respect -force_key_frames setting
Aman Gupta [Wed, 7 Aug 2019 17:20:51 +0000 (10:20 -0700)]
avcodec/vaapi_encode: respect -force_key_frames setting

This was a regression in 5fdcf85bbffe7451c227478fda62da5c0938f27d

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
5 months agotools/target_dec_fuzzer: Increase maxpixels threshold for dirac
Michael Niedermayer [Sat, 24 Aug 2019 23:00:30 +0000 (01:00 +0200)]
tools/target_dec_fuzzer: Increase maxpixels threshold for dirac

wavelets allow significant size expansion and they are also not
very fast.

Fixes: Timeout
Fixes: 16480/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5659892689403904 (108sec -> 17ms)
Fixes: 16480/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5749422717140992 (big ->15sec)

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>
5 months agotools/target_dec_fuzzer: Do not corrupt the packet size return
Michael Niedermayer [Sun, 25 Aug 2019 18:41:57 +0000 (20:41 +0200)]
tools/target_dec_fuzzer: Do not corrupt the packet size return

Fixes: Timeout (infinite)
Fixes: 16732/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-5642166377906176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/alac: Check for bps of 0
Michael Niedermayer [Thu, 8 Aug 2019 23:23:49 +0000 (01:23 +0200)]
avcodec/alac: Check for bps of 0

Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 15764/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5102101203517440

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavfilter/vf_derain: reindent code after last commit
Xuewei Meng [Mon, 26 Aug 2019 07:09:46 +0000 (15:09 +0800)]
avfilter/vf_derain: reindent code after last commit

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agodoc/examples/decode_video: add input file format information for usage
Steven Liu [Wed, 21 Aug 2019 11:34:49 +0000 (19:34 +0800)]
doc/examples/decode_video: add input file format information for usage

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agodoc/examples/decode_audio: print message about how to play the output file
Steven Liu [Wed, 21 Aug 2019 11:34:28 +0000 (19:34 +0800)]
doc/examples/decode_audio: print message about how to play the output file

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agoavformat/hlsenc: remove unused value
Steven Liu [Wed, 21 Aug 2019 02:24:36 +0000 (10:24 +0800)]
avformat/hlsenc: remove unused value

CID: 1452644
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agoavformat/hlsenc: fix memleak of filename
Steven Liu [Wed, 21 Aug 2019 02:24:25 +0000 (10:24 +0800)]
avformat/hlsenc: fix memleak of filename

CID: 1452445
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agoavformat/hlsenc: fix memleak in hls_write_trailer
Steven Liu [Wed, 21 Aug 2019 02:24:12 +0000 (10:24 +0800)]
avformat/hlsenc: fix memleak in hls_write_trailer

fix CID: 1426931

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
5 months agolibavfilter: Add dehaze-filter option in existing derain.
Xuewei Meng [Thu, 22 Aug 2019 10:28:44 +0000 (18:28 +0800)]
libavfilter: Add dehaze-filter option in existing derain.

Add the support of dehaze filter in existing derain filter source
code. As the processing procedure in FFmpeg is the same for current
derain and dehaze, we reuse the derain filter source code. The
model training and generation scripts are in repo
https://github.com/XueweiMeng/derain_filter.git

Reviewed-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: Xuewei Meng <xwmeng96@gmail.com>
5 months agolavc/x264: Also clean-up libx264rgb after init errors.
Carl Eugen Hoyos [Sun, 25 Aug 2019 14:09:40 +0000 (16:09 +0200)]
lavc/x264: Also clean-up libx264rgb after init errors.

Missed in c180f0f6

5 months agoavformat/movenc: add muxing support for Dolby TrueHD streams
James Almer [Thu, 1 Aug 2019 03:54:53 +0000 (00:54 -0300)]
avformat/movenc: add muxing support for Dolby TrueHD streams

Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavformat/mov: add demuxing support for Dolby TrueHD streams
James Almer [Thu, 1 Aug 2019 03:49:08 +0000 (00:49 -0300)]
avformat/mov: add demuxing support for Dolby TrueHD streams

Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/mlp_parser: export AVCodecContext frame_size
James Almer [Sun, 25 Aug 2019 01:41:52 +0000 (22:41 -0300)]
avcodec/mlp_parser: export AVCodecContext frame_size

Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavcodec/mlp_parse: move TrueHD channel layout and sample rate related code to the...
James Almer [Wed, 31 Jul 2019 20:54:28 +0000 (17:54 -0300)]
avcodec/mlp_parse: move TrueHD channel layout and sample rate related code to the header

It will be needed by the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
5 months agoavformat/dhav: handle files missing data at start
Paul B Mahol [Sat, 24 Aug 2019 16:03:46 +0000 (18:03 +0200)]
avformat/dhav: handle files missing data at start

Try to seek to end of file and if signature is found seek backwards until
last valid chunk is found.

5 months agoavformat/dhav: gracefully handle corrupted files
Paul B Mahol [Sat, 24 Aug 2019 08:59:49 +0000 (10:59 +0200)]
avformat/dhav: gracefully handle corrupted files

Try to find next valid chunk in offsets of 0x8000 from last good one.

5 months agofate/als: Add test for conformance file with 512 channels.
Thilo Borgmann [Thu, 22 Aug 2019 19:21:12 +0000 (21:21 +0200)]
fate/als: Add test for conformance file with 512 channels.

5 months agoavcodec/videotoolbox_hevc: avoid leaking cached_hw_frames_ctx
Pavel Koshevoy [Wed, 7 Aug 2019 02:42:15 +0000 (20:42 -0600)]
avcodec/videotoolbox_hevc: avoid leaking cached_hw_frames_ctx

vtctx->cached_hw_frames_ctx is unref'd in videotoolbox_uninit,
but videotoolbox_hevc used ff_videotoolbox_uninit which
doesn't unref cache_hw_frames_ctx.

Signed-off-by: Pavel Koshevoy <pkoshevoy@gmail.com>
5 months agoavcodec/omx: Fix handling of fragmented buffers
Dave Stevenson [Thu, 17 Jan 2019 17:39:34 +0000 (17:39 +0000)]
avcodec/omx: Fix handling of fragmented buffers

See https://trac.ffmpeg.org/ticket/7687

If an encoded frame is returned split over two or more
IL buffers due to the size, then there is a race between
whether get_buffer will fail, return NULL, and a truncated
frame is passed on, or IL will return the remaining part
of the encoded frame.
If get_buffer returns NULL, part of the frame is left behind
in the codec, and will be collected on the next call. That
then leaves a frame stuck in the codec. Repeat enough times
and the codec FIFO is full, and the pipeline stalls.

A performance improvement in the Raspberry Pi firmware means
that the timing has changed, and now frequently drops into the
case where get_buffer returns NULL.

Add code such that should a buffer be received without
OMX_BUFFERFLAG_ENDOFFRAME that get_buffer is called with wait
set, so we wait for the remainder of the frame.
This code has been made conditional on the Pi build in case
other IL implementations don't handle ENDOFFRAME correctly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Martin Storsjö <martin@martin.st>
5 months agoavcodec/omx: ensure zerocopy mode can be disabled on rpi builds
Aman Gupta [Thu, 22 Aug 2019 18:02:45 +0000 (11:02 -0700)]
avcodec/omx: ensure zerocopy mode can be disabled on rpi builds

fixes https://trac.ffmpeg.org/ticket/6586

Signed-off-by: Aman Gupta <aman@tmm1.net>
5 months agoavcodec/omx: add support for -force_key_frames
Aman Gupta [Wed, 21 Aug 2019 17:39:07 +0000 (10:39 -0700)]
avcodec/omx: add support for -force_key_frames

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Martin Storsjö <martin@martin.st>
5 months agoMAINTAINERS: add myself to OMX
Aman Gupta [Thu, 22 Aug 2019 21:10:26 +0000 (14:10 -0700)]
MAINTAINERS: add myself to OMX

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavformat/mpegtsenc: get rid of packet counting for sdt/pat/pmt
Marton Balint [Thu, 8 Aug 2019 07:53:10 +0000 (09:53 +0200)]
avformat/mpegtsenc: get rid of packet counting for sdt/pat/pmt

The packet counting based approach caused excessive sdt/pat/pmt for VBR, so
let's use a timestamp based approach instead similar to how we emit PCRs.
SDT/PAT/PMT period should be consistent for both VBR and CBR from now on.

Also change the type of sdt_period and pat_period to AV_OPT_TYPE_DURATION so no
floating point math is necessary.

Fixes ticket #3714.

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agoavformat/mpegtsenc: move some code around and simplify a bit
Marton Balint [Wed, 14 Aug 2019 22:51:10 +0000 (00:51 +0200)]
avformat/mpegtsenc: move some code around and simplify a bit

PCR does not need to be recalcualted for CBR when inserting a NULL or PCR only
packet.

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agoavformat/mpegtsenc: add support for setting PCR interval for VBR streams
Marton Balint [Mon, 12 Aug 2019 21:32:11 +0000 (23:32 +0200)]
avformat/mpegtsenc: add support for setting PCR interval for VBR streams

Also document the algorithm for the default PCR interval.

Fixes ticket #8061.

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agoavformat/mpegtsenc: rename pcr_period variable to pcr_period_ms
Marton Balint [Thu, 8 Aug 2019 20:35:25 +0000 (22:35 +0200)]
avformat/mpegtsenc: rename pcr_period variable to pcr_period_ms

Signed-off-by: Marton Balint <cus@passwd.hu>
5 months agoavcodec/alac: Fix multiple integer overflows in lpc_prediction()
Michael Niedermayer [Thu, 8 Aug 2019 17:48:19 +0000 (19:48 +0200)]
avcodec/alac: Fix multiple integer overflows in lpc_prediction()

Fixes: signed integer overflow: 2088795537 + 2147254401 cannot be represented in type 'int'
Fixes: signed integer overflow: -1500363496 + -1295351808 cannot be represented in type 'int'
Fixes: signed integer overflow: -79560 * 32640 cannot be represented in type 'int'
Fixes: signed integer overflow: 2088910005 + 2088796058 cannot be represented in type 'int'
Fixes: signed integer overflow: -117258064 - 2088725225 cannot be represented in type 'int'
Fixes: signed integer overflow: 2088725225 - -117258064 cannot be represented in type 'int'
Fixes: 15739/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5630664122040320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/smacker: Check that not all tables are skiped
Michael Niedermayer [Thu, 8 Aug 2019 20:38:11 +0000 (22:38 +0200)]
avcodec/smacker: Check that not all tables are skiped

If all tables are skipped it would be impossible to encode any
"non black" video.

Fixes: Timeout (78sec -> 1ms)
Fixes: 15821/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5652598838788096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
5 months agoavcodec/pictordec: Optimize picmemset() for single plane full lines
Michael Niedermayer [Fri, 2 Aug 2019 21:10:35 +0000 (23:10 +0200)]
avcodec/pictordec: Optimize picmemset() for single plane full lines

Fixes: Timeout (72sec -> 1sec)
Fixes: 15512/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PICTOR_fuzzer-5663942342344704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>