aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/g2meet.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-10 00:20:26 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-23 10:14:25 +0100
commitd26198ada3279e9d7ef5d3d2cca13b0eff5144f0 (patch)
tree9660cec663e721d0e8a6629a0d23cb7e0a747827 /libavcodec/g2meet.c
parentf180f515de4428e56514a86ea76eaa13e472f87c (diff)
downloadffmpeg-d26198ada3279e9d7ef5d3d2cca13b0eff5144f0.tar.gz
avcodec/g2meet, mjpegdec: Factor out common VLC initialization code
While just at it, remove the nb_codes parameter: It is redundant (the number of codes is implicitly contained in the array containing how many entries of a specific size there are) and for this reason it might even be wrong, so it is better to check what is actually used instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/g2meet.c')
-rw-r--r--libavcodec/g2meet.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 70dc8c72a3..68b1b9dc74 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -41,6 +41,7 @@
#include "internal.h"
#include "jpegtables.h"
#include "mjpeg.h"
+#include "mjpegdec.h"
#define EPIC_PIX_STACK_SIZE 1024
#define EPIC_PIX_STACK_MAX (EPIC_PIX_STACK_SIZE - 1)
@@ -159,45 +160,24 @@ typedef struct G2MContext {
int cursor_hot_x, cursor_hot_y;
} G2MContext;
-static av_cold int build_vlc(VLC *vlc, const uint8_t *bits_table,
- const uint8_t *val_table, int nb_codes,
- int is_ac)
-{
- uint8_t huff_size[256] = { 0 };
- uint16_t huff_code[256];
- uint16_t huff_sym[256];
- int i;
-
- ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
-
- for (i = 0; i < 256; i++)
- huff_sym[i] = i + 16 * is_ac;
-
- if (is_ac)
- huff_sym[0] = 16 * 256;
-
- return ff_init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1,
- huff_code, 2, 2, huff_sym, 2, 2, 0);
-}
-
static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)
{
int ret;
- ret = build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc, 12, 0);
+ ret = ff_mjpeg_build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,
+ avpriv_mjpeg_val_dc, 0, avctx);
if (ret)
return ret;
- ret = build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc, 12, 0);
+ ret = ff_mjpeg_build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,
+ avpriv_mjpeg_val_dc, 0, avctx);
if (ret)
return ret;
- ret = build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance, 251, 1);
+ ret = ff_mjpeg_build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,
+ avpriv_mjpeg_val_ac_luminance, 1, avctx);
if (ret)
return ret;
- ret = build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance, 251, 1);
+ ret = ff_mjpeg_build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,
+ avpriv_mjpeg_val_ac_chrominance, 1, avctx);
if (ret)
return ret;