Skip to content

Commit 6b4b2da

Browse files
committed
fix(mmserver): handle differing width/height in encode granularity
1 parent 152d82c commit 6b4b2da

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

mm-server/src/compositor/video/vulkan_encode.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ impl EncoderInner {
149149

150150
trace!(?input_format, width, height, "using input format");
151151

152-
assert_eq!(
153-
capabilities.picture_access_granularity.width,
154-
capabilities.picture_access_granularity.height
155-
);
156-
157152
let buffer_size_alignment = capabilities.min_bitstream_buffer_size_alignment as usize;
158153

159154
let session = {

mm-server/src/compositor/video/vulkan_encode/h264.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ impl H264Encoder {
142142
caps.video_caps.picture_access_granularity.height
143143
);
144144

145-
let mb_size = caps.video_caps.picture_access_granularity.width;
146-
trace!("mb size: {}", mb_size);
145+
let mb_width = caps.video_caps.picture_access_granularity.width;
146+
let mb_height = caps.video_caps.picture_access_granularity.height;
147+
trace!("mb size: {mb_width}x{mb_height}");
147148

148-
let aligned_width = params.width.next_multiple_of(mb_size);
149-
let aligned_height = params.height.next_multiple_of(mb_size);
149+
let aligned_width = params.width.next_multiple_of(mb_width);
150+
let aligned_height = params.height.next_multiple_of(mb_height);
150151

151152
trace!(
152153
"aligned width: {}, height: {}",
@@ -202,8 +203,8 @@ impl H264Encoder {
202203
pic_order_cnt_type: StdVideoH264PocType_STD_VIDEO_H264_POC_TYPE_0,
203204
log2_max_pic_order_cnt_lsb_minus4: log2_max_frame_num_minus4,
204205
log2_max_frame_num_minus4,
205-
pic_width_in_mbs_minus1: (aligned_width / mb_size) - 1,
206-
pic_height_in_map_units_minus1: (aligned_height / mb_size) - 1,
206+
pic_width_in_mbs_minus1: (aligned_width / mb_width) - 1,
207+
pic_height_in_map_units_minus1: (aligned_height / mb_height) - 1,
207208
frame_crop_right_offset: crop_right,
208209
frame_crop_bottom_offset: crop_bottom,
209210

0 commit comments

Comments
 (0)