summaryrefslogtreecommitdiff
path: root/libavformat/mpegenc.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/avformat: Move AVOutputFormat internals out of public headerAndreas Rheinhardt2023-02-091-49/+50
| | | | | | | | | | | | | | This commit does for AVOutputFormat what commit 20f972701806be20a77f808db332d9489343bb78 did for AVCodec: It adds a new type FFOutputFormat, moves all the internals of AVOutputFormat to it and adds a now reduced AVOutputFormat as first member. This does not affect/improve extensibility of both public or private fields for muxers (it is still a mess due to lavd). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/(mpeg|mpegts|mxf|sup)enc: Use const uint8_t* to access pkt dataAndreas Rheinhardt2022-07-041-1/+1
| | | | | | | | | The packets muxers receive are not guaranteed to be writable, so they must not be modified. Ergo only access the packet's data via a const uint8_t*. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegenc: Fix ever growing FIFO and infinite loop on errorAndreas Rheinhardt2022-04-051-4/+9
| | | | | | | | | | | | | | | | | | | | | Since the switch to the new FIFO API in commit ea511196a6c85eb433e10cdbecb0b2c722faf20d, the FIFO is always grown by the amount of data intended to be written into it even in case the FIFO has enough free space. Fix this by only growing the FIFO if needed and then only by the amount that is actually needed. The allocation errors that resulted from this uncovered another bug: The context is left in an inconsistent state in case the FIFO can't be grown, because the FIFO does not contain as much data as the sizes contained in the PacketDesc list claim. This led to an infinite loop in output_packet() (called from mpeg_mux_end()). Fix this by growing the FIFO before adding a new PacketDesc element, thereby preventing the context from becoming inconsistent. Reported-by: Nicolas Gaullier <nicolas.gaullier@cji.paris> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-161-0/+2
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* mpegenc: convert to new channel layout APIVittorio Giovara2022-03-151-5/+5
| | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/mpegenc: switch to new FIFO APIAnton Khirnov2022-02-071-17/+23
|
* avformat/mpegenc: Simplify writing padding/stuffingAndreas Rheinhardt2021-09-271-17/+9
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mpegenc: Deduplicate AVClassesAndreas Rheinhardt2021-07-081-15/+9
| | | | | | | | The child_class_next API relied on different (de)muxers to use different AVClasses; yet this API has been replaced by child_class_iterate. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-271-9/+9
| | | | | | | 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/mpegenc: Forward error codeAndreas Rheinhardt2021-02-191-3/+4
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpegenc: Avoid adding invalid packet to queueAndreas Rheinhardt2021-02-191-12/+12
| | | | | | Do this by moving the check before the allocation. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpegenc: Fix leak in case trailer is never writtenAndreas Rheinhardt2021-02-191-0/+5
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpegenc: Ensure packet queue stays validAndreas Rheinhardt2021-02-191-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MPEG-PS muxer uses a custom queue of custom packets. To keep track of it, it has a pointer (named predecode_packet) to the head of the queue and a pointer to where the next packet is to be added (it points to the next-pointer of the last element of the queue); furthermore, there is also a pointer that points into the queue (called premux_packet). The exact behaviour was as follows: If premux_packet was NULL when a packet is received, it is taken to mean that the old queue is empty and a new queue is started. premux_packet will point to the head of said queue and the next_packet-pointer points to its next pointer. If predecode_packet is NULL, it will also made to point to the newly allocated element. But if premux_packet is NULL and predecode_packet is not, then there will be two queues with head elements premux_packet and predecode_packet. Yet only elements reachable from predecode_packet are ever freed, so the premux_packet queue leaks. Worse yet, when the predecode_packet queue will be eventually exhausted, predecode_packet will be made to point into the other queue and when predecode_packet will be freed, the next pointer of the preceding element of the queue will still point to the element just freed. This element might very well be still reachable from premux_packet which leads to use-after-frees lateron. This happened in the tickets mentioned below. Fix this by never creating two queues in the first place by checking for predecode_packet to know whether the queue is empty. If premux_packet is NULL, then it is set to the newly allocated element of the queue. Fixes tickets #6887, #8188 and #8266. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpegenc: Fix integer overflow with AV_NOPTS_VALUEMichael Niedermayer2020-05-211-1/+1
| | | | | | | | Fixes: signed integer overflow: -9223372036854775808 - 45000 cannot be represented in type 'long' Fixes: ticket8187 Found-by: Suhwan Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: convert some avio_flush() calls to ↵Marton Balint2020-01-071-2/+2
| | | | | | | | | | | | | | | | | avio_write_marker(AVIO_DATA_MARKER_FLUSH_POINT) Converting explicit avio_flush() calls helps us to buffer more data and avoid flushing the IO context too often which causes reduced IO throughput for non-streamed file output. The user can control FLUSH_POINT flushing behaviour using the -flush_packets option, the default typically means to flush unless a non-streamed file output is used, so this change should have no adverse effect on streaming even if it is assumed that after an avio_flush() the output buffer is clean so small seekbacks within the output buffer will work even when the IO context is not seekable. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: remove unneeded avio_flush() calls from the end of write_trailer ↵Marton Balint2020-01-071-1/+0
| | | | | | | functions The IO context is always flushed by libavformat/mux.c after write_trailer is called, so this change should have no effect at all.
* avformat/mpegenc: check for stream private data during deinitJames Almer2019-10-181-0/+2
| | | | | | Prevents pointer dereferences when streams were not fully initialized. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mpegenc: Fix memleaks and return valuesAndreas Rheinhardt2019-10-171-12/+19
| | | | | | | | | | | | | | | | | | If there is an error in mpeg_mux_init() (the write_header function of the various MPEG-PS muxers), two things might happen: 1. Several fifos might leak. Instead of freeing them, the goto fail part of the functions freed the private data of the AVStreams instead, although this will be freed later in free_stream() anyway. 2. And if the function is exited via goto fail, it automatically returned AVERROR(ENOMEM), although this is also used when the error is not a memory allocation failure. Both of these issues happened in ticket #8284 and have been fixed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegenc - reject unsupported audio streamsGyan Doshi2019-04-221-0/+10
| | | | | Only MP1, MP2, MP3, 16-bit PCM_DVD, PCM S16BE, AC3 and DTS audio codecs are supported by the muxer.
* avformat/mpegenc: extend muxing PCM-DVD to other depthsPaul B Mahol2018-12-011-6/+21
| | | | Fixes #6783.
* avformat/mpegenc - log error msgs for unsupported LPCM streamsGyan Doshi2018-02-221-3/+12
| | | | | | | The MPEG-PS muxer only accepts PCM streams having up to 8 channels and the following sampling rates: 32/44.1/48/96 kHz. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegenc - accept PCM_DVD streamsGyan Doshi2018-02-161-2/+21
| | | | | | | | PCM_S16BE stream packets in MPEG-PS have a 3-byte header and are recognized as PCM_DVD by the demuxer which prevents their correct remuxing in MPEG-1/2 PS. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegenc - fix typo in VBV warningGyan Doshi2018-01-301-1/+1
| | | | | | Default VBV buffer size is 230KB, not 130KB. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegenc: Check for av_mallocz() failureMichael Niedermayer2016-12-211-0/+2
| | | | | | Fixes CID1257787 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'Clément Bœsch2016-06-211-3/+3
|\ | | | | | | | | | | | | * commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb': cosmetics: Fix spelling mistakes Merged-by: Clément Bœsch <u@pkh.me>
| * cosmetics: Fix spelling mistakesVittorio Giovara2016-05-041-3/+3
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | Merge commit '9200514ad8717c63f82101dc394f4378854325bf'Derek Buitenhuis2016-04-101-18/+18
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * lavf: replace AVStream.codec with AVStream.codecparAnton Khirnov2016-02-231-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, AVStream contains an embedded AVCodecContext instance, which is used by demuxers to export stream parameters to the caller and by muxers to receive stream parameters from the caller. It is also used internally as the codec context that is passed to parsers. In addition, it is also widely used by the callers as the decoding (when demuxer) or encoding (when muxing) context, though this has been officially discouraged since Libav 11. There are multiple important problems with this approach: - the fields in AVCodecContext are in general one of * stream parameters * codec options * codec state However, it's not clear which ones are which. It is consequently unclear which fields are a demuxer allowed to set or a muxer allowed to read. This leads to erratic behaviour depending on whether decoding or encoding is being performed or not (and whether it uses the AVStream embedded codec context). - various synchronization issues arising from the fact that the same context is used by several different APIs (muxers/demuxers, parsers, bitstream filters and encoders/decoders) simultaneously, with there being no clear rules for who can modify what and the different processes being typically delayed with respect to each other. - avformat_find_stream_info() making it necessary to support opening and closing a single codec context multiple times, thus complicating the semantics of freeing various allocated objects in the codec context. Those problems are resolved by replacing the AVStream embedded codec context with a newly added AVCodecParameters instance, which stores only the stream parameters exported by the demuxers or read by the muxers.
* | Merge commit '8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca'Hendrik Leppkes2015-12-171-5/+10
|\ \ | |/ | | | | | | | | | | * commit '8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca': mpegenc: use the CPB props side data Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * mpegenc: use the CPB props side dataAnton Khirnov2015-12-061-5/+10
| | | | | | | | | | Do not access the encoder options, since it makes no sense when the AVStream codec context is not the encoding context.
* | lavf/mpegenc: provide better feedback in case of invalid media typeStefano Sabatini2015-08-271-1/+3
| |
* | avformat/mpegenc: Replace *0.7 by *7/10Michael Niedermayer2015-05-251-1/+1
| | | | | | | | | | | | | | This avoids another float computation, avoiding a potential source of rounding issues Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mpegenc: Do not use floats for vcd_padding_bitrateMichael Niedermayer2015-05-251-9/+9
| | | | | | | | | | | | This reduces the risk for rounding differences. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '1a3eb042c704dea190c644def5b32c9cee8832b8'Michael Niedermayer2015-04-201-4/+4
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '1a3eb042c704dea190c644def5b32c9cee8832b8': Replace av_dlog with normal av_log at trace level Conflicts: ffplay.c libavdevice/fbdev_dec.c libavfilter/avfilter.c libavfilter/internal.h libavfilter/setpts.c libavfilter/src_movie.c libavfilter/vf_crop.c libavfilter/vf_drawtext.c libavfilter/vf_fieldorder.c libavformat/assdec.c libavformat/avidec.c libavformat/flvdec.c libavformat/http.c libavformat/ipmovie.c libavformat/isom.c libavformat/mov.c libavformat/mpegenc.c libavformat/mpegts.c libavformat/mpegtsenc.c libavformat/mux.c libavformat/mxfdec.c libavformat/nsvdec.c libavformat/oggdec.c libavformat/r3d.c libavformat/rtspdec.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Replace av_dlog with normal av_log at trace levelVittorio Giovara2015-04-191-4/+4
| | | | | | | | This applies to every library where performance is not critical.
* | avformat/mpegenc: Ignore max_delay if no other options remainMichael Niedermayer2015-03-011-11/+21
| | | | | | | | | | | | | | Fixes assertion failure Fixes Ticket4335 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'Michael Niedermayer2015-02-141-2/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e': avformat: Don't anonymously typedef structs Conflicts: libavformat/adtsenc.c libavformat/aiffenc.c libavformat/avidec.c libavformat/gif.c libavformat/iff.c libavformat/img2dec.c libavformat/jvdec.c libavformat/matroskadec.c libavformat/udp.c libavformat/wtvdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avformat: Don't anonymously typedef structsDiego Biurrun2015-02-141-2/+2
| |
* | Merge commit '01168bf1405ddbf671f1074a927b951b8777adbb'Michael Niedermayer2015-01-071-1/+0
|\ \ | |/ | | | | | | | | | | * commit '01168bf1405ddbf671f1074a927b951b8777adbb': mpeg: Remove unused field Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mpeg: Remove unused fieldLuca Barbato2015-01-071-1/+0
| |
| * mpegenc: prevent a NULL pointer dereferenceVittorio Giovara2014-11-241-1/+1
| | | | | | | | | | CC: libav-stable@libav.org Bug-Id: CID 29261
| * mpegenc: limit the maximum muxrateAnton Khirnov2014-08-271-1/+1
| | | | | | | | | | | | It is written to the file as a 22-bit value. CC: libav-stable@libav.org
* | avformat/mpegenc: Use av_freep() to avoid leaving stale pointers in memoryMichael Niedermayer2014-12-211-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mpegenc: replace always enabled asserts by av_assert0()Michael Niedermayer2014-12-191-9/+6
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avformat/mpegenc: assert that premux_packet is non nullMichael Niedermayer2014-11-241-1/+3
| | | | | | | | | | Based on: 065923b0781b06a2604f69f4e2c2407b7750a854 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '4e9e6fa99f3ff83cedbf6c378d62065ae419a3b9'Michael Niedermayer2014-08-261-4/+9
|\ \ | |/ | | | | | | | | | | * commit '4e9e6fa99f3ff83cedbf6c378d62065ae419a3b9': mpeg: Write H264 streams at offset 2 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mpeg: Write H264 streams at offset 2Luca Barbato2014-08-261-4/+9
| | | | | | | | It hints that the content is H264 according to HD-DVD.
* | Merge commit '8c6f430291374cf6d2cfb85cdbb809803b5a7d83'Michael Niedermayer2014-08-101-1/+2
|\ \ | |/ | | | | | | | | | | | | | | | | * commit '8c6f430291374cf6d2cfb85cdbb809803b5a7d83': mpeg: Suppress a compiler warning on callback type Conflicts: libavformat/mpegenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * mpeg: Suppress a compiler warning on callback typeLuca Barbato2014-08-091-1/+2
| |
* | Merge commit 'e4c9e59a4547adaaa0ce9f25b0d0c5b91ae15472'Michael Niedermayer2014-08-081-309/+331
|\ \ | |/ | | | | | | | | | | | | | | | | * commit 'e4c9e59a4547adaaa0ce9f25b0d0c5b91ae15472': mpeg: K&R formatting cosmetics Conflicts: libavformat/mpegenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>