]> git.sesse.net Git - mlt/commitdiff
Drop support for FFmpeg v0.5 and v0.6 and require swscale.
authorDan Dennedy <dan@dennedy.org>
Tue, 19 Mar 2013 04:55:06 +0000 (21:55 -0700)
committerDan Dennedy <dan@dennedy.org>
Sat, 23 Mar 2013 20:06:14 +0000 (13:06 -0700)
This is cleanup work to make way for more version handling to handle
current git master of libav that removes deprecated APIs.

src/modules/avformat/Makefile
src/modules/avformat/configure
src/modules/avformat/consumer_avformat.c
src/modules/avformat/factory.c
src/modules/avformat/filter_avcolour_space.c
src/modules/avformat/filter_avdeinterlace.c
src/modules/avformat/filter_avresample.c
src/modules/avformat/filter_swscale.c
src/modules/avformat/producer_avformat.c

index eceb375934b59b838fa230a520d82d9da5e1899e..0d26b04b8aeaa6d4bd34de3931340ad12eb155bb 100644 (file)
@@ -7,6 +7,7 @@ include config.mak
 LDFLAGS += -lavformat$(AVFORMAT_SUFFIX)
 LDFLAGS += -lavcodec$(AVFORMAT_SUFFIX)
 LDFLAGS += -lavutil$(AVFORMAT_SUFFIX)
+LDFLAGS += -lswscale$(AVFORMAT_SUFFIX)
 LDFLAGS += $(EXTRA_LIBS)
 
 ifndef CODECS
@@ -20,10 +21,8 @@ OBJS = factory.o
 ifdef FILTERS
 OBJS += filter_avcolour_space.o \
            filter_avresample.o \
-           filter_avdeinterlace.o
-ifdef SWSCALE
-OBJS += filter_swscale.o
-endif
+           filter_avdeinterlace.o \
+           filter_swscale.o
 CFLAGS += -DFILTERS
 endif
 
@@ -38,11 +37,6 @@ OBJS += producer_avformat.o \
 CFLAGS += -DCODECS
 endif
 
-ifdef SWSCALE
-CFLAGS += -DSWSCALE
-LDFLAGS += -lswscale$(AVFORMAT_SUFFIX)
-endif
-
 ifdef DEVICES
 CFLAGS += -DAVDEVICE
 LDFLAGS += -lavdevice$(AVFORMAT_SUFFIX)
index c8f55a387071cf2295c4bd6332a4a610739247bc..a919456ac548c5a297998ba5606dca3ac4900d4d 100755 (executable)
@@ -17,7 +17,6 @@ FFmpeg/avformat options:
   --avformat-shared=path  - Link against a shared installation of libavformat (default)
   --avformat-static=path  - Link against a static build of libavformat
   --avformat-ldextra=libs - Provide additional libs to link with
-  --avformat-swscale      - Use libswcale instead of img_convert (with --avformat-static)
   --avformat-suffix=suff  - Specify a custom suffix
   --avformat-no-codecs    - Disable the producer and consumer to avoid the codecs
   --avformat-no-filters   - Disable the filters to make a codecs+muxers-only plugin
@@ -57,7 +56,6 @@ else
        export shared_ffmpeg=
        export extra_libs=
        export avformat_suffix=
-       export swscale=
        export codecs=true
        export filters=true
        export devices=true
@@ -72,8 +70,6 @@ else
                        --avformat-shared=* )   shared_ffmpeg="${i#--avformat-shared=}" ;;
                        --avformat-ldextra=* )  extra_libs="${i#--avformat-ldextra=}" ;;
                        --avformat-suffix=* )   avformat_suffix="${i#--avformat-suffix=}" ;;
-                       --avformat-swscale )    swscale=true ;;
-                       --avformat-swscaler )   swscale=true ;;
                        --avformat-no-codecs )  codecs=false ;;
                        --avformat-no-filters ) filters=false ;;
                        --avformat-no-devices ) devices=false ;;
@@ -91,13 +87,9 @@ else
                        echo "CFLAGS+=-DAVDATADIR=\\\"${static_ffmpeg}/ffpresets/\\\"" >> config.mak
                        echo "CFLAGS+=-I$static_ffmpeg" >> config.mak
                        echo "LDFLAGS+=-L$static_ffmpeg/libavformat -L$static_ffmpeg/libavcodec -L$static_ffmpeg/libavutil" >> config.mak
+                       echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
                        [ $targetos = "Darwin" ] &&
                                echo "LDFLAGS+=-single_module" >> config.mak
-                       if [ "$swscale" != "" ]
-                       then
-                               echo "LDFLAGS+=-L$static_ffmpeg/libswscale" >> config.mak
-                               echo "SWSCALE=1" >> config.mak
-                       fi
                        if [ "$devices" = "true" ]
                        then
                                echo "LDFLAGS+=-L$static_ffmpeg/libavdevice" >> config.mak
@@ -128,18 +120,13 @@ else
                esac
                echo "CFLAGS+=$(pkg-config --cflags libavformat${avformat_suffix})" >> config.mak
                echo "LDFLAGS+=$(pkg-config --libs-only-L libavformat${avformat_suffix})" >> config.mak
