Log in

View Full Version : Do B-Frames really improve quality?


madman_looney
31st August 2003, 08:34
Lately I have become skeptic as to the effectiveness of b-frames. To put it to the test I encoded a movie in low bitrate (730k) using 3 methods: no b-frames, b-frames with a threshold of 0, and b-frames with a threshold of 40. I then tried to assess the qualities of the 3 encodes.

What I found was that the encode with no b-frames looked the best. Its average quantizer was lower than the b-frames encodes (4.5 as opposed to 5), and its PSNR was signifantly higher (43 as opposed to 30!).

All encodes were done with Koepi's 240603 version, using the same settings except for b-frames (motion 6, chroma motion, vhq4, chroma optimizer, trellis).

Selur
31st August 2003, 08:40
just wondering:

what did you choose for the rest of the b-frame settings?
(max b-frame?, b-frame quant ratio?, offset?)

OUTPinged_
31st August 2003, 08:45
1. You shouldn't mistake b-frame's quantizers with inter-frame quantizers, since it is most probably that you got it all added into average.

2. B-frames do improve quality. But keep in mind that some frames will be better, some frames will be worse. The trick is that during playback overal impression of a movie would be better. So you cannot judge if b-frames are better or worse by frame-by-frame comparison.

Compression gain would be about 15-25%. Definitely not a small one.

Barker
31st August 2003, 08:52
Yet another B-Frame quality thread? :o

I thought it was established long ago that B-Frames don't change frame quality, they just increase compressibility, making the overall file smaller, allowing higher bitrate throughout the movie?

I could be talking out of my arse, so correct me if I'm wrong, I just remember a few threads answering this question.

There is a search button at the top of the forum page, if anyone is interested :confused:

Regards,
Barker

superdump
31st August 2003, 10:26
The point of B-frames is that they have a better quality than P-frames at the same quant. So to maintain a similar quality level, the B-frames are encoded at a slightly higher quant at a substantial space saving. These bits can be redistributed across the rest of the video. The bitrate remains the same for a given filesize, obviously, but the bits are used more efficiently.

However, I don't know why your encode without B-frames looks better. What movie is it?

Barker
31st August 2003, 10:36
But, correct me if I'm wrong, B frames are just a higher spectrum of reference frames, right?

madman_looney
31st August 2003, 11:27
The b-frames settings I used: max 2, ratio 150, offset 75. The two b-frames encodes were with thresholds of 0 and 40, and the non b-frames encode with a max of 0.

The higher quantizers used for b-frames which should not cost in quality explain the higher average quantizer, but this is why I also calculated PSNR. The PSNR results really surprised me. I was expecting a slightly higher PSNR on the b-frames encode, while what I got was an extermely low PSNR of 30, as opposed to a PSNR of 43 in the non b-frames encode.

superdump
31st August 2003, 11:55
madman_looney: When calculating the PSNR how did you do it? XviD encodes with b-frames create a dummy first frame and so if you don't trim it off, all consequent frames will be offset by one thus drastically reducing the PSNR.

I personally suggest you use a VBLE encode as your source file and a script similar to this for testing XviD with B-frames:
name="xvidwithb-frames.avi"

source=avisource("vble.avi").converttoyuy2()
test=avisource(name).converttoyuy2().deleteframe(0)

compare(test,source,"",name+".PSNR.txt",false)

When testing xvid clips without B-frames disable the '.deleteframe(0)' by putting a '#' just before the full stop. [i.e. '#.deleteframe(0)']

Try testing again with this method. :)

Barker: I'll have to look into that.

Nibor
31st August 2003, 11:57
Damn :D I was to slow...

Hehe, I think your AVS-Script is wrong then :p

If you do a compare, you have to cut off the first frame in your encode with b-frames like this :
ClipToCompare = AviSource("bframesencode.avi").Trim(1,0).ConvertToYUY2()
That's necessary because the first frame from the VfW-Codec output of an encode with b-frames is this "b-frame decoder lag" frame...

If you don't do that, the PSNR must be this low, because each two frames which are compared are not the same!

-= Nibor =-

madman_looney
31st August 2003, 12:10
Thanks :)

I didn't delete the first frame on the b-frames compare script, so that must be it. I'll change the script and run the comparison again.