summaryrefslogtreecommitdiff
path: root/libavcodec/av1_parser.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@googlemail.com>2019-02-11 23:47:43 +0100
committerMark Thompson <sw@jkqxz.net>2019-02-25 21:40:13 +0000
commitb8c45bbcbc207293f955e838ea66106f4b65b1ac (patch)
treee46eb58202941ad69cbd56f142a7900c7499ae13 /libavcodec/av1_parser.c
parentc5b452ed2f16a0d7bf01d7d84097337f8756987b (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/av1_parser.c')
-rw-r--r--libavcodec/av1_parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c
index 8df66498f4..bb8737a393 100644
--- a/libavcodec/av1_parser.c
+++ b/libavcodec/av1_parser.c
@@ -72,7 +72,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
goto end;
}
- ff_cbs_fragment_uninit(s->cbc, td);
+ ff_cbs_fragment_reset(s->cbc, td);
}
ret = ff_cbs_read(s->cbc, td, data, size);
@@ -159,7 +159,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
}
end:
- ff_cbs_fragment_uninit(s->cbc, td);
+ ff_cbs_fragment_reset(s->cbc, td);
s->cbc->log_ctx = NULL;
@@ -193,6 +193,7 @@ static void av1_parser_close(AVCodecParserContext *ctx)
{
AV1ParseContext *s = ctx->priv_data;
+ ff_cbs_fragment_free(s->cbc, &s->temporal_unit);
ff_cbs_close(&s->cbc);
}