+               echo "CFLAGS+=$(pkg-config --cflags libswscale${avformat_suffix})" >> config.mak
+               echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale${avformat_suffix})" >> config.mak
                if [ "$devices" = "true" ]
                then
                        echo "CFLAGS+=$(pkg-config --cflags libavdevice${avformat_suffix})" >> config.mak
                        echo "LDFLAGS+=$(pkg-config --libs-only-L libavdevice${avformat_suffix})" >> config.mak
                fi
-               avcodec_version=$(pkg-config --modversion libavcodec${avformat_suffix})
-               if [ "$swscale" != "" ] || [ $(echo $avcodec_version | cut -d. -f1) -gt 52 ] || ( [ $(echo $avcodec_version | cut -d. -f1) -ge 52 ] && [ $(echo $avcodec_version | cut -d. -f2) -ge 21 ] )
-               then
-                       echo "CFLAGS+=$(pkg-config --cflags libswscale${avformat_suffix})" >> config.mak
-                       echo "LDFLAGS+=$(pkg-config --libs-only-L libswscale${avformat_suffix})" >> config.mak
-                       echo "SWSCALE=1" >> config.mak
-               fi
                
                if [ "$vdpau" = "true" ]
                then
index 4f56dd74d32d8be51fbce12c289809914f4ed774..04a1ac1af10a19f5eaf9cf5d00fa0138dabd173a 100644 (file)
 // avformat header files
 #include <libavformat/avformat.h>
 #include <libavformat/avio.h>
-#ifdef SWSCALE
 #include <libswscale/swscale.h>
-#endif
-#if LIBAVUTIL_VERSION_INT >= ((50<<16)+(8<<8)+0)
 #include <libavutil/pixdesc.h>
-#endif
 #include <libavutil/mathematics.h>
-
-#if LIBAVUTIL_VERSION_INT >= ((50<<16)+(38<<8)+0)
-#  include <libavutil/samplefmt.h>
-#else
-#  define AV_SAMPLE_FMT_NONE SAMPLE_FMT_NONE
-#  define AV_SAMPLE_FMT_U8  SAMPLE_FMT_U8
-#  define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
-#  define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
-#  define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
-#endif
-
-#if LIBAVUTIL_VERSION_INT < (50<<16)
-#define PIX_FMT_RGB32 PIX_FMT_RGBA32
-#define PIX_FMT_YUYV422 PIX_FMT_YUV422
-#endif
+#include <libavutil/samplefmt.h>
 
 #if LIBAVCODEC_VERSION_MAJOR >= 53
 #include <libavutil/opt.h>
@@ -461,12 +443,8 @@ static void apply_properties( void *obj, mlt_properties properties, int flags )
                if ( opt )
 #if LIBAVUTIL_VERSION_INT >= ((51<<16)+(12<<8)+0)
                        av_opt_set( obj, opt_name, mlt_properties_get_value( properties, i), 0 );
-#elif LIBAVCODEC_VERSION_INT >= ((52<<16)+(7<<8)+0)
-                       av_set_string3( obj, opt_name, mlt_properties_get_value( properties, i), alloc, NULL );
-#elif LIBAVCODEC_VERSION_INT >= ((51<<16)+(59<<8)+0)
-                       av_set_string2( obj, opt_name, mlt_properties_get_value( properties, i), alloc );
 #else
-                       av_set_string( obj, opt_name, mlt_properties_get_value( properties, i) );
+                       av_set_string3( obj, opt_name, mlt_properties_get_value( properties, i), alloc, NULL );
 #endif
        }
 }
