summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avcodec, avfilter, avformat: Remove redundant avpriv_align_put_bitsAndreas Rheinhardt2020-08-01
| | | | | | | | flush_put_bits() already fills the bitstream with zeroes, so it is unnecessary to align the bitstream before. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/apm: fix APM_FILE_HEADER_SIZE valueZane van Iperen2020-07-30
| | | | | | Value was incorrectly changed in 3bf1be210150b435c51c7c8eb8fd05a1fca08814. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/hlsenc: increase initial program date time precisionMarton Balint2020-07-29
| | | | | | | | | Also query time only once, not for every variant stream, otherwise variant streams might get a slightly different initial program date time. And we can set this unconditionally because HLS_PROGRAM_DATE_TIME flag is checked elsewhere. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/smacker: Don't return packets for streams with AVDISCARD_ALLAndreas Rheinhardt2020-07-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Fix duration for PCM audioAndreas Rheinhardt2020-07-28
| | | | | | | | | | | | For non-PCM audio, a Smacker frame contains the size of the decoded audio in the first four bytes of the audio packet data; for PCM data, said information would be redundant and according to [1] this field does not exist. Therefore this commit sets the duration and timestamps properly for PCM audio. [1]: https://wiki.multimedia.cx/index.php/Smacker#Audio_Track_Chunk Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Set audio durationAndreas Rheinhardt2020-07-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Support seeking to first frameTimotej Lazar2020-07-28
| | | | | | | | | Add .read_seek function to the smacker demuxer for the special case of seeking to ts=0. This is useful because smacker – like bink, with a similar implementation – was mostly used to encode clips in video games, where random seeks are rare but looping media are common. Signed-off-by: Timotej Lazar <timotej.lazar@araneo.si>
* lavf/srt: fix build fail when used the libsrt 1.4.1Jun Zhao2020-07-28
| | | | | | | | | | | | libsrt changed the: SRTO_SMOOTHER -> SRTO_CONGESTION SRTO_STRICTENC -> SRTO_ENFORCEDENCRYPTION and removed the front of deprecated options (SRTO_SMOOTHER/SRTO_STRICTENC) in the header, it's lead to build fail fix #8760 Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/ape: Error out in case of EOF in the headerMichael Niedermayer2020-07-26
| | | | | | | | Fixes: OOM Fixes: 24375/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6216862443241472 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/segafilmenc: Avoid seek when writing headerAndreas Rheinhardt2020-07-26
| | | | | | | | | | | | | | | | | | Up until now, the Sega FILM muxer would first write all the packet data, then shift the data (in the muxer's write_trailer function) by the amount necessary to write the header at the front (which entails a seek to the front), then seek back to the beginning and actually write the header. This commit changes this: The dynamic buffer that is used to write the sample table (containing information about each sample in the file) is now used to write the complete header. This is possible because the size of everything in the header except the sample table is known in advance. Said buffer can then be used as one of the two temporary buffers used for shifting which also reduces the amount one has to allocate for this. Thereby the header will be written when shifting, so that the second seek to the beginning is unnecessary. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/segafilmenc: Don't store packet info in linked listAndreas Rheinhardt2020-07-26
| | | | | | | | | | | | | | | | | Up until now, the Sega FILM muxer would store some information about each packet in a linked list. When writing the trailer, the information in said linked list would be used to write a table in the file header. Each entry in said table is 16 bytes long, but each entry of the linked list is 32 bytes long (assuming 64 bit pointer and no padding). Therefore it makes sense to remove the linked list and write the array entries directly into a dynamic buffer while writing the packet (this is possible because the table entries don't depend on any information not available when writing the packet (the offset is not relative to the beginning of the file, but to the end of the table). This also simplifies writing the array at the end (there is no need to traverse a linked list). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/segafilmenc: Simplify writing two bytesAndreas Rheinhardt2020-07-26
| | | | | | Use avio_wb16() instead of avio_write() to write two zero bytes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/segafilmenc: Remove write-only variableAndreas Rheinhardt2020-07-26
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/segafilm: Reorder elements of struct to make it smallerAndreas Rheinhardt2020-07-26
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/daudenc: Return proper error codes instead if -1Andreas Rheinhardt2020-07-26
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/daudenc: Turn write_header function into init functionAndreas Rheinhardt2020-07-26
| | | | | | daud_write_header() doesn't write anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/webmdashenc: CosmeticsAndreas Rheinhardt2020-07-26
| | | | | | | | | Mostly using intermediate pointers for accesses (i.e. storing s->pb in a variable pb and then using pb for writing instead of s->pb) to improve readability. Furthermore, the opening brace '{' of a function has been moved into a line of its own in instances where it wasn't before. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/webmdashenc: Only check for existence of metadata if it is usedAndreas Rheinhardt2020-07-26
| | | | | | | Also return proper error codes when it is absent: AVERROR(EINVAL) instead of AVERROR_INVALIDDATA. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/webmdashenc: Avoid allocations, fix memleakAndreas Rheinhardt2020-07-26
| | | | | | | | | | | | | | | | | | | When using the WebM DASH Manifest muxer, every stream of each adaptation set has to contain a metadata entry containing the filename of the source file. In case of live stream manifests, said filename has to conform to a pattern of <file_description>_<representation_id>.<extension>. These pieces are used to create the other strings that are actually output. Up until now, these other strings would be allocated, used once and then freed directly after usage. This commit changes this: The function that allocated and assembled these strings now returns pointers to the '_' and '.' delimiters and so that the caller can easily pick substrings from it without needing to copy the string. Avoiding allocations also fixes a memleak: One of the allocated strings would leak upon a subsequent allocation failure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/webmdashenc: Fix segfault when no filename is given when liveAndreas Rheinhardt2020-07-26
| | | | | | by checking a bit earlier. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/riffenc: correct calculation for extradata sizeGyan Doshi2020-07-26
| | | | | | In 1ec2b3de5a, the extradata size was affected when the raster was signaled as flipped due to user-set option rather than via extradata. This resulted in a wrong header size being written. Fixed.
* avformat/mpegtsenc: use local variable store st->codecpar->codec_idLimin Wang2020-07-25
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: reindent the last commitLimin Wang2020-07-25
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegtsenc: simplify code for condition checksLimin Wang2020-07-25
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/matroskadec: Slightly simplify version checkAndreas Rheinhardt2020-07-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/matroskadec: Avoid undefined pointer arithmeticAndreas Rheinhardt2020-07-24
| | | | | | | | | | | | | | | | The Matroska demuxer currently always opens a GetByteContext to read the content of the projection's private data buffer; it does this even if there is no private data buffer in which case opening the GetByteContext will lead to a NULL + 0 which is undefined behaviour. Furthermore, in this case the code relied both on the implicit checks of the bytestream2 API as well as on the fact that it returns zero if there is not enough data available. Both of these issues have been addressed by not using the bytestream API any more; instead the data is simply read directly by using AV_RB. This is possible because the offsets are constants. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mxfdec: Fix memleak upon repeating tagsAndreas Rheinhardt2020-07-24
| | | | | | | | | | | When parsing MXF encountering some tags leads to allocations. And when these tags were encountered repeatedly, this could lead to memleaks, because the pointer to the old data got simply overwritten with a pointer to the new data (or to NULL on allocation failure). This has been fixed. Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mxfdec: Fix memleak when parsing tag failsAndreas Rheinhardt2020-07-24
| | | | | | | | | | | | | | The MXF demuxer uses an array of pointers to different structures of metadata (all containing a common initial sequence containing a type field to distinguish them) and some of these structures contain pointers to separately allocated subelements. If an error happens while reading and creating the tags, the semi-finished new tag is freed using the function to free these tags. But this function doesn't free the already allocated subelements, because the type has not been set yet. This commit changes this. Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mxfdec: Fix memleak when adding element to array failsAndreas Rheinhardt2020-07-24
| | | | | | | | | Said array contains pointers to other structs and both the designated new element as well as other stuff contained in it (e.g. strings) leak if the new element can't be added to the array. Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat: add apm muxerZane van Iperen2020-07-21
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avcodec/apm: fix sample_rate checkZane van Iperen2020-07-21
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/sbgdec: Check for overflow in parse_timestamp()Michael Niedermayer2020-07-20
| | | | | | | | | Fixes: signed integer overflow: 33986707200000000 + 9195561788997000192 cannot be represented in type 'long' Fixes: 23790/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6554232198266880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/dashdec: enable custom interrup callback in sub-demuxerJun Zhao2020-07-20
| | | | | | | Enable the custom callback in sub-demuxer Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: enable custom interrup callback in sub-demuxerJun Zhao2020-07-20
| | | | | | | Enable the custom callback in sub-demuxer Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/crypto.c: remove unnecessary codeSteven Liu2020-07-20
| | | | | | | | Because the newpos variable is set value before use it. The newpos variable declared at the head partition of crypto_seek. Make the code clean. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/apm: fix variable/structure names and cosmeticsZane van Iperen2020-07-19
|
* avformat/apm: use the entire APMState structure as extradataZane van Iperen2020-07-19
| | | | | Is the "actual" codec extradata instead of the hand-crafted one from the previous revision.
* avformat/apm: read header correctlyZane van Iperen2020-07-19
| | | | | | The leading WAVEFORMATEX in .APM files is malformed: * The nAvgBytesPerSec field is wrong, and * sizeof(cbSize) is 4 instead of 2.
* avformat/au: Avoid allocation for metadata stringAndreas Rheinhardt2020-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | | When there are potentially annotation (i.e. metadata) fields to write, au_get_annotations() is called to produce a string with them. To do so, it uses an AVBPrint which is finalized to create the string. This is wasteful, because it always leads to an allocation even if the string actually fits into the internal buffer of the AVBPrint. This commit changes this by making au_get_annotations() modify an AVBPrint that resides on the stack of the caller (i.e. of au_write_header()). Furthermore, the AVBPrint is now checked for truncation; limiting the allocations implicit in the AVBPrint allowed to offload the overflow checks. Notice that these were not correct before: The size parameter of avio_write() is an int, yet the string in the AVBPrint was allowed to grow bigger than INT_MAX. And if the length of the string was so near UINT_MAX that the length + 32 overflowed, the old code would write the first eight bytes of the string and nothing more, leading to an invalid file. Finally, the special case in which the metadata dictionary of the AVFormatContext is empty (in which case one still has to write eight binary zeroes) is now no longer treated specially, because this case no longer incurs any allocation. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/au: Simplify writing string into AVBPrintAndreas Rheinhardt2020-07-18
| | | | | | by using av_bprintf() instead of several av_bprint_append(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/au: Remove redundant av_freep()Andreas Rheinhardt2020-07-18
| | | | | | | | | | This av_freep(&key) in conjunction with the fact that the loop condition checks for key != NULL was equivalent to a av_freep(&key) + a break immediately thereafter. But given that there is an av_freep(&key) directly after the loop, the av_freep(&key) is unnecessary and the break can also be added explicitly. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/au: Store strings instead of pointers to strings in arrayAndreas Rheinhardt2020-07-18
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: fix atom type to string conversionZhao Zhili2020-07-16
| | | | | | | The conversion was endian-dependent, and it may contain non-printable characters. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/riffenc: indicate storage of flipped RGB bitmapsGyan Doshi2020-07-15
| | | | | | | | | | | | | Some legacy applications such as AVI2MVE expect raw RGB bitmaps to be stored bottom-up, whereas our RIFF BITMAPINFOHEADER assumes they are always stored top-down and thus write a negative value for height. This can prevent reading of these files. Option flipped_raw_rgb added to AVI and Matroska muxers which will write positive value for height when enabled. Note that the user has to flip the bitmaps beforehand using other means such as the vflip filter.
* API: add AV_PKT_DATA_S12M_TIMECODE to AVPacketSideDataTypeLimin Wang2020-07-15
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mov: fix missing line break in messagesMoritz Barsnick2020-07-12
| | | | | | One of them can be triggered by https://samples.ffmpeg.org/F4V/H263_NM_f.mp4. Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
* lavf/udp: fix the comments for default UDP socket recvbuf sizeJun Zhao2020-07-12
| | | | | | | | 15d160cc0b2 increased the UDP socket receiving buffer size (64K ->384K), but missed to update this comments. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/sdp: Fix potential write beyond end of bufferAndreas Rheinhardt2020-07-10
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mm: Check for existence of audio streamAndreas Rheinhardt2020-07-10
| | | | | | | | | No audio stream is created unconditionally and if none has been created, no packet with stream_index 1 may be returned. This fixes an assert in ff_read_packet() in libavformat/utils reported in ticket #8782. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavformat/dashenc.c: Support mpd update periodSiyuan Huang2020-07-09
| | | | | | According ISO 23009-1, in live cases, mpd refresh period should be configurable Signed-off-by: Siyuan Huang <saber.huang@samsung.com>