You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/h274: don't read from uninitialized array members
This bug flew under the radar because, in practice, these values are 0-initialized for the first invocation. But for subsequent invocations (with different h/v values), reading from the uninitialized parts of `out` is undefined behavior. Avoid this by simply adjusting the iteration range of the following loops. Has the added benefit of being a minor speedup. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -74,9 +74,9 @@ static void init_slice_c(int8_t out[64][64], uint8_t h, uint8_t v,
|
|||||||
|
|
||||||
// 64x64 inverse integer transform
|
// 64x64 inverse integer transform
|
||||||
for (int y = 0; y < 64; y++) {
|
for (int y = 0; y < 64; y++) {
|
||||||
for (int x = 0; x < 64; x++) {
|
for (int x = 0; x <= freq_h; x++) {
|
||||||
int32_t sum = 0;
|
int32_t sum = 0;
|
||||||
for (int p = 0; p < 64; p++)
|
for (int p = 0; p <= freq_v; p++)
|
||||||
sum += R64T[y][p] * out[x][p];
|
sum += R64T[y][p] * out[x][p];
|
||||||
tmp[y][x] = (sum + 128) >> 8;
|
tmp[y][x] = (sum + 128) >> 8;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ static void init_slice_c(int8_t out[64][64], uint8_t h, uint8_t v,
|
|||||||
for (int y = 0; y < 64; y++) {
|
for (int y = 0; y < 64; y++) {
|
||||||
for (int x = 0; x < 64; x++) {
|
for (int x = 0; x < 64; x++) {
|
||||||
int32_t sum = 0;
|
int32_t sum = 0;
|
||||||
for (int p = 0; p < 64; p++)
|
for (int p = 0; p <= freq_h; p++)
|
||||||
sum += tmp[y][p] * R64T[x][p]; // R64T^T = R64
|
sum += tmp[y][p] * R64T[x][p]; // R64T^T = R64
|
||||||
// Renormalize and clip to [-127, 127]
|
// Renormalize and clip to [-127, 127]
|
||||||
out[y][x] = av_clip((sum + 128) >> 8, -127, 127);
|
out[y][x] = av_clip((sum + 128) >> 8, -127, 127);
|
||||||
|
Reference in New Issue
Block a user