summaryrefslogtreecommitdiff
path: root/libavformat/av1.c
Commit message (Collapse)AuthorAge
* avformat/av1: add support for passing through MP4/Matroska av1cJan Ekström2020-11-24
|
* avformat/av1: Avoid using dynamic buffer when assembling av1cAndreas Rheinhardt2020-06-26
| | | | | | | | | Given that AV1 only has exactly one sequence header, it is unnecessary to copy the content of said sequence header into an intermediate dynamic buffer; instead the sequence header can be copied from where it is in the input buffer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/av1: Avoid allocation + copying when filtering OBUsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Certain types of OBUs are stripped away before muxing into Matroska and ISOBMFF; there are two functions to do this: One that outputs by directly writing in an AVIOContext and one that returns a freshly allocated buffer with the units not stripped away copied into it. The latter option is bad for performance, especially when the input does already not contain any of the units intended to be stripped away (this covers typical remuxing scenarios). Therefore this commit changes this by avoiding allocating and copying when possible; it is possible if the OBUs to be retained are consecutively in the input buffer (without an OBU to be discarded between them). In this case, the caller receives the offset as well as the length of the part of the buffer that contains the units to be kept. This also avoids copying when e.g. the only unit to be discarded is a temporal delimiter at the front. For a 22.7mb/s file with average framesize 113 kB this improved the time for the calls to ff_av1_filter_obus_buf() when writing Matroska from 313319 decicycles to 2368 decicycles; for another file with 1.5mb/s (average framesize 7.3 kB) it improved from 34539 decicycles to 1922 decicyles. For these files the only units that needed to be stripped away were temporal unit delimiters at the front. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1, avc, hevc: Remove av_freep()Andreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | ff_av1_filter_obus_buf() and ff_avc_parse_nal_units_buf() both have a pointer-to-pointer parameter which they use to pass a newly allocated buffer to the caller. And both functions freed what this pointer points to before overwriting it. But no caller of these functions used this feature, but some had to initialize the pointer just because of this. So remove it and update the documentation of ff_av1_filter_obus_buf() wrt this fact. ff_hevc_annexb2mp4_buf in contrast did not free the pointer. This has been documented, too. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: Improve filtering AV1 OBUsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both ISOBMFF as well as Matroska require certain OBUs to be stripped before muxing them. There are two functions for this purpose; one writes directly into an AVIOContext, the other returns a freshly allocated buffer with the undesired units stripped away. The latter one actually relies on the former by means of a dynamic buffer. This has several drawbacks: The underlying buffer might have to be reallocated multiple times; the buffer will eventually be overallocated; the data will not be directly copied into the final buffer, but rather first in the write buffer (in chunks of 1024 byte) and then written in these chunks. Moreover, the API for dynamic buffers is defective wrt error checking and as a consequence, the earlier code would indicate a length of -AV_INPUT_BUFFER_PADDING_SIZE on allocation failure, but it would not return an error; there would also be no error in case the arbitrary limit of INT_MAX/2 that is currently imposed on dynamic buffers is hit. This commit changes this: The buffer is now parsed twice, once to get the precise length which will then be allocated; and once to actually write the data. For a 22.7mb/s file with average framesize 113 kB this improved the time for the calls to ff_av1_filter_obus_buf() when writing Matroska from 753662 decicycles to 313319 decicycles (based upon 50 runs a 2048 frames each); for another 1.5mb/s file (with average framesize of 7.3 kB) it improved from 79270 decicycles to 34539 decicycles (based upon 50 runs a 4096 frames). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1, hevc: Make *_buf-functions return 0 on successAndreas Rheinhardt2020-01-26
| | | | | | | | | | | The output size is already returned via a pointer argument, so there is no need to return it via the ordinary return value as well. The rationale behind this is to not poison the return value on success. It also unifies the behaviour of the *_buf-functions for AVC, AV1 and HEVC. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_av1: rename enable_intraintra_compound flagFei Wang2019-12-11
| | | | | | | | rename enable_intraintra_compound to enable_interintra_compound, which keep same as AV1 sepc(v1.0.0-errata1). Signed-off-by: Fei Wang <fei.w.wang@intel.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: Avoid allocation for small headersAndreas Rheinhardt2019-11-28
| | | | | | | | By using avio_get_dyn_buf() + ffio_free_dyn_buf() instead of avio_close_dyn_buf() + av_free() one can avoid an allocation + copy for small headers. Furthermore, it simplifies freeing. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/av1: Fix leak of dynamic buffer in case of parsing failureAndreas Rheinhardt2019-11-22
| | | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: combine high_bitdepth and twelve_bit into a single bitdepth valueJames Almer2019-08-03
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: rename some AV1SequenceParameters fieldsJames Almer2019-08-03
| | | | | | Cosmetic change. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: split off sequence header parsing from the av1C writing functionJames Almer2019-08-03
| | | | | | It will be used by the dash muxer Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: add color config values to AV1SequenceParametersJames Almer2019-08-03
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: Initialize padding in ff_isom_write_av1cJeremy Dorfman via ffmpeg-devel2019-04-08
| | | | | | | | Otherwise, AV1 encodes with FFmpeg trigger use-of-uninitialized-value warnings under MemorySanitizer, and the output buffer potentially changes from run to run. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: zero initialize the seq_params structJames Almer2018-09-02
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: filter out tile list OBUs from samplesJames Almer2018-08-17
| | | | | | As per the updated spec. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: update ff_isom_write_av1c() to the latest revision of the specJames Almer2018-08-17
| | | | | | | | | | This will get ISOBMFF and Matroska up to date with the revised AV1 Codec Configuration Box spec. For now keep propagating raw OBUs as extradata until all libavcodec modules are adapted to handle AV1CodecConfigurationRecord formatted extradata. Tested-by: Thomas Daede <bztdlinux@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: reorder OBUs before writting them in ff_isom_write_av1c()James Almer2018-08-02
| | | | | | Make sure Sequence Header is first, and only allow one of its kind. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/av1_parse: return size of the parsed OBU in parse_obu_header()James Almer2018-08-02
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: return an error when no data is provided to ff_isom_write_av1c()James Almer2018-08-02
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: add support for AV1 streamsJames Almer2018-07-20
Signed-off-by: James Almer <jamrial@gmail.com>