From 073f081762b78501e57c6bc2667c004858739edf Mon Sep 17 00:00:00 2001 From: Steven Walters Date: Sat, 18 Jun 2011 14:12:34 -0400 Subject: [PATCH] Fix deprecation in libavformat usage Replace av_open_input_file with avformat_open_input. Now requires libavformat 53.2.0 or newer. --- configure | 12 ++++-------- input/lavf.c | 20 +++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/configure b/configure index 16007e06..d539afe0 100755 --- a/configure +++ b/configure @@ -744,15 +744,11 @@ if [ "$lavf" = "auto" ] ; then done fi LAVF_LIBS="-L. $LAVF_LIBS" - if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2(0,0,0,0);" ; then - if cpp_check libavcodec/avcodec.h "$LAVF_CFLAGS $LAVF_LIBS" "LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,64,0)" ; then - if [ "$swscale" = "yes" ]; then - lavf="yes" - else - echo "Warning: libavformat is not supported without swscale support" - fi + if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avformat_open_input(0,0,0,0);" ; then + if [ "$swscale" = "yes" ]; then + lavf="yes" else - echo "Warning: libavcodec is too old, update to ffmpeg r22735+" + echo "Warning: libavformat is not supported without swscale support" fi fi fi diff --git a/input/lavf.c b/input/lavf.c index dc9fe55f..424d3cb0 100644 --- a/input/lavf.c +++ b/input/lavf.c @@ -29,6 +29,7 @@ #undef DECLARE_ALIGNED #include #include +#include typedef struct { @@ -136,16 +137,13 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c if( !strcmp( psz_filename, "-" ) ) psz_filename = "pipe:"; - /* if resolution was passed in, parse it and colorspace into parameters. this allows raw video support */ - AVFormatParameters *param = NULL; + /* if resolution was passed in, place it and colorspace into options. this allows raw video support */ + AVDictionary *options = NULL; if( opt->resolution ) { - param = calloc( 1, sizeof(AVFormatParameters) ); - if( !param ) - return -1; - sscanf( opt->resolution, "%dx%d", ¶m->width, ¶m->height ); - param->pix_fmt = opt->colorspace ? av_get_pix_fmt( opt->colorspace ) : PIX_FMT_YUV420P; - FAIL_IF_ERROR( param->pix_fmt == PIX_FMT_NONE, "unsupported colorspace: %s\n", opt->colorspace ); + av_dict_set( &options, "video_size", opt->resolution, 0 ); + const char *csp = opt->colorspace ? opt->colorspace : av_get_pix_fmt_name( PIX_FMT_YUV420P ); + av_dict_set( &options, "pixel_format", csp, 0 ); } /* specify the input format. this is helpful when lavf fails to guess */ @@ -153,9 +151,9 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c if( opt->format ) FAIL_IF_ERROR( !(format = av_find_input_format( opt->format )), "unknown file format: %s\n", opt->format ); - FAIL_IF_ERROR( av_open_input_file( &h->lavf, psz_filename, format, 0, param ), "could not open input file\n" ) - if( param ) - free( param ); + FAIL_IF_ERROR( avformat_open_input( &h->lavf, psz_filename, format, &options ), "could not open input file\n" ) + if( options ) + av_dict_free( &options ); FAIL_IF_ERROR( av_find_stream_info( h->lavf ) < 0, "could not find input stream info\n" ) int i = 0; -- 2.47.3