[Ffmpeg-devel] [PATCH] Add Dirac support to ffmpeg]

Andrew Kennedy andrew.kennedy
Thu Aug 25 18:00:31 CEST 2005

**Amended Dirac patch for ffmpeg
**Tested with ffmpeg cvs (as of August 25, 2005 10:00am)
**Author(s): Andrew Kennedy (dirac_dev at users.sourceforge.net) (main)
              Anuradha Suraparaju (asuraparaju at users.sourceforge.net)
              (minor mods)

Dirac is an open-source video codec currently under development. Both
the encoder and decoder have been integrated with ffmpeg. This patch is
only a basic integration such that only the salient paremeters are
currently passed from ffmpeg to Dirac. As Dirac develops, especially
with the integration of  a formalised bit-stream syntax,  then more
complex screnarios can be dealt with. Encoded Dirac files, with the
right patch, can be played back using MPlayer.

Please feel free to modify/add-to the code.

These are the instructions for enabling Dirac support in ffmpeg source

1. Download Dirac from sourceforge and build and install Dirac
    cvs -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/dirac login

     cvs -z3 -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/dirac co -P 

    cd compress
    make install

    The last step installs the Dirac share encoder and decoder libraries
    in /usr/local/lib (which is the default install point).

2. Download ffmpeg from cvs
    cvs -z9 -d:pserver:anonymous at mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg

3. Apply the patch

    cd ffmpeg
    patch -p1 < ffmpeg-dirac-patch.txt

4. Build and Install

    ./configure --enable-dirac
    make install

The option '--enable-dirac' must be used during configuration in order
to pick-up the Dirac code during building.

Sample Usage: (encoding)
ffmpeg -s 720x576 -i input_file.yuv -vcodec dirac -qscale 15 dirac_output.drc

The output from the encoder is exactly as it is written to the .drc
encoded file. Dirac bit-rate is controlled by a quality-factor (currently a 
basic intepretation from
qscale. A qscale of 1 maps to dirac quality factor 10 and 30 maps to
quality factor 1). Dirac bitstreams can be wrapped in avi by using the
-f avi option.

ffmpeg -i input.drc output.yuv


At 21:28 25/07/2005, you wrote:
>On Monday 25 July 2005 17:48, Andrew Kennedy wrote:
> > Hi,
> >
> > I've altered the code in line with your recommendations. However, I'm still
> >
> > not entirely clear about the following:
> > >and if i understand the demuxing code in drc.c correctly, then it does
> > > only split the stream into packets, this should be done in a AVParser
> > > instead for raw "containers", and the remaining (de)muxing code might fit
> > > better in libavformat/raw.c instead of a separate file, but a separate
> > > file is fine too if preferred
> >
> > So, if I understand this correctly, the parsing code in drc.c is shifted to
> > parser.c (or a suitable place to use a Dirac parser). This then receives
> > data from the 'raw' file read in raw.c. Is this correct?
>yes, but let me explain why it should be done that way
>if there is just one container format and one codec then it doesnt matter 
>where the spliting into packets is done but if there are several container
>formats like lets say a raw "container" which just stores everything from the
>encoder without any headers, a container like mpeg-ps which has headers but
>no knowledge of the frame/packet boundaries either and a container like avi
>or quicktime which has knowledge of frame/packet boundaries
>now if you wish to copy the video stream without decoding&reencoding it from
>either the raw or mpeg-ps formats into mov/avi/... then you need to split it
>into 1-frame packets but if that code is not demuxer independent then it
>would need to be duplicated for every demuxer which doesnt know about frame
>boundaries (raw, mpeg-ps, mpeg-ts, ...)
> > I thought
> > av_read_frame() should read an entire frame of data, so I'm not clear how
> > this is now possible. Are you saying that I should use the boolean in
> > avcodec_decode_video() because the frame boundaries will now be split
> > across packets? Please can you elaborate.
>av_read_frame() uses the AVParser if one is available to change the input
>stream of random chunks into 1-frame packets (see av_read_frame() in utils.c)
>ffmpeg-devel mailing list
>ffmpeg-devel at mplayerhq.hu
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ffmpeg-dirac-patch.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20050825/aab6d926/attachment.txt>

More information about the ffmpeg-devel mailing list