@@ -634,7 +612,7 @@ static AVStream *add_audio_stream( mlt_consumer consumer, AVFormatContext *oc, A
                apply_properties( c, properties, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM );
 
                int audio_qscale = mlt_properties_get_int( properties, "aq" );
-        if ( audio_qscale > QSCALE_NONE )
+               if ( audio_qscale > QSCALE_NONE )
                {
                        c->flags |= CODEC_FLAG_QSCALE;
                        c->global_quality = FF_QP2LAMBDA * audio_qscale;
@@ -649,15 +627,10 @@ static AVStream *add_audio_stream( mlt_consumer consumer, AVFormatContext *oc, A
                c->channels = channels;
 
                if ( mlt_properties_get( properties, "alang" ) != NULL )
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(43<<8)+0)
 #if LIBAVUTIL_VERSION_INT >= ((51<<16)+(8<<8)+0)
                        av_dict_set( &oc->metadata, "language", mlt_properties_get( properties, "alang" ), 0 );
 #else
                        av_metadata_set2( &oc->metadata, "language", mlt_properties_get( properties, "alang" ), 0 );
-#endif
-#else
-
-                       strncpy( st->language, mlt_properties_get( properties, "alang" ), sizeof( st->language ) );
 #endif
        }
        else
@@ -683,7 +656,6 @@ static int open_audio( mlt_properties properties, AVFormatContext *oc, AVStream
        else
                codec = avcodec_find_encoder( c->codec_id );
 
-#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(122<<8)+0)
        // Process properties as AVOptions on the AVCodec
        if ( codec && codec->priv_class )
        {
@@ -702,7 +674,6 @@ static int open_audio( mlt_properties properties, AVFormatContext *oc, AVStream
                }
                apply_properties( c->priv_data, properties, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM );
        }
-#endif
 
        // Continue if codec found and we can open it
 #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
@@ -840,13 +811,8 @@ static AVStream *add_video_stream( mlt_consumer consumer, AVFormatContext *oc, A
                c->time_base.den = mlt_properties_get_int( properties, "frame_rate_num" );
                if ( st->time_base.den == 0 )
                        st->time_base = c->time_base;
-#if LIBAVUTIL_VERSION_INT >= ((50<<16)+(8<<8)+0)
                c->pix_fmt = pix_fmt ? av_get_pix_fmt( pix_fmt ) : PIX_FMT_YUV420P;
-#else
-               c->pix_fmt = pix_fmt ? avcodec_get_pix_fmt( pix_fmt ) : PIX_FMT_YUV420P;
-#endif
                
-#if LIBAVCODEC_VERSION_INT > ((52<<16)+(28<<8)+0)
                switch ( colorspace )
                {
                case 170:
@@ -865,7 +831,6 @@ static AVStream *add_video_stream( mlt_consumer consumer, AVFormatContext *oc, A
                        c->colorspace = AVCOL_SPC_BT709;
                        break;
                }
-#endif
 
                if ( mlt_properties_get( properties, "aspect" ) )
                {
@@ -878,9 +843,7 @@ static AVStream *add_video_stream( mlt_consumer consumer, AVFormatContext *oc, A
                        c->sample_aspect_ratio.num = mlt_properties_get_int( properties, "sample_aspect_num" );
                        c->sample_aspect_ratio.den = mlt_properties_get_int( properties, "sample_aspect_den" );
                }
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(21<<8)+0)
                st->sample_aspect_ratio = c->sample_aspect_ratio;
-#endif
 
                if ( mlt_properties_get_double( properties, "qscale" ) > 0 )
                {
@@ -1049,7 +1012,6 @@ static int open_video( mlt_properties properties, AVFormatContext *oc, AVStream
        else
                codec = avcodec_find_encoder( video_enc->codec_id );
 
-#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(122<<8)+0)
        // Process properties as AVOptions on the AVCodec
        if ( codec && codec->priv_class )
        {
@@ -1068,7 +1030,6 @@ static int open_video( mlt_properties properties, AVFormatContext *oc, AVStream
                }
                apply_properties( video_enc->priv_data, properties, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM );
        }
-#endif
 
        if( codec && codec->pix_fmts )
        {
@@ -1188,11 +1149,7 @@ static void *consumer_thread( void *arg )
        int count = 0;
 
        // Allocate the context
-#if (LIBAVFORMAT_VERSION_INT >= ((52<<16)+(26<<8)+0))
        AVFormatContext *oc = avformat_alloc_context( );
-#else
-       AVFormatContext *oc = av_alloc_format_context( );
-#endif
 
        // Streams
        AVStream *video_st = NULL;
@@ -1230,27 +1187,15 @@ static void *consumer_thread( void *arg )
 
        // Check for user selected format first
        if ( format != NULL )
-#if LIBAVFORMAT_VERSION_INT < ((52<<16)+(45<<8)+0)
-               fmt = guess_format( format, NULL, NULL );
-#else
                fmt = av_guess_format( format, NULL, NULL );
-#endif
 
        // Otherwise check on the filename
        if ( fmt == NULL && filename != NULL )
-#if LIBAVFORMAT_VERSION_INT < ((52<<16)+(45<<8)+0)
-               fmt = guess_format( NULL, filename, NULL );
-#else
                fmt = av_guess_format( NULL, filename, NULL );
-#endif
 
        // Otherwise default to mpeg
        if ( fmt == NULL )
-#if LIBAVFORMAT_VERSION_INT < ((52<<16)+(45<<8)+0)
-               fmt = guess_format( "mpeg", NULL, NULL );
-#else
                fmt = av_guess_format( "mpeg", NULL, NULL );
-#endif
 
        // We need a filename - default to stdout?
        if ( filename == NULL || !strcmp( filename, "" ) )
@@ -1313,7 +1258,6 @@ static void *consumer_thread( void *arg )
        }
 
        // Write metadata
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0)
        for ( i = 0; i < mlt_properties_count( properties ); i++ )
        {
                char *name = mlt_properties_get_name( properties, i );
@@ -1325,44 +1269,15 @@ static void *consumer_thread( void *arg )
                        {
                                markup[0] = '\0';
                                if ( !strstr( key, ".stream." ) )
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(43<<8)+0)
 #if LIBAVUTIL_VERSION_INT >= ((51<<16)+(8<<8)+0)
                                        av_dict_set( &oc->metadata, key, mlt_properties_get_value( properties, i ), 0 );
 #else
                                        av_metadata_set2( &oc->metadata, key, mlt_properties_get_value( properties, i ), 0 );
-#endif
-#else
-                                       av_metadata_set( &oc->metadata, key, mlt_properties_get_value( properties, i ) );
 #endif
                        }
                        free( key );
                }
        }
-#else
-       char *tmp = NULL;
-       int metavalue;
-
-       tmp = mlt_properties_get( properties, "meta.attr.title.markup");
-       if (tmp != NULL) snprintf( oc->title, sizeof(oc->title), "%s", tmp );
-
-       tmp = mlt_properties_get( properties, "meta.attr.comment.markup");
-       if (tmp != NULL) snprintf( oc->comment, sizeof(oc->comment), "%s", tmp );
-
-       tmp = mlt_properties_get( properties, "meta.attr.author.markup");
-       if (tmp != NULL) snprintf( oc->author, sizeof(oc->author), "%s", tmp );
-
-       tmp = mlt_properties_get( properties, "meta.attr.copyright.markup");
-       if (tmp != NULL) snprintf( oc->copyright, sizeof(oc->copyright), "%s", tmp );
-
-       tmp = mlt_properties_get( properties, "meta.attr.album.markup");
-       if (tmp != NULL) snprintf( oc->album, sizeof(oc->album), "%s", tmp );
-
-       metavalue = mlt_properties_get_int( properties, "meta.attr.year.markup");
-       if (metavalue != 0) oc->year = metavalue;
-
-       metavalue = mlt_properties_get_int( properties, "meta.attr.track.markup");
-       if (metavalue != 0) oc->track = metavalue;
-#endif
 
        oc->oformat = fmt;
        snprintf( oc->filename, sizeof(oc->filename), "%s", filename );
@@ -1437,17 +1352,13 @@ static void *consumer_thread( void *arg )
                {
                        mlt_properties p = mlt_properties_load( fpre );
                        apply_properties( oc, p, AV_OPT_FLAG_ENCODING_PARAM );
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(110<<8)+0)
                        if ( oc->oformat && oc->oformat->priv_class && oc->priv_data )
                                apply_properties( oc->priv_data, p, AV_OPT_FLAG_ENCODING_PARAM );
-#endif
                        mlt_properties_close( p );
                }
                apply_properties( oc, properties, AV_OPT_FLAG_ENCODING_PARAM );
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(110<<8)+0)
                if ( oc->oformat && oc->oformat->priv_class && oc->priv_data )
                        apply_properties( oc->priv_data, properties, AV_OPT_FLAG_ENCODING_PARAM );
-#endif
 
                if ( video_st && !open_video( properties, oc, video_st, vcodec? vcodec : NULL ) )
                        video_st = NULL;
@@ -1791,7 +1702,6 @@ static void *consumer_thread( void *arg )
                                                }
 
                                                // Do the colour space conversion
