From 6f21f5f488f8a82bcb156ff763ddf1737a7fd4a8 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 27 Nov 2017 17:59:56 +0100 Subject: [PATCH] h263: track first line state too --- src/codecs/h263/decoder.rs | 9 ++++++--- src/codecs/h263/mod.rs | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/codecs/h263/decoder.rs b/src/codecs/h263/decoder.rs index 15e18fc..420f6f8 100644 --- a/src/codecs/h263/decoder.rs +++ b/src/codecs/h263/decoder.rs @@ -215,8 +215,11 @@ impl H263BaseDecoder { if slice.is_at_end(mb_pos) || (slice.needs_check() && mb_pos > 0 && bd.is_slice_end()) { slice = bd.decode_slice_header(&pinfo)?; - //mvi.reset(self.mb_w, mb_x, pinfo.get_mvmode()); - //cbpi.reset(self.mb_w); + if !self.is_gob { + mvi.reset(self.mb_w, mb_x, pinfo.get_mvmode()); + cbpi.reset(self.mb_w); + sstate.first_line = true; + } } let binfo = bd.decode_block_header(&pinfo, &slice, &sstate)?; @@ -228,7 +231,7 @@ impl H263BaseDecoder { bd.decode_block_intra(&binfo, &sstate, binfo.get_q(), i, (cbp & (1 << (5 - i))) != 0, &mut blk[i])?; if apply_acpred && (binfo.acpred != ACPredMode::None) { let has_b = (i == 1) || (i == 3) || (mb_x > 0); - let has_a = (i == 2) || (i == 3) || (mb_y > 0); + let has_a = (i == 2) || (i == 3) || !sstate.first_line; let (b_mb, b_blk) = if has_b { if (i == 1) || (i == 3) { (mb_pos, i - 1) diff --git a/src/codecs/h263/mod.rs b/src/codecs/h263/mod.rs index c5d63fc..7e5064e 100644 --- a/src/codecs/h263/mod.rs +++ b/src/codecs/h263/mod.rs @@ -120,6 +120,7 @@ pub struct SliceState { pub is_iframe: bool, pub mb_x: usize, pub mb_y: usize, + pub first_line: bool, } const SLICE_NO_END: usize = 99999999; @@ -141,10 +142,10 @@ impl SliceInfo { impl SliceState { pub fn new(is_iframe: bool) -> Self { - SliceState { is_iframe: is_iframe, mb_x: 0, mb_y: 0 } + SliceState { is_iframe: is_iframe, mb_x: 0, mb_y: 0, first_line: true } } pub fn next_mb(&mut self) { self.mb_x += 1; } - pub fn new_row(&mut self) { self.mb_x = 0; self.mb_y += 1; } + pub fn new_row(&mut self) { self.mb_x = 0; self.mb_y += 1; self.first_line = false; } } #[derive(Debug,Clone,Copy)] -- 2.39.5