[FFmpeg-devel] [PATCH 07/29] avcodec/jpegtables: Move ff_mjpeg_build_huffman_codes to mjpegenc_common
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Thu Feb 18 05:41:52 EET 2021
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 at gmail.com>
---
libavcodec/jpegtables.c | 21 ---------------------
libavcodec/jpegtables.h | 4 ----
libavcodec/mjpegenc_common.c | 21 +++++++++++++++++++++
libavcodec/mjpegenc_common.h | 3 +++
4 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index e44bc7a22a..ef3f8dee20 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -122,24 +122,3 @@ const uint8_t avpriv_mjpeg_val_ac_chrominance[] =
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa
};
-
-/* 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 i, j, k,nb, code, sym;
-
- k = 0;
- code = 0;
- for(i=1;i<=16;i++) {
- nb = bits_table[i];
- for(j=0;j<nb;j++) {
- sym = val_table[k++];
- huff_size[sym] = i;
- huff_code[sym] = code;
- code++;
- }
- code <<= 1;
- }
-}
diff --git a/libavcodec/jpegtables.h b/libavcodec/jpegtables.h
index aa38df4033..0907280445 100644
--- a/libavcodec/jpegtables.h
+++ b/libavcodec/jpegtables.h
@@ -36,8 +36,4 @@ extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_luminance[];
extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_chrominance[];
-void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
- const uint8_t *bits_table,
- const uint8_t *val_table);
-
#endif /* AVCODEC_JPEGTABLES_H */
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.
*
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index e8698d18c6..b432baac3e 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -35,6 +35,9 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
+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 ff_mjpeg_encode_stuffing(MpegEncContext *s);
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4]);
--
2.27.0
More information about the ffmpeg-devel
mailing list