static void apply_properties( void *obj, mlt_properties properties, int flags, int alloc )
{
int i;
- int count = mlt_properties_count( properties );
+ int count = mlt_properties_count( properties );
for ( i = 0; i < count; i++ )
{
const char *opt_name = mlt_properties_get_name( properties, i );
const AVOption *opt = av_find_opt( obj, opt_name, NULL, flags, flags );
+
if ( opt != NULL )
#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(7<<8)+0)
av_set_string3( obj, opt_name, mlt_properties_get_value( properties, i), alloc, NULL );
return st;
}
-static int open_audio( AVFormatContext *oc, AVStream *st, int audio_outbuf_size, const char *codec_name )
+static int open_audio( mlt_properties properties, AVFormatContext *oc, AVStream *st, int audio_outbuf_size, const char *codec_name )
{
// We will return the audio input size from here
int audio_input_frame_size = 0;
else
codec = avcodec_find_encoder( c->codec_id );
+#if LIBAVCODEC_VERSION_MAJOR > 52
+ // Process properties as AVOptions on the AVCodec
+ if ( codec && codec->priv_class && c->priv_data )
+ {
+ char *apre = mlt_properties_get( properties, "apre" );
+ if ( apre )
+ {
+ mlt_properties p = mlt_properties_load( apre );
+ apply_properties( c->priv_data, p, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, 1 );
+ mlt_properties_close( p );
+ }
+ apply_properties( c->priv_data, properties, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, 0 );
+ }
+#endif
+
avformat_lock();
// Continue if codec found and we can open it
return picture;
}
-static int open_video(AVFormatContext *oc, AVStream *st, const char *codec_name)
+static int open_video( mlt_properties properties, AVFormatContext *oc, AVStream *st, const char *codec_name )
{
// Get the codec
AVCodecContext *video_enc = st->codec;
else
codec = avcodec_find_encoder( video_enc->codec_id );
+#if LIBAVCODEC_VERSION_MAJOR > 52
+ // Process properties as AVOptions on the AVCodec
+ if ( codec && codec->priv_class && video_enc->priv_data )
+ {
+ char *vpre = mlt_properties_get( properties, "vpre" );
+ if ( vpre )
+ {
+ mlt_properties p = mlt_properties_load( vpre );
+ apply_properties( video_enc->priv_data, p, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, 1 );
+ mlt_properties_close( p );
+ }
+ apply_properties( video_enc->priv_data, properties, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, 0 );
+ }
+#endif
+
if( codec && codec->pix_fmts )
{
const enum PixelFormat *p = codec->pix_fmts;
{
mlt_properties p = mlt_properties_load( fpre );
apply_properties( oc, p, AV_OPT_FLAG_ENCODING_PARAM, 1 );
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ if ( oc->oformat && oc->oformat->priv_class && oc->priv_data )
+ apply_properties( oc->priv_data, p, AV_OPT_FLAG_ENCODING_PARAM, 1 );
+#endif
mlt_properties_close( p );
}
apply_properties( oc, properties, AV_OPT_FLAG_ENCODING_PARAM, 0 );
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ if ( oc->oformat && oc->oformat->priv_class && oc->priv_data )
+ apply_properties( oc->priv_data, properties, AV_OPT_FLAG_ENCODING_PARAM, 1 );
+#endif
- if ( video_st && !open_video( oc, video_st, vcodec? vcodec : NULL ) )
+ if ( video_st && !open_video( properties, oc, video_st, vcodec? vcodec : NULL ) )
video_st = NULL;
for ( i = 0; i < MAX_AUDIO_STREAMS && audio_st[i]; i++ )
{
- audio_input_frame_size = open_audio( oc, audio_st[i], audio_outbuf_size,
+ audio_input_frame_size = open_audio( properties, oc, audio_st[i], audio_outbuf_size,
acodec? acodec : NULL );
if ( !audio_input_frame_size )
audio_st[i] = NULL;
return NULL;
}
-static void add_parameters( mlt_properties params, void *object, int req_flags, const char *unit )
+static void add_parameters( mlt_properties params, void *object, int req_flags, const char *unit, const char *subclass )
{
const AVOption *opt = NULL;
// Add the parameter metadata for this AVOption.
mlt_properties_set( p, "identifier", opt->name );
- mlt_properties_set( p, "description", opt->help );
+ if ( subclass )
+ {
+ char *s = malloc( strlen( opt->help ) + strlen( subclass ) + 4 );
+ strcpy( s, opt->help );
+ strcat( s, " (" );
+ strcat( s, subclass );
+ strcat( s, ")" );
+ mlt_properties_set( p, "description", s );
+ }
+ else
+ mlt_properties_set( p, "description", opt->help );
+
+
switch ( opt->type )
{
case FF_OPT_TYPE_FLAGS:
mlt_properties_set_int( p, "minimum", (int) opt->min );
if ( opt->max != INT_MAX )
mlt_properties_set_int( p, "maximum", (int) opt->max );
- mlt_properties_set_int( p, "default", (int) opt->default_val );
+#if LIBAVUTIL_VERSION_MAJOR > 50
+ mlt_properties_set_int( p, "default", (int) opt->default_val.dbl );
+#endif
}
else
{
mlt_properties_set_int64( p, "minimum", (int64_t) opt->min );
if ( opt->max != INT64_MAX )
mlt_properties_set_int64( p, "maximum", (int64_t) opt->max );
+#if LIBAVUTIL_VERSION_MAJOR > 50
+ mlt_properties_set_int64( p, "default", (int64_t) opt->default_val.dbl );
+#endif
break;
case FF_OPT_TYPE_FLOAT:
mlt_properties_set( p, "type", "float" );
mlt_properties_set_double( p, "minimum", opt->min );
if ( opt->max != FLT_MAX )
mlt_properties_set_double( p, "maximum", opt->max );
+#if LIBAVUTIL_VERSION_MAJOR > 50
+ mlt_properties_set_double( p, "default", opt->default_val.dbl );
+#endif
break;
case FF_OPT_TYPE_DOUBLE:
mlt_properties_set( p, "type", "float" );
mlt_properties_set_double( p, "minimum", opt->min );
if ( opt->max != DBL_MAX )
mlt_properties_set_double( p, "maximum", opt->max );
+#if LIBAVUTIL_VERSION_MAJOR > 50
+ mlt_properties_set_double( p, "default", opt->default_val.dbl );
+#endif
break;
case FF_OPT_TYPE_STRING:
mlt_properties_set( p, "type", "string" );
+#if LIBAVUTIL_VERSION_MAJOR > 50
+ mlt_properties_set( p, "default", opt->default_val.str );
+#endif
break;
case FF_OPT_TYPE_RATIONAL:
mlt_properties_set( p, "type", "string" );
{
// Create a 'values' sequence.
mlt_properties values = mlt_properties_new();
- mlt_properties_set_data( p, "values", values, 0, (mlt_destructor) mlt_properties_close, NULL );
// Recurse to add constants in this group to the 'values' sequence.
- add_parameters( values, object, req_flags, opt->unit );
+ add_parameters( values, object, req_flags, opt->unit, NULL );
+ if ( mlt_properties_count( values ) )
+ mlt_properties_set_data( p, "values", values, 0, (mlt_destructor) mlt_properties_close, NULL );
+ else
+ mlt_properties_close( values );
}
}
}
AVCodecContext *avcodec = avcodec_alloc_context();
int flags = ( type == consumer_type )? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM;
- add_parameters( params, avformat, flags, NULL );
- add_parameters( params, avcodec, flags, NULL );
+ add_parameters( params, avformat, flags, NULL, NULL );
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ avformat_init();
+ AVOutputFormat *f = NULL;
+ while ( ( f = av_oformat_next( f ) ) )
+ if ( f->priv_class )
+ add_parameters( params, &f->priv_class, flags, NULL, f->name );
+#endif
+
+ add_parameters( params, avcodec, flags, NULL, NULL );
+#if LIBAVCODEC_VERSION_MAJOR > 52
+ AVCodec *c = NULL;
+ while ( ( c = av_codec_next( c ) ) )
+ if ( c->priv_class )
+ add_parameters( params, &c->priv_class, flags, NULL, c->name );
+#endif
av_free( avformat );
av_free( avcodec );
}
mlt_events_unblock( properties, producer );
apply_properties( self->video_format, properties, AV_OPT_FLAG_DECODING_PARAM );
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ 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
self->audio_index = audio_index;
if ( self->video_format && video_index > -1 )
// Process properties as AVOptions
apply_properties( codec_context, properties, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM );
+#if LIBAVCODEC_VERSION_MAJOR > 52
+ if ( codec->priv_class && codec_context->priv_data )
+ apply_properties( codec_context->priv_data, properties, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM );
+#endif
// Reset some image properties
mlt_properties_set_int( properties, "width", self->video_codec->width );
// Process properties as AVOptions
if ( context )
+ {
apply_properties( context, properties, AV_OPT_FLAG_DECODING_PARAM );
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ if ( context->iformat && context->iformat->priv_class && context->priv_data )
+ apply_properties( context->priv_data, properties, AV_OPT_FLAG_DECODING_PARAM );
+#endif
+ }
}
// Exception handling for video_index
// Process properties as AVOptions
apply_properties( codec_context, properties, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM );
+#if LIBAVCODEC_VERSION_MAJOR > 52
+ 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;
}