[XviD-devel] Two Encoders

peter ross xvid-devel@xvid.org
Mon, 18 Nov 2002 22:24:11 +1100


hi,

>Because Bframe encoding is not finished (I guess). The structure is
>hopefully going to change to something more readable...
>Also, Bframes-SMP is only possible if Bframes are active,
>and I don't trust in out Bframe-decision routines, yet, to use them for
>"production" material. Quality-targeted SMP is always possible.

the FRAMEINFO structure is fairly rock-solid, and i've no intentions
of changing it. if anything, iam plan to consolidate/reshape other
stuctures such that all frame related data is stored in FRAMEINFO.
ie. i'd like to have only

Encoder     -- encoder context
MBParam     -- video-object context. global stuff, like width/height
FRAMEINFO   -- frames/vops
MACROBLOCKS -- macroblocks

RateControl -- ratecontrol with generic update,getquant
                                       (simular to vfw/src/2pass.c)
Bitstream   -- Bitstream reader/writer
IMAGE       -- Image

>But the main point was, that I am looking for ways to multithread
>_without_ having to mess with xvidcore itself ( I don't like the #ifdef
>solutions, and huge ifs even less). Simple calling two or more copies

fair enough. #ifdefs are bad software engineering,
and there's still some of 'em in xvidcore dev-api-3.
in addition to my next commit, i'd like to remove the BFRAMES #defs,
since xvidcore nolonger compiles without BFRAMES.

>the encoder could be a wrapper function. Just call encoder_create(),
>but with a "XVID_MULTIENCODE" flag. Since a pointer to Encoder-Structure
>is passed to the calling routine, internal changes could be done from the
>wrapper, too. Neither the core itself, nor the calling application would
>have to care about SMP or not.

right. here's my suggestion for simple quality-based-smp:

1. modify xvid_encraw (or whatever) such that each thread maintains
   one instance of the encoder.

2. the main/control thread, will instruct each worker thread to encode
   the current frame. obviously, each thread will use different
   encoding settings.

3. the main/control will wait for all the worker threads to finished.
   it will then determine the optimal encoding, ie. which thread
   produced the shortest frame length.

4. copy the internal encoder state of the optimal thread, to all the
   other worker threads (ie. the reference image, and mvs).
   this is the messiest part: i suggest #includ'ing encoder.h into
   xvid_rawenc.c, and perform an image_copy on he reference image.

5. write bitstream frame to disk, read next input frame from source,
   and goto 1.

-- pete

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963