Commit Graph

20194 Commits

Author SHA1 Message Date
Petri Hintukainen 7a6bd54152 Add SUP/PGS subtitle muxer
Fixes ticket #2208
2017-09-09 12:07:14 +02:00
Steven Liu ab96e2ca81 avformat/dashdec: free resource allocated by xml
modify from av_free to xmlFree

Suggested-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2017-09-09 08:34:07 +08:00
Steven Liu 96d70694ae avformat/dashdec: add dash demuxer base version
ffmpeg need a dash demuxer for demux the dash formats base on
https://github.com/samsamsam-iptvplayer/exteplayer3/blob/master/tmp/ffmpeg/patches/3.2.2/000001_add_dash_demux.patch

TODO:
1. support multi bitrate dash.

v2 fixed:
1. from autodetect to disabled
2. from camelCase code style to ffmpeg code style
3. from RepType to AVMediaType
4. fix variable typo
5. change time value from uint32_t to uint64_t
6. removed be used once API
7. change 'time(NULL)`, except it is not 2038-safe.' to av_gettime and av_timegm
8. merge complex free operation to free_fragment
9. use API from snprintf to av_asprintf

v3 fixed:
1. fix typo from --enabled-xml2 to --enable-xml2

v4 fixed:
1. from --enable-xml2 to --enable-libxml2
2. move system includes to top
3. remove nouse includes
4. rename enum name
5. add a trailing comma for the last entry enum
6. fix comment typo
7. add const to DASHContext class front
8. check sscanf if return arguments and give warning message when error
9. check validity before free seg->url and seg
10. check if the val is null, before use atoll

v5 fixed:
1. fix typo from mainifest to manifest

v6 fixed:
1. from realloc to av_realloc
2. from free to av_free

v7 fixed:
1. remove the -lxml2 from configure when require_pkg_config

v8 fixed:
1. fix replace filename template by av_asprintf secure problem

v9 modified:
1. make manifest parser clearly

