ec-hw: Vulkan decode follows mid-stream size and DPB changes
Browse files at this commitfc0a0f7ba9dc39e0d98e6785839cfe10fe464828Parent: 42021c73 changed files +31 -35
- crates/ec-hw/src/vkdec264.rs +13 -9
- crates/ec-hw/src/vkdec265.rs +14 -18
- crates/ec-hw/src/vkdec_av1.rs +4 -8
crates/ec-hw/src/vkdec264.rsmodified+13 -9
| @@ -91,6 +91,7 @@ impl VkH264Decoder { | ||
| 91 | 91 | let header = NalHeader::parse(first)?; |
| 92 | 92 | match header.unit_type { |
| 93 | 93 | NalUnitType::Sps => { |
| 94 | + self.finish_picture()?; | |
| 94 | 95 | let mut rbsp = std::mem::take(&mut self.rbsp); |
| 95 | 96 | unescape_rbsp(payload, &mut rbsp); |
| 96 | 97 | let sps = Sps::parse(&rbsp); |
| @@ -233,11 +234,14 @@ impl VkH264Decoder { | ||
| 233 | 234 | } |
| 234 | 235 | let slots = (self.dpb.capacity() as u32 + 1).min(MAX_SLOTS); |
| 235 | 236 | let (w, h) = (sps.coded_width, sps.coded_height); |
| 236 | - let (max_width, max_height, slots) = match &self.session { | |
| 237 | - Some(s) if w <= s.max_width && h <= s.max_height && slots <= s.slots => return Ok(()), | |
| 238 | - Some(s) => (w.max(s.max_width), h.max(s.max_height), slots.max(s.slots)), | |
| 239 | - None => (w, h, slots), | |
| 240 | - }; | |
| 237 | + if let Some(s) = &self.session | |
| 238 | + && s.max_width == w | |
| 239 | + && s.max_height == h | |
| 240 | + && slots <= s.slots | |
| 241 | + { | |
| 242 | + return Ok(()); | |
| 243 | + } | |
| 244 | + self.bump(true); | |
| 241 | 245 | self.current = None; |
| 242 | 246 | self.dpb.clear(); |
| 243 | 247 | self.pics.clear(); |
| @@ -245,8 +249,8 @@ impl VkH264Decoder { | ||
| 245 | 249 | let h264 = H264DecodeSession::new( |
| 246 | 250 | &self.gpu, |
| 247 | 251 | &H264DecodeConfig { |
| 248 | - max_width, | |
| 249 | - max_height, | |
| 252 | + max_width: w, | |
| 253 | + max_height: h, | |
| 250 | 254 | max_dpb_slots: slots, |
| 251 | 255 | profile_idc: sps.profile_idc, |
| 252 | 256 | }, |
| @@ -255,8 +259,8 @@ impl VkH264Decoder { | ||
| 255 | 259 | self.session = Some(Session { |
| 256 | 260 | h264: Rc::new(RefCell::new(h264)), |
| 257 | 261 | ring, |
| 258 | - max_width, | |
| 259 | - max_height, | |
| 262 | + max_width: w, | |
| 263 | + max_height: h, | |
| 260 | 264 | slots, |
| 261 | 265 | }); |
| 262 | 266 | self.params_dirty = true; |
crates/ec-hw/src/vkdec265.rsmodified+14 -18
| @@ -95,6 +95,7 @@ impl VkH265Decoder { | ||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | NalUnitType::Sps => { |
| 98 | + self.finish_picture()?; | |
| 98 | 99 | let sps = Sps::parse(&nal.rbsp())?; |
| 99 | 100 | self.dpb.max_reorder = sps.max_num_reorder_pics as usize; |
| 100 | 101 | self.dpb.max_dec_pic_buffering = sps.max_dec_pic_buffering_minus1 as usize + 1; |
| @@ -234,20 +235,15 @@ impl VkH265Decoder { | ||
| 234 | 235 | sps.pic_width_in_luma_samples, |
| 235 | 236 | sps.pic_height_in_luma_samples, |
| 236 | 237 | ); |
| 237 | - let (max_width, max_height, slots) = match &self.session { | |
| 238 | - Some(s) | |
| 239 | - if s.bit_depth == bit_depth | |
| 240 | - && w <= s.max_width | |
| 241 | - && h <= s.max_height | |
| 242 | - && slots <= s.slots => | |
| 243 | - { | |
| 244 | - return Ok(()); | |
| 245 | - } | |
| 246 | - Some(s) if s.bit_depth == bit_depth => { | |
| 247 | - (w.max(s.max_width), h.max(s.max_height), slots.max(s.slots)) | |
| 248 | - } | |
| 249 | - _ => (w, h, slots), | |
| 250 | - }; | |
| 238 | + if let Some(s) = &self.session | |
| 239 | + && s.bit_depth == bit_depth | |
| 240 | + && s.max_width == w | |
| 241 | + && s.max_height == h | |
| 242 | + && slots <= s.slots | |
| 243 | + { | |
| 244 | + return Ok(()); | |
| 245 | + } | |
| 246 | + self.bump(true); | |
| 251 | 247 | self.current = None; |
| 252 | 248 | self.dpb.pictures.clear(); |
| 253 | 249 | self.outputs.clear(); |
| @@ -255,8 +251,8 @@ impl VkH265Decoder { | ||
| 255 | 251 | let h265 = H265DecodeSession::new( |
| 256 | 252 | &self.gpu, |
| 257 | 253 | &H265DecodeConfig { |
| 258 | - max_width, | |
| 259 | - max_height, | |
| 254 | + max_width: w, | |
| 255 | + max_height: h, | |
| 260 | 256 | max_dpb_slots: slots, |
| 261 | 257 | bit_depth, |
| 262 | 258 | }, |
| @@ -266,8 +262,8 @@ impl VkH265Decoder { | ||
| 266 | 262 | h265: Rc::new(RefCell::new(h265)), |
| 267 | 263 | ring, |
| 268 | 264 | bit_depth, |
| 269 | - max_width, | |
| 270 | - max_height, | |
| 265 | + max_width: w, | |
| 266 | + max_height: h, | |
| 271 | 267 | slots, |
| 272 | 268 | }); |
| 273 | 269 | self.params_dirty = true; |
crates/ec-hw/src/vkdec_av1.rsmodified+4 -8
| @@ -219,15 +219,11 @@ impl VkAv1Decoder { | ||
| 219 | 219 | |
| 220 | 220 | fn ensure_session(&mut self, seq: &SequenceHeader, width: u32, height: u32) -> Result<()> { |
| 221 | 221 | let bit_depth = seq.color_config.bit_depth; |
| 222 | + let width = seq.max_frame_width.max(width); | |
| 223 | + let height = seq.max_frame_height.max(height); | |
| 222 | 224 | let mut session = match self.session.take() { |
| 223 | - Some(s) if s.bit_depth == bit_depth && width <= s.width && height <= s.height => s, | |
| 224 | - old => { | |
| 225 | - let (width, height) = match &old { | |
| 226 | - Some(s) if s.bit_depth == bit_depth => { | |
| 227 | - (width.max(s.width), height.max(s.height)) | |
| 228 | - } | |
| 229 | - _ => (width, height), | |
| 230 | - }; | |
| 225 | + Some(s) if s.bit_depth == bit_depth && s.width == width && s.height == height => s, | |
| 226 | + _ => { | |
| 231 | 227 | self.refs = RefSlots::new(); |
| 232 | 228 | let av1 = Av1DecodeSession::new( |
| 233 | 229 | &self.gpu, |