Commit Graph

91272 Commits

Author SHA1 Message Date
Karthick Jeyapal 2efdbf7367 avformat/dashenc: Added option for Segment file format
Right now segment file format is chosen to be either mp4 or webm based on the codec format.
This patch makes that choice configurable by the user, instead of being decided by the muxer.

Also with this change per-stream choice segment file format(based on codec type) is not possible.
All the output audio and video streams should be in the same file format.
2018-05-28 10:52:01 +05:30
Michael Niedermayer e3275f937d avcodec/ac3dec: Check that the number of channels with dependant streams is valid
Fixes: left shift of 1 by 63 places cannot be represented in type 'long long'
Fixes: out of array access
Fixes: 7284/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_fuzzer-5767914968842240

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 23:10:12 +02:00
Michael Niedermayer e3f656f2de avcodec/ac3dec: Fix null pointer dereference in ac3_decode_frame()
Fixes: index 8 out of bounds for type 'uint8_t *[8]'
Fixes: 7273/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EAC3_fuzzer-6296497667702784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 23:10:12 +02:00
Michael Niedermayer 90475db97e avcodec/aacdec_fixed: use 64bit to avoid overflow in rounding in apply_dependent_coupling_fixed()
Fixes: signed integer overflow: -2141499320 + -14469590 cannot be represented in type 'int'
Fixes: 7351/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-6351214791884800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 23:10:12 +02:00
Michael Niedermayer 62cb6fadf3 oavcodec/aacpsdsp_template: Use unsigned for hs0X to prevent undefined behavior
Fixes: signed integer overflow: 1073741842 + 1784008138 cannot be represented in type 'int'
Fixes: 6792/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5677589835284480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 23:10:12 +02:00
Michael Niedermayer 53f241218d avcodec/g723_1dec: Clip bits2 in both directions
Fixes: shift exponent 33 is too large for 32-bit type 'int'
Fixes: 6743/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G723_1_fuzzer-5823772687859712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 23:10:12 +02:00
Michael Niedermayer e1182fac1a avcodec/mpeg4videoenc: Use 64 bit for times in mpeg4_encode_gop_header()
Fixes truncation
Fixes Assertion n <= 31 && value < (1U << n) failed at libavcodec/put_bits.h:169
Fixes: ffmpeg_crash_2.avi

Found-by: Thuan Pham <thuanpv@comp.nus.edu.sg>, Marcel Böhme, Andrew Santosa and Alexandru RazvanCaciulescu with AFLSmart

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 23:10:12 +02:00
Carl Eugen Hoyos fbb283cfef lavc/hevcdec: Treat clean random access nals as keyframes for -skip_frame.
Fixes ticket #7227.

Reviewed-by: Mark Thompson
2018-05-27 22:51:06 +02:00
Michael Niedermayer df3d962d2e libavformat/mxfenc: Add some () to attempt to workaround build issue on osx
fixes ticket7209

Tested-by: Jim DeLaHunt <from.ffmpeg-dev@jdlh.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 21:38:33 +02:00
Michael Niedermayer 1386a199f9 configure: Omit fsanitize flags if they are already specified by the user
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-27 21:38:33 +02:00
Reino Wijnsma 0263c52f4d configure: fix check for mbedtls
Add missing libraries needed when linking with a static build of MbedTLS.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-05-27 16:18:18 -03:00
Marton Balint 2b05981312 avformat/mxf: fix NTSC 59.94 samples per frame layout
FFmbc uses this.
bmx uses this.
XAVC MXF Mapping and Operating Points prefers this.
Basic rounding rules also yields these numbers.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-27 19:55:09 +02:00
Gagandeep Singh 9cefb9e7ec lavc/cfhd: interlaced frame decoding added
ticket #5522 output of given samples significantly improved
2018-05-27 15:16:45 +01:00
Michael Niedermayer 63c4a4b0d6 avcodec/mlpdec: Only change noise_type if the related fields are valid
Fixes: inconsistency
Fixes:runtime error: index 8 out of bounds for type 'int32_t [8]'
Fixes: 6686/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5191383498358784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-26 00:54:55 +02:00
Michael Niedermayer 10c8521265 indeo4: Decode all or nothing of a band header.
This avoids inconsistent value combinations.
Alternatively it would be possible to add more checks and careful use of
temporary variables, but my try of this quickly seemed to become
a rather large change.
The disadvantage of this, is that the struct is copied back and forth.

