[xiph-commits] r15368 - in trunk/ffmpeg2theora: . scons-tools src

j at svn.xiph.org j at svn.xiph.org
Fri Oct 3 07:50:10 PDT 2008


Author: j
Date: 2008-10-03 07:50:09 -0700 (Fri, 03 Oct 2008)
New Revision: 15368

Added:
   trunk/ffmpeg2theora/scons-tools/
   trunk/ffmpeg2theora/scons-tools/crossmingw.py
Modified:
   trunk/ffmpeg2theora/
   trunk/ffmpeg2theora/SConstruct
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
- add mingw cross compile to scons script
- fix pkg-config tests on Mac OS X
- add -D_FILE_OFFSET_BITS=64 to support large files again
- make framehook conditional, ffmpeg no longer installs this
  (needs porting to libavfilter)



Property changes on: trunk/ffmpeg2theora
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2008-10-02 20:09:39.670000076 +0200
committer: j
properties: 
	branch-nick: ffmpeg2theora

   + timestamp: 2008-10-03 16:34:08.151000023 +0200
committer: j
properties: 
	branch-nick: ffmpeg2theora

Name: bzr:file-ids
   - src/ffmpeg2theora.c	6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.c

   + SConstruct	sconstruct-20080523165848-8nlost8hilp0zdcm-1
scons-tools	sconstools-20081003133654-zl51dx2gdl5y97oz-1
scons-tools/crossmingw.py	crossmingw.py-20081003133654-zl51dx2gdl5y97oz-2
src/ffmpeg2theora.c	6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.c

Name: bzr:revision-id:v3-single1-dHJ1bmsvZmZtcGVnMnRoZW9yYQ..
   - 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld
207 j-20080527205840-zeestdde3v1zks9k
208 j-20080527210129-e73y56uwmzbcid00
209 j-20080527211813-5ll680ed1q4byp16
210 j-20080528102006-aeippim0tn70mz3f
211 j-20080528104907-40kiidjojvta8j61
212 j-20080528111329-vkqbt7xkat2o9h4z
213 j-20080529102940-q9xdwm5v9espzomv
214 j-20080529111405-nmh99aon1kmh22qm
215 j-20080530094948-ncq064s4uggd9z95
216 j-20080530095056-hko2vjfwipikwjyu
217 j-20080530171822-bab8sy8lpotf8081
218 j-20080603170442-v0pxspvfcucvsaex
219 j-20080617110355-xwbeg1xidmv8fubp
220 j-20080617110518-khqlhaan52kz3lii
221 j-20080723194934-63m20dc3zmkhwj4o
222 j-20080724140108-ntgbrk6913nvtk4b
223 j-20080802221321-3fcp0s6rehryx0n5
224 j-20080802221340-0s6mh8llk6nyon5d
225 j-20080901112127-tyeax385hwukjt13
226 j-20080915075112-fg3yc8radbplosnc
227 j-20080921103515-w89p8jqwt3oq5u20
228 j-20080921103703-prnl3ls2f6u4g177
229 j-20080921104137-otk3xx827h5cofwl
230 j-20080921104242-dswny7jm93stokej
231 j-20081001102101-rl2rf1x9u8e5zrqk
232 j-20081001103246-0uwni13nt5b2mqyw
233 j-20081001104039-68e6rbv58e743plv
234 j-20081001111423-31lxb69fs7023eqi
235 j-20081001112345-eo9e3eheszd68pkb
236 j-20081002180939-vwdafec5iu2ihyq6

   + 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld
207 j-20080527205840-zeestdde3v1zks9k
208 j-20080527210129-e73y56uwmzbcid00
209 j-20080527211813-5ll680ed1q4byp16
210 j-20080528102006-aeippim0tn70mz3f
211 j-20080528104907-40kiidjojvta8j61
212 j-20080528111329-vkqbt7xkat2o9h4z
213 j-20080529102940-q9xdwm5v9espzomv
214 j-20080529111405-nmh99aon1kmh22qm
215 j-20080530094948-ncq064s4uggd9z95
216 j-20080530095056-hko2vjfwipikwjyu
217 j-20080530171822-bab8sy8lpotf8081
218 j-20080603170442-v0pxspvfcucvsaex
219 j-20080617110355-xwbeg1xidmv8fubp
220 j-20080617110518-khqlhaan52kz3lii
221 j-20080723194934-63m20dc3zmkhwj4o
222 j-20080724140108-ntgbrk6913nvtk4b
223 j-20080802221321-3fcp0s6rehryx0n5
224 j-20080802221340-0s6mh8llk6nyon5d
225 j-20080901112127-tyeax385hwukjt13
226 j-20080915075112-fg3yc8radbplosnc
227 j-20080921103515-w89p8jqwt3oq5u20
228 j-20080921103703-prnl3ls2f6u4g177
229 j-20080921104137-otk3xx827h5cofwl
230 j-20080921104242-dswny7jm93stokej
231 j-20081001102101-rl2rf1x9u8e5zrqk
232 j-20081001103246-0uwni13nt5b2mqyw
233 j-20081001104039-68e6rbv58e743plv
234 j-20081001111423-31lxb69fs7023eqi
235 j-20081001112345-eo9e3eheszd68pkb
236 j-20081002180939-vwdafec5iu2ihyq6
237 j-20081003143408-49wdpdkvhnf719rq


