aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegenc_common.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-10 00:31:46 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-23 10:14:25 +0100
commit6eae9c1d3946771c577faeda9e4394a26063dd22 (patch)
tree0b8b5fdc431308c41859fc70ab708ec29b6f79e8 /libavcodec/mjpegenc_common.c
parentd26198ada3279e9d7ef5d3d2cca13b0eff5144f0 (diff)
downloadffmpeg-6eae9c1d3946771c577faeda9e4394a26063dd22.tar.gz
avcodec/jpegtables: Move ff_mjpeg_build_huffman_codes to mjpegenc_common
Since g2meet.c doesn't use it any more, only encoders use it and the place for their common code is mjpegenc_common.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mjpegenc_common.c')
-rw-r--r--libavcodec/mjpegenc_common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 0b82777ec9..720b18d448 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -466,6 +466,27 @@ void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
}
}
+/* isn't this function nicer than the one in the libjpeg ? */
+void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
+ const uint8_t *bits_table,
+ const uint8_t *val_table)
+{
+ int k, code;
+
+ k = 0;
+ code = 0;
+ for (int i = 1; i <= 16; i++) {
+ int nb = bits_table[i];
+ for (int j = 0; j < nb; j++) {
+ int sym = val_table[k++];
+ huff_size[sym] = i;
+ huff_code[sym] = code;
+ code++;
+ }
+ code <<= 1;
+ }
+}
+
/**
* Builds all 4 optimal Huffman tables.
*