@ -2751,8 +2751,13 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
return 0 ;
return 0 ;
}
}
AVFormatContext * avformat_alloc_output_context ( const char * format , AVOutputFormat * oformat , const char * filename ) {
int avformat_alloc_output_context2 ( AVFormatContext * * avctx , AVOutputFormat * oformat ,
const char * format , const char * filename )
{
AVFormatContext * s = avformat_alloc_context ( ) ;
AVFormatContext * s = avformat_alloc_context ( ) ;
int ret = 0 ;
* avctx = NULL ;
if ( ! s )
if ( ! s )
goto nomem ;
goto nomem ;
@ -2761,11 +2766,13 @@ AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputForma
oformat = av_guess_format ( format , NULL , NULL ) ;
oformat = av_guess_format ( format , NULL , NULL ) ;
if ( ! oformat ) {
if ( ! oformat ) {
av_log ( s , AV_LOG_ERROR , " Requested output format '%s' is not a suitable output format \n " , format ) ;
av_log ( s , AV_LOG_ERROR , " Requested output format '%s' is not a suitable output format \n " , format ) ;
ret = AVERROR ( EINVAL ) ;
goto error ;
goto error ;
}
}
} else {
} else {
oformat = av_guess_format ( NULL , filename , NULL ) ;
oformat = av_guess_format ( NULL , filename , NULL ) ;
if ( ! oformat ) {
if ( ! oformat ) {
ret = AVERROR ( EINVAL ) ;
av_log ( s , AV_LOG_ERROR , " Unable to find a suitable output format for '%s' \n " ,
av_log ( s , AV_LOG_ERROR , " Unable to find a suitable output format for '%s' \n " ,
filename ) ;
filename ) ;
goto error ;
goto error ;
@ -2787,14 +2794,26 @@ AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputForma
if ( filename )
if ( filename )
av_strlcpy ( s - > filename , filename , sizeof ( s - > filename ) ) ;
av_strlcpy ( s - > filename , filename , sizeof ( s - > filename ) ) ;
return s ;
* avctx = s ;
return 0 ;
nomem :
nomem :
av_log ( s , AV_LOG_ERROR , " Out of memory \n " ) ;
av_log ( s , AV_LOG_ERROR , " Out of memory \n " ) ;
ret = AVERROR ( ENOMEM ) ;
error :
error :
avformat_free_context ( s ) ;
avformat_free_context ( s ) ;
return NULL ;
return ret ;
}
}
# if FF_API_ALLOC_OUTPUT_CONTEXT
AVFormatContext * avformat_alloc_output_context ( const char * format ,
AVOutputFormat * oformat , const char * filename )
{
AVFormatContext * avctx ;
int ret = avformat_alloc_output_context2 ( & avctx , oformat , format , filename ) ;
return ret < 0 ? NULL : avctx ;
}
# endif
static int validate_codec_tag ( AVFormatContext * s , AVStream * st )
static int validate_codec_tag ( AVFormatContext * s , AVStream * st )
{
{
const AVCodecTag * avctag ;
const AVCodecTag * avctag ;