LDFLAGS += -lavformat$(AVFORMAT_SUFFIX)
LDFLAGS += -lavcodec$(AVFORMAT_SUFFIX)
LDFLAGS += -lavutil$(AVFORMAT_SUFFIX)
+LDFLAGS += -lswscale$(AVFORMAT_SUFFIX)
LDFLAGS += $(EXTRA_LIBS)
ifndef CODECS
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
CFLAGS += -DCODECS
endif
-ifdef SWSCALE
-CFLAGS += -DSWSCALE
-LDFLAGS += -lswscale$(AVFORMAT_SUFFIX)
-endif
-
ifdef DEVICES
CFLAGS += -DAVDEVICE
LDFLAGS += -lavdevice$(AVFORMAT_SUFFIX)
--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
export shared_ffmpeg=
export extra_libs=
export avformat_suffix=
- export swscale=
export codecs=true
export filters=true
export devices=true
--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 ;;
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
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
// 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>
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
}
}
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;
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
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 )
{
}
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)
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:
c->colorspace = AVCOL_SPC_BT709;
break;
}
-#endif
if ( mlt_properties_get( properties, "aspect" ) )
{
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 )
{
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 )
{
}
apply_properties( video_enc->priv_data, properties, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM );
}
-#endif
if( codec && codec->pix_fmts )
{
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;
// 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, "" ) )
}
// 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 );
{
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 );
{
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;
}
// Do the colour space conversion
-#ifdef SWSCALE
int flags = SWS_BICUBIC;
#ifdef USE_MMX
flags |= SWS_CPU_CAPS_MMX;
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 );
{
#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
}
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;
}
#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
}
// 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>
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;
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,
{
AVPicture input;
AVPicture output;
-#ifdef SWSCALE
int flags = SWS_BICUBIC | SWS_ACCURATE_RND;
if ( out_fmt == PIX_FMT_YUYV422 )
#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 )
output.data, output.linesize);
sws_freeContext( context );
}
-#else
- img_convert( &output, out_fmt, &input, in_fmt, width, height );
-#endif
}
/** Do it :-).
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 )
{
return NULL;
}
}
-#else
- return NULL;
-#endif
-#endif
mlt_filter filter = mlt_filter_new( );
if ( filter != NULL )
filter->process = filter_process;
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,
// 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)
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 );
#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;
// 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
#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
#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
{
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 );
#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 )
{
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 )
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 );
// 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 );
// 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
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
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;
}
}
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)
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 );
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" ) )
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,
sws_freeContext( context );
else
error = 1;
-#endif
}
return error;
}
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)
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;
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 )
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
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.
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
// 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;
}