X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;ds=sidebyside;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv3040.rs;h=8da291b2d507e4facaad37c1b79b9d73dcbceae1;hb=5536ee658e0edf2f73970fb5d0aa724a92d6c223;hp=c3526196356ca9da336dfd4f891b17c46affa7a1;hpb=16cbd8c0f1508886caf521710e0ab14e55c089a9;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index c352619..8da291b 100644 --- a/nihav-realmedia/src/codecs/rv3040.rs +++ b/nihav-realmedia/src/codecs/rv3040.rs @@ -536,6 +536,9 @@ fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_ validate!(slice_no < slice_offs.len()); br.seek((slice_offs[slice_no] * 8) as u32)?; let mut shdr = bd.decode_slice_header(br, old_width, old_height)?; + if ((shdr.width == 0) || (shdr.height == 0)) && (shdr.ftype != FrameType::I) { + return Err(DecoderError::MissingReference); + } if slice_no < slice_offs.len() - 1 { let cur_pos = br.tell() as u32; br.seek((slice_offs[slice_no + 1] * 8) as u32)?; @@ -566,6 +569,9 @@ const RV34_MB_MAX_SIZES: [usize; 6] = [ 0x2F, 0x62, 0x18B, 0x62F, 0x18BF, 0x23FF const RV34_SLICE_START_BITS: [u8; 6] = [ 6, 7, 9, 11, 13, 14 ]; pub fn get_slice_start_offset_bits(w: usize, h: usize) -> u8 { + if (w == 0) || (h == 0) { + return 0; + } let mb_size = ((w + 15) >> 4) * ((h + 15) >> 4) - 1; let mut idx: usize = 0; while (idx < 5) && (RV34_MB_MAX_SIZES[idx] < mb_size) { idx += 1; } @@ -1249,6 +1255,7 @@ impl RV34Decoder { sstate.q_dc = bd.quant_dc(true, q); self.decode_mb_intra(&sstate, &imode, &mut buf, &mut br, is_16)?; } else { + sstate.q_dc = bd.quant_dc(false, q); imode.fill_block(0); self.decode_mb_inter(&sstate, &mbh, &mut buf, &mut br, is_16)?; }