Fixes: index 6 out of bounds for type 'const uint16_t [5][16]'
Fixes: 6557/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO4_fuzzer-4787296550256640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-26 00:54:55 +02:00
Michael Niedermayer f77eee67e2 avcodec/ac3dec: Use frame_size if superframe_size is 0
Fixes: Infinite loop
Fixes: 7669/clusterfuzz-testcase-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4689042185650176
Fixes: 7670/clusterfuzz-testcase-ffmpeg_AV_CODEC_ID_AC3_fuzzer-4706306762997760
Fixes: 7672/clusterfuzz-testcase-ffmpeg_AV_CODEC_ID_EAC3_fuzzer-4702108499574784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-26 00:54:55 +02:00
Carl Eugen Hoyos 085fe9822d lavc/hevc_ps: Use correct pix_fmt AV_PIX_FMT_GRAY9 for 9-bit 4:0:0 input. 2018-05-25 20:46:11 +02:00
Carl Eugen Hoyos 7b51b8020c lavc/j2kenc: Support AV_PIX_FMT_PAL8. 2018-05-25 20:09:22 +02:00
Carl Eugen Hoyos 42b4351333 lavf/img2dec: Auto-detect xwd images. 2018-05-25 20:06:34 +02:00
Carl Eugen Hoyos 7c333dc6a7 doc/codecs: Remove option sc_factor.
Fixes ticket #7228.
The option was disabled since 4a62f477 and removed in 6e69525e.
2018-05-24 18:23:53 +02:00
Steven Liu 50df4c958b avformat/hlsenc: support http method for hls fmp4
fix ticket: 7160

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2018-05-24 11:55:58 +08:00
Steven Liu 04b6060616 avformat/dashdec: replace user-agent to user_agent for deprecate warning message 2018-05-24 11:49:04 +08:00
Colin NG 93fc96e199 avformat/dashdec: Fix for ticket 7149 (Segfault when decoding dash streams)
simplify the code to check common init section
2018-05-24 11:49:00 +08:00
Colin NG 9aee574dd0 avformat/dashdec: Fix for ticket 7149 (Segfault when decoding dash streams)
Add NULL pointer check for init_section
2018-05-24 11:48:39 +08:00
Mark Thompson 8ef51a4092 hwcontext_vaapi: Fix mapping from DRM
This was broken by bed670a1de, which added
an assert that always failed.
2018-05-24 01:20:31 +01:00
Michael Niedermayer fe84f70819 avformat/mov: replace a value error by clipping into valid range in mov_read_stsc()
Fixes: #7165

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-22 21:05:45 +02:00
Michael Niedermayer 919e37377a avformat/bintext: Reduce detection for random .bin files as it more likely is not a multimedia related file
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-22 21:05:45 +02:00
Carl Eugen Hoyos 1083808c48 lavc/jpeg2000dec: Move a variable declaration closer to its usage. 2018-05-22 12:55:46 +02:00
Carl Eugen Hoyos 848ce6f0a6 lavc/jpeg2000dec: Use a define to clarify the meaning of a constant. 2018-05-22 12:54:32 +02:00
Carl Eugen Hoyos 15f50ccc6f lavc/h264_parse: Remove a superfluous linebreak. 2018-05-22 12:48:53 +02:00
Thomas Volkert c24d247e2c libavformat: add mbedTLS based TLS
Signed-off-by: James Almer <jamrial@gmail.com>
2018-05-21 19:43:04 -03:00
James Almer 27df34bf1f avcodec/libvpxenc: fix setting amount of threads used for encoding
The libvpx doxy says that a value of 0 for the g_threads field is
equivalent to a value of 1, whereas for avctx->thread_count it means
the maximum amount of threads possible for the host system.

Use av_cpu_count() to get the correct thread count when auto threads
is requested.

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-05-21 18:52:31 -03:00
Mark Thompson ba7d1377e8 hwcontext: Add test for device creation and derivation
This uses any devices it can find on the host system - on a system with no
hardware device support or in builds with no support included it will do
nothing and pass.
2018-05-21 20:54:52 +01:00
Aman Gupta 70d25268c2 avformat/mpegts: fix memory leak with merge_pmt_versions=1
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-21 12:16:06 -07:00
Aman Gupta fc2daf36f9 doc: remove AVStream private fields from APIchanges
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-21 12:13:14 -07:00
Aman Gupta 64680fff3b avformat/mpegts: rename variable to clarify meaning
Both stream_id and stream_identifier are used in this file,
and have different meanings. The latter comes from the
stream_identifier_descriptor.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-21 12:13:14 -07:00
Michael Niedermayer 2c2d689c56 avformat/mov: Only fail for STCO/STSC contradictions if both exist
Fixes regression with playback of GF9720Repeal20the20Eighth20with20Helen20Linehan.m4a
See: crbug 822666

Found-by: "Mattias Wadman <mattias.wadman@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-21 01:50:21 +02:00
Michael Niedermayer 56e76bd057 avformat/mov: Break out early if chunk_count is 0 in mov_build_index()
Without this some operations might overflow (undefined behavior)
even though the index adding loop would never execute

