diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-10-01 23:36:09 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-10-09 09:15:40 +0200 |
commit | 566280c3f464512446768fa5ee625edbf6a53c81 (patch) | |
tree | b56036faa7bb50e271de7cd98eaf289147fda298 /libavcodec/huffyuv.c | |
parent | 83a8b9fac7b03a3a9c703e2a0641ab2cc35efaae (diff) | |
download | ffmpeg-566280c3f464512446768fa5ee625edbf6a53c81.tar.gz |
avcodec/huffyuv: Split HYuvContext into decoder and encoder context
While the share of elements used by both is quite big, the amount
of code shared between the decoders and encoders is negligible.
Therefore one can easily split the context if one wants to.
The reasons for doing so are that the non-shared elements
are non-negligible: The stats array which is only used by
the encoder takes 524288B of 868904B (on x64); similarly,
pix_bgr_map which is only used by the decoder takes 16KiB.
Furthermore, using a shared context also entails inclusions
of unneeded headers like put_bits.h for the decoder and get_bits.h
for the encoder (and all of these and much more for huffyuv.c).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/huffyuv.c')
-rw-r--r-- | libavcodec/huffyuv.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 23a2bb2537..bbe4b952b0 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -30,10 +30,11 @@ #include <stdint.h> +#include "libavutil/attributes.h" +#include "libavutil/error.h" +#include "libavutil/log.h" #include "libavutil/mem.h" -#include "avcodec.h" -#include "bswapdsp.h" #include "huffyuv.h" int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n) @@ -55,25 +56,25 @@ int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int return 0; } -av_cold int ff_huffyuv_alloc_temp(HYuvContext *s, int width) +av_cold int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width) { int i; for (i=0; i<3; i++) { - s->temp[i] = av_malloc(4 * width + 16); - if (!s->temp[i]) + temp[i] = av_malloc(4 * width + 16); + if (!temp[i]) return AVERROR(ENOMEM); - s->temp16[i] = (uint16_t*)s->temp[i]; + temp16[i] = (uint16_t*)temp[i]; } return 0; } -av_cold void ff_huffyuv_common_end(HYuvContext *s) +av_cold void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3]) { int i; for(i = 0; i < 3; i++) { - av_freep(&s->temp[i]); - s->temp16[i] = NULL; + av_freep(&temp[i]); + temp16[i] = NULL; } } |