Modified: trunk/ffmpeg2theora/SConstruct
===================================================================
--- trunk/ffmpeg2theora/SConstruct	2008-10-03 14:49:57 UTC (rev 15367)
+++ trunk/ffmpeg2theora/SConstruct	2008-10-03 14:50:09 UTC (rev 15368)
@@ -8,6 +8,14 @@
 pkg_version="0.21+svn"
 pkg_name="ffmpeg2theora"
 
+scons_version=(0,98,0)
+
+try:
+    EnsureSConsVersion(*scons_version)
+except TypeError:
+    print 'SCons %d.%d.%d or greater is required, but you have an older version' % scons_version
+    Exit(2)
+
 opts = Options()
 opts.AddOptions(
   BoolOption('static', 'Set to 1 for static linking', 0),
@@ -17,7 +25,8 @@
   ('mandir', 'man documentation', 'PREFIX/man'),
   ('destdir', 'extra install time prefix', ''),
   ('APPEND_CCFLAGS', 'Additional C/C++ compiler flags'),
-  ('APPEND_LINKFLAGS', 'Additional linker flags')
+  ('APPEND_LINKFLAGS', 'Additional linker flags'),
+  BoolOption('crossmingw', 'Set to 1 for crosscompile with mingw', 0)
 )
 env = Environment(options = opts)
 Help(opts.GenerateHelpText(env))
@@ -27,6 +36,9 @@
   pkg_flags+=" --static"
   env.Append(LINKFLAGS=["-static"])
 
+if env['crossmingw']:
+    env.Tool('crossmingw', toolpath = ['scons-tools'])
+
 prefix = env['prefix']
 if env['destdir']:
   if prefix.startswith('/'): prefix = prefix[1:]
@@ -39,16 +51,28 @@
   '-DPACKAGE_VERSION=\\"%s\\"' % pkg_version,
   '-DPACKAGE_STRING=\\"%s-%s\\"' % (pkg_name, pkg_version),
   '-DPACKAGE=\\"%s\\"' % pkg_name,
+  '-D_FILE_OFFSET_BITS=64'
 ])
+
 env.Append(CCFLAGS = Split('$APPEND_CCFLAGS'))
 env.Append(LINKFLAGS = Split('$APPEND_LINKFLAGS'))
 
 if env['debug'] and env['CC'] == 'gcc':
   env.Append(CCFLAGS=["-g", "-O2", "-Wall"])
 
+if GetOption("help"):
+    Return()
+
+def TryAction(action):
+    import os
+    ret = os.system(action)
+    if ret == 0:
+        return (1, '')
+    return (0, '')
+
 def CheckPKGConfig(context, version): 
   context.Message( 'Checking for pkg-config... ' ) 
-  ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0] 
+  ret = TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0] 
   context.Result( ret ) 
   return ret 
 
@@ -58,7 +82,7 @@
     action = 'PKG_CONFIG_PATH=%s pkg-config --exists "%s"' % (os.environ['PKG_CONFIG_PATH'], name)
   else:
     action = 'pkg-config --exists "%s"' % name
-  ret = context.TryAction(action)[0]
+  ret = TryAction(action)[0]
   context.Result( ret ) 
   return ret
 
@@ -66,9 +90,10 @@
   'CheckPKGConfig' : CheckPKGConfig,
   'CheckPKG' : CheckPKG,
   })
-  
-if not conf.CheckPKGConfig('0.15.0'): 
-   print 'pkg-config >= 0.15.0 not found.' 
+
+pkg_version='0.15.0'
+if not conf.CheckPKGConfig(pkg_version): 
+   print 'pkg-config >= %s not found.' % pkg_version 
    Exit(1)
 
 XIPH_LIBS="ogg >= 1.1 vorbis vorbisenc theora >= 1.0beta1"
