}
impl Mode {
- fn get_channels(&self) -> usize {
- match *self {
+ fn get_channels(self) -> usize {
+ match self {
Mode::Mono => 1,
_ => 2,
}
Codebook::new(&mut vq5, CodebookMode::MSB).unwrap(),
Codebook::new(&mut vq6, CodebookMode::MSB).unwrap()];
Codebooks {
- cpl_cb: cpl_cb,
- quant_cb: quant_cb,
- vq_cb: vq_cb,
+ cpl_cb,
+ quant_cb,
+ vq_cb,
}
}
}
gain_tab[i] = pow_tab[i + 53].powf(8.0 / fsamples);
}
let size = samples;
- CookDSP { imdct: IMDCT::new(samples*2, false), window: window, out: [0.0; 2048], size, pow_tab, hpow_tab, gain_tab }
+ CookDSP { imdct: IMDCT::new(samples*2, false), window, out: [0.0; 2048], size, pow_tab, hpow_tab, gain_tab }
}
}
let cend = COOK_CPL_BAND[self.subbands - 1] as usize;
if br.read_bool()? {
let cb = &codebooks.cpl_cb[(self.js_bits - 2) as usize];
- for i in cstart..cend+1 {
+ for i in cstart..=cend {
self.decouple[i] = br.read_cb(cb)? as u8;
}
} else {
- for i in cstart..cend+1 {
+ for i in cstart..=cend {
self.decouple[i] = br.read(self.js_bits)? as u8;
}
}
mod rv34codes;
#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
#[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
mod rv34dsp;
#[cfg(feature="decoder_realvideo1")]
pub mod rv30;
#[cfg(feature="decoder_realvideo3")]
#[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
+#[allow(clippy::neg_multiply)]
pub mod rv30dsp;
#[cfg(feature="decoder_realvideo4")]
pub mod rv40;
#[cfg(feature="decoder_realvideo4")]
#[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
pub mod rv40dsp;
#[cfg(feature="decoder_realvideo6")]
pub mod rv60;
pub mod rv60codes;
#[cfg(feature="decoder_realvideo6")]
#[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
pub mod rv60dsp;
#[cfg(feature="decoder_realaudio144")]
}
let a = (1 << 12) - ((src[i + 1] * src[i + 1]) >> 12);
let scale = if a != 0 { (1 << 24) / a } else { (1 << 24) };
- for j in 0..(i+1) {
+ for j in 0..=i {
let result = (src[j] - ((tmp3[i + 1] * src[i - j]) >> 12)).checked_mul(scale);
if let Some(val) = result {
dst[j] = val >> 12;
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
1,
SND_S16_FORMAT, NBLOCKS * BLOCKSIZE);
- self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+ self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
Ok(())
} else {
Err(DecoderError::InvalidData)
for i in 0..(order + start + non_rec) {
work[i] = win[i] * hist[i];
}
- for i in (0..order + 1).rev() {
+ for i in (0..=order).rev() {
let src1 = &work[(order - i)..];
let src2 = &work[order + start - i..];
tmp1[i] = scalarprod(&work[order..], src1, start);
tmp2[i] = scalarprod(&work[order + start..], src2, non_rec);
}
- for i in 0..(order + 1) {
+ for i in 0..=order {
rec[i] = rec[i] * 0.5625 + tmp1[i];
temp[i] = rec[i] + tmp2[i];
}
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
1,
SND_F32P_FORMAT, NBLOCKS * BLOCKSIZE);
- self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+ self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
Ok(())
} else {
Err(DecoderError::InvalidData)
let table_bytes = table_bits >> 3;
validate!((table_bytes + 3 <= pktbuf.len()) && (pktbuf.len() <= RALF_MAX_PACKET_SIZE));
let cmp_len = table_bytes + 2;
- validate!(&pktbuf[..cmp_len] == &self.pkt_buf[..cmp_len]);
+ validate!(pktbuf[..cmp_len] == self.pkt_buf[..cmp_len]);
{
let copy_size = pktbuf.len() - cmp_len;
let dst = &mut self.pkt_buf[RALF_MAX_PACKET_SIZE..][..copy_size];
self.blocks.truncate(0);
{
let mut br = BitReader::new(&self.pkt_buf[2..], table_bytes, BitReaderMode::BE);
- while br.tell() < table_bits.into() {
+ while br.tell() < table_bits {
let size = br.read(13 + self.channels).unwrap() as usize;
let pts;
if br.read_bool().unwrap() {
impl RV10SliceInfo {
fn new(is_p: bool, qscale: u8, mb_x: usize, mb_y: usize, mb_c: usize) -> Self {
- RV10SliceInfo { is_p: is_p, qscale: qscale, mb_x: mb_x, mb_y: mb_y, mb_c: mb_c }
+ RV10SliceInfo { is_p, qscale, mb_x, mb_y, mb_c }
}
}
let soff = nslices * 8 + 1;
RealVideo10BR {
br: BitReader::new(&src[soff..], src.len() - soff, BitReaderMode::BE),
- tables: tables,
+ tables,
num_slices: nslices,
slice_no: 0,
slice_off: slice_offs,
h: height,
mb_w: (width + 15) >> 4,
mb_h: (height + 15) >> 4,
- new_ver: new_ver,
+ new_ver,
dc_coded: [false; 3],
last_dc: [0; 3],
- mvmode: mvmode,
+ mvmode,
}
}
let chroma_dc_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let tables = Tables {
- intra_mcbpc_cb: intra_mcbpc_cb,
- inter_mcbpc_cb: inter_mcbpc_cb,
- cbpy_cb: cbpy_cb,
- rl_cb: rl_cb,
- aic_rl_cb: aic_rl_cb,
- mv_cb: mv_cb,
- luma_dc_cb: luma_dc_cb,
- chroma_dc_cb: chroma_dc_cb,
+ intra_mcbpc_cb,
+ inter_mcbpc_cb,
+ cbpy_cb,
+ rl_cb,
+ aic_rl_cb,
+ mv_cb,
+ luma_dc_cb,
+ chroma_dc_cb,
};
RealVideo10Decoder{
info: NACodecInfoRef::default(),
dec: H263BaseDecoder::new_with_opts(false, false, false),
- tables: tables,
+ tables,
w: 0,
h: 0,
new_ver: false,
impl CodeReader {
pub fn new(codes: &'static [u16], bits: &'static [u8]) -> Self {
- CodeReader { codes: codes, bits: bits }
+ CodeReader { codes, bits }
}
}
impl RV20SliceInfo {
fn new(ftype: Type, seq: u32, qscale: u8, mb_x: usize, mb_y: usize, mb_pos: usize, w: usize, h: usize) -> Self {
- RV20SliceInfo { ftype: ftype, seq: seq, qscale: qscale, mb_x: mb_x, mb_y: mb_y, mb_pos: mb_pos, w: w, h: h }
+ RV20SliceInfo { ftype, seq, qscale, mb_x, mb_y, mb_pos, w, h }
}
}
}
RealVideo20BR {
br: BitReader::new(&src[soff..], src.len() - soff, BitReaderMode::BE),
- tables: tables,
+ tables,
num_slices: nslices,
slice_no: 0,
slice_off: slice_offs,
w: width,
h: height,
- mb_w: mb_w,
- mb_h: mb_h,
+ mb_w,
+ mb_h,
mb_pos_bits: mbpb,
- minor_ver: minor_ver,
- rpr: rpr,
+ minor_ver,
+ rpr,
}
}
let mv_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let tables = Tables {
- intra_mcbpc_cb: intra_mcbpc_cb,
- inter_mcbpc_cb: inter_mcbpc_cb,
- mbtype_b_cb: mbtype_b_cb,
- cbpy_cb: cbpy_cb,
- cbpc_b_cb: cbpc_b_cb,
- rl_cb: rl_cb,
- aic_rl_cb: aic_rl_cb,
- mv_cb: mv_cb,
+ intra_mcbpc_cb,
+ inter_mcbpc_cb,
+ mbtype_b_cb,
+ cbpy_cb,
+ cbpc_b_cb,
+ rl_cb,
+ aic_rl_cb,
+ mv_cb,
};
RealVideo20Decoder{
info: NACodecInfoRef::default(),
dec: H263BaseDecoder::new_b_frames(false),
- tables: tables,
+ tables,
w: 0,
h: 0,
minor_ver: 0,
let start = br.read(get_slice_start_offset_bits(w, h))? as usize;
br.skip(1)?;
- Ok(RV34SliceHeader{ ftype: ftype, quant: q, deblock: deblock, pts: pts, width: w, height: h, start: start, end: 0, set_idx: 0 })
+ Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx: 0 })
}
fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, _has_top: bool) -> DecoderResult<()> {
for _ in 0..4 {
let idx = if ftype == FrameType::P { 0 } else { 1 };
Ok(MBInfo { mbtype: RV30_MB_TYPES[idx][code], skip_run: 0, dquant: dq })
}
- fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], _mbinfo: &Vec<RV34MBInfo>) -> (MV, MV) {
+ fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], _mbinfo: &[RV34MBInfo]) -> (MV, MV) {
let mb_x = sstate.mb_x;
let mb_y = sstate.mb_y;
let mv_f;
if src.len() < num_rpr * 2 + 8 { return Err(DecoderError::ShortData); }
self.bd.rpr_bits = ((num_rpr >> 1) + 1) as u8;
if self.bd.rpr_bits > 3 { self.bd.rpr_bits = 3; }
- for i in 0..num_rpr+1 {
+ for i in 0..=num_rpr {
self.bd.widths.push ((src[6 + i * 2] as usize) << 2);
self.bd.heights.push((src[7 + i * 2] as usize) << 2);
}
impl<T:Copy> GenericCache<T> {
pub fn new(height: usize, stride: usize, default: T) -> Self {
let mut ret = Self {
- stride: stride,
- height: height,
+ stride,
+ height,
xpos: 0,
data: Vec::with_capacity((height + 1) * stride),
- default: default,
+ default,
};
ret.reset();
ret
}
impl MBType {
- pub fn is_intra(&self) -> bool {
- (*self == MBType::MBIntra) || (*self == MBType::MBIntra16)
+ pub fn is_intra(self) -> bool {
+ (self == MBType::MBIntra) || (self == MBType::MBIntra16)
}
- pub fn is_16(&self) -> bool {
- (*self == MBType::MBIntra16) || (*self == MBType::MBP16x16Mix)
+ pub fn is_16(self) -> bool {
+ (self == MBType::MBIntra16) || (self == MBType::MBP16x16Mix)
}
- pub fn is_intra_or_16(&self) -> bool {
+ pub fn is_intra_or_16(self) -> bool {
self.is_intra() || self.is_16()
}
- pub fn get_num_mvs(&self) -> usize {
- match *self {
+ pub fn get_num_mvs(self) -> usize {
+ match self {
MBType::MBIntra | MBType::MBIntra16 |
MBType::MBSkip | MBType::MBDirect => 0,
MBType::MBP16x16 | MBType::MBP16x16Mix |
MBType::Invalid => unreachable!(),
}
}
- pub fn is_fwd(&self) -> bool {
- match *self {
+ pub fn is_fwd(self) -> bool {
+ match self {
MBType::MBP16x16 | MBType::MBP16x16Mix |
MBType::MBP16x8 | MBType::MBP8x16 | MBType::MBP8x8 |
MBType::MBForward => true,
_ => false,
}
}
- pub fn is_bwd(&self) -> bool {
- match *self {
+ pub fn is_bwd(self) -> bool {
+ match self {
MBType::MBBidir | MBType::MBBackward => true,
_ => false,
}
}
- pub fn has_mv_dir(&self, fwd: bool) -> bool {
- match *self {
+ pub fn has_mv_dir(self, fwd: bool) -> bool {
+ match self {
MBType::MBBidir => true,
MBType::MBForward if fwd => true,
MBType::MBBackward if !fwd => true,
_ => false,
}
}
- pub fn is_nomv(&self) -> bool {
- match *self {
+ pub fn is_nomv(self) -> bool {
+ match self {
MBType::MBIntra | MBType::MBIntra16 | MBType::MBSkip | MBType::MBDirect => true,
_ => false,
}
}
- /*pub fn is_16x16(&self) -> bool {
- match *self {
+ /*pub fn is_16x16(self) -> bool {
+ match self {
MBType::MBP16x8 | MBType::MBP8x16 | MBType::MBP8x8 => false,
_ => true,
}
}*/
- fn get_weight(&self) -> usize {
- match *self {
+ fn get_weight(self) -> usize {
+ match self {
MBType::MBIntra => 0,
MBType::MBIntra16 => 1,
MBType::MBSkip => unreachable!(),
fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()>;
fn quant_dc(&self, is_intra: bool, q: u8) -> u8;
fn decode_inter_mb_hdr(&mut self, br: &mut BitReader, ftype: FrameType, mbtype: MBType) -> DecoderResult<MBInfo>;
- fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &Vec<RV34MBInfo>) -> (MV, MV);
+ fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &[RV34MBInfo]) -> (MV, MV);
}
pub trait RV34DSP {
Ok(())
}
-fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_no: usize, slice_offs: &Vec<usize>, old_width: usize, old_height: usize) -> DecoderResult<RV34SliceHeader> {
+fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult<RV34SliceHeader> {
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)?;
fn decode_mv(br: &mut BitReader) -> DecoderResult<MV> {
let x = br.read_code_signed(IntCodeType::Gamma)? as i16;
let y = br.read_code_signed(IntCodeType::Gamma)? as i16;
- Ok(MV{ x: x, y: y })
+ Ok(MV{ x, y })
}
fn do_mc_16x16(dsp: &Box<dyn RV34DSP>, buf: &mut NAVideoBuffer<u8>, prevbuf: &NAVideoBuffer<u8>, mb_x: usize, mb_y: usize, mv: MV, avg: bool) {
let vb = vt.get_vbuf();
let avg_buf = vb.unwrap();
RV34Decoder {
- is_rv30: is_rv30,
+ is_rv30,
coderead: RV34Codes::new(),
- dsp: dsp,
+ dsp,
cdsp: RV34CommonDSP::new(),
ipbs: IPBShuffler::new(),
mvi: MVInfo::new(),
last_ts: 0, next_ts: 0,
ratio1: 0, ratio2: 0,
is_b: false,
- avg_buf: avg_buf,
+ avg_buf,
base_ts: 0,
}
}
if is_i16 {
let imode = br.read(2)? as i8;
im.fill_block(imode);
- return Ok(MBInfo { mbtype: MBType::MBIntra16, skip_run: 0, dquant: false });
+ Ok(MBInfo { mbtype: MBType::MBIntra16, skip_run: 0, dquant: false })
} else {
let dq = if !has_dq {
if !self.is_rv30 { !br.read_bool()? } else { false }
decode_dquant(br, q)?;
}
bd.decode_intra_pred(br, im.cache.data.as_mut_slice(), im.cache.xpos, im.cache.stride, has_top)?;
- return Ok(MBInfo { mbtype: MBType::MBIntra, skip_run: 0, dquant: dq });
+ Ok(MBInfo { mbtype: MBType::MBIntra, skip_run: 0, dquant: dq })
}
}
fn decode_mb_header_inter(&mut self, bd: &mut RV34BitstreamDecoder, br: &mut BitReader, ftype: FrameType, mbtype: MBType, im: &mut IntraModeState, q: u8, has_top: bool) -> DecoderResult<MBInfo> {
if hdr.mbtype.is_intra() {
return self.decode_mb_header_intra(bd, br, hdr.mbtype.is_16(), im, q, has_top, true);
}
- return Ok(hdr);
+ Ok(hdr)
}
fn decode_mb_intra(&mut self, sstate: &SState, imode: &IntraModeState, buf: &mut NAVideoBuffer<u8>, br: &mut BitReader, is_16: bool) -> DecoderResult<()> {
let ini_off = slice_offs.len() * 8 + 1;
let mut br = BitReader::new(&src[ini_off..], src.len() - ini_off, BitReaderMode::BE);
- let hdr0 = decode_slice_header(&mut br, bd, 0, &slice_offs, self.width, self.height)?;
+ let hdr0 = decode_slice_header(&mut br, bd, 0, slice_offs.as_slice(), self.width, self.height)?;
validate!((hdr0.width != 0) && (hdr0.height != 0));
self.width = hdr0.width;
self.height = hdr0.height;
if !self.is_b {
self.mvi.set_mb(mb_x, mb_y, mbh.mbtype, &self.ref_mvi, &mvs, &sstate);
} else {
- let (mv_f, mv_b) = bd.predict_b_mv(&sstate, &self.mvi, mbh.mbtype, &mvs, &mbinfo);
+ let (mv_f, mv_b) = bd.predict_b_mv(&sstate, &self.mvi, mbh.mbtype, &mvs, mbinfo.as_slice());
self.mvi.fill(mb_x, mb_y, true, mv_f);
self.mvi.fill(mb_x, mb_y, false, mv_b);
}
self.decode_mb_inter(&sstate, &mbh, &mut buf, &mut br, is_16)?;
}
- let mi = RV34MBInfo { cbp: cbp, q: q, mbtype: mbh.mbtype, deblock: 0, cbp_c: 0 };
+ let mi = RV34MBInfo { cbp, q, mbtype: mbh.mbtype, deblock: 0, cbp_c: 0 };
mbinfo.push(mi);
if is_intra {
mbinfo[mb_pos].deblock = 0xFFFF;
($c1 * 6) * ($s[$o] as i32) + ($c1 * 9) * ($s[$o + 1] as i32) + ($c1) * ($s[$o + 2] as i32)
);
($s: ident, $o: expr, $c1: expr, $d1: expr, $d2: expr) => (
- (-$c1) * ($s[$o - 1] as i32) + ($c1 * $d1) * ($s[$o] as i32) + ($c1 * $d2) * ($s[$o + 1] as i32) + (-$c1) * ($s[$o + 2] as i32)
+ -($c1) * ($s[$o - 1] as i32) + ($c1 * $d1) * ($s[$o] as i32) + ($c1 * $d2) * ($s[$o + 1] as i32) + -($c1) * ($s[$o + 2] as i32)
);
($s: ident, $o: expr, $ss: expr, $c1: expr, $c2: expr, $d1: expr, $d2: expr) => (
((mc_matrix!($s, $o - $ss, -1, $d1, $d2) +
syms.push(i as u16);
}
- RV34CodeReader { codes: codes, lengths: lengths, syms: syms }
+ RV34CodeReader { codes, lengths, syms }
}
}
syms.push(RV34_CBP_SYMS[i]);
}
- RV34CBPCodeReader { codes: codes, lengths: lengths, syms: syms }
+ RV34CBPCodeReader { codes, lengths, syms }
}
}
let cset = CoefSet::new(intra, set);
let mut coderead = RV34CodeReader::new(&RV34_INTRA_COEFFS[set]);
let coeffs = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
- FullSet { cbp: cbp, cset: cset, coeffs: coeffs }
+ FullSet { cbp, cset, coeffs }
} else {
let cbp0 = CBPSet::new(intra, set, 0);
let cbp: Vec<CBPSet> = vec![cbp0];
let cset = CoefSet::new(intra, set);
let mut coderead = RV34CodeReader::new(&RV34_INTER_COEFFS[set]);
let coeffs = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
- FullSet { cbp: cbp, cset: cset, coeffs: coeffs }
+ FullSet { cbp, cset, coeffs }
}
}
}
0xE0, 0xE1, 0xE2, 0xE4, 0xE5, 0xE6, 0xE8, 0xE9, 0xEA,
];
-const RV34_INTRA_CBPPAT: &'static [[[u8; 1296]; 2]; 5] = &[
+const RV34_INTRA_CBPPAT: &[[[u8; 1296]; 2]; 5] = &[
[
[
8, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 6,
],
];
-const RV34_INTRA_CBP: &'static [[[u8; 16]; 8]; 5] = &[
+const RV34_INTRA_CBP: &[[[u8; 16]; 8]; 5] = &[
[
[ 0, 3, 3, 4, 3, 5, 5, 5, 2, 5, 4, 6, 4, 6, 6, 6, ],
[ 0, 2, 3, 4, 2, 5, 6, 7, 3, 6, 5, 7, 4, 7, 8, 8, ],
],
];
-const RV34_INTRA_FIRSTPAT: &'static [[[u8; 864]; 4]; 5] = &[
+const RV34_INTRA_FIRSTPAT: &[[[u8; 864]; 4]; 5] = &[
[
[
0, 10, 5, 10, 7, 12, 9, 11, 8, 13, 9, 12, 10, 13, 11, 12,
],
];
-const RV34_INTRA_SECONDPAT: &'static [[[u8; 108]; 2]; 5] = &[
+const RV34_INTRA_SECONDPAT: &[[[u8; 108]; 2]; 5] = &[
[
[
0, 5, 10, 3, 6, 10, 7, 8, 9, 4, 6, 10, 6, 7, 9, 8,
],
];
-const RV34_INTRA_THIRDPAT: &'static [[[u8; 108]; 2]; 5] = &[
+const RV34_INTRA_THIRDPAT: &[[[u8; 108]; 2]; 5] = &[
[
[
0, 5, 10, 3, 6, 10, 7, 8, 10, 4, 7, 10, 6, 7, 10, 8,
],
];
-const RV34_INTRA_COEFFS: &'static [[u8; 32]; 5] = &[
+const RV34_INTRA_COEFFS: &[[u8; 32]; 5] = &[
[
1, 3, 3, 4, 4, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9,
9, 9, 10, 10, 10, 11, 11, 11, 10, 10, 10, 12, 13, 14, 15, 15,
]
];
-const RV34_INTER_CBPPAT: &'static [[u8; 1296]; 7] = &[
+const RV34_INTER_CBPPAT: &[[u8; 1296]; 7] = &[
[
7, 9, 9, 8, 9, 8, 9, 8, 9, 9, 8, 8, 8, 8, 8, 4,
7, 10, 11, 10, 11, 10, 12, 10, 12, 11, 11, 10, 11, 10, 10, 7,
[ 0, 4, 4, 3, 5, 4, 5, 4, 5, 5, 4, 4, 3, 4, 4, 3 ]
]];
-const RV34_INTER_FIRSTPAT: &'static [[[u8; 864]; 2]; 7] = &[
+const RV34_INTER_FIRSTPAT: &[[[u8; 864]; 2]; 7] = &[
[
[
0, 7, 5, 7, 5, 7, 6, 6, 7, 10, 7, 9, 8, 9, 8, 7,
],
];
-const RV34_INTER_SECONDPAT: &'static [[[u8; 108]; 2]; 7] = &[
+const RV34_INTER_SECONDPAT: &[[[u8; 108]; 2]; 7] = &[
[
[
0, 4, 8, 3, 6, 8, 6, 7, 8, 4, 6, 8, 6, 7, 8, 7,
],
];
-const RV34_INTER_THIRDPAT: &'static [[[u8; 108]; 2]; 7] = &[
+const RV34_INTER_THIRDPAT: &[[[u8; 108]; 2]; 7] = &[
[
[
0, 5, 8, 3, 6, 9, 6, 7, 9, 4, 6, 9, 6, 7, 9, 8,
DC128
}
+type IPred4x4Func = fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]);
+
pub struct RV34CommonDSP {
- pub ipred4x4: [fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]); 15],
+ pub ipred4x4: [IPred4x4Func; 15],
pub ipred8x8: [fn(buf: &mut [u8], idx: usize, stride: usize); 7],
pub ipred16x16: [fn(buf: &mut [u8], idx: usize, stride: usize); 7],
}
}
}
-const IPRED_FUNCS4X4: [fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]); 15] = [
+const IPRED_FUNCS4X4: [IPred4x4Func; 15] = [
ipred_4x4_ver, ipred_4x4_hor, ipred_4x4_dc,
ipred_4x4_diag_down_left, ipred_4x4_diag_down_right,
ipred_4x4_ver_right, ipred_4x4_hor_down, ipred_4x4_ver_left, ipred_4x4_hor_up,
RealVideo40BR {
width: 0,
height: 0,
- aic_top_cb: aic_top_cb,
- aic_mode1_cb: aic_mode1_cb,
- aic_mode2_cb: aic_mode2_cb,
- ptype_cb: ptype_cb,
- btype_cb: btype_cb,
+ aic_top_cb,
+ aic_mode1_cb,
+ aic_mode2_cb,
+ ptype_cb,
+ btype_cb,
had_skip_run: false,
}
}
- fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &Vec<RV34MBInfo>, mbtype: MBType, fwd: bool) -> MV {
+ fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &[RV34MBInfo], mbtype: MBType, fwd: bool) -> MV {
let mut pred_mvs: [MV; 3] = [ZERO_MV; 3];
let mut mv_count: usize = 0;
let mb_x = sstate.mb_x;
self.had_skip_run = false;
- Ok(RV34SliceHeader{ ftype: ftype, quant: q, deblock: deblock, pts: pts, width: w, height: h, start: start, end: 0, set_idx: set_idx })
+ Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx })
}
fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()> {
let start;
mbtype = if ftype == FrameType::P { br.read_cb(&self.ptype_cb[idx])? }
else { br.read_cb(&self.btype_cb[idx])? };
}
- Ok(MBInfo { mbtype: mbtype, skip_run: 0, dquant: dquant })
+ Ok(MBInfo { mbtype, skip_run: 0, dquant })
}
- fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &Vec<RV34MBInfo>) -> (MV, MV) {
+ fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &[RV34MBInfo]) -> (MV, MV) {
let mut mv_f = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, true);
let mut mv_b = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, false);
{
println!("edata:");
-for i in 0..src.len() { print!(" {:02X}", src[i]); } println!("");
+for i in 0..src.len() { print!(" {:02X}", src[i]); } println!();
}
if src.len() < 2 { return Err(DecoderError::InvalidData); }
];
impl PUType {
- fn get_num_mvs(&self) -> usize {
- match *self {
+ fn get_num_mvs(self) -> usize {
+ match self {
PUType::Full => 1,
PUType::Quarters => 4,
_ => 2,
}
}
- fn get_mv_size(&self, part_no: usize, size: usize) -> (usize, usize) {
+ fn get_mv_size(self, part_no: usize, size: usize) -> (usize, usize) {
let mv_size = size >> 2;
- match *self {
+ match self {
PUType::Full => (mv_size, mv_size),
PUType::N2Hor => (mv_size, mv_size >> 1),
PUType::N2Ver => (mv_size >> 1, mv_size),
PUType::Quarters => (mv_size >> 1, mv_size >> 1),
PUType::N4Hor => {
if part_no == 0 {
- (mv_size, mv_size >> 2)
+ (mv_size, mv_size >> 2)
} else {
- (mv_size, 3 * mv_size >> 2)
+ (mv_size, (3 * mv_size) >> 2)
}
},
PUType::N34Hor => {
if part_no == 0 {
- (mv_size, 3 * mv_size >> 2)
+ (mv_size, (3 * mv_size) >> 2)
} else {
- (mv_size, mv_size >> 2)
+ (mv_size, mv_size >> 2)
}
},
PUType::N4Ver => {
if part_no == 0 {
- ( mv_size >> 2, mv_size)
+ ( mv_size >> 2, mv_size)
} else {
- (3 * mv_size >> 2, mv_size)
+ ((3 * mv_size) >> 2, mv_size)
}
},
PUType::N34Ver => {
if part_no == 0 {
- (3 * mv_size >> 2, mv_size)
+ ((3 * mv_size) >> 2, mv_size)
} else {
- ( mv_size >> 2, mv_size)
+ ( mv_size >> 2, mv_size)
}
},
}
}
- fn has_hor_split(&self) -> bool {
- match *self {
+ fn has_hor_split(self) -> bool {
+ match self {
PUType::N2Hor | PUType::N4Hor | PUType::N34Hor | PUType::Quarters => true,
_ => false,
}
}
- fn has_ver_split(&self) -> bool {
- match *self {
+ fn has_ver_split(self) -> bool {
+ match self {
PUType::N2Ver | PUType::N4Ver | PUType::N34Ver | PUType::Quarters => true,
_ => false,
}
const SKIP_MV_REF: [MVRef; 4] = [ MVRef::Skip0, MVRef::Skip1, MVRef::Skip2, MVRef::Skip3 ];
impl MVRef {
- fn get_skip_mv_num(&self) -> usize {
- match *self {
+ fn get_skip_mv_num(self) -> usize {
+ match self {
MVRef::Skip1 => 1,
MVRef::Skip2 => 2,
MVRef::Skip3 => 3,
_ => 0,
}
}
- fn is_ref0(&self) -> bool {
- match *self {
+ fn is_ref0(self) -> bool {
+ match self {
MVRef::Ref0 | MVRef::Ref0AndBRef => true,
_ => false,
}
}
- fn is_fwd(&self) -> bool {
- match *self {
+ fn is_fwd(self) -> bool {
+ match self {
MVRef::Ref0 | MVRef::Ref1 | MVRef::Ref0AndBRef => true,
_ => false,
}
}
- fn is_bwd(&self) -> bool {
- match *self {
+ fn is_bwd(self) -> bool {
+ match self {
MVRef::BRef | MVRef::Ref0AndBRef => true,
_ => false,
}
}
impl PUInfo {
- fn is_intra(&self) -> bool { self.cu_type == CUType::Intra }
+ fn is_intra(self) -> bool { self.cu_type == CUType::Intra }
}
const RV60_CANDIDATE_INTRA_ANGLES: [u8; 6] = [ 0, 1, 10, 26, 18, 2 ];
ipbs: IPBShuffler::new(),
ipred: IntraPredContext::new(),
dsp: RV60DSP::new(),
- avg_buf: avg_buf,
+ avg_buf,
y_coeffs: [0; 16 * 16],
u_coeffs: [0; 8 * 8],
v_coeffs: [0; 8 * 8],
let inv_angle = RV60_IPRED_INV_ANGLE[angle - 10];
let add_size = (size * (ang_weight as usize) + 31) >> 5;
if size <= 16 {
- for i in 0..size+1 {
+ for i in 0..=size {
filtered1[32-1 + i] = self.l[i];
}
- for i in 0..size+1 {
+ for i in 0..=size {
filtered2[32-1 + i] = self.t[i];
}
} else {
let inv_angle = RV60_IPRED_INV_ANGLE[26 - angle];
let add_size = (size * (ang_weight as usize) + 31) >> 5;
if size <= 16 {
- for i in 0..size+1 {
+ for i in 0..=size {
filtered1[32-1 + i] = self.t[i];
}
- for i in 0..size+1 {
+ for i in 0..=size {
filtered2[32-1 + i] = self.l[i];
}
} else {
#[cfg(feature="demuxer_real")]
mod realmedia;
-const RM_DEMUXERS: &[&'static DemuxerCreator] = &[
+const RM_DEMUXERS: &[&DemuxerCreator] = &[
#[cfg(feature="demuxer_real")]
&realmedia::RealMediaDemuxerCreator {},
#[cfg(feature="demuxer_real")]
];
pub fn realmedia_register_all_demuxers(rd: &mut RegisteredDemuxers) {
- for demuxer in RM_DEMUXERS.into_iter() {
+ for demuxer in RM_DEMUXERS.iter() {
rd.add_demuxer(*demuxer);
}
}
Deinterleaver::Generic |
Deinterleaver::Sipro => {
let bsize = (info.frame_size as usize) * (info.factor as usize);
- buf = Vec::with_capacity(bsize);
- buf.resize(bsize, 0u8);
+ buf = vec![0; bsize];
},
Deinterleaver::VBR => {
buf = Vec::new();
deint = Deinterleaver::None;
buf = Vec::new();
}
- RMAudioStream { deint: deint, iinfo: iinfo, buf: buf, sub_packet: 0 }
+ RMAudioStream { deint, iinfo, buf, sub_packet: 0 }
}
fn read_apackets(&mut self, queued_packets: &mut Vec<NAPacket>, src: &mut ByteReader, stream: NAStreamRef, ts: u32, keyframe: bool, payload_size: usize) -> DemuxerResult<NAPacket> {
let (tb_num, tb_den) = stream.get_timebase();
fn read_video_buf(src: &mut ByteReader, stream: NAStreamRef, ts: u32, keyframe: bool, frame_size: usize) -> DemuxerResult<NAPacket> {
let size = (frame_size as usize) + 9;
- let mut vec: Vec<u8> = Vec::with_capacity(size);
- vec.resize(size, 0);
+ let mut vec: Vec<u8> = vec![0; size];
//v[0] = 0; // 1 slice
vec[4] = 1;
src.read_buf(&mut vec[9..])?;
} else if ((tag2 == mktag!('V', 'I', 'D', 'O')) || (tag2 == mktag!('I', 'M', 'A', 'G'))) && ((tag as usize) <= edata.len()) {
Self::parse_video_stream(strmgr, &mut str_data.streams, stream_no, &mut src, edata.as_slice(), tag2)?;
} else if tag == mktag!(b"LSD:") {
- let extradata = Some(edata.clone());
+ let extradata = Some(edata.to_owned());
src.read_skip(4)?; //version
let channels = src.read_u16be()?;
validate!(end - start <= (header_len as u64) + 2);
Ok(RealAudioInfo {
- fcc: fcc, flavor: flavor,
+ fcc, flavor,
sample_rate: 8000, sample_size: 16, channels: 1, channel_mask: 0,
- granularity: granularity, bytes_per_minute: bytes_per_minute,
- total_bytes: total_bytes, edata_size: 0,
+ granularity, bytes_per_minute,
+ total_bytes, edata_size: 0,
ileave_info: None,
})
}
};
Ok(RealAudioInfo {
- fcc: fcc, flavor: flavor,
- sample_rate: sample_rate, sample_size: sample_size as u16, channels: channels, channel_mask: 0,
- granularity: granularity, bytes_per_minute: bytes_per_minute,
+ fcc, flavor,
+ sample_rate, sample_size: sample_size as u16, channels, channel_mask: 0,
+ granularity, bytes_per_minute,
total_bytes: total_bytes & 0xFFFFFF, edata_size: 0,
- ileave_info: ileave_info,
+ ileave_info,
})
}
let ileave_info = if is_interleaved != 0 {
Some(InterleaveInfo {
- id: interleaver_id, factor: ileave_factor, block_size: ileave_block_size, frame_size: frame_size,
+ id: interleaver_id, factor: ileave_factor, block_size: ileave_block_size, frame_size,
})
} else {
None
}
Ok(RealAudioInfo {
- fcc: fcc, flavor: flavor,
- sample_rate: sample_rate, sample_size: sample_size as u16, channels: channels, channel_mask: 0,
- granularity: granularity, bytes_per_minute: bytes_per_minute,
- total_bytes: total_bytes & 0xFFFFFF, edata_size: edata_size,
- ileave_info: ileave_info,
+ fcc, flavor,
+ sample_rate, sample_size: sample_size as u16, channels, channel_mask: 0,
+ granularity, bytes_per_minute,
+ total_bytes: total_bytes & 0xFFFFFF, edata_size,
+ ileave_info,
})
}
//println!("mime = {}", mime);
let edata_size = self.src.read_u32be()? as usize;
let edata: Option<Vec<u8>> = if edata_size == 0 { None } else {
- let mut edvec: Vec<u8> = Vec::with_capacity(edata_size);
- edvec.resize(edata_size, 0);
+ let mut edvec: Vec<u8> = vec![0; edata_size];
self.src.read_buf(&mut edvec)?;
Some(edvec)
};
let extradata = if ainfo.edata_size == 0 {
None
} else {
- let mut dta: Vec<u8> = Vec::with_capacity(ainfo.edata_size as usize);
- dta.resize(ainfo.edata_size as usize, 0);
+ let mut dta: Vec<u8> = vec![0; ainfo.edata_size as usize];
self.src.read_buf(dta.as_mut_slice())?;
Some(dta)
};
impl IVRRecord {
fn read_string(src: &mut ByteReader) -> DemuxerResult<Vec<u8>> {
let len = src.read_u32be()? as usize;
- let mut val = Vec::with_capacity(len);
- val.resize(len, 0);
+ let mut val = vec![0; len];
src.read_buf(val.as_mut_slice())?;
Ok(val)
}
4 => {
let name = Self::read_string(src)?;
let len = src.read_u32be()? as usize;
- let mut val = Vec::with_capacity(len);
- val.resize(len, 0);
+ let mut val = vec![0; len];
src.read_buf(val.as_mut_slice())?;
Ok(IVRRecord::BinaryData(name, val))
},
RecordDemuxer {
start_pos: pos,
cur_pos: pos,
- start_str: start_str,
+ start_str,
remap_ids: Vec::new(),
}
}
loop {
let rec = IVRRecord::read(src)?;
match rec {
- IVRRecord::Packet { ts, str, flags, len, checksum: _ } => {
+ IVRRecord::Packet { ts, str, flags, len, .. } => {
let payload_size = len;
let sr = self.remap_ids.iter().position(|x| *x == str);
validate!(sr.is_some());
extern crate nihav_core;
+#[cfg(feature="decoders")]
+#[allow(clippy::cast_lossless)]
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::excessive_precision)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::too_many_arguments)]
+#[allow(clippy::unreadable_literal)]
+#[allow(clippy::useless_let_if_seq)]
pub mod codecs;
+#[cfg(feature="demuxers")]
+#[allow(clippy::cast_lossless)]
+#[allow(clippy::too_many_arguments)]
+#[allow(clippy::unreadable_literal)]
+#[allow(clippy::useless_let_if_seq)]
pub mod demuxers;
\ No newline at end of file