v10 fixed:
1. fix function API name code style
2. remove redundant strreplace call
3. remove redundant memory operation and check return value from get_content_url()
4. add space between ) and {
5. remove no need to log the value for print

v11 fixed:
1. from atoll to strtoll
Suggested-by: Michael Niedermayer <michael@niedermayer.cc>

v12 fixed:
1. remove strreplace and instead by av_strreplace
Suggested-by: Nicolas George <george@nsup.org>

v13 fixed:
1. fix bug: cannot play:
http://dash.edgesuite.net/akamai/bbb_30fps/bbb_30fps.mpd
Reported-by: Andy Furniss <adf.lists@gmail.com>

v14 fixed:
1. fix bug: TLS connection was non-properly terminated
2. fix bug: No trailing CRLF found in HTTP header
Reported-by: Andy Furniss <adf.lists@gmail.com>

v15 fixed:
1. play youtube link: ffmpeg -i $(youtube-dl -J "https://www.youtube.com/watch?v=XmL19DOP_Ls" | jq -r ".requested_formats[0].manifest_url")
2. code refine for timeline living stream
Reported-by: Ricardo Constantino <wiiaboo@gmail.com>

v16 fixed:
1. remove the snprintf and instead by get_segment_filename make safety
2. remove unnecessary loops
3. updated xmlStrcmp and xmlFree to av_* functions
4. merge code repeat into one function
5. add memory alloc faild check
6. update update_init_section and open_url
7. output safety error message when filename template not safe
Suggested-by : wm4 <nfxjfg@googlemail.com>

v17 fixed:
1. add memory alloc faild check
2. fix resource space error at free_representation

v18 fixed:
1. add condition of template format

v19 fixed:
1. fix typo of the option describe

v20 fixed:
1. add the c->base_url alloc check
2. make the DASHTmplId same to dashenc

v21 fixed:
1. remove get_repl_pattern_and_format and get_segment_filename
2. process use dashcomm APIs

v22 fixed:
1. modify the include "dashcomm.h" to include "dash.h"
2. use internal API from dash_fill_tmpl_params to ff_dash_fill_tmpl_params

Signed-off-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: samsamsam <samsamsam@o2.pl>
2017-09-09 08:32:03 +08:00
James Almer 27b7800ba9 avformat/matroskaenc: also write tags when output is WebM
WebM supports a subset of elements from the Tags master.
See https://www.webmproject.org/docs/container/#tagging

Reviewed-by: Ivan Janatra <janatra@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-08 20:02:43 -03:00
Michael Niedermayer afc9c683ed avformat/asfdec: Fix DoS in asf_build_simple_index()
Fixes: Missing EOF check in loop
No testcase

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-07 15:19:22 +02:00
Michael Niedermayer 9cb4eb7728 avformat/mov: Fix DoS in read_tfra()
Fixes: Missing EOF check in loop
No testcase

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-07 15:19:22 +02:00
Michael Niedermayer 913feb6263 avformat/gdv: Make FixedSize static
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-07 15:19:22 +02:00
Steven Liu ef7fe81b85 flvdec: Check the avio_seek return value after reading a metadata packet
merge from libav: 585dc1aece

If the metadata packet is corrupted, flv_read_metabody can accidentally
read past the start of the next packet. If the start of the next packet
had been flushed out of the IO buffer, we would be unable to seek to
the right position (on a nonseekable stream).

Prefer to clearly error out instead of silently trying to read from a
desynced stream which will only be interpreted as garbage.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2017-09-07 08:30:14 +08:00
Karthick J 837c55e072 avformat/hlsenc: Added configuration to override HTTP User-Agent
Signed-off-by: Karthick J <kjeyapal@akamai.com>
Signed-off-by: Steven Liu <lq@onvideo.cn>
2017-09-05 23:30:52 +08:00
Alex Converse 4d2b9ece45 avformat/flvdec: Set need_context_update when setting the initial extradata
Fixes ticket 6398.

Debugged with the help of James Almer and Hendrik Leppkes.
2017-09-03 20:01:39 -07:00
wm4 5d76674756 lavf: make avio_read_partial() public
Main use-case is proxying avio through a foreign I/O layer and a custom
AVIO context, without losing latency and performance characteristics.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>

Merged from Libav commit 173b56218f.
2017-09-01 17:56:33 +02:00
James Almer 877076ffa1 avformat/avio: update avio_alloc_context() doxy
It must be freed using avio_context_free() starting with commit
b12e4d3bb8.

Found-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-01 12:26:36 -03:00
Steven Liu adeb41afb8 avformat/dash:add copyright to dash.c
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2017-09-01 18:52:56 +08:00
Anton Khirnov 78a7af823b Use the new AVIOContext destructor.
(cherry picked from commit 6f554521af)
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-01 02:16:33 -03:00
Anton Khirnov b12e4d3bb8 avio: add a destructor for AVIOContext
Before this commit, AVIOContext is to be freed with a plain av_free(),
which prevents us from adding any deeper structure to it.

(cherry picked from commit 99684f3ae7)
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-01 01:51:15 -03:00
Steven Liu 837580f458 avformat/dash: move reused API to common file and header file
move from dashenc, move DASHTmplId and dash_fill_tmpl_params to
dash.c, they will be used by dash demuxer and dash muxer.

v2 fixed:
1. rename common file from dashcomm.* to dash.*
Suggested-by: Hendrik Leppkes <h.leppkes@gmail.com>

v3 fixed:
1. rename header file pre defined
2. add ff_ prefix for the internal API
Suggested-by: James Almer <jamrial@gmail.com>

Suggested-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Steven Liu <lq@onvideo.cn>
2017-09-01 10:20:56 +08:00
孙浩(晓黑) 9d00fb9d70 avformat/mxfdec: Fix Sign error in mxf_read_primer_pack()
Fixes: 20170829B.mxf

Co-Author: 张洪亮(望初)" <wangchu.zhl@alibaba-inc.com>
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 01:48:39 +02:00
孙浩(晓黑) 900f39692c avformat/mxfdec: Fix DoS issues in mxf_read_index_entry_array()
Fixes: 20170829A.mxf

Co-Author: 张洪亮(望初)" <wangchu.zhl@alibaba-inc.com>
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 01:48:35 +02:00
孙浩(晓黑) c24bcb5536 avformat/nsvdec: Fix DoS due to lack of eof check in nsvs_file_offset loop.
Fixes: 20170829.nsv

Co-Author: 张洪亮(望初)" <wangchu.zhl@alibaba-inc.com>
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 01:48:31 +02:00
Daniel Glöckner feb1dbc7bd avformat/mov: prevent duplication of first fragment's ctts_data
MP4 files with fragments might have the first moof box that is mentioned
in a fragment index before the first mdat box. Since it is then already
parsed by mov_read_header, we have to make sure that mov_switch_root
will not parse it again when seeking by setting the headers_read flag in
the index. Parsing it a second time would cause the ctts_data array to
receive a second copy of the information from the trun box, leading to
wrong PTS values for the second and following fragments in presence of
B-frames.

Fixes ticket 6560.

Signed-off-by: Daniel Glöckner <daniel-gl@gmx.net>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 00:56:32 +02:00
Dale Curtis f1e47f8713 avformat/mov: Bail when invalid sample data is present.
ctts data in ffmpeg relies on the index entries array to be 1:1
with samples... yet sc->sample_count can be read directly from
the 'stsz' box and index entries are only generated if a chunk
count has been read from 'stco' box.

Ensure that if sc->sample_count > 0, sc->chunk_count is too as
a basic sanity check. Additionally we need to check that after
the index is built we have the right number of entries, so we
also check in mov_read_trun() that sc->sample_count ==
st->nb_index_entries.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-09-01 00:56:32 +02:00
Justin Ruggles 1a0d9b503d avformat/concatdec: add fallback for calculating file duration
If a file does not have a known duration, this leads to the timestamps
starting over for the next file, causing non-monotonic timestamps.
To prevent this, track the duration during demuxing and use it to
determine the current file duration before opening the next file.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-08-31 15:33:52 +01:00
Paras Chadha df475db9a2 Add FITS Muxer
Signed-off-by: Paras Chadha <paraschadha18@gmail.com>
2017-08-30 12:13:02 +02:00
Paras Chadha 207f0cff2a Add FITS Demuxer
Signed-off-by: Paras Chadha <paraschadha18@gmail.com>
2017-08-30 12:13:01 +02:00
Michael Niedermayer f762555a90 avformat/mxfenc: Replace literal numbers by named enum values.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-30 02:15:36 +02:00
Michael Niedermayer 429f3266c1 avformat/mxfenc: Check that the video codec in D-10 is MPEG-2
Others do not work, but nothing rejects them prior to this patch if the
parameters otherwise match

Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-29 21:16:32 +02:00
Carl Eugen Hoyos d4fbe99dab lavf/dump: Remove superfluous cast. 2017-08-29 01:33:47 +02:00
Michael Niedermayer 4f05e2e2dc avformat/mvdec: Fix DoS due to lack of eof check
Fixes: loop.mv

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:23:37 +02:00
孙浩 and 张洪亮(望初) 96f24d1bee avformat/rl2: Fix DoS due to lack of eof check
Fixes: loop.rl2

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:23:30 +02:00
孙浩 and 张洪亮(望初) 124eb202e7 avformat/rmdec: Fix DoS due to lack of eof check
Fixes: loop.ivr

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:23:13 +02:00
孙浩 and 张洪亮(望初) 7e80b63ecd avformat/cinedec: Fix DoS due to lack of eof check
Fixes: loop.cine

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:22:08 +02:00
孙浩 and 张洪亮(望初) 7f9ec5593e avformat/asfdec: Fix DoS due to lack of eof check
Fixes: loop.asf

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:21:42 +02:00
Michael Niedermayer 7ec414892d avformat/hls: Fix DoS due to infinite loop
Fixes: loop.m3u

The default max iteration count of 1000 is arbitrary and ideas for a better solution are welcome

Found-by: Xiaohei and Wangchu from Alibaba Security Team

Previous version reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:19:00 +02:00
Carl Eugen Hoyos 9d494c5e55 lavf/rawenc: Add little- and big-endian G.726 muxers. 2017-08-26 11:43:09 +02:00
Carl Eugen Hoyos f61e2dcfc3 lavf/g726: Demuxer for raw G.726 streams, both left- and right-justified.
Compatible with the binary encoder attached to ticket #6596 (right-aligned)
and a sample from a SEG Mp3-Player (left-aligned).
2017-08-24 12:55:46 +02:00
Dale Curtis 37e8edc9f5 avformat/mov: Fix trampling of ctts during seeks when sidx support is enabled.
When sidx box support is enabled, the code will skip reading all
trun boxes (each containing ctts entries for samples inthat box).

If seeks are attempted before all ctts values are known, the old
code would dump ctts entries into the wrong location. These are
then used to compute pts values which leads to out of order and
incorrectly timestamped packets.

This patch fixes ctts processing by always using the index returned
by av_add_index_entry() as the ctts_data index. When the index gains
new entries old values are reshuffled as appropriate.

This approach makes sense since the mov demuxer is already relying
on the mapping of AVIndex entries to samples for correct demuxing.

As a result of this all ctts entries are now 1-count. A followup
change will be submitted to remove support for > 1 count entries
which will simplify seeking.

Notes for future improvement:
Probably there are other boxes (stts, stsc, etc) that are impacted
by this issue... this patch only attempts to fix ctts since it
completely breaks packet timestamping.

This patch continues using an array for the ctts data, which is not
the most ideal given the rearrangement that needs to happen (via
memmove as new entries are read in). Ideally AVIndex and the ctts
data would be set-type structures so addition is always worst case
O(lg(n)) instead of the O(n^2) that exists now; this slowdown is
noticeable during seeks.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-24 11:02:22 +02:00
Michael Niedermayer c42a1388a6 avformat/rtpdec_h264: Fix heap-buffer-overflow
Fixes: rtp_sdp/poc.sdp

Found-by: Bingchang <l.bing.chang.bc@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-23 22:19:33 +02:00
Vitaly Buka eca2a49716 avformat/aviobuf: Fix signed integer overflow in avio_seek()
Signed integer overflow is undefined behavior.
Detected with clang and -fsanitize=signed-integer-overflow

Signed-off-by: Vitaly Buka <vitalybuka@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-23 03:17:11 +02:00
Vitaly Buka 4a404cb5b9 avformat/mov: Fix signed integer overflows with total_size
Signed integer overflow is undefined behavior.
Detected with clang and -fsanitize=signed-integer-overflow

Signed-off-by: Vitaly Buka <vitalybuka@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-23 03:17:11 +02:00
Steven Liu 20a6b198b4 avformat/hlsenc: move free fmp4_init_filename after hls_window operation
fix ticket id: 6599

Signed-off-by: Steven Liu <lq@onvideo.cn>
2017-08-22 10:21:42 +08:00
bnnm e7053f3316 lavf/bink: fix latest header and add all existing revisions
KB2 'i' found in Life is Strange (Xbox 360), rest verified against binkconv.exe

Signed-off-by: bnnm <bananaman255@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-20 11:33:51 +02:00
Jacob Trimble f4544163b2 libavformat/mov: Fix inserting frames before current_frame.
When using streaming input, it may be possible to see frames that appear
before the current_frame.  When these frames are inserted into the
index, the current_frame needs to be updated so it is still pointing
at the same frame.

Signed-off-by: Jacob Trimble <modmaker@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-18 03:02:11 +02:00
Marton Balint 7160992431 avformat/utils: always av_reduce r_frame_rate
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
2017-08-17 21:02:40 +02:00
Nikolas Bowe 4b54d5a721 avformat/mov: Fix memory leak when reading DDTS box.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-16 03:35:13 +02:00
Michael Niedermayer 511e10f673 avformat/avidec: Move packet skip after prefix and related checks
This fixes loosing packets
Fixes: big.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-11 12:07:08 +02:00
James Almer c100330a8f avformat/movenc: reindent after the previous commit 2017-08-09 23:15:38 -03:00
Sasi Inguva e7e1fbc49b lavf/movenc.c: Set sgpd and sbgp atoms to represent decoder delay for AAC.
According to https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html and ISO-IEC-14496-12 Section 10.1.1.1 and 10.1.1.3

Signed-off-by: Sasi Inguva <isasi@google.com>
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-10 02:43:53 +02:00
DeHackEd eabeb9093a avformat/hlsenc: allow dynamic encryption key rotation
Makes behaviour of 805ce25b1d optional, re-enables
HLS key rotation feature

Reviewed-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: DHE <git@dehacked.net>
2017-08-06 15:10:35 +08:00
Steven Siloti 949debd1d1 avformat/utils: fix memory leak in avformat_free_context
The pointer to the packet queue is stored in the internal structure
so the queue needs to be flushed before internal is freed.

Signed-off-by: Steven Siloti <ssiloti@bittorrent.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-05 23:24:02 +02:00
Steven Liu 738b29cfb6 avformat/hlsenc: support fmp4 single file mode
add byterange mode of the hls fmp4

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Steven Liu <lq@onvideo.cn>
2017-08-04 21:38:55 +08:00