[MEncoder-users] avi to h264 crashing itunes

Guillaume POIRIER poirierg at gmail.com
Sat Sep 13 22:57:44 CEST 2008


Hello,

On Sat, Sep 13, 2008 at 3:45 PM, Christian Ebert <blacktrash at gmx.net> wrote:
> * Guillaume POIRIER on Friday, September 12, 2008 at 22:54:33 +0200

>> Now, I'd like to know if trellis _can't_ be implemented without cabac
>> or it's just that x264 folks just didn't care to implement that.
>>
>> /me joins #x264
>
> And, did you get answers?

Yep, here's the IRC log:

       <poirierg>      is that right that x264's tellis quant
optimization only works with
CABAC enabled?
       encoder/encoder.c:488 seems to agree with that statement
       my question then is: how come it needs cabac? Can it be modified so
that it works with CAVLC too?
       <Dark_Shikari>  poirierg: yes
       back
       <poirierg>      or does it require too much code changes?
       <Dark_Shikari>  you would need a completely new trellis function
       trellis's complexity comes solely from the problem of turning the
entropy coder's possible states into a djikstra's algorithm graph
search
       CAVLC can exist; there is a paper on CAVLC trellis
       and even if you couldn't do trellis, you could do QNS, which I
implemented a while ago but was awfully slow
       <poirierg>      after all, xvid and lavc have trellis, and no cabac, so I
imagined that it doesn't have to be tied to cabac
       <Dark_Shikari>  Not exactly
       Xvid/LAVC's trellis is simpler because VLC-coding in MPEG-4/2 is simpler
       CAVLC has the "CA"
       <poirierg>      context-adaptive
       <Dark_Shikari>  the VLC tables used change based on previous coefficients
       this means you either need a smarter algorithm or you need to make
more incorrect assumptions
       Originally pengvado thought it was exponential-time only, but
apparently someone came up with a polynomial time version in some
paper
       <poirierg>      for cabac or cavlc?
       <Dark_Shikari>  cavlc
       <poirierg>      Dark_Shikari: do the subject of trellis+cavlc come around
often around here?
       <Dark_Shikari>  not really
       I don't consider CAVLC very important, though I don't consider it
totally unimportant either
       given that I've had a half dozen patches related solely to it
       <Dark_Shikari>  and given I spent all that time rewriting the
bitstream writer
       <poirierg>      I'm asking that because ipod doesn't support cabac so you
can only use basic encoding options
       which kind of suck...
       <Dark_Shikari>  of course for ipod you don't care too much
about efficiency...
       since you have low resolution but a high bitrate cap and a
gigantic hard disk
       and no bandwidth limitations
       <poirierg>      it depends on what your strategy is!
       <Dark_Shikari>  either way, if you want to write one, patches welcome
       its rather low on my priority list, a list that isn't getting shorter
because pengvado isn't giving feedbakc to my patches and I don't want
to unilaterally commit large changes
       <poirierg>      if you want to "archive" your videos in an
ipod-compatible
way, you may as well not blow all your bits in artifacts, and use the
best encoding options around
       <Dark_Shikari>  ipods have a max bitrate of 10mbit or so
       you don't really have to worry
       <poirierg>      sorry, that's not what I meant
       <Dark_Shikari>  either way, as I said, patches welcome :>
       <poirierg>      I meant: if you want the best quality per bitrate, then
it'll be nice to have such options available
       <Dark_Shikari>  of course
       well, if you want THE best
       you can use QNS ;)
       (only a dozen or two times slower than trellis!)
       <poirierg>      is your patch still available?
       <Dark_Shikari>  somewhere
       it won't work anymore, you'll have to make minor modifications
       There's a Japanese guy who chnaged it to make it useful by having it
have its own option
       its an extremely brute-force patch--it uses a full iDCT for
every single coeff
       and a full bit cost calculation instead of a transition table
like trellis
       and no asm for distortion calculation
       total cost per coefficient checked is like 500 clocks
       and it might check a few dozen coeffs if not a hundred or more
       I still have the patch somewhere
       but IMO its not very interesting except for testing arbitrary
distortion metrics
       poirierg: http://pastebin.com/f79803700
       <poirierg>      I don't know why I'm asking you this: when QNS became
available in lavc, I ended up not using it since it's was too damn
expensive
       <Dark_Shikari>  and the lavc one is extremely heavily optimized
       its only a bit slower than trellis
       not even an order of magnitude
       <poirierg>      I'm not sure if you somewhat answered that: is
x264's code
modular enough to allow a clean implementation of trellis+cavlc?
       <Dark_Shikari>  Yes
       in fact, if you converted trellis to a function pointer, you could do
it without an if statement
       trellis is setup so the main trellis is inlined into
trellis_4x4_cabac and trellis_8x8_cabac, which are then called
       you could just add a new trellis, and trellis_4x4_cavlc and
trellis_8x8_cavlc
       <poirierg>      I'm not saying that I may write it since video coding
isn't my area of expertise... On the other hand, you need to get your
hands dirty to become a video encoding coder....
       I hope what's I'm writing makes sense...
       <Dark_Shikari>  I suspect that trellis is not the best thing to dive into
       because its a very complex algorithm
       Even today, I could not write the cabac trellis algorithm again if I
couldn't see the original
       <poirierg>      and that's because your not a penguin malvaldo ;)
       <Dark_Shikari>  =p
       <poirierg>      J/K
       I think I outta work on porting some more SSE code to AltiVec code
instead of busting my head to the wall with trellis

-- 
One should not give up hope on imbeciles. With a little training, you
can make them into soldiers.
 -- Pierre Desproges



More information about the MEncoder-users mailing list