summaryrefslogtreecommitdiff
path: root/libavformat/mpegts.c
Commit message (Collapse)AuthorAge
* all: Use av_memdup() where appropriateAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegts: fix stream index in verbose log messageMarton Balint2021-11-25
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: Fix for the DOVI video stream descriptorLimin Wang2021-10-28
| | | | | | By <<Dolby Vision Streams Within the MPEG-2 Transport Stream Format v1.2>> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/mpegts: add support for stream_type 0xd4, which is AVS3Limin Wang2021-10-20
| | | | | | | | GB/T 17975.1 Information technology-Generic coding of moving pictures and associated audio information-Part 1:Systems Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* libavformat/hls: add support for decryption of HLS media segments encrypted ↵Nachiket Tarate2021-10-13
| | | | | | | | | | | using SAMPLE-AES encryption method Apple HTTP Live Streaming Sample Encryption: https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/mpegts: fix max_packet_size in mpegts payload parsingMarton Balint2021-10-10
| | | | | | | | | | | | | | | | | The maximum allowed useful PES payload data was set to PES_packet_length, but it is in fact smaller by the length of the PES header. This changes how corrupt streams are packetized: - If PES header length is bigger than PES_packet_length then the PES packet payload will be handled as an unbound packet - PES packets with payload across multiple MPEGTS packets will always be splitted if with the next chunk of data the payload should exceed PES_packet_length, previously a PES_header_length amount of excess was allowed. Fixes ticket #9355. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: rename PES total_size to PES_packet_lengthMarton Balint2021-10-10
| | | | | | | | | This renames PESContext->total_size to PESContext->PES_packet_length and keeps it 0 for unbound packets, so its name and semantics will match the standard. There should be no change in functionality. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: delay allocation of PES bufferMarton Balint2021-10-10
| | | | | | This allows us to allocate the buffer in a single code path. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: use named constants for stream_id typesMarton Balint2021-10-10
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: use actually read packet size in mpegts_resync special caseMichael Niedermayer2021-10-07
| | | | | | | | | Fixes: infinite loop Fixes: 37986/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTSRAW_fuzzer-5292311517462528 - Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: fixes overflow when parsing the PMTNicolas Jorge Dato2021-09-18
| | | | | | | | | | When a possible overflow was detected, there was a break to exit the while loop. However, it should have already substracted 2 bytes from program_info_length (descriptor ID + length). Fixes ticket #9422. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: Avoid allocation for AVStreamInternalAndreas Rheinhardt2021-09-17
| | | | | | | | | | Do this by allocating AVStream together with the data that is currently in AVStreamInternal; or rather: Put AVStream at the beginning of a new structure called FFStream (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVStreamInternal altogether. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Avoid allocation for AVFormatInternalAndreas Rheinhardt2021-09-17
| | | | | | | | | | | | | Do this by allocating AVFormatContext together with the data that is currently in AVFormatInternal; or rather: Put AVFormatContext at the beginning of a new structure called FFFormatContext (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVFormatInternal altogether. The biggest simplifications occured in avformat_alloc_context(), where one can now simply call avformat_free_context() in case of errors. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avio: Move internal AVIOContext fields to avio_internal.hAndreas Rheinhardt2021-08-25
| | | | | | | | | | | | | | Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: move AVStream.stream_identifier to AVStreamInternalJames Almer2021-05-07
| | | | | | It's a private field, no reason to have it exposed in a public header. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: move AVStream.{parser,need_parsing} to AVStreamInternalJames Almer2021-05-07
| | | | | | | Those are private fields, no reason to have them exposed in a public header. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: move AVStream.probe_packets to AVStreamInternalJames Almer2021-05-07
| | | | | | It's a private fields, no reason to have it exposed in a public header. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-27
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegts: set correct extradata size for Opus streamsJames Almer2021-04-16
| | | | | | | map_type 0 is always 19 bytes, whereas map_type 1 and 255 are 21 + channel count bytes. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegts: add missing sample_rate value to Opus extradataJames Almer2021-04-16
| | | | | | Finishes fixing ticket #9190. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegts: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: remove some mpegts details from AVStreamMarton Balint2021-01-09
| | | | | | | | | | | | | | | | These fields were added to support -merge_pmt_versions, but the mpegts demuxer is also keeping track its programs internally, so that should be a better place to handle it. Also it is not a very good idea to keep fields like program_num or pmt_stream_idx in an AVStream, because a single stream can be part of multiple programs, multiple PMTs, so the stream attributes can refer to any program the stream is part of. Since they are not part of public API, lets simply remove them, or rather replace them with placeholders for ABI compatibility with libavdevice. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: use stream index based lookup with merge_pmt_versions if ↵Marton Balint2021-01-09
| | | | | | | | | | | | | | stream identifier matches multiple streams Also make sure we are checking the old state of the streams because otherwise some streams might already have the newly parsed stream identifiers which corrupts matching. Fixes streams having the same identifier mixed up on pmt version change. Fixes ticket #9006. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: only clear programs which no longer exist or have a new PMTMarton Balint2021-01-09
| | | | | | | | | | | Otherwise there can be a small period when the programs only contain the PMT pid. Also make sure skip_clear only affects AVProgram clear, and that pmt_pid is always kept as the first entry of the PID list of the programs. Also reject PMTs for programs on the wrong PID. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: rework clearing and adding pid to programMarton Balint2021-01-09
| | | | | | And use better function names. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: never discard PAT pidMarton Balint2021-01-09
| | | | | | | | PID 0 was removed from the pid list when then PMT was parsed, it is better to explictly avoid it from being discarded instead of keeing it in the list of every program. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: Fix argument type for av_logMichael Niedermayer2020-12-28
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: simplify nb_packets codeMichael Niedermayer2020-12-22
| | | | | Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: Increase pcr_incr width to 64bitMichael Niedermayer2020-12-22
| | | | | | | | | | Fixes: division by zero Fixes: 26459/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTSRAW_fuzzer-5666350112178176 Fixes: 28154/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTSRAW_fuzzer-5195728439476224 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: Limit iterations of get_packet_size()Michael Niedermayer2020-11-29
| | | | | | | | | | This is a pathological case where the fuzzer provides only 2 bytes per iteration. Fixes: Timeout (>30 -> 0.9sec) Fixes: 26488/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTS_fuzzer-5911031077142528 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: make sure mpegts_read_header always stops at the first pmtMarton Balint2020-11-19
| | | | | | | | | | | mpegts_read_header stops parsing the file at the first PMT. However the check that ensured this was wrong because streams can also be added before the first PMT is received (e.g. EIT). So let's make sure we are in the header reading phase by checking if ts->pkt is unset instead of checking if the number of streams found so far is 0. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: Limit copied data to spaceMichael Niedermayer2020-11-07
| | | | | | | | | Fixes: out of array access Fixes: 26816/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTSRAW_fuzzer-6282861159907328.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{pts_wrap_*,update_initial_durations_done} to ↵Anton Khirnov2020-10-28
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* avformat/mpegts: replace magic descriptor_tag values with definesBrad Hards2020-10-16
| | | | | | | | This takes the used values from ISO/IEC 13818-1 Table 2-45 and adds them to the mpegts.h header. No functional changes. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: make sure mpegts_resync do not run out of the initially ↵Marton Balint2020-10-09
| | | | | | requested probe buffer Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: only reset timestamps to NOPTS for DVB teletextJan Ekström2020-08-18
| | | | | | | | | | | While having the possibility of non-NOPTS values that can suddenly jump in time due to adjustments to match PCR is not nice for DVB subtitles, apparently the parser for this format bases its behavior on whether the packets' timestamps are NOPTS or not. Thus while we can adjust timestamps, we should exclude DVB subtitles from the timestamp unsetting logic. Fixes #8844
* avformat/mpegts: Don't leave context in inconsistent state upon errorAndreas Rheinhardt2020-08-10
| | | | | | | | | | | | | | | Up until now, opening a section filter works as follows: A filter is opened and (on success) attached to the MpegTSContext. Then a buffer for said filter is allocated and upon success attached to the section filter; on error, the filter is simply freed without removing it from the MpegTSContext, leaving the latter in an inconsistent state. This leads to use-after-frees lateron. This commit fixes this by allocating the buffer first; the filter is only opened if the buffer could be successfully allocated. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpegts: use get_packet_size in mpegts_resync for determining ↵Marton Balint2020-05-27
| | | | | | | | | | | | | | | | | | | raw_packet_size The old resync logic had some bugs, for example the packet size could stuck into 192 bytes, because pos47_full was not updated for every packet, and for unseekable inputs the resync logic simply skipped some 0x47 sync bytes, therefore the calculated distance between sync bytes was a multiple of 188 bytes. AVIO only buffers a single packet (for UDP/mpegts, that usually means 1316 bytes), so for every ten consecutive 188-byte MPEGTS packets there was always a seek failure, and that caused the old code to not find the 188 byte pattern across 10 consecutive packets. This patch changes the custom logic to the one which is used when probing to determine the packet size. This was already proposed as a FIXME a long time ago...
* avformat/mpegts: Shuffle avio_seekMichael Niedermayer2020-05-17
| | | | | | | | | | This avoids accessing an old, no longer valid buffer. Fixes: out of array access Fixes: crash_audio-2020 Found-by: le wu <shoulewoba@gmail.com> Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: fix av_freep for dovi pointerLimin Wang2020-05-01
| | | | | Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* lavf/mpegts: support DOVI Video Stream Descriptorvacingfang2020-04-23
| | | | | | | | | | | | | support DOVI Video Stream Descriptor from Dolby Vision Streams Within the MPEG-2 Transport Stream Format V1.2 From the spec: https://www.dolby.com/us/en/technologies/\ dolby-vision/dolby-vision-bitstreams-in-mpeg-2-transport-\ stream-multiplex-v1.2.pdf. export the DOVI information with sidedata. Signed-off-by: vacingfang <vacingfang@tencent.com>
* avformat/mpegts: use buffer pools for allocating PES payloadsMarton Balint2020-04-04
| | | | | | | | | | | | | | | | | | | | | This brings a performance improvement when demuxing files, most of the improvement comes from buffer pooling unbound packets. time ffprobe -i samples/ffmpeg-bugs/trac/ticket6132/Samsung_HDR_-_Chasing_the_Light.ts -show_packets >/dev/null 2>&1 Before: real 0m1.967s user 0m1.471s sys 0m0.493s After: real 0m1.497s user 0m1.364s sys 0m0.129s Based on a patch of James Almer. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: Improve the position determination for ↵Michael Niedermayer2020-02-27
| | | | | | | | | avpriv_mpegts_parse_packet() Fixes: assertion failure Fixes: Ticket 8005 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Remove unnecessary av_packet_unref()Andreas Rheinhardt2020-02-10
| | | | | | | | | Since bae8844e the packet will always be unreferenced when a demuxer returns an error, so that a lot of calls to av_packet_unref() in lots of demuxers are now redundant and can be removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: Forward errors where possibleAndreas Rheinhardt2019-12-12
| | | | | | | | | | It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: add support for EPG extraction from mpegtsAnthony Delannoy2019-09-19
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* lavf/mpegts: Support demuxing AVS2.hwrenx2019-09-18
|
* avformat/mpegts: Check if ready on SCTE receptionAnthony Delannoy2019-09-03
| | | | | | | | On some DVB stream SCTE-35 data packet are available before the end of MpegTSContext initialization. We have to check if it is the case to avoid a SEGFAULT. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mpegts: fix teletext PTS when selecting teletext streams onlyMarton Balint2019-08-31
| | | | | | | | | | | | | | | 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>