diff options
author | Andreas Rheinhardt <andreas.rheinhardt@googlemail.com> | 2019-02-12 01:47:43 +0300 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2019-02-26 00:40:13 +0300 |
commit | b8c45bbcbc207293f955e838ea66106f4b65b1ac (patch) | |
tree | e46eb58202941ad69cbd56f142a7900c7499ae13 /libavcodec/vaapi_encode_mjpeg.c | |
parent | c5b452ed2f16a0d7bf01d7d84097337f8756987b (diff) |
libavcodec/cbs: Stop needlessly reallocating the units array
Currently, a fragment's unit array is constantly reallocated during
splitting of a packet. This commit changes this: One can keep the units
array by distinguishing between the number of allocated and the number
of valid units in the units array.
The more units a packet is split into, the bigger the benefit.
So MPEG-2 benefits the most; for a video coming from an NTSC-DVD
(usually 32 units per frame) the average cost of cbs_insert_unit (for a
single unit) went down from 6717 decicycles to 450 decicycles (based
upon 10 runs with 4194304 runs each); if each packet consists of only
one unit, it went down from 2425 to 448; for a H.264 video where most
packets contain nine units, it went from 4431 to 450.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
Diffstat (limited to 'libavcodec/vaapi_encode_mjpeg.c')
-rw-r--r-- | libavcodec/vaapi_encode_mjpeg.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index f0ea292098..72e794604a 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -142,7 +142,7 @@ static int vaapi_encode_mjpeg_write_image_header(AVCodecContext *avctx, err = 0; fail: - ff_cbs_fragment_uninit(priv->cbc, frag); + ff_cbs_fragment_reset(priv->cbc, frag); return err; } @@ -515,6 +515,7 @@ static av_cold int vaapi_encode_mjpeg_close(AVCodecContext *avctx) { VAAPIEncodeMJPEGContext *priv = avctx->priv_data; + ff_cbs_fragment_free(priv->cbc, &priv->current_fragment); ff_cbs_close(&priv->cbc); return ff_vaapi_encode_close(avctx); |