[FFmpeg-devel] [PATCH] bring -qpfile option of x264 to ffmpeg

Ying Bian bianying
Sun Mar 1 20:03:19 CET 2009


On Sat, Feb 28, 2009 at 9:13 PM, Michael Niedermayer <michaelni at gmx.at>wrote:

> On Sat, Feb 28, 2009 at 06:56:15PM +0800, Ying Bian wrote:
> > On Fri, Feb 27, 2009 at 11:25 PM, Michael Niedermayer <michaelni at gmx.at
> >wrote:
> >
> > > On Fri, Feb 27, 2009 at 10:44:43PM +0800, Ying Bian wrote:
> > > > Hi,
> > > >
> > > > This is a patch which brings the -qpfile option of x264 to ffmpeg.
> > > > See the help message from "x264 --longhelp":
> > > >       --qpfile <string>       Force frametypes and QPs for some or
> all
> > > > frames
> > > >                               Format of each line: framenumber
> frametype
> > > QP
> > > >                               QP of -1 lets x264 choose. Frametypes:
> > > > I,i,P,B,b.
> > > >
> > > > I believe sometimes this is useful.
> > > >
> > > > - by
> > >
> > > > From 2a1f8d36b4895fc00c28bf014756700cf53edf04 Mon Sep 17 00:00:00
> 2001
> > > > From: ybian <bianying at gmail.com>
> > > > Date: Thu, 26 Feb 2009 02:14:28 +0800
> > > > Subject: [PATCH] bring -qpfile option of x264 to ffmpeg
> > > >
> > > > ---
> > > >  libavcodec/avcodec.h |    7 +++++++
> > > >  libavcodec/libx264.c |   43
> +++++++++++++++++++++++++++++++++++++++++++
> > > >  libavcodec/options.c |    1 +
> > > >  3 files changed, 51 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > index f38ad2b..38d2dd0 100644
> > > > --- a/libavcodec/avcodec.h
> > > > +++ b/libavcodec/avcodec.h
> > > > @@ -2315,6 +2315,13 @@ typedef struct AVCodecContext {
> > > >       * - decoding: unused.
> > > >       */
> > > >      float rc_min_vbv_overflow_use;
> > > > +
> > > > +    /**
> > > > +     * qpfile to force frametypes or QPs for some or all frames,
> only
> > > used for libx264
> > > > +     * - encoding: Set by user.
> > > > +     * - decoding: unused.
> > > > +     */
> > > > +    char* qpfile;
> > > >  } AVCodecContext;
> > >
> > > lavc does not access files out of design principles ... (its something
> > > about
> > > the media file not being a file, there being no disk or such ...)
> > >
> > > also setting QPs should be supported over the input AVFrames
> > > its the user apps job (=ffmpeg.c) to read and parse qpfile and
> > > set the fields of the structs.
> > >
> > > now i see and agree this would be code duplication between user apps,
> > > and libav could provide helper functions to do such common tasks but
> that
> > > has to be kept as optional part not as only and mandatory way to
> > > perform something
> > >
> > > [...]
> > > --
> > > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > >
> > > He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
> > >
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG v1.4.9 (GNU/Linux)
> > >
> > > iD8DBQFJqAXvYR7HhwQLD6sRAmq8AJoDZoEZ9sVO2EYt9duJLe/zRUtf6gCgi8cH
> > > kauojvUed2yrpvqu1A093so=
> > > =nx3Y
> > > -----END PGP SIGNATURE-----
> > >
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel at mplayerhq.hu
> > > https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
> > >
> >
> > Michael,
> >
> > Thanks for comments.  As I am new to ffmpeg, can you confirm my following
> > questions?
> >
> > 1. I agree to put the option in the application level.  If I do, I would
> > parse the qpfile (with a helper function)
> >    against ost->frame_number at the beginning of
> ffmpeg.c/do_video_output,
> > and then set the fields of
> >    in_picture structure.  I assume the in_picture.pict_type should be set
> to
> > frame_type from qpfile, but
> >    how to set qp value to in_picture?
>
> AVFrame.quality should work but it might not in which case that need fixing
> ...
> and there is rc_override
>
>
> >
> > 2. Where do you think is the best place to put the parse_qpfile helper
> > function?
>
> a new libavcodec/helper_api.c/h
>
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Many that live deserve death. And some that die deserve life. Can you give
> it to them? Then do not be too eager to deal out death in judgement. For
> even the very wise cannot see all ends. -- Gandalf
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iD8DBQFJqTiDYR7HhwQLD6sRAtOeAJoD1uHIyr5DRsUfDWGimU8GsKHY7gCfboMZ
> GtvbP+DGqIuWE7Mi/HlukYc=
> =PzP6
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>

Michael,

How about this one?  I am not quite sure about the code placement in
ffmpeg.c but
this version seems to work at least with libx264...

- by
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bring-qpfile-option-of-x264-to-ffmpeg-2nd-try.patch
Type: application/octet-stream
Size: 10559 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090302/18f98607/attachment.obj>



More information about the ffmpeg-devel mailing list