[Theora-dev] Patch that fixes distortions during static scenes

Aaron Colwell acolwell at real.com
Thu Mar 3 07:28:07 PST 2005


On Thu, Mar 03, 2005 at 02:15:32PM +0100, Ivan Popov wrote:
> Hi Aaron,
> 
> > Here is a patch that fixes distortions that appear during scenes with no 
> > motion. Tbe problem was that UpdateFrame() was not being called when a 
> > MotionScore of 0 was computed. Since UpdateFrame() was not called the buffer
> > returned by theora_encode_packetout() would be the same buffer that was output
> > for the last frame that had a non-zero MotionScore. This is obviously incorrect
> > behavior. I've just moved the UpdateFrame() out of the (MotionScore > 0) 
> > conditional block. 
> 
> this fix definitely removes the "accumulating artifacts" I observed.
> Thanks!
> 
> On the other side, other keyframe-related artifacts are in place,
> and I see a problem which is quite opposite to one you descibed.
> It looks like a keyframe is being encoded with a "too bad" quality,
> so that the following frames gradually improve it.
> This looks like a perfect behaviour when a keyframe is inserted as the scene
> changes, but as well very bad during static scenes (causing a burst
> of artifacts).

This commonly happens with static scenes because the encoders rate control
logic doesn't try to store up bits for the keyframe. It just looks at the
current number of bits it has for the frame and tries to find a Q that
fits that. In a static scene there are few blocks to update so it computes
a really high Q for the frame. When the keyframe comes around it has MANY
more blocks to encode so it has to drop the Q by a lot. These large shifts in
Q are what cause both the artifact I mentioned and the one you mentioned.
The rate control logic needs to have some sort of mechanism to regulate 
changes in Q so that such drastic events don't happen. I'm planning on 
looking into a solution for this problem.

> 
> It looks even more strange as it happens when we clearly have a huge
> excess of unused bits - I ask for 2000 kbit/s and get about 250 kbit/s

I'm guessing that it is less noticable at this bitrate. Depending on the
frame size and frame rate this still may not be enough for the encoder to
think it has enough bits to encode the key frame at the same Q as the
interframe. Are you seeing this in the Amelie clip? If not send me a link
to the clip and I'll look into it.

> 
> On the third side, I can reduce the probablility of such "error bursts"
> by tweaking keyframe frequency - yet it feels like a workaround for
> an unexpected encoder behaviour. I guess the bit-allocation machinery
> has some problems yet.

I haven't looked into how the keyframe frequency effects this problem, but
I'm not suprised that it helps some. I'll take a look at this as well. 

Aaron

> 
> Again, thanks for fix!
> --
> Ivan
> 
> 


More information about the Theora-dev mailing list