[FFmpeg-devel] [RFC] Fixing libx264.c

Jason Garrett-Glaser darkshikari
Fri May 22 05:02:32 CEST 2009

> AVCodecContext.scenechange_threshold == 0 means default, not disabled
> disabled would be INT_MAX
> Its a simple bug in libx264.c of not translating from lavc API to x264 API

So if(!scenecut threshold) {leave it as x264's default} ?

>> 3. ?ffmpeg sets directpred to "temporal".
>> Why it's broken currently: directpred temporal breaks horrifically
>> when b-pyramid is applied, so it's easy to mix the two improperly
>> (spatial is a better default anyways, and is the one x264 uses).
>> Solution: set the default to spatial in options.c (which it should be).
> its a little annying semantically as mpeg4 asp has no spatial and thus
> strictly mpeg4 should fail with the default.
> maybe none or auto would be better defaults.
> though i have no real objection to change it to spatial if you want, its
> just a little dirty for codecs that dont support spatial

Well, equivalently, ffmpeg defaults to opengop but x264 doesn't support opengop.

>> 4. ?ffmpeg turns off chroma ME.
>> Why it's broken currently: It's forced off below subme=5 anyways, and
>> above it's practically always useful.
>> Solution: Disconnect the option.
>> 5. ?ffmpeg turns off fast pskip.
>> Why it's broken currently: This should practically always be on; it
>> costs a lot of speed to leave it off (for no real benefit).
>> Solution: Disconnect the option, or if only x264 uses the option, set
>> it on by default.
>> 8. ?ffmpeg turns off adaptive b-frame placement by default.
>> Why it's broken: Non-adaptive B-frame placement seriously sucks. ?But
>> this option is actually useful (0-off, 1-fast, 2-optimal), so I don't
>> want to disconnect it.
>> Solution: This is very important, but I can't come up with one.
>> 9. ?Partitions are all off by default.
>> Why it's broken: Turning off all partitions cripples compression.
>> Partitions are actually useful to tweak, but the defaults should be
>> "all on except p4x4," not all off.
>> Solution: Adjust options.c to force the defaults correctly, since only
>> x264 uses the partition options.
>> 10. ?Loop filter is off by default.
>> Why it's broken: Nobody should be turning it off except maybe to
>> encode for some really slow CPU or something. ?Critical for
>> compression quality, costs nearly no speed.
>> Solution: Turn it on by default? ?Might affect other codecs. ?Or
>> disconnect the option.
> The defaults in ffmpeg are generally all stuff disabled, changing that
> requires per codec defaults as otherwise codecs would per default receive
> settings they dont support (like a loop filter for mpeg1)

But what about options that don't affect anything other than x264,
e.g. partitions?

> hmm, are our options here even semantically identical to x264s?
> qscale*x isnt the same as log(qscale)*x or am i missing something?

Ah, you're right.  So it's just a matter of ffmpeg disagreeing with
x264 on optimal values (potentially related to the fact that ffmpeg
appears to use both a "b-frame QP offset" and "b-frame QP factor",
while x264 does not.

Dark Shikari

More information about the ffmpeg-devel mailing list