Skip to content

Commit 39e70dd

Browse files
youennfphiln
authored andcommitted
OSS: [WebRTC] Heap-buffer-overflow in av1_get_one_pass_rt_params - Heap Buffer Overflow in AV1 Video Encoder
rdar://106645234 Reviewed by Eric Carlson. Cherry-picking of https://aomedia.googlesource.com/aom/+/bee1caded272127a6d6b70ac79479083d183d5d0%5E%21/#F0. I had to manually apply the patch since it does not apply cleanly. * Source/ThirdParty/libwebrtc/Source/third_party/libaom/source/libaom/av1/encoder/ratectrl.c: (av1_rc_postencode_update): (av1_rc_postencode_update_drop_frame): (av1_get_one_pass_rt_params): * Source/ThirdParty/libwebrtc/Source/third_party/libaom/source/libaom/av1/encoder/ratectrl.h: Originally-landed-as: 259548.439@safari-7615-branch (4a5ecd489674). rdar://106645234 Canonical link: https://commits.webkit.org/264347@main
1 parent 91e9b2e commit 39e70dd

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Source/ThirdParty/libwebrtc/Source/third_party/libaom/source/libaom/av1/encoder/ratectrl.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,8 @@ void av1_rc_postencode_update(AV1_COMP *cpi, uint64_t bytes_used) {
21362136
}
21372137
#endif
21382138
if (current_frame->frame_type == KEY_FRAME) rc->frames_since_key = 0;
2139+
rc->prev_coded_width = cm->width;
2140+
rc->prev_coded_height = cm->height;
21392141
// if (current_frame->frame_number == 1 && cm->show_frame)
21402142
/*
21412143
rc->this_frame_target =
@@ -2152,6 +2154,8 @@ void av1_rc_postencode_update_drop_frame(AV1_COMP *cpi) {
21522154
cpi->rc.rc_2_frame = 0;
21532155
cpi->rc.rc_1_frame = 0;
21542156
cpi->rc.prev_avg_frame_bandwidth = cpi->rc.avg_frame_bandwidth;
2157+
cpi->rc.prev_coded_width = cpi->common.width;
2158+
cpi->rc.prev_coded_height = cpi->common.height;
21552159
}
21562160

21572161
int av1_find_qindex(double desired_q, aom_bit_depth_t bit_depth,
@@ -3096,8 +3100,15 @@ void av1_get_one_pass_rt_params(AV1_COMP *cpi,
30963100
}
30973101
}
30983102
// Check for scene change: for SVC check on base spatial layer only.
3099-
if (cpi->sf.rt_sf.check_scene_detection && svc->spatial_layer_id == 0)
3100-
rc_scene_detection_onepass_rt(cpi);
3103+
if (cpi->sf.rt_sf.check_scene_detection && svc->spatial_layer_id == 0) {
3104+
if (rc->prev_coded_width == cm->width &&
3105+
rc->prev_coded_height == cm->height) {
3106+
rc_scene_detection_onepass_rt(cpi);
3107+
} else if (cpi->src_sad_blk_64x64) {
3108+
aom_free(cpi->src_sad_blk_64x64);
3109+
cpi->src_sad_blk_64x64 = NULL;
3110+
}
3111+
}
31013112
// Check for dynamic resize, for single spatial layer for now.
31023113
// For temporal layers only check on base temporal layer.
31033114
if (cpi->oxcf.resize_cfg.resize_mode == RESIZE_DYNAMIC) {

Source/ThirdParty/libwebrtc/Source/third_party/libaom/source/libaom/av1/encoder/ratectrl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ typedef struct {
253253
int frame_level_fast_extra_bits;
254254

255255
double frame_level_rate_correction_factors[RATE_FACTOR_LEVELS];
256+
257+
int prev_coded_width;
258+
int prev_coded_height;
256259
/*!\endcond */
257260
} RATE_CONTROL;
258261

0 commit comments

Comments
 (0)