-#ifdef SWSCALE
                                                int flags = SWS_BICUBIC;
 #ifdef USE_MMX
                                                flags |= SWS_CPU_CAPS_MMX;
@@ -1804,9 +1714,6 @@ static void *consumer_thread( void *arg )
                                                sws_scale( context, (const uint8_t* const*) input->data, input->linesize, 0, height,
                                                        output->data, output->linesize);
                                                sws_freeContext( context );
-#else
-                                               img_convert( ( AVPicture * )output, video_st->codec->pix_fmt, ( AVPicture * )input, PIX_FMT_YUYV422, width, height );
-#endif
 
                                                mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
 
@@ -2050,10 +1957,8 @@ on_fatal_error:
        {
 #if LIBAVFORMAT_VERSION_MAJOR >= 53
                if ( oc->pb  ) avio_close( oc->pb );
-#elif LIBAVFORMAT_VERSION_MAJOR >= 52
-               if ( oc->pb  ) url_fclose( oc->pb );
 #else
-               url_fclose( &oc->pb );
+               if ( oc->pb  ) url_fclose( oc->pb );
 #endif
        }
 
index 6908db8173f2f51a765f128b5f9e52655d13ee76..773a80355a10165d025311c3a5a1b6eaa36ce26a 100644 (file)
@@ -135,10 +135,8 @@ static void *create_service( mlt_profile profile, mlt_service_type type, const c
        if ( !strcmp( id, "avresample" ) )
                return filter_avresample_init( arg );
 #endif
-#ifdef SWSCALE
        if ( !strcmp( id, "swscale" ) )
                return filter_swscale_init( profile, arg );
-#endif
 #endif
        return NULL;
 }
@@ -378,8 +376,6 @@ MLT_REPOSITORY
 #if LIBAVCODEC_VERSION_INT < ((54<<16)+(26<<8)+0)
        MLT_REGISTER( filter_type, "avresample", create_service );
 #endif
-#ifdef SWSCALE
        MLT_REGISTER( filter_type, "swscale", create_service );
 #endif
-#endif
 }
index 3733733ec5aa748a8673e417e275e210cb254bbb..2e5fc6244d597ad620ab315f67537e494687a71b 100644 (file)
 
 // ffmpeg Header files
 #include <libavformat/avformat.h>
-#ifdef SWSCALE
 #include <libswscale/swscale.h>
