summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
...
* avformat/argo_brp: allow v1.1 ASF streams to have a non-22050 sample rate in ↵Zane van Iperen2020-09-27
| | | | | | | | | | | | | | | | certain circumstances It seems that in files where the BASF block isn't first, v1.1 ASF streams are allowed to be non-22050. Either this format is really inconsistent, or FX Fighter and Croc just ignored the sample rate field, requiring the v1.1 restriction in the first place. This bumps the version to 1.2 in these streams so they're not "corrected". Found in Alien Odyssey games files in: ./GRAPHICS/COMMBUNK/{{COMADD1,COMM2_{1,2,3E},COMM3_{2,3,4,5,6}},FADE{1,2}}.BRP Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/argo_brp: cosmeticsZane van Iperen2020-09-27
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/argo_brp: handle the case where the BASF block isn't the firstZane van Iperen2020-09-27
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/argo_brp: support MASK streamsZane van Iperen2020-09-27
| | | | | | We can't actually use them though. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/argo_{asf,brp}: fix potential segfault in ff_argo_asf_fill_stream()Zane van Iperen2020-09-27
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/http: fix memleakZhao Zhili2020-09-25
| | | | | Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: add IPU demuxerPaul B Mahol2020-09-24
|
* avformat/flvdec: RtmpSampleAccess no longer breaks stream detectionPeter van der Spek2020-09-23
| | | | | | | | | | | | | | | | | Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP stream that contains a |RtmpSampleAccess AMF object prior to the onMetaData AMF object. In the debug log it would show "[flv] Unknown type |RtmpSampleAccess". This functionality broke in commit d7638d8dfc3c4ffd0dc18a64937a5a07ed67b354 as unknown metadata packets now result in an opaque data stream, and the |RtmpSampleAccess packet was an "unknown" metadata packet type. With this change the RTMP streams are correctly detected when there is a |RtmpSampleAccess object prior to the onMetaData object. Signed-off-by: Peter van der Spek <p.vanderspek@bluebillywig.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/swfdec: Reorder allocations/initializationsAndreas Rheinhardt2020-09-23
| | | | | | | | | | | | | | | | | The earlier code would first attempt to allocate two buffers, then attempt to allocate an AVIOContext, using one of the new buffers I/O buffer, then check the allocations. On success, a z_stream that is used in the AVIOContext's read_packet callback is initialized afterwards. There are two problems with this: In case the allocation of the I/O buffer fails avio_alloc_context() will be given a NULL read buffer with a size > 0. This works right now, but it is fragile. The second problem is that the z_stream used in the read_packet callback is not functional when avio_alloc_context() is allocated (it might be that avio_alloc_context() might already fill the buffer in the future). This commit fixes both of these problems by reordering the operations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/swfdec: Fix memleaks on errorAndreas Rheinhardt2020-09-23
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/argo_asf: implement seekingZane van Iperen2020-09-23
| | | | | | | Causes some error as the ADPCM predictors aren't known, but the difference is negligible and not audible. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/magicyuv: add support for recently added new formatPaul B Mahol2020-09-22
|
* avformat/movenc: simplify ISML manifest bit rate logicJan Ekström2020-09-22
| | | | | The newly calculated average bit rate value is pretty much what is being done here.
* avformat/movenc: use more fall-back values for average bit rate fieldsJan Ekström2020-09-22
| | | | | | | | | If the average bit rate cannot be calculated, such as in the case of streamed fragmented mp4, utilize various available parameters in priority order. Tests are updated where the esds or btrt or ISML manifest boxes' output changes.
* avformat/movenc: implement writing of the btrt boxJan Ekström2020-09-22
| | | | | | | | | | | This is utilized by various media ingests to figure out the bit rate of the content you are pushing towards it, so write it for video, audio and subtitle tracks in case at least one nonzero value is available. It is only mentioned for timed metadata sample descriptions in QTFF, so limit it only to ISOBMFF (MODE_MP4) mode. Updates the FATE tests which have their results changed due to the 20 extra bytes being written per track.
* avformat/movenc: utilize bit rate helper function in ISML writingJan Ekström2020-09-21
| | | | | This way we have a single location in movenc which utilizes the CPB properties.
* avformat/movenc: split MPEG-4 bit rate value calculationJan Ekström2020-09-21
| | | | This can now be re-utilized in other places.
* avformat/moflex: Check pop_int() for overflowMichael Niedermayer2020-09-21
| | | | | | | | | Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 'int' Fixes: 25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464 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>
* avformat/vividas: Check for EOF in first loop in track_header()Michael Niedermayer2020-09-21
| | | | | | | | | Fixes: timeout (243sec -> a few ms) Fixes: 25716/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5764093666131968 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>
* avformat/wvdec: Check rate for overflowMichael Niedermayer2020-09-21
| | | | | | | | Fixes: signed integer overflow: 6000 * -2147483648 cannot be represented in type 'int' Fixes: 25700/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6578316302352384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/dashdec: Avoid duplicating stringAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix memleak on allocation error, avoid allocationAndreas Rheinhardt2020-09-21
| | | | | | | | | | get_content_url() allocates two buffers for temporary strings and when one of them couldn't be allocated, it simply returns, although one of the two allocations could have succeeded and would leak in this scenario. This can be fixed by avoiding one of the temporary buffers. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: CosmeticsAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | 1. Perform the necessary reindentations after the last few commits. 2. Adapt switches to the ordinary indentation style. 3. Now that the effective lifetimes of the variables containing the freshly allocated strings used when parsing the representation are disjoint, the variables can be replaced by a single variable. Doing so has the advantage of making it more clear that these are throwaway variables, hence it has been done. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove redundant casts to constAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Return early for unsupported representationsAndreas Rheinhardt2020-09-21
| | | | | | | | | This allows to reduce the level of indentation for parsing the supported representations (audio, video and subtitles). It also allows to avoid some allocations and frees for unsupported representations. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove redundant checksAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | This commit removes two always-true checks as well as a dead default case of a switch. The check when parsing manifests is always true, because we now jump to the cleaning code in case the format of the representation is unknown. The default case of the switch is dead, because the type of the representation is already checked at the beginning of parse_manifest_representation(). The check when reading the header is dead, because we error out if an error happened before. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix memleaks on error to add representation to dynarrayAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | | Up until now, the DASH demuxer used av_dynarray_add() to add audio/video/subtitles representations to arrays. Yet av_dynarray_add() frees the array upon failure, leading to leaks of its elements; furthermore, the element to be added leaks, too. This has been fixed by using av_dynarray_add_nofree() instead and by freeing the elements that could not be added to the list. Furthermore, errors from this are now checked and returned. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of representation languagesAndreas Rheinhardt2020-09-21
| | | | | | | | | | These languages are normally freed after having been added as metadata to their respective AVStreams. Yet if one never reaches said point, they leak. This can happen as a result of an error when reading the header or as a result of refreshing the manifests. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of string on error when parsing representationAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | | | | | The DASH demuxer currently extracts several strings at once from an xml document before processing them one by one; these strings are allocated, stored in local variables and need to be freed by the demuxer itself. So if an error happens when processing one of them, all strings need to be freed before returning. This has simply not been done, leading to leaks. A simple fix would be to add the necessary code for freeing; yet there is a better solution: Avoid having several strings at the same time by extracting a string, processing it and immediately freeing it. That way one only has to free at most one string on error. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of representation on errorAndreas Rheinhardt2020-09-21
| | | | | | | | | | | If parsing a representation fails, it is not added to the list of representations and is therefore not freed in dash_close(); it therefore leaked in most error paths in parse_manifest_representation() (some error paths had (incomplete) code for freeing). This commit fixes freeing the representation in this case. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove unused index of representationAndreas Rheinhardt2020-09-21
| | | | | | | It is always zero. Also remove other unused elements. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix memleaks upon read_header failureAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Check allocation of AVProgramAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec, hls: Update correct pointer to AVDictionaryAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | | | | | | | | | | open_url() in the DASH as well in the hls demuxer share a common bug: They modify an AVDictionary (i.e. set a new entry) given to them as AVDictionary *, yet if this new entry leads to reallocation and relocation of the AVDictionary, the caller's pointer will become dangling, leading to use-after-frees. So pass an AVDictionary **. (With the current implementation of AVDictionary the above can only happen if the AVDictionary was empty initially (in which case the new AVDictionary leaks); furthermore if the I/O is ordinary (i.e. opened by avio_open2() or ffio_open_whitelist()), the dict is never empty (it contains an rw_timeout entry from save_avio_options()). So this issue could only happen if the caller sets a nondefault io_open callback, but no AVIOContext (the AVFMT_FLAG_CUSTOM_IO flag won't be set in this case). In case of the HLS demuxer, it was also necessary that setting the "seekable" entry failed. Yet one should simply not rely on internals of the AVDict API.) Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of AVDictionary on errorAndreas Rheinhardt2020-09-21
| | | | | | | | Just postpone the allocation of the dict until it is really needed (after the checks that can fail). Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Free subtitle representations on exitAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Free strings as soon as they aren't needed anymoreAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Don't overwrite and leak old initialization fragmentsAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Don't leave representation in inconsistent state on errorAndreas Rheinhardt2020-09-21
| | | | | | | | | This currently doesn't cause any trouble, because the only caller did not clean up the representation upon error at all; but fixing this is a prerequisite for doing so. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove dead codeAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | The code in question seems to have been copied from about 70 lines above; yet the code here is only executed if some of the variables (namely representation_segmenttemplate_node and fragment_template_node) are NULL, so it makes no sense to check them for a child element. Also remove a redundant resetting of a pointer to an AVFormatContext after avformat_close_input() (which already sets the pointer to NULL). Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Avoid double free on errorAndreas Rheinhardt2020-09-21
| | | | | | | | | When using one of the AV_DICT_DONT_STRDUP_KEY/VAL flags, av_dict_set() already frees the key/value on error, so that freeing it again would lead to a double free. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/aaxdec: Fix potential integer overflowAndreas Rheinhardt2020-09-20
| | | | | | | | | | | | | | | | | | | | | | | The AAX demuxer reads a 32bit number containing the amount of entries of an array and stores it in an uint32_t. Yet when iterating over this array, a loop counter of type int is used. This leads to undefined behaviour if the amount of entries is not in the range of int; to avoid this, it is generally good to use the same type for the loop counter as for the variable it is compared to. This is done in one of the two loops affected by this. In the other loop, the undefined behaviour can begin even earlier: Here the loop counter is multiplied by an uint16_t which can overflow as soon as the loop counter is > 2^15. Using an unsigned type would avoid the undefined behaviour, but truncation would still be possible, so use an uint64_t. Also use an uint32_t for a variable containing an index in said array. This fixes Coverity issue #1466767. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/swf: Separate mux and demux contextsAndreas Rheinhardt2020-09-20
| | | | | | | | | There was almost no overlap between them: The only field used by both was an int named samples_per_frame. Therefore this commit separates them. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/wc3movie: Cleanup on wc3_read_header() failureMichael Niedermayer2020-09-20
| | | | | | | | Fixes: memleak Fixes: 23660/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6007508031504384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/wc3movie: Move wc3_read_close() upMichael Niedermayer2020-09-20
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: fix typo in commentsZhao Zhili2020-09-20
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/tedcaptionsdec: Fix leak of AVBPrint upon errorAndreas Rheinhardt2020-09-20
| | | | | | | | | | | | | | | | The tedcaptions demuxer uses an AVBPrint whose string is not restricted to its internal buffer; it therefore needs to be cleaned up, yet this is not done on error, as parse_file() returned simply returned directly. This is fixed by going to fail first in such cases. Furthermore, there is also a second way how this string can leak: By having more than one subtitle per subtitle block, as the new one simply overwrites the old one in this case as the AVBPrint is initialized each time upon encountering a subtitle line. The code has been modified to simply append the new subtitle to the old one, so that the old one can't leak any more. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/argo_brp: don't pass AVStream into avpriv_request_sample()Zane van Iperen2020-09-20
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/argo_brp: set BVID packet durationZane van Iperen2020-09-20
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/argo_brp: handle multiple BASF blocksZane van Iperen2020-09-20
| | | | | | | Turns out that there are files with multiple (reasonably-sized) BASF blocks. Some of the files just have particularly large frames (~10s). Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>