diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-01-23 17:08:32 +0100 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-01-26 12:41:32 -0300 |
commit | d4bbc0db011151191ebc5e14af4be28127715cbd (patch) | |
tree | 9d4744e41042fb1d9aeec97a702a08a171f89776 /libavformat/av1.h | |
parent | e8518c2580f78a727d1e5d32c9cb6fe453ea5e53 (diff) | |
download | ffmpeg-d4bbc0db011151191ebc5e14af4be28127715cbd.tar.gz |
avformat/av1: Improve filtering AV1 OBUs
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>
Diffstat (limited to 'libavformat/av1.h')
-rw-r--r-- | libavformat/av1.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavformat/av1.h b/libavformat/av1.h index 0578435376..acba12612c 100644 --- a/libavformat/av1.h +++ b/libavformat/av1.h @@ -61,7 +61,7 @@ int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size); * * @param pb pointer to the AVIOContext where the filtered bitstream shall be * written - * @param buf input data buffer + * @param in input data buffer * @param out pointer to pointer that will hold the allocated data buffer * @param size size of the input data buffer. The size of the resulting output data buffer will be written here @@ -69,7 +69,7 @@ int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size); * @return 0 in case of success, a negative AVERROR code in case of failure. * On failure, out and size are unchanged */ -int ff_av1_filter_obus_buf(const uint8_t *buf, uint8_t **out, int *size); +int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out, int *size); /** * Parses a Sequence Header from the the provided buffer. |