-#endif
-
-#if LIBAVUTIL_VERSION_INT < (50<<16)
-#define PIX_FMT_YUYV422 PIX_FMT_YUV422
-#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -76,7 +70,6 @@ static int convert_mlt_to_av_cs( mlt_image_format format )
 
 static void set_luma_transfer( struct SwsContext *context, int colorspace, int use_full_range )
 {
-#if defined(SWSCALE) && (LIBSWSCALE_VERSION_INT >= ((0<<16)+(7<<8)+2))
        int *coefficients;
        const int *new_coefficients;
        int full_range;
@@ -109,7 +102,6 @@ static void set_luma_transfer( struct SwsContext *context, int colorspace, int u
                sws_setColorspaceDetails( context, new_coefficients, full_range, new_coefficients, full_range,
                        brightness, contrast, saturation );
        }
-#endif
 }
 
 static void av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt,
@@ -117,7 +109,6 @@ static void av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt
 {
        AVPicture input;
        AVPicture output;
-#ifdef SWSCALE
        int flags = SWS_BICUBIC | SWS_ACCURATE_RND;
 
        if ( out_fmt == PIX_FMT_YUYV422 )
@@ -130,11 +121,9 @@ static void av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt
 #ifdef USE_SSE
        flags |= SWS_CPU_CAPS_MMX2;
 #endif
-#endif /* SWSCALE */
 
        avpicture_fill( &input, in, in_fmt, width, height );
        avpicture_fill( &output, out, out_fmt, width, height );
-#ifdef SWSCALE
        struct SwsContext *context = sws_getContext( width, height, in_fmt,
                width, height, out_fmt, flags, NULL, NULL, NULL);
        if ( context )
@@ -144,9 +133,6 @@ static void av_convert_image( uint8_t *out, uint8_t *in, int out_fmt, int in_fmt
                        output.data, output.linesize);
                sws_freeContext( context );
        }