@@ -93,6 +118,11 @@
 for lib in FFMPEG_LIBS.split():
     env.ParseConfig('pkg-config %s "%s"' % (pkg_flags, lib))
 
+if conf.CheckCHeader('libavformat/framehook.h'):
+    env.Append(CCFLAGS=[
+      '-DHAVE_FRAMEHOOK'
+    ])
+
 KATE_LIBS="oggkate"
 if os.path.exists("./libkate/misc/pkgconfig"):
   os.environ['PKG_CONFIG_PATH'] = "./libkate/misc/pkgconfig:" + os.environ.get('PKG_CONFIG_PATH', '')
@@ -110,7 +140,7 @@
 env = conf.Finish()
 
 # ffmpeg2theora 
-ffmpeg2theora = env.Copy()
+ffmpeg2theora = env.Clone()
 ffmpeg2theora_sources = glob('src/*.c')
 ffmpeg2theora.Program('ffmpeg2theora', ffmpeg2theora_sources)
 

Added: trunk/ffmpeg2theora/scons-tools/crossmingw.py
===================================================================
--- trunk/ffmpeg2theora/scons-tools/crossmingw.py	                        (rev 0)
+++ trunk/ffmpeg2theora/scons-tools/crossmingw.py	2008-10-03 14:50:09 UTC (rev 15368)
@@ -0,0 +1,167 @@
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "crossmingw.py 0.96.90.D001 2005/02/15 20:11:37 knight"
+
+import os
+import os.path
+import string
+
+import SCons.Action
+import SCons.Builder
+import SCons.Tool
+import SCons.Util
+
+# This is what we search for to find mingw:
+prefixes = SCons.Util.Split("""
+    mingw32-
+    mingw32msvc-
+    i386-mingw32-
+    i486-mingw32-
+    i586-mingw32-
+    i686-mingw32-
+    i386-mingw32msvc-
+    i486-mingw32msvc-
+    i586-mingw32msvc-
+    i686-mingw32msvc-
+""")
+
+def find(env):
+    for prefix in prefixes:
+        # First search in the SCons path and then the OS path:
+        if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'):
+            return prefix
+
+    return ''
+
+def shlib_generator(target, source, env, for_signature):
+    cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS']) 
+
+    dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+    if dll: cmd.extend(['-o', dll])
+
+    cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS'])
+
+    implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
+    if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature))
+
+    def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+    if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature))
+
+    return [cmd]
+
+def shlib_emitter(target, source, env):
+    dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+    no_import_lib = env.get('no_import_lib', 0)
+
+    if not dll:
+        raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+    
+    if not no_import_lib and \
+       not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
+
+        # Append an import library to the list of targets.
+        target.append(env.ReplaceIxes(dll,  
+                                      'SHLIBPREFIX', 'SHLIBSUFFIX',
+                                      'LIBPREFIX', 'LIBSUFFIX'))
+
+    # Append a def file target if there isn't already a def file target
+    # or a def file source. There is no option to disable def file
+    # target emitting, because I can't figure out why someone would ever
+    # want to turn it off.
+    def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+    def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+    if not def_source and not def_target:
+        target.append(env.ReplaceIxes(dll,  
+                                      'SHLIBPREFIX', 'SHLIBSUFFIX',
+                                      'WIN32DEFPREFIX', 'WIN32DEFSUFFIX'))
+    
+    return (target, source)
+                         
+
+shlib_action = SCons.Action.Action(shlib_generator, generator=1)
+
+res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
+
+res_builder = SCons.Builder.Builder(action=res_action, suffix='.o',
+                                    source_scanner=SCons.Tool.SourceFileScanner)
+SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
+
+def generate(env):
+    mingw_prefix = find(env)
+
+    if mingw_prefix:
+        dir = os.path.dirname(env.WhereIs(mingw_prefix + 'gcc') or SCons.Util.WhereIs(mingw_prefix + 'gcc'))
+
+        # The mingw bin directory must be added to the path:
+        path = env['ENV'].get('PATH', [])
+        if not path: 
+            path = []
+        if SCons.Util.is_String(path):
+            path = string.split(path, os.pathsep)
+
+        env['ENV']['PATH'] = string.join([dir] + path, os.pathsep)
+
+    # Most of mingw is the same as gcc and friends...
+    gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas']
+    for tool in gnu_tools:
+        SCons.Tool.Tool(tool)(env)
+
+    #... but a few things differ:
+    env['CC'] = mingw_prefix + 'gcc'
+    env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+    env['CXX'] = mingw_prefix + 'g++'
+    env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
+    env['SHLINKCOM']   = shlib_action
+    env.Append(SHLIBEMITTER = [shlib_emitter])
+    env['LINK'] = mingw_prefix + 'g++'
+    env['AS'] = mingw_prefix + 'as'
+    env['WIN32DEFPREFIX']        = ''
+    env['WIN32DEFSUFFIX']        = '.def'
+    env['SHOBJSUFFIX'] = '.o'
+    env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+    env['RC'] = mingw_prefix + 'windres'
+    env['RCFLAGS'] = SCons.Util.CLVar('')
+    env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS ${INCPREFIX}${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
+    env['BUILDERS']['RES'] = res_builder
+    
+    # Some setting from the platform also have to be overridden:
+    env['OBJPREFIX']      = ''
+    env['OBJSUFFIX']      = '.o'
+    env['LIBPREFIX']      = 'lib'
+    env['LIBSUFFIX']      = '.a'
+    env['SHOBJPREFIX']    = '$OBJPREFIX'
+    env['SHOBJSUFFIX']    = '$OBJSUFFIX'
+    env['PROGPREFIX']     = ''
+    env['PROGSUFFIX']     = '.exe'
+    env['LIBPREFIX']      = ''
+    env['LIBSUFFIX']      = '.lib'
+    env['SHLIBPREFIX']    = ''
+    env['SHLIBSUFFIX']    = '.dll'
+    env['LIBPREFIXES']    = [ '$LIBPREFIX' ]
+    env['LIBSUFFIXES']    = [ '$LIBSUFFIX' ]
+
+def exists(env):
+    return find(env)

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2008-10-03 14:49:57 UTC (rev 15367)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2008-10-03 14:50:09 UTC (rev 15368)
@@ -29,7 +29,9 @@
 
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
+#ifdef HAVE_FRAMEHOOK
 #include "libavformat/framehook.h"
+#endif
 #include "libswscale/swscale.h"
 #include "libpostproc/postprocess.h"
 
@@ -852,9 +854,10 @@
                                                venc->width, venc->height,
                                                output->qscale_table, output->qstride,
                                                ppMode, ppContext, this->pix_fmt);
