diff options
| -rw-r--r-- | meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch | 89 | ||||
| -rw-r--r-- | meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb | 4 |
2 files changed, 92 insertions, 1 deletions
diff --git a/meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch b/meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch new file mode 100644 index 0000000000..2775a81cc8 --- /dev/null +++ b/meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | From 92f9b28ed84a77138105475beba16c146bdaf984 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Paul B Mahol <onemda@gmail.com> | ||
| 3 | Date: Sat, 12 Nov 2022 16:12:00 +0100 | ||
| 4 | Subject: [PATCH] avcodec/rpzaenc: stop accessing out of bounds frame | ||
| 5 | |||
| 6 | Upstream-Status: Backport [https://github.com/FFmpeg/FFmpeg/commit/92f9b28ed84a77138105475beba16c146bdaf984] | ||
| 7 | |||
| 8 | Signed-off-by: <narpat.mali@windriver.com> | ||
| 9 | |||
| 10 | --- | ||
| 11 | libavcodec/rpzaenc.c | 22 +++++++++++++++------- | ||
| 12 | 1 file changed, 15 insertions(+), 7 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c | ||
| 15 | index d710eb4f82..4ced9523e2 100644 | ||
| 16 | --- a/libavcodec/rpzaenc.c | ||
| 17 | +++ b/libavcodec/rpzaenc.c | ||
| 18 | @@ -205,7 +205,7 @@ static void get_max_component_diff(const BlockInfo *bi, const uint16_t *block_pt | ||
| 19 | |||
| 20 | // loop thru and compare pixels | ||
| 21 | for (y = 0; y < bi->block_height; y++) { | ||
| 22 | - for (x = 0; x < bi->block_width; x++){ | ||
| 23 | + for (x = 0; x < bi->block_width; x++) { | ||
| 24 | // TODO: optimize | ||
| 25 | min_r = FFMIN(R(block_ptr[x]), min_r); | ||
| 26 | min_g = FFMIN(G(block_ptr[x]), min_g); | ||
| 27 | @@ -278,7 +278,7 @@ static int leastsquares(const uint16_t *block_ptr, const BlockInfo *bi, | ||
| 28 | return -1; | ||
| 29 | |||
| 30 | for (i = 0; i < bi->block_height; i++) { | ||
| 31 | - for (j = 0; j < bi->block_width; j++){ | ||
| 32 | + for (j = 0; j < bi->block_width; j++) { | ||
| 33 | x = GET_CHAN(block_ptr[j], xchannel); | ||
| 34 | y = GET_CHAN(block_ptr[j], ychannel); | ||
| 35 | sumx += x; | ||
| 36 | @@ -325,7 +325,7 @@ static int calc_lsq_max_fit_error(const uint16_t *block_ptr, const BlockInfo *bi | ||
| 37 | int max_err = 0; | ||
| 38 | |||
| 39 | for (i = 0; i < bi->block_height; i++) { | ||
| 40 | - for (j = 0; j < bi->block_width; j++){ | ||
| 41 | + for (j = 0; j < bi->block_width; j++) { | ||
| 42 | int x_inc, lin_y, lin_x; | ||
| 43 | x = GET_CHAN(block_ptr[j], xchannel); | ||
| 44 | y = GET_CHAN(block_ptr[j], ychannel); | ||
| 45 | @@ -420,7 +420,9 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels, | ||
| 46 | uint16_t *dest_pixels, | ||
| 47 | const BlockInfo *bi, int block_counter) | ||
| 48 | { | ||
| 49 | - for (int y = 0; y < 4; y++) { | ||
| 50 | + const int y_size = FFMIN(4, bi->image_height - bi->row * 4); | ||
| 51 | + | ||
| 52 | + for (int y = 0; y < y_size; y++) { | ||
| 53 | memcpy(dest_pixels, src_pixels, 8); | ||
| 54 | dest_pixels += bi->rowstride; | ||
| 55 | src_pixels += bi->rowstride; | ||
| 56 | @@ -730,14 +732,15 @@ post_skip : | ||
| 57 | |||
| 58 | if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK | ||
| 59 | uint16_t *row_ptr; | ||
| 60 | - int rgb555; | ||
| 61 | + int y_size, rgb555; | ||
| 62 | |||
| 63 | block_offset = get_block_info(&bi, block_counter); | ||
| 64 | |||
| 65 | row_ptr = &src_pixels[block_offset]; | ||
| 66 | + y_size = FFMIN(4, bi.image_height - bi.row * 4); | ||
| 67 | |||
| 68 | - for (int y = 0; y < 4; y++) { | ||
| 69 | - for (int x = 0; x < 4; x++){ | ||
| 70 | + for (int y = 0; y < y_size; y++) { | ||
| 71 | + for (int x = 0; x < 4; x++) { | ||
| 72 | rgb555 = row_ptr[x] & ~0x8000; | ||
| 73 | |||
| 74 | put_bits(&s->pb, 16, rgb555); | ||
| 75 | @@ -745,6 +748,11 @@ post_skip : | ||
| 76 | row_ptr += bi.rowstride; | ||
| 77 | } | ||
| 78 | |||
| 79 | + for (int y = y_size; y < 4; y++) { | ||
| 80 | + for (int x = 0; x < 4; x++) | ||
| 81 | + put_bits(&s->pb, 16, 0); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | block_counter++; | ||
| 85 | } else { // FOUR COLOR BLOCK | ||
| 86 | block_counter += encode_four_color_block(min_color, max_color, | ||
| 87 | -- | ||
| 88 | 2.34.1 | ||
| 89 | |||
diff --git a/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb b/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb index a0c98d4ae0..43b858984b 100644 --- a/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb +++ b/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb | |||
| @@ -22,7 +22,9 @@ LIC_FILES_CHKSUM = "file://COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ | |||
| 22 | file://COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \ | 22 | file://COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \ |
| 23 | file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02" | 23 | file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02" |
| 24 | 24 | ||
| 25 | SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz" | 25 | SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \ |
| 26 | file://0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch" | ||
| 27 | |||
| 26 | SRC_URI[sha256sum] = "619e706d662c8420859832ddc259cd4d4096a48a2ce1eefd052db9e440eef3dc" | 28 | SRC_URI[sha256sum] = "619e706d662c8420859832ddc259cd4d4096a48a2ce1eefd052db9e440eef3dc" |
| 27 | 29 | ||
| 28 | # Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717 | 30 | # Build fails when thumb is enabled: https://bugzilla.yoctoproject.org/show_bug.cgi?id=7717 |
