From: <sba...@us...> - 2013-02-15 23:59:45
|
Revision: 4884 http://sourceforge.net/p/fuse-emulator/code/4884 Author: sbaldovi Date: 2013-02-15 23:59:42 +0000 (Fri, 15 Feb 2013) Log Message: ----------- Fix the build on Debian stable and fix a crash when encoding H.264 (more from bug #272) (thanks, Fred). Modified Paths: -------------- trunk/fuse-utils/configure.ac trunk/fuse-utils/fmfconv_ff.c trunk/fuse-utils/hacking/ChangeLog Modified: trunk/fuse-utils/configure.ac =================================================================== --- trunk/fuse-utils/configure.ac 2013-02-15 23:49:36 UTC (rev 4883) +++ trunk/fuse-utils/configure.ac 2013-02-15 23:59:42 UTC (rev 4884) @@ -93,6 +93,10 @@ then AC_SUBST(FFMPEG_LIBS) AC_DEFINE([USE_FFMPEG], 1, [Defined if ffmpeg available and requested]) + AC_CHECK_LIB(avutil, av_dict_set, + AC_DEFINE([HAVE_FFMPEG_AVDICTIONARY],1,[Defined if AVDictionary is available]), + true + ) dnl AC_CHECK_LIB(avcore, av_get_bytes_per_sample, AC_CHECK_LIB(avutil, av_get_bytes_per_sample, AC_DEFINE([HAVE_FFMPEG_BYTES_SAMPLE],1,[Defined if av_get_bytes_per_sample available]), @@ -102,10 +106,18 @@ AC_DEFINE([HAVE_FFMPEG_SAMPLE_FMT],1,[Defined if av_get_bits_per_sample_fmt available]), true ) + AC_CHECK_LIB(avcodec, avcodec_open2, + AC_DEFINE([HAVE_FFMPEG_AVCODEC_OPEN2],1,[Defined if avcodec_open2 is available]), + true + ) AC_CHECK_LIB(avformat, avio_open, AC_DEFINE([HAVE_FFMPEG_AVIO_OPEN],1,[Defined if avio_open available]), true ) + AC_CHECK_LIB(avformat, avformat_new_stream, + AC_DEFINE([HAVE_FFMPEG_AVFORMAT_NEW_STREAM],1,[Defined if avformat_new_stream is available]), + true + ) AC_CHECK_LIB(avformat, avformat_write_header, AC_DEFINE([HAVE_FFMPEG_AVFORMAT_WRITE_HEADER],1,[Defined if avformat_write_header available]), true Modified: trunk/fuse-utils/fmfconv_ff.c =================================================================== --- trunk/fuse-utils/fmfconv_ff.c 2013-02-15 23:49:36 UTC (rev 4883) +++ trunk/fuse-utils/fmfconv_ff.c 2013-02-15 23:59:42 UTC (rev 4884) @@ -59,6 +59,7 @@ #include <stdlib.h> #include <libavformat/avformat.h> +#include <libavutil/mathematics.h> #include <libswscale/swscale.h> #include "libspectrum.h" @@ -108,7 +109,9 @@ static int res_rte = -1; +#ifdef HAVE_FFMPEG_AVDICTIONARY static void setup_x264_dict( AVDictionary ** pm ); +#endif int ffmpeg_resample_audio( void ) @@ -211,12 +214,21 @@ { AVCodecContext *c; +#ifdef HAVE_FFMPEG_AVFORMAT_NEW_STREAM + audio_st = avformat_new_stream( oc, NULL ); +#else audio_st = av_new_stream( oc, 1 ); +#endif + if( !audio_st ) { printe( "FFMPEG: Could not allocate audio stream stream\n" ); return 1; } +#ifdef HAVE_FFMPEG_AVFORMAT_NEW_STREAM + audio_st->id = 1; +#endif + c = audio_st->codec; c->codec_id = codec_id; c->codec_type = AVMEDIA_TYPE_AUDIO; @@ -242,6 +254,7 @@ { AVCodecContext *c; AVCodec *codec; + int ret; c = audio_st->codec; @@ -253,7 +266,13 @@ } /* open it */ - if( avcodec_open2( c, codec, NULL ) < 0 ) { +#ifdef HAVE_FFMPEG_AVCODEC_OPEN2 + ret = avcodec_open2( c, codec, NULL ); +#else + ret = avcodec_open( c, codec ); +#endif + + if( ret < 0 ) { printe( "FFMPEG: could not open audio codec\n" ); return 1; } @@ -419,7 +438,12 @@ { AVCodecContext *c; +#ifdef HAVE_FFMPEG_AVFORMAT_NEW_STREAM + video_st = avformat_new_stream( oc, NULL ); +#else video_st = av_new_stream( oc, 0 ); +#endif + if( !video_st ) { printe( "FFMPEG: Could not allocate video stream\n" ); return 1; @@ -450,6 +474,10 @@ c->max_qdiff = 4; c->qmin = 10; c->qmax = 51; +#ifndef HAVE_FFMPEG_AVDICTIONARY + c->crf = 23; + c->cqp = -1; +#endif c->qcompress = 0.0; c->me_method = 8; c->trellis = 1; @@ -457,9 +485,6 @@ c->partitions = X264_PART_I4X4 | X264_PART_I8X8 | X264_PART_P8X8 | X264_PART_P4X4 | X264_PART_B8X8; */ c->flags2 |= 0; - - setup_x264_dict( c->priv_data ); - } /* some formats want stream headers to be separate */ if( oc->oformat->flags & AVFMT_GLOBALHEADER ) @@ -497,6 +522,7 @@ { AVCodec *codec; AVCodecContext *c; + int ret; c = video_st->codec; @@ -528,12 +554,21 @@ } } +#ifdef HAVE_FFMPEG_AVCODEC_OPEN2 + AVDictionary *options = NULL; if( ffmpeg_libx264 ) { - setup_x264_dict( c->priv_data ); + setup_x264_dict( &options ); } /* open the codec */ - if( avcodec_open2( c, codec, NULL ) < 0 ) { + ret = avcodec_open2( c, codec, &options ); + + av_dict_free( &options ); +#else + ret = avcodec_open( c, codec ); +#endif + + if( ret < 0 ) { printe( "FFMPEG: could not open video codec\n" ); return 1; } @@ -586,6 +621,8 @@ ret = av_interleaved_write_frame( oc, &pkt ); } else { + ffmpeg_pict->pts = c->frame_number; + /* encode the image */ out_size = avcodec_encode_video( c, video_outbuf, video_outbuf_size, ffmpeg_pict ); /* if zero size, it means the image was buffered */ @@ -896,7 +933,11 @@ encode = 0; } if( p2 && strcmp( p->name, p2->name ) == 0 ) { +#ifdef HAVE_FFMPEG_AVCODEC_OPEN2 if( p->encode2 ) encode=1; +#else + if( p->encode ) encode=1; +#endif } } if( p2 == NULL ) break; @@ -962,6 +1003,7 @@ putc('\n', stdout); } +#ifdef HAVE_FFMPEG_AVDICTIONARY static void setup_x264_dict( AVDictionary ** dict ) { @@ -971,8 +1013,9 @@ av_dict_set( dict, "8x8dct", "1", 0 ); av_dict_set( dict, "fast-pskip", "1", 0 ); av_dict_set( dict, "qp", "-1", 0 ); - av_dict_set( dict, "crf", "0", 0 ); + av_dict_set( dict, "crf", "23", 0 ); av_dict_set( dict, "preset", "medium", 0 ); } +#endif /* ifdef HAVE_FFMPEG_AVDICTIONARY */ #endif /* ifdef USE_FFMPEG */ Modified: trunk/fuse-utils/hacking/ChangeLog =================================================================== --- trunk/fuse-utils/hacking/ChangeLog 2013-02-15 23:49:36 UTC (rev 4883) +++ trunk/fuse-utils/hacking/ChangeLog 2013-02-15 23:59:42 UTC (rev 4884) @@ -397,3 +397,5 @@ Shmakov) (Fred). 20130212 man/audio2tape.1: fix input file specification (Fred). 20130216 AUTHORS,man/createhdf.1,man/raw2hdf.1: fix broken URLs (Sergio). +20130216 configure.ac,fmfconv_ff.c: fix the build on Debian stable and fix a + crash when encoding H.264 (more from bug #272) (thanks, Fred) (Sergio). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |