History

avcodec/speedhqenc: Call correct function

Up until now, the SpeedHQ encoder called a wrong function for init: void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256], uint8_t *uni_ac_vlc_len); Yet the first argument actually used is of type RLTable; the size of said struct is less than 256 if the size of a pointer is four, leading to an access beyond the end of the RLTable. This commit fixes this by calling the actually intended function: init_uni_ac_vlc() from mpeg12enc.c. It was intended to use this function [1], yet doing so was forgotten when the patch was actually applied. [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-July/266187.html

Andreas Rheinhardt committed 5 years ago

Commit 628d02a1 parent 43b4c664 files · +11 −5Browse files

Unified · Split

4 files
  1. libavcodec/Makefile +1 −1
  2. libavcodec/mpeg12.h +1 −0
  3. libavcodec/mpeg12enc.c +8 −3
  4. libavcodec/speedhqenc.c +1 −1
libavcodec/Makefile+1−1
@@ -626,7 +626,7 @@ OBJS-$(CONFIG_SONIC_DECODER) += sonic.o · 625 unmodified lines
626626 OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
627627 OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o
628628 OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o mpeg12.o mpeg12data.o simple_idct.o
629−OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o speedhqenc.o
629+OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o mpeg12enc.o speedhqenc.o
630630 OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o
631631 OBJS-$(CONFIG_SRGC_DECODER) += mscc.o
632632 OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o
libavcodec/mpeg12.h+1−0
@@ -37,6 +37,7 @@ void ff_mpeg12_common_init(MpegEncContext *s); · 36 unmodified lines
3737 }
3838
3939 void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags);
40+void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len);
4041
4142 static inline int decode_dc(GetBitContext *gb, int component)
4243 {
libavcodec/mpeg12enc.c+8−3
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727
2828 #include <stdint.h>
2929
30+#include "config.h"
3031 #include "libavutil/attributes.h"
3132 #include "libavutil/avassert.h"
3233 #include "libavutil/log.h"
@@ -44,6 +45,7 @@ · 11 unmodified lines
4445 #include "mpegvideo.h"
4546 #include "profiles.h"
4647
48+#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
4749 static const uint8_t svcd_scan_offset_placeholder[] = {
4850 0x10, 0x0E, 0x00, 0x80, 0x81, 0x00, 0x80,
4951 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -64,8 +66,9 @@ static uint8_t mpeg1_index_run[2][64]; · 14 unmodified lines
6466 static int8_t mpeg1_max_level[2][64];
6567
6668 #define A53_MAX_CC_COUNT 0x1f
69+#endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
6770
68−static av_cold void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len)
71+av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len)
6972 {
7073 int i;
7174
@@ -100,6 +103,7 @@ static av_cold void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len) · 28 unmodified lines
100103 }
101104 }
102105
106+#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
103107 static int find_frame_rate_index(MpegEncContext *s)
104108 {
105109 int i;
@@ -1045,8 +1049,8 @@ static av_cold void mpeg12_encode_init_static(void) · 939 unmodified lines
10451049 mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];
10461050 }
10471051
1048− init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
1049− init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
1052+ ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
1053+ ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
10501054
10511055 /* build unified dc encoding tables */
10521056 for (int i = -255; i < 256; i++) {
@@ -1222,3 +1226,4 @@ AVCodec ff_mpeg2video_encoder = { · 169 unmodified lines
12221226 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
12231227 .priv_class = &mpeg2_class,
12241228 };
1229+#endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
libavcodec/speedhqenc.c+1−1
@@ -104,7 +104,7 @@ static av_cold void speedhq_init_static_data(void) · 103 unmodified lines
104104 speedhq_chr_dc_uni[i + 255] = bits + (code << 8);
105105 }
106106
107− ff_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len);
107+ ff_mpeg1_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len);
108108 }
109109
110110 av_cold int ff_speedhq_encode_init(MpegEncContext *s)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t