No testcase known

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-21 01:38:56 +02:00
Jerome Borsboom fac5849915 avcodec/vc1: FIELDTX is only present in interlaced frame I/BI pictures
If v->fieldtx_is_raw is not reset to zero, it may spill over from a previous
interlaced frame I/BI picture.

Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 23:56:30 +02:00
Michael Niedermayer cadf7a7f39 avformat/mp3dec: require 90% of a file to be mp3 if only 1 mp3 frame is found in sequence
This eliminates several low score detections of non mp3 files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Michael Niedermayer 81b3e7c9c3 avformat/mp3dec: Require 50% of the file to be mp3 frames in the maxframes>200 probing test
This corrects several misdetections of large files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Michael Niedermayer 60d1792779 avformat/mp3dec: Require probing data to be 50% mp3 frames for low score probing to succeed
This massively reduces the detection of random data as low score mp3
It may improve security by making it harder to read non multimedia data

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Jerome Borsboom 2b86472a65 avcodec/vc1: fix calculation of the last line of a slice
Only for the last slice of the first field is the last line of the slice
equal to the height of the field.

Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Jerome Borsboom ca878845ae avcodec/vc1: DIRECTBIT is only present in inter MBs
DIRECTBIT was decoded before the intra/inter MB branching when decoding
interlace frame B pictures. Resulting in mistakenly also decoding it for intra
MBs where this syntax element is not present.

Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-20 13:17:36 +02:00
Martin Vignali 411f7141a3 avdevice/sdl2 : add option to define if the window quit action is available 2018-05-19 14:55:15 +02:00
Martin Vignali 644130bcaa avdevice/sdl2output : fix setting window_size 2018-05-19 14:55:11 +02:00
Aman Gupta 16b4f97b72 avformat/mpegts: add merge_pmt_versions option
This new optional flag makes it easier to deal with mpegts
samples where the PMT is updated and elementary streams move
to different PIDs in the middle of playback.

Previously, new AVStreams were created per PID, and it was up
to the user to figure out which streams had migrated to a new PID
(by iterating over the list of AVProgram and making guesses), and
switch seamlessly to the new AVStream during playback.

Transcoding or remuxing these streams with ffmpeg on the CLI was
also quite painful, and the user would need to extract each set
of PIDs into a separate file and then stitch them back together.

With this new option, the mpegts demuxer will automatically detect
PMT changes and feed data from the new PID to the original AVStream
that was created for the orignal PID. For mpegts samples with
stream_identifier_descriptor available, the unique ID is used to
merge PIDs together. If the stream id is not available, the demuxer
attempts to map PIDs based on their position within the PMT.

With this change, I am able to playback and transcode/remux these
two samples which previously caused issues:

    https://tmm1.s3.amazonaws.com/pmt-version-change.ts
    https://kuroko.fushizen.eu/videos/pid_switch_sample.ts

I also have another longer sample in which the PMT changes
repeatedly and ES streams move to different pids three times
during playback:

    https://tmm1.s3.amazonaws.com/multiple-pmt-change.ts

Demuxing this sample with the new option shows several new log
messages as the PMT changes are handled:

    [mpegts] detected PMT change (program=1, version=3/6, pcr_pid=0xf98/0xfb7)
    [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfb7
    [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfb8
    [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfb9
    [mpegts] detected PMT change (program=1, version=6/3, pcr_pid=0xfb7/0xf98)
    [mpegts] detected PMT change (program=1, version=3/4, pcr_pid=0xf98/0xf9b)
    [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xf9b
    [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xf9c
    [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xf9d
    [mpegts] detected PMT change (program=1, version=4/5, pcr_pid=0xf9b/0xfa9)
    [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfa9
    [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfaa
    [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfab
    [mpegts] detected PMT change (program=1, version=5/6, pcr_pid=0xfa9/0xfb7)

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 19:00:29 -07:00
Aman Gupta 24579bf537 avformat/mpegts: keep track of PMT details in AVProgram/AVStream
With these fields, the user has enough information to
detect PMT changes and switch to new streams when the PMT
is updated with new ES pids.

To do so, the user would monitor the AVProgram they're interested
in for changes to pmt_version. If the version changes, they would
iterate over the program's streams to find new streams added with
the updated version number.

If new versions of streams are found, then the user would first try
to replace existing streams where stream_identifier matched.
If stream_identifier is not available, then the user would compare
pmt_stream_idx instead to replace the stream that was previously
at the same position within the PMT.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 19:00:29 -07:00
Aman Gupta 2b2f2f65f3 avformat: add fields to AVProgram/AVStream for PMT change tracking
These fields will allow the mpegts demuxer to expose details about
the PMT/program which created the AVProgram and its AVStreams.

In mpegts, a PMT which advertises streams has a version number
which can be incremented at any time. When the version changes,
the pids which correspond to each of it's streams can also change.

Since ffmpeg creates a new AVStream per pid by default, an API user
needs the ability to (a) detect when the PMT changed, and (b) tell
which AVStream were added to replace earlier streams.

This has been a long-standing issue with ffmpeg's handling of mpegts
streams with PMT changes, and I found two related patches in the wild
that attempt to solve the same problem:

The first is in MythTV's ffmpeg fork, where they added a
void (*streams_changed)(void*); to AVFormatContext and call it from
their fork of the mpegts demuxer whenever the PMT changes.

The second was proposed by XBMC in
https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html,
where they created a new AVMEDIA_TYPE_DATA stream with id=0 and
attempted to send packets to it whenever the PMT changed.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-18 19:00:29 -07:00
James Almer 79126ce80e avfilter/vsrc_testsrc: fix a preprocessor check
Signed-off-by: James Almer <jamrial@gmail.com>
2018-05-18 17:42:57 -03:00