summaryrefslogtreecommitdiff
path: root/libavformat/av1.h
Commit message (Collapse)AuthorAge
* 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: Fix nits in the documentation of ff_av1_filter_obus_buf()Andreas Rheinhardt2020-01-26
| | | | | 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>
* 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: fix AV1CodecConfigurationBox name in doxyJames Almer2019-07-30
| | | | 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>