+#ifdef HAVE_FRAMEHOOK
                             if(this->vhook)
                                 frame_hook_process((AVPicture *)output, this->pix_fmt, venc->width,venc->height, 0);
-
+#endif
                             if (this->frame_topBand || this->frame_leftBand) {
                                 if (av_picture_crop((AVPicture *)output_tmp, (AVPicture *)output,
                                     this->pix_fmt, this->frame_topBand, this->frame_leftBand) < 0) {
@@ -1032,6 +1035,7 @@
 
 static void add_frame_hooker(const char *arg)
 {
+#ifdef HAVE_FRAMEHOOK
     int argc = 0;
     char *argv[64];
     int i;
@@ -1046,6 +1050,7 @@
         fprintf(stderr, "Failed to add video hook function: %s\n", arg);
         exit(1);
     }
+#endif
 }
 
 AVRational get_framerate(const char* arg)
@@ -1177,8 +1182,10 @@
         "Input options:\n"
         "      --deinterlace      force deinterlace, otherwise only material\n"
         "                          marked as interlaced will be deinterlaced\n"
+#ifdef HAVE_FRAMEHOOK
         "      --vhook            you can use ffmpeg's vhook system, example:\n"
         "        ffmpeg2theora --vhook '/path/watermark.so -f wm.gif' input.dv\n"
+#endif
         "  -f, --format           specify input format\n"
         "      --inputfps fps     override input fps\n"
         "      --audiostream id   by default the last audio stream is selected,\n"
@@ -1278,7 +1285,9 @@
       {"contrast",required_argument,NULL,'C'},
       {"saturation",required_argument,NULL,'Z'},
       {"nosound",0,&flag,NOSOUND_FLAG},
+#ifdef HAVE_FRAMEHOOK
       {"vhook",required_argument,&flag,VHOOK_FLAG},
+#endif
       {"framerate",required_argument,NULL,'F'},
       {"aspect",required_argument,&flag,ASPECT_FLAG},
       {"v2v-preset",required_argument,NULL,'p'},



More information about the commits mailing list