Skip to content

Commit

Permalink
codec/av1/parser: optimize initialization of loop_filter_delta_enabled
Browse files Browse the repository at this point in the history
Use an immediate array value instead of indexing its members one by one.
  • Loading branch information
Gnurou committed Jun 24, 2024
1 parent d70777a commit f77d389
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/codec/av1/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,15 +1963,7 @@ impl Parser {
}

fh.loop_filter_params.loop_filter_delta_enabled = true;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::Intra as usize] = 1;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::Last as usize] = 0;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::Last2 as usize] = 0;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::Last3 as usize] = 0;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::BwdRef as usize] = 0;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::Golden as usize] = -1;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::AltRef as usize] = -1;
fh.loop_filter_params.loop_filter_ref_deltas[ReferenceFrameType::AltRef2 as usize] = -1;

fh.loop_filter_params.loop_filter_ref_deltas = [1, 0, 0, 0, -1, 0, -1, -1];
fh.loop_filter_params.loop_filter_mode_deltas = Default::default();
}

Expand Down Expand Up @@ -2332,15 +2324,7 @@ impl Parser {
if fh.coded_lossless || fh.allow_intrabc {
lf.loop_filter_level[0] = 0;
lf.loop_filter_level[1] = 0;

lf.loop_filter_ref_deltas[ReferenceFrameType::Intra as usize] = 1;
lf.loop_filter_ref_deltas[ReferenceFrameType::Last as usize] = 0;
lf.loop_filter_ref_deltas[ReferenceFrameType::Last2 as usize] = 0;
lf.loop_filter_ref_deltas[ReferenceFrameType::Last3 as usize] = 0;
lf.loop_filter_ref_deltas[ReferenceFrameType::BwdRef as usize] = 0;
lf.loop_filter_ref_deltas[ReferenceFrameType::Golden as usize] = -1;
lf.loop_filter_ref_deltas[ReferenceFrameType::AltRef as usize] = -1;
lf.loop_filter_ref_deltas[ReferenceFrameType::AltRef2 as usize] = -1;
lf.loop_filter_ref_deltas = [1, 0, 0, 0, -1, 0, -1, -1];

for delta in &mut lf.loop_filter_mode_deltas {
*delta = 0;
Expand Down

0 comments on commit f77d389

Please sign in to comment.