filter_alpha: usize,
loop_thr: i16,
mv_range: i16,
+ loop_filter: bool,
}
impl MVEstimator {
- pub fn new(ref_frame: NAVideoBufferRef<u8>, mc_buf: NAVideoBufferRef<u8>, loop_thr: i16, mv_range: i16) -> Self {
+ pub fn new(ref_frame: NAVideoBufferRef<u8>, mc_buf: NAVideoBufferRef<u8>, loop_thr: i16, mv_range: i16, loop_filter: bool) -> Self {
Self {
ref_blk: [[0; 64]; 6],
ref_frame, mc_buf,
filter_alpha: 0,
loop_thr,
mv_range,
+ loop_filter,
}
}
pub fn mc_block(&mut self, dst_idx: usize, plane: usize, x: usize, y: usize, mv: MV) {
};
let tmp_blk = self.mc_buf.get_data_mut().unwrap();
get_block(tmp_blk, 16, self.ref_frame.clone(), plane, x, y, sx, sy);
- if (msx & 7) != 0 {
- let foff = (8 - (sx & 7)) as usize;
- let off = 2 + foff;
- vp31_loop_filter(tmp_blk, off, 1, 16, 12, self.loop_thr);
- }
- if (msy & 7) != 0 {
- let foff = (8 - (sy & 7)) as usize;
- let off = (2 + foff) * 16;
- vp31_loop_filter(tmp_blk, off, 16, 1, 12, self.loop_thr);
+ if self.loop_filter {
+ if (msx & 7) != 0 {
+ let foff = (8 - (sx & 7)) as usize;
+ let off = 2 + foff;
+ vp31_loop_filter(tmp_blk, off, 1, 16, 12, self.loop_thr);
+ }
+ if (msy & 7) != 0 {
+ let foff = (8 - (sy & 7)) as usize;
+ let off = (2 + foff) * 16;
+ vp31_loop_filter(tmp_blk, off, 16, 1, 12, self.loop_thr);
+ }
}
let copy_mode = (mx == 0) && (my == 0);
let mut bicubic = !copy_mode && is_luma && self.bicubic;
pub me_mode: MVSearchMode,
pub me_range: i16,
+ pub loop_filter: bool,
}
macro_rules! read_block {
let mut cur_blk = [[0u8; 64]; 6];
- let mut mv_est = MVEstimator::new(ref_frame, mc_buf, loop_thr, self.me_range);
+ let mut mv_est = MVEstimator::new(ref_frame, mc_buf, loop_thr, self.me_range, self.loop_filter);
let mut mv_search = self.me_mode.create_search();
let mut cur_blk = [[0u8; 64]; 6];
self.src_mbs[mb_pos].fill(&mut cur_blk);
- let mut mv_est = MVEstimator::new(ref_frame, mc_buf, loop_thr, self.me_range);
+ let mut mv_est = MVEstimator::new(ref_frame, mc_buf, loop_thr, self.me_range, self.loop_filter);
let mut mv_search = self.me_mode.create_search();
let mut cur_blk = [[0u8; 64]; 6];
- let mut mv_est = MVEstimator::new(ref_frame.clone(), mc_buf.clone(), loop_thr, self.me_range);
+ let mut mv_est = MVEstimator::new(ref_frame.clone(), mc_buf.clone(), loop_thr, self.me_range, self.loop_filter);
let mut mv_est_g = if let Some(gold_frm) = gold_frame {
- Some(MVEstimator::new(gold_frm, mc_buf.clone(), loop_thr, self.me_range))
+ Some(MVEstimator::new(gold_frm, mc_buf.clone(), loop_thr, self.me_range, self.loop_filter))
} else {
None
};
last_gold: bool,
me_mode: MVSearchMode,
me_range: i16,
+ use_lf: bool,
force_q: Option<usize>,
fast: bool,
last_gold: false,
me_mode: MVSearchMode::default(),
me_range: 16,
+ use_lf: false,
force_q: None,
fast: false,
self.stats.reset();
let multistream = self.huffman || self.version != VERSION_VP60;
- let loop_filter = false;
self.fenc.prepare_intra_blocks();
self.fenc.prepare_inter_blocks(false);
self.fenc.apply_dc_prediction(&mut self.dc_pred);
self.fenc.predict_mvs();
- self.write_inter_frame(bw, quant, multistream, loop_filter, golden_frame)?;
+ self.write_inter_frame(bw, quant, multistream, self.fenc.loop_filter, golden_frame)?;
Ok(golden_frame)
}
self.stats.reset();
let multistream = self.huffman || self.version != VERSION_VP60;
- let loop_filter = false;
let last_frm = self.last_frame.get_vbuf().unwrap();
let gold_frm = if !self.last_gold {
self.fenc.predict_mvs();
self.estimate_blocks(false);
- self.write_inter_frame(bw, quant, multistream, loop_filter, golden_frame)?;
+ self.write_inter_frame(bw, quant, multistream, self.fenc.loop_filter, golden_frame)?;
Ok(false)
}
let golden_frame = if is_intra {
self.encode_intra(&mut bw, quant)?
} else if !self.fast {
+ self.fenc.loop_filter = self.use_lf && self.profile == VP6_ADVANCED_PROFILE;
self.fenc.estimate_mvs(self.last_frame.get_vbuf().unwrap(), self.mc_buf.clone(), false);
if !self.last_gold {
self.fenc.estimate_mvs(self.gold_frame.get_vbuf().unwrap(), self.mc_buf.clone(), true);
}
self.encode_inter(&mut bw, quant)?
} else {
+ self.fenc.loop_filter = false;
self.encode_inter_fast(&mut bw, quant)?
};
self.fenc.reconstruct_frame(&mut self.dc_pred, self.last_frame.get_vbuf().unwrap());
const HUFFMAN_OPTION: &str = "huffman";
const QUANT_OPTION: &str = "quant";
const VERSION_OPTION: &str = "version";
+const LF_OPTION: &str = "loopfilt";
const MV_SEARCH_OPTION: &str = "mv_mode";
const MV_RANGE_OPTION: &str = "mv_range";
const FAST_OPTION: &str = "fast";
NAOptionDefinition {
name: MV_RANGE_OPTION, description: "motion search range (in pixels)",
opt_type: NAOptionDefinitionType::Int(Some(0), Some(30)) },
+ NAOptionDefinition {
+ name: LF_OPTION, description: "use loop filter",
+ opt_type: NAOptionDefinitionType::Bool },
NAOptionDefinition {
name: FAST_OPTION, description: "faster (but worse) encoding",
opt_type: NAOptionDefinitionType::Bool },
self.huffman = bval;
}
},
+ LF_OPTION => {
+ if let NAValue::Bool(bval) = option.value {
+ self.use_lf = bval;
+ }
+ },
VERSION_OPTION => {
if let NAValue::String(ref string) = option.value {
self.version = match string.as_str() {
let enc_options = &[
NAOption { name: super::QUANT_OPTION, value: NAValue::Int(42) },
];
- encode_test("vp6-bool.avi", enc_options, &[0xb57f49e5, 0x6b48accd, 0xc28fadb3, 0xc89a30d2]);
+ encode_test("vp6-bool.avi", enc_options, &[0x32d6e50d, 0xb627c751, 0xc7f2f8e0, 0x66cc8791]);
}
#[test]
fn test_vp6_encoder_fast() {
NAOption { name: super::QUANT_OPTION, value: NAValue::Int(42) },
NAOption { name: super::FAST_OPTION, value: NAValue::Bool(true) },
];
- encode_test("vp6-fast.avi", enc_options, &[0xb8037ce1, 0xc00ade72, 0x3c0b73c2, 0xbfc4113d]);
+ encode_test("vp6-fast.avi", enc_options, &[0xb87856e2, 0x4b061f55, 0x15f83bef, 0x0211f5cd]);
}
#[test]
fn test_vp6_encoder_rc() {
let enc_options = &[
];
- encode_test("vp6-rc.avi", enc_options, &[0x2164fb25, 0xe91984ac, 0x22316452, 0x45b65730]);
+ encode_test("vp6-rc.avi", enc_options, &[0x91253bb3, 0x90b4b4af, 0x04c414ea, 0x7a76d616]);
}
#[test]
fn test_vp6_encoder_huff() {
NAOption { name: super::HUFFMAN_OPTION, value: NAValue::Bool(true) },
NAOption { name: super::QUANT_OPTION, value: NAValue::Int(42) },
];
- encode_test("vp6-huff.avi", enc_options, &[0x6e9bb23d, 0xde296d92, 0x4c225bae, 0x3651e31f]);
+ encode_test("vp6-huff.avi", enc_options, &[0xb843eebc, 0x4c7a24a3, 0x040906b5, 0x4c86b1aa]);
}
}