-#else
-       img_convert( &output, out_fmt, &input, in_fmt, width, height );
-#endif
 }
 
 /** Do it :-).
@@ -319,8 +305,6 @@ static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
 
 mlt_filter filter_avcolour_space_init( void *arg )
 {
-#ifdef SWSCALE
-#if (LIBSWSCALE_VERSION_INT >= ((0<<16)+(7<<8)+2))
        // Test to see if swscale accepts the arg as resolution
        if ( arg )
        {
@@ -334,10 +318,6 @@ mlt_filter filter_avcolour_space_init( void *arg )
                                return NULL;
                }
        }
-#else
-       return NULL;
-#endif
-#endif
        mlt_filter filter = mlt_filter_new( );
        if ( filter != NULL )
                filter->process = filter_process;
index aa1327817b0f866d8744106b14e189d639c97cd7..b4cf0eab78f3dfaf98d486be9da11e9115600538 100644 (file)
@@ -81,10 +81,6 @@ static uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0,};
                     movd_r2m(mm1,dst[0]);
 #endif
 
-#if LIBAVUTIL_VERSION_INT < (50<<16)
-#define PIX_FMT_YUYV422 PIX_FMT_YUV422
-#endif
-
 /* filter parameters: [-1 4 2 4 -1] // 8 */
 static inline void deinterlace_line(uint8_t *dst, 
                             const uint8_t *lum_m4, const uint8_t *lum_m3, 
index 78ea6a57a7025e3c4e7cd418bc97ee8c21b91659..8cc43f2545676abd1b86ec4189df55f9e3dc29fb 100644 (file)
 
 // ffmpeg Header files
 #include <libavformat/avformat.h>
-#if LIBAVUTIL_VERSION_INT >= ((50<<16)+(38<<8)+0)
-#  include <libavutil/samplefmt.h>
-#else
-#  define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
-#endif
+#include <libavutil/samplefmt.h>
 
 #if LIBAVCODEC_VERSION_INT < ((54<<16)+(26<<8)+0)
 
@@ -84,12 +80,8 @@ static int resample_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
                if ( resample == NULL || *frequency != mlt_properties_get_int( filter_properties, "last_frequency" ) )
                {
                        // Create the resampler
-#if (LIBAVCODEC_VERSION_INT >= ((52<<16)+(15<<8)+0))
                        resample = av_audio_resample_init( *channels, *channels, output_rate, *frequency,
                                AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16, 16, 10, 0, 0.8 );
-#else
-                       resample = audio_resample_init( *channels, *channels, output_rate, *frequency );
-#endif
 
                        // And store it on properties
                        mlt_properties_set_data( filter_properties, "audio_resample", resample, 0, ( mlt_destructor )audio_resample_close, NULL );
index 8e88f7c623df199df972d45837415bc52b298fd1..e70a37dad56a0375553d3dbd7c0562f909b16867 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#if LIBAVUTIL_VERSION_INT < (50<<16)
-#define PIX_FMT_RGB32 PIX_FMT_RGBA32
-#define PIX_FMT_YUYV422 PIX_FMT_YUV422
-#endif
-
 static inline int convert_mlt_to_av_cs( mlt_image_format format )
 {
        int value = 0;
index af7e552eeb0f5962848fa48cf13f85b9123e90a6..ff4b9beb59d747d7974096419c3c887e619a7344 100644 (file)
 
 // ffmpeg Header files
 #include <libavformat/avformat.h>
-#ifdef SWSCALE
-#  include <libswscale/swscale.h>
-#endif
-
-#if LIBAVUTIL_VERSION_INT >= ((50<<16)+(38<<8)+0)
-#  include <libavutil/samplefmt.h>
-#else
-#  define AV_SAMPLE_FMT_U8  SAMPLE_FMT_U8
-#  define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
-#  define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
-#  define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
-#  if (LIBAVCODEC_VERSION_INT >= ((51<<16)+(71<<8)+0))
-const char *avcodec_get_sample_fmt_name(int sample_fmt);
-#  endif
-#endif
+#include <libswscale/swscale.h>
+#include <libavutil/samplefmt.h>
+#include <libavutil/pixdesc.h>
 
 #ifdef VDPAU
 #  include <libavcodec/vdpau.h>
 #endif
-#if (LIBAVUTIL_VERSION_INT > ((50<<16)+(7<<8)+0))
-#  include <libavutil/pixdesc.h>
-#endif
 #if (LIBAVUTIL_VERSION_INT >= ((51<<16)+(8<<8)+0))
 #  include <libavutil/dict.h>
 #endif
@@ -63,11 +48,6 @@ const char *avcodec_get_sample_fmt_name(int sample_fmt);
 #include <pthread.h>
 #include <limits.h>
 
-#if LIBAVUTIL_VERSION_INT < (50<<16)
-#define PIX_FMT_RGB32 PIX_FMT_RGBA32
-#define PIX_FMT_YUYV422 PIX_FMT_YUV422
-#endif
-
 #if LIBAVCODEC_VERSION_MAJOR >= 53
 #include <libavutil/opt.h>
 #define CODEC_TYPE_VIDEO      AVMEDIA_TYPE_VIDEO
@@ -82,10 +62,7 @@ const char *avcodec_get_sample_fmt_name(int sample_fmt);
 
 #define MAX_AUDIO_STREAMS (32)
 #define MAX_VDPAU_SURFACES (10)
-
-#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
-#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
-#endif
+#define MAX_AUDIO_FRAME_SIZE (192000) // 1 second of 48khz 32bit audio
 
 struct producer_avformat_s
 {
@@ -341,19 +318,13 @@ static mlt_properties find_default_streams( producer_avformat self )
                                        self->video_index = i;
                                mlt_properties_set( meta_media, key, "video" );
                                snprintf( key, sizeof(key), "meta.media.%d.stream.frame_rate", i );
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(42<<8)+0)
                                double ffmpeg_fps = av_q2d( context->streams[ i ]->avg_frame_rate );
                                if ( isnan( ffmpeg_fps ) || ffmpeg_fps == 0 )
                                        ffmpeg_fps = av_q2d( context->streams[ i ]->r_frame_rate );
                                mlt_properties_set_double( meta_media, key, ffmpeg_fps );
-#else
-                               mlt_properties_set_double( meta_media, key, av_q2d( context->streams[ i ]->r_frame_rate ) );
-#endif
 
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(21<<8)+0)
                                snprintf( key, sizeof(key), "meta.media.%d.stream.sample_aspect_ratio", i );
                                mlt_properties_set_double( meta_media, key, av_q2d( context->streams[ i ]->sample_aspect_ratio ) );
-#endif
                                snprintf( key, sizeof(key), "meta.media.%d.codec.width", i );
                                mlt_properties_set_int( meta_media, key, codec_context->width );
                                snprintf( key, sizeof(key), "meta.media.%d.codec.height", i );
@@ -369,7 +340,6 @@ static mlt_properties find_default_streams( producer_avformat self )
 #endif
                                snprintf( key, sizeof(key), "meta.media.%d.codec.sample_aspect_ratio", i );
                                mlt_properties_set_double( meta_media, key, av_q2d( codec_context->sample_aspect_ratio ) );
-#if LIBAVCODEC_VERSION_INT > ((52<<16)+(28<<8)+0)
                                snprintf( key, sizeof(key), "meta.media.%d.codec.colorspace", i );
                                switch ( codec_context->colorspace )
                                {
@@ -388,7 +358,6 @@ static mlt_properties find_default_streams( producer_avformat self )
                                        mlt_properties_set_int( meta_media, key, codec_context->width * codec_context->height > 750000 ? 709 : 601 );
                                        break;
                                }
-#endif
                                break;
                        case CODEC_TYPE_AUDIO:
                                if ( !codec_context->channels )
@@ -398,13 +367,8 @@ static mlt_properties find_default_streams( producer_avformat self )
                                        self->audio_index = i;
 
                                mlt_properties_set( meta_media, key, "audio" );
-#if LIBAVUTIL_VERSION_INT >= ((50<<16)+(38<<8)+0)
                                snprintf( key, sizeof(key), "meta.media.%d.codec.sample_fmt", i );
                                mlt_properties_set( meta_media, key, av_get_sample_fmt_name( codec_context->sample_fmt ) );
-#elif (LIBAVCODEC_VERSION_INT >= ((51<<16)+(71<<8)+0))
-                               snprintf( key, sizeof(key), "meta.media.%d.codec.sample_fmt", i );
-                               mlt_properties_set( meta_media, key, avcodec_get_sample_fmt_name( codec_context->sample_fmt ) );
-#endif
                                snprintf( key, sizeof(key), "meta.media.%d.codec.sample_rate", i );
                                mlt_properties_set_int( meta_media, key, codec_context->sample_rate );
                                snprintf( key, sizeof(key), "meta.media.%d.codec.channels", i );
@@ -417,10 +381,8 @@ static mlt_properties find_default_streams( producer_avformat self )
 //             mlt_properties_set_double( meta_media, key, av_q2d( context->streams[ i ]->time_base ) );
                snprintf( key, sizeof(key), "meta.media.%d.codec.name", i );
                mlt_properties_set( meta_media, key, codec->name );
-#if (LIBAVCODEC_VERSION_INT >= ((51<<16)+(55<<8)+0))
                snprintf( key, sizeof(key), "meta.media.%d.codec.long_name", i );
                mlt_properties_set( meta_media, key, codec->long_name );
-#endif
                snprintf( key, sizeof(key), "meta.media.%d.codec.bit_rate", i );
                mlt_properties_set_int( meta_media, key, codec_context->bit_rate );
 //             snprintf( key, sizeof(key), "meta.media.%d.codec.time_base", i );
@@ -431,7 +393,6 @@ static mlt_properties find_default_streams( producer_avformat self )
 //             mlt_properties_set_int( meta_media, key, codec_context->level );
 
                // Read Metadata
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0)
 #if LIBAVUTIL_VERSION_INT >= ((51<<16)+(8<<8)+0)
                while ( ( tag = av_dict_get( stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX ) ) )
 #else
@@ -444,9 +405,7 @@ static mlt_properties find_default_streams( producer_avformat self )
                                mlt_properties_set( meta_media, key, tag->value );
                        }
                }
