PDA

View Full Version : DivX vs XviD @ fixed quant compressing flash animation


dimzon
26th June 2006, 11:44
Hi!
I'm trying to convert SWF animation file to AVI for HW playback
I captured it into lossless format, convert fps from 12 to 24 using AviSynth ( ConvertFPS(24) ) and trying to compess it into MPEG4 ASP using both DivX 6.2.5 and XviD 1.2
I choose mp3 112kbps for audio, fixed quant 2 for video.
Original swf: http://htf.ru/getswfrar.phtml?Id=64

I'm using such settings:

X1: XVID 1.2, DXN HT PAL profile, trellis quantizer, 1b-frame, packed bitstream, croma optimizer, cartoon mode, croma motion, motion search 6, VHQ 4, VHQ for B-frames ON, fixed quant=2
filesize: 10 907 172 bytes

X2: XVID 1.2, DXN HT PAL profile, trellis quantizer, no b-frames, croma optimizer, cartoon mode, croma motion, motion search 6, VHQ 4, fixed quant=2
filesize: 10 543 474 bytes


D1: DivX 6.2.5, Insane quality, HT profile, H263 optimized, no b-frames, target quant=2
filesize: 11 860 678 bytes

D2: DivX 6.2.5, Insane quality, HT profile, H263, no b-frames, target quant=2
filesize: 11 815 572 bytes

D3: DivX 6.2.5, Insane quality, HT profile, H263, no b-frames, psy=Shaping, target quant=2
filesize: 11 857 528 bytes

D4: DivX 6.2.5, Insane quality, HT profile, H263, no b-frames, psy=Masking, target quant=2
filesize: 10 940 416 bytes

D5: DivX 6.2.5, Insane quality, HT profile, H263 optimized, no b-frames, psy=Masking, target quant=2
filesize: 10 829 854 bytes

Sagittaire
26th June 2006, 12:20
Well don't mean anything ... because quality can be not the same.

Moreover setting like psy (shaping or masking) are adaptative quantisation. In theory use these function make no strict constant quantizer encoding.

Sagittaire
26th June 2006, 13:32
For exemple MPEG4 ASP from Libavcodec done only 9 614 377 bytes at q2 without bframes ...

dimzon
26th June 2006, 13:54
For exemple MPEG4 ASP from Libavcodec done only 9 614 377 bytes at q2 without bframes ...
Keep in mind - filesize include audio @ 112 kbps ;)

dimzon
26th June 2006, 14:50
Seems like I know why XviD movie is smaller
Packed bitstream: No
QPel: No
GMC: No
Interlaced: No
Aspect ratio: Square pixels
Quant type: H.263

I-VOPs: 52 (1,66%)
P-VOPs: 2516 (80,18%)
B-VOPs: 0 (0,00%)
S-VOPs: 0 (0,00%)
N-VOPs: 570 (18,16%)


Actually source fps is 12 converted to 24 so I believe i must got 50% N-VOPs instead of just 18%....

Maybe I need to tweak some XviD parameters

Sagittaire
26th June 2006, 18:30
Seems like I know why XviD movie is smaller
Packed bitstream: No
QPel: No
GMC: No
Interlaced: No
Aspect ratio: Square pixels
Quant type: H.263

I-VOPs: 52 (1,66%)
P-VOPs: 2516 (80,18%)
B-VOPs: 0 (0,00%)
S-VOPs: 0 (0,00%)
N-VOPs: 570 (18,16%)


Actually source fps is 12 converted to 24 so I believe i must got 50% N-VOPs instead of just 18%....

Maybe I need to tweak some XviD parameters

It's not for that ... it's simply because all MPEG4 ASP don't work in the same way. Same quantizer done simply different quality for different size with exactly the same setting for your source:

XviD 1.2 at q2
ME 6, VHQ4, Trelli, H263, no bframe
532 Kbps for VES and OPSNR = 48.7027 dB

DivX 6.2.5 at q2
Insame, H263 optimized, no bframe
574 Kbps for VES and OPSNR = 49.4318 dB

Libavcodec ASP at q2
RDO, SADT for all, Chroma search, trelli, no bframe
496 Kbps for VES and OPSNR = 48.5554 dB

dimzon
26th June 2006, 18:41
Same quantizer done simply different quality for different size with exactly the same setting for your source
OMG. Never think about it befor. I believe (in past) final quantizer + matrix 100% determine quality... So I really don't understand how (and why) different encoders produce different quality at same quantizer + matrix...

Sagittaire
26th June 2006, 20:13
OMG. Never think about it befor. I believe (in past) final quantizer + matrix 100% determine quality... So I really don't understand how (and why) different encoders produce different quality at same quantizer + matrix...

encoding is not simply DCT quantisation:
- RDO process can be different
- ME can be different
- trelli can be different

... etc etc etc

Manao
26th June 2006, 22:39
When deciding what encoding mode to use ( intra or inter, a vector MV1 or a vector MV2... ), the encoder considers two things : the distorsion of the encoding mode ( ie, how close to the source the result will be ), and the number of bits taken by the mode. The best choice isn't always the lowest number of bits, nor the lowest distorsion. You have to take both into account, hence, you'll try to minimize distorsion + lambda * bits, where lambda is a parameter that the encoder can freely choose. But, in choosing it, the encoder set a bit/quality tradeoff. Since encoders may use different lambdas, it results in different quality / bits tradeoff, at the same quantizers.

Trellis is also ruled by the same lambda.

When trellis isn't used, the quantization step still leaves some room for choices that can drastically change the quality / bit tradeoff. Quantizing amounts to rounding. And, when you round, you have very much leeway. 0.6, for example, can be rounded down to 0 or up 1. The distorsion would be lower with 1, but the bitrate lower with 0. Xvid, for example, rounds 0.74 toward 0 and 0.75 toward 1. If it rounded to the closest integer, the filesize would increase by 50% ( and the PSNR by more than 1 dB )

In the end, all encoding choices ( not ruled by psychovisual considerations ) come down to that bit / distorsion tradeoff, in a way or another.