@ -26,7 +26,6 @@
/* #define DEBUG */
/* #define DEBUG */
# include <float.h> /* DBL_MIN, DBL_MAX */
# include <float.h> /* DBL_MIN, DBL_MAX */
# include <fcntl.h> /* O_RDONLY */
# include "libavutil/bprint.h"
# include "libavutil/bprint.h"
# include "libavutil/channel_layout.h"
# include "libavutil/channel_layout.h"
@ -42,13 +41,6 @@
# include "libavformat/internal.h"
# include "libavformat/internal.h"
# include "avdevice.h"
# include "avdevice.h"
# if HAVE_UNISTD_H
# include <unistd.h> /* close() */
# endif
# if HAVE_IO_H
# include <io.h>
# endif
typedef struct {
typedef struct {
AVClass * class ; ///< class for private options
AVClass * class ; ///< class for private options
char * graph_str ;
char * graph_str ;
@ -123,22 +115,23 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
}
}
if ( lavfi - > graph_filename ) {
if ( lavfi - > graph_filename ) {
AVBPrint graph_file_pb ;
uint8_t * file_buf , * graph_buf ;
int fd = avpriv_open ( lavfi - > graph_filename , O_RDONLY ) ;
size_t file_bufsize ;
if ( fd = = - 1 )
ret = av_file_map ( lavfi - > graph_filename ,
FAIL ( AVERROR ( EINVAL ) ) ;
& file_buf , & file_bufsize , 0 , avctx ) ;
av_bprint_init ( & graph_file_pb , 0 , AV_BPRINT_SIZE_UNLIMITED ) ;
if ( ret < 0 )
ret = av_bprint_fd_contents ( & graph_file_pb , fd ) ;
goto end ;
av_bprint_chars ( & graph_file_pb , ' \0 ' , 1 ) ;
close ( fd ) ;
/* create a 0-terminated string based on the read file */
if ( ! ret & & ! av_bprint_is_complete ( & graph_file_pb ) )
graph_buf = av_malloc ( file_bufsize + 1 ) ;
ret = AVERROR ( ENOMEM ) ;
if ( ! graph_buf ) {
if ( ret ) {
av_file_unmap ( file_buf , file_bufsize ) ;
av_bprint_finalize ( & graph_file_pb , NULL ) ;
FAIL ( AVERROR ( ENOMEM ) ) ;
FAIL ( ret ) ;
}
}
if ( ( ret = av_bprint_finalize ( & graph_file_pb , & lavfi - > graph_str ) ) )
memcpy ( graph_buf , file_buf , file_bufsize ) ;
FAIL ( ret ) ;
graph_buf [ file_bufsize ] = 0 ;
av_file_unmap ( file_buf , file_bufsize ) ;
lavfi - > graph_str = graph_buf ;
}
}
if ( ! lavfi - > graph_str )
if ( ! lavfi - > graph_str )