-#endif
        }
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0)
 #if LIBAVUTIL_VERSION_INT >= ((51<<16)+(8<<8)+0)
        while ( ( tag = av_dict_get( context->metadata, "", tag, AV_DICT_IGNORE_SUFFIX ) ) )
 #else
@@ -459,22 +418,6 @@ static mlt_properties find_default_streams( producer_avformat self )
                        mlt_properties_set( meta_media, key, tag->value );
                }
        }
-#else
-       if ( context->title && strcmp( context->title, "" ) )
-               mlt_properties_set(properties, "meta.attr.title.markup", context->title );
-       if ( context->author && strcmp( context->author, "" ) )
-               mlt_properties_set(properties, "meta.attr.author.markup", context->author );
-       if ( context->copyright && strcmp( context->copyright, "" ) )
-               mlt_properties_set(properties, "meta.attr.copyright.markup", context->copyright );
-       if ( context->comment )
-               mlt_properties_set(properties, "meta.attr.comment.markup", context->comment );
-       if ( context->album )
-               mlt_properties_set(properties, "meta.attr.album.markup", context->album );
-       if ( context->year )
-               mlt_properties_set_int(properties, "meta.attr.year.markup", context->year );
-       if ( context->track )
-               mlt_properties_set_int(properties, "meta.attr.track.markup", context->track );
-#endif
 
        return meta_media;
 }
@@ -536,12 +479,7 @@ static double get_aspect_ratio( mlt_properties properties, AVStream *stream, AVC
                }
                else
                {
-                       AVRational ar =
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(21<<8)+0)
-                               stream->sample_aspect_ratio;
-#else
-                               codec_context->sample_aspect_ratio;
-#endif
+                       AVRational ar = stream->sample_aspect_ratio;
                        // Override FFmpeg's notion of DV aspect ratios, which are
                        // based upon a width of 704. Since we do not have a normaliser
                        // that crops (nor is cropping 720 wide ITU-R 601 video always desirable)
