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
626OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o626OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
627OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o627OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o
628OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o mpeg12.o mpeg12data.o simple_idct.o628OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o mpeg12.o mpeg12data.o simple_idct.o
629OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o speedhqenc.o629OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o mpeg12enc.o speedhqenc.o
630OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o630OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o
631OBJS-$(CONFIG_SRGC_DECODER) += mscc.o631OBJS-$(CONFIG_SRGC_DECODER) += mscc.o
632OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o632OBJS-$(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
37}37}
38 38
39void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags);39void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags);
40void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len);
40 41
41static inline int decode_dc(GetBitContext *gb, int component)42static inline int decode_dc(GetBitContext *gb, int component)
42{43{
libavcodec/mpeg12enc.c+8−3
@@ -27,6 +27,7 @@ · 26 unmodified lines
27 27
28#include <stdint.h>28#include <stdint.h>
29 29
30#include "config.h"
30#include "libavutil/attributes.h"31#include "libavutil/attributes.h"
31#include "libavutil/avassert.h"32#include "libavutil/avassert.h"
32#include "libavutil/log.h"33#include "libavutil/log.h"
@@ -44,6 +45,7 @@ · 11 unmodified lines
44#include "mpegvideo.h"45#include "mpegvideo.h"
45#include "profiles.h"46#include "profiles.h"
46 47
48#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
47static const uint8_t svcd_scan_offset_placeholder[] = {49static const uint8_t svcd_scan_offset_placeholder[] = {
48 0x10, 0x0E, 0x00, 0x80, 0x81, 0x00, 0x80,50 0x10, 0x0E, 0x00, 0x80, 0x81, 0x00, 0x80,
49 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,51 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -64,8 +66,9 @@ static uint8_t mpeg1_index_run[2][64]; · 14 unmodified lines
64static int8_t mpeg1_max_level[2][64];66static int8_t mpeg1_max_level[2][64];
65 67
66#define A53_MAX_CC_COUNT 0x1f68#define A53_MAX_CC_COUNT 0x1f
69#endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
67 70
68static av_cold void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len)71av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len)
69{72{
70 int i;73 int i;
71 74
@@ -100,6 +103,7 @@ static av_cold void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len) · 28 unmodified lines
100 }103 }
101}104}
102 105
106#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
103static int find_frame_rate_index(MpegEncContext *s)107static int find_frame_rate_index(MpegEncContext *s)
104{108{
105 int i;109 int i;
@@ -1045,8 +1049,8 @@ static av_cold void mpeg12_encode_init_static(void) · 939 unmodified lines
1045 mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];1049 mpeg1_index_run[0][i] = ff_rl_mpeg1.index_run[0][i];
1046 }1050 }
1047 1051
1048 init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);1052 ff_mpeg1_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);1053 ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
1050 1054
1051 /* build unified dc encoding tables */1055 /* build unified dc encoding tables */
1052 for (int i = -255; i < 256; i++) {1056 for (int i = -255; i < 256; i++) {
@@ -1222,3 +1226,4 @@ AVCodec ff_mpeg2video_encoder = { · 169 unmodified lines
1222 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,1226 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1223 .priv_class = &mpeg2_class,1227 .priv_class = &mpeg2_class,
1224};1228};
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
104 speedhq_chr_dc_uni[i + 255] = bits + (code << 8);104 speedhq_chr_dc_uni[i + 255] = bits + (code << 8);
105 }105 }
106 106
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);
108}108}
109 109
110av_cold int ff_speedhq_encode_init(MpegEncContext *s)110av_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