[FFmpeg-devel] [PATCH] add ME_T/ESA to avcodec.h

Michael Niedermayer michaelni
Thu Jun 5 02:30:57 CEST 2008


On Wed, Jun 04, 2008 at 11:55:23PM +0100, Robert Swain wrote:
> On 4 Jun 2008, at 21:56, Baptiste Coudurier wrote:
> > Michael Niedermayer wrote:
> >> On Wed, Jun 04, 2008 at 11:18:46AM -0700, Baptiste Coudurier wrote:
> >>> Michael Niedermayer wrote:
> >>>> On Wed, Jun 04, 2008 at 08:09:02AM -0600, Jason Garrett-Glaser  
> >>>> wrote:
> >>>>>> Id just tell users to use FULL if they mean FULL ...
> >>>>> IMO for consistency with other x264 options "esa" should be  
> >>>>> available,
> >>>>> but it should just be an alias for full.  Takes minimal code and  
> >>>>> makes
> >>>> ok
> >>>>
> >>>> but IMHO ESA is not a logic abbreviation for full search, just me  
> >>>> 2 cent
> >>>>
> >>>>
> >>>>> the interface that little bit more user friendly, something that  
> >>>>> is
> >>>>> sorely needed with x264 encoding under ffmpeg.
> >>>> People prefer complaining about problems than working on  
> >>>> solutions ...
> >>>>
> >>> Well I do work on solutions :>
> >>
> >> Me too, ive a half finished per codec defaults change locally ...
> >
> > Awesome !
> 
> I made some patches for this that didn't quite work that used the  
> 'wrong' approach. Baptiste said they should use AVOption instead but I  
> was unaware of this API at the time and by the time I'd finished  
> writing it only to be told it would need rewriting, I didn't have the  
> motivation to fix it up. :)
> 
> If you want to look at what I did, they are patches 0001-0004* here:
> 
> http://www.swains.plus.com/superdump/ffmpeg/patches/
> 
> I would appreciate if you made what you've done available too as I may  
> have some criticisms! :)

Code below,
just put -vpre anime-hq on the command line and have a file with the path
~/.ffmpeg/mpeg4-anime-hq.ffpreset
with all your AVOptoion key=value stuff in it
similar for other codecs.

minor known bug, -vpre must be after -vcodec

Iam planning to commit the code if there are no objections ...


Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 13638)
+++ ffmpeg.c	(working copy)
@@ -3636,6 +3636,41 @@
     return 0;
 }
 
+static int opt_preset(const char *opt, const char *arg)
+{
+    FILE *f;
+    char tmp[100], tmp2[100];
+    char *home= getenv("HOME");
+
+    snprintf(tmp, sizeof(tmp), "%s/.ffmpeg/%s.ffpreset", home, arg);
+    f= fopen(tmp, "r");
+    if(!f){
+        char *codec_name= *opt == 'v' ? video_codec_name :
+                          *opt == 'a' ? audio_codec_name :
+                                        subtitle_codec_name;
+        snprintf(tmp, sizeof(tmp), "%s/.ffmpeg/%s-%s.ffpreset", home, codec_name, arg);
+        f= fopen(tmp, "r");
+    }
+
+    if(!f){
+        fprintf(stderr, "Preset file not found\n");
+        av_exit(1);
+    }
+
+    while(!feof(f)){
+        int e= fscanf(f, "%99[^=]=%99[^\n]\n", tmp, tmp2);
+        if(e!=2){
+            fprintf(stderr, "Preset file invalid\n");
+            av_exit(1);
+        }
+        opt_default(tmp, tmp2);
+    }
+
+    fclose(f);
+
+    return 0;
+}
+
 static const OptionDef options[] = {
     /* main options */
     { "L", OPT_EXIT, {(void*)show_license}, "show license" },
@@ -3758,6 +3793,10 @@
     { "vbsf", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
     { "sbsf", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
 
+    { "apre", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "", "preset" },
+    { "vpre", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "", "preset" },
+    { "spre", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "", "preset" },
+
     { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
     { NULL, },
 };

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080605/6a64694b/attachment.pgp>



More information about the ffmpeg-devel mailing list