@@ -577,12 +515,7 @@ static double get_aspect_ratio( mlt_properties properties, AVStream *stream, AVC
        else
        {
                AVRational codec_sar = codec_context->sample_aspect_ratio;
-               AVRational stream_sar =
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(21<<8)+0)
-                       stream->sample_aspect_ratio;
-#else
-                       { 0, 1 };
-#endif
+               AVRational stream_sar = stream->sample_aspect_ratio;
                if ( codec_sar.num > 0 )
                {
                        mlt_properties_set_int( properties, "meta.media.sample_aspect_num", codec_sar.num );
@@ -692,10 +625,8 @@ static char* parse_url( mlt_profile profile, const char* URL, AVInputFormat **fo
                                                params->channel = atoi( value );
                                        else if ( !strcmp( name, "channels" ) )
                                                params->channels = atoi( value );
-#if (LIBAVUTIL_VERSION_INT > ((50<<16)+(7<<8)+0))
                                        else if ( !strcmp( name, "pix_fmt" ) )
                                                params->pix_fmt = av_get_pix_fmt( value );
-#endif
                                        else if ( !strcmp( name, "width" ) )
                                                params->width = atoi( value );
                                        else if ( !strcmp( name, "height" ) )
@@ -829,7 +760,6 @@ static int get_basic_info( producer_avformat self, mlt_profile profile, const ch
                        get_aspect_ratio( properties, format->streams[ self->video_index ], codec_context, NULL );
                }
 
-#ifdef SWSCALE
                // Verify that we can convert this to YUV 4:2:2
                // TODO: we can now also return RGB and RGBA and quite possibly more in the future.
                struct SwsContext *context = sws_getContext( codec_context->width, codec_context->height, codec_context->pix_fmt,
@@ -838,7 +768,6 @@ static int get_basic_info( producer_avformat self, mlt_profile profile, const ch
                        sws_freeContext( context );
                else
                        error = 1;
-#endif
        }
        return error;
 }
@@ -895,10 +824,8 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha
        if ( !error && self->video_format )
        {
                apply_properties( self->video_format, properties, AV_OPT_FLAG_DECODING_PARAM );
-#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(110<<8)+0)
                if ( self->video_format->iformat && self->video_format->iformat->priv_class && self->video_format->priv_data )
                        apply_properties( self->video_format->priv_data, properties, AV_OPT_FLAG_DECODING_PARAM );
-#endif
        }
 
 #if LIBAVFORMAT_VERSION_INT > ((53<<16)+(6<<8)+0)
@@ -1212,7 +1139,6 @@ static void get_audio_streams_info( producer_avformat self )
 
 static void set_luma_transfer( struct SwsContext *context, int colorspace, int use_full_range )
 {
-#if defined(SWSCALE) && (LIBSWSCALE_VERSION_INT >= ((0<<16)+(7<<8)+2))
        int *coefficients;
        const int *new_coefficients;
        int full_range;
@@ -1245,7 +1171,6 @@ static void set_luma_transfer( struct SwsContext *context, int colorspace, int u
                sws_setColorspaceDetails( context, new_coefficients, full_range, new_coefficients, full_range,
                        brightness, contrast, saturation );
        }
-#endif
 }
 
 static mlt_image_format pick_pix_format( enum PixelFormat pix_fmt )
@@ -1306,7 +1231,6 @@ static mlt_audio_format pick_audio_format( int sample_fmt )
 static void convert_image( producer_avformat self, AVFrame *frame, uint8_t *buffer, int pix_fmt,
        mlt_image_format *format, int width, int height, uint8_t **alpha )
 {
-#ifdef SWSCALE
        int flags = SWS_BICUBIC | SWS_ACCURATE_RND;
 
 #ifdef USE_MMX
@@ -1384,37 +1308,6 @@ static void convert_image( producer_avformat self, AVFrame *frame, uint8_t *buff
                        output.data, output.linesize);
                sws_freeContext( context );
        }
-#else
-       if ( *format == mlt_image_yuv420p )
-       {
-               AVPicture pict;
-               pict.data[0] = buffer;
-               pict.data[1] = buffer + width * height;
-               pict.data[2] = buffer + ( 5 * width * height ) / 4;
-               pict.linesize[0] = width;
-               pict.linesize[1] = width >> 1;
-               pict.linesize[2] = width >> 1;
-               img_convert( &pict, PIX_FMT_YUV420P, (AVPicture *)frame, pix_fmt, width, height );
-       }
-       else if ( *format == mlt_image_rgb24 )
-       {
-               AVPicture output;
-               avpicture_fill( &output, buffer, PIX_FMT_RGB24, width, height );
-               img_convert( &output, PIX_FMT_RGB24, (AVPicture *)frame, pix_fmt, width, height );
-       }
-       else if ( *format == mlt_image_rgb24a || *format == mlt_image_opengl )
-       {
-               AVPicture output;
-               avpicture_fill( &output, buffer, PIX_FMT_RGB32, width, height );
-               img_convert( &output, PIX_FMT_RGB32, (AVPicture *)frame, pix_fmt, width, height );
-       }
-       else
-       {
-               AVPicture output;
-               avpicture_fill( &output, buffer, PIX_FMT_YUYV422, width, height );
-               img_convert( &output, PIX_FMT_YUYV422, (AVPicture *)frame, pix_fmt, width, height );
-       }
-#endif
 }
 
 /** Allocate the image buffer and set it on the frame.
@@ -2392,7 +2285,7 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
                        sizeof_sample = sample_bytes( codec_context );
 
                        // Check for audio buffer and create if necessary
-                       self->audio_buffer_size[ index ] = AVCODEC_MAX_AUDIO_FRAME_SIZE * sizeof_sample;
+                       self->audio_buffer_size[ index ] = MAX_AUDIO_FRAME_SIZE * sizeof_sample;
                        self->audio_buffer[ index ] = mlt_pool_alloc( self->audio_buffer_size[ index ] );
 
                        // Check for decoder buffer and create if necessary
@@ -2601,10 +2494,8 @@ static int audio_codec_init( producer_avformat self, int index, mlt_properties p
 
                // Process properties as AVOptions
                apply_properties( codec_context, properties, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM );
-#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(122<<8)+0)
                if ( codec && codec->priv_class && codec_context->priv_data )
                        apply_properties( codec_context->priv_data, properties, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM );
-#endif
        }
        return self->audio_codec[ index ] && self->audio_index > -1;
 }