Commit 05f04384 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Update to current libav/ffmpeg API

parent b7b6029f
...@@ -858,10 +858,10 @@ if [ "$swscale" = "auto" ] ; then ...@@ -858,10 +858,10 @@ if [ "$swscale" = "auto" ] ; then
[ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil" [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_init_context(0,0,0);" ; then if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_init_context(0,0,0);" ; then
if cpp_check "libavutil/pixdesc.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "defined(PIX_FMT_RGB)" ; then if cpp_check "libavutil/pixdesc.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "defined(AV_PIX_FMT_FLAG_RGB)" ; then
swscale="yes" swscale="yes"
else else
echo "Warning: PIX_FMT_RGB is missing from libavutil, update for swscale support" echo "Warning: AV_PIX_FMT_FLAG_RGB is missing from libavutil, update for swscale support"
fi fi
fi fi
fi fi
...@@ -874,7 +874,7 @@ if [ "$lavf" = "auto" ] ; then ...@@ -874,7 +874,7 @@ if [ "$lavf" = "auto" ] ; then
fi fi
if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
LAVF_LIBS="-lavformat" LAVF_LIBS="-lavformat"
for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32 -lws2_32; do
cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib" cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
done done
fi fi
......
...@@ -45,8 +45,8 @@ static int full_check( video_info_t *info, x264_param_t *param ) ...@@ -45,8 +45,8 @@ static int full_check( video_info_t *info, x264_param_t *param )
#include <libavutil/opt.h> #include <libavutil/opt.h>
#include <libavutil/pixdesc.h> #include <libavutil/pixdesc.h>
#ifndef PIX_FMT_BGRA64 #ifndef AV_PIX_FMT_BGRA64
#define PIX_FMT_BGRA64 PIX_FMT_NONE #define AV_PIX_FMT_BGRA64 AV_PIX_FMT_NONE
#endif #endif
typedef struct typedef struct
...@@ -143,19 +143,19 @@ static int convert_csp_to_pix_fmt( int csp ) ...@@ -143,19 +143,19 @@ static int convert_csp_to_pix_fmt( int csp )
switch( csp&X264_CSP_MASK ) switch( csp&X264_CSP_MASK )
{ {
case X264_CSP_YV12: /* specially handled via swapping chroma */ case X264_CSP_YV12: /* specially handled via swapping chroma */
case X264_CSP_I420: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_YUV420P16 : PIX_FMT_YUV420P; case X264_CSP_I420: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_YUV420P16 : AV_PIX_FMT_YUV420P;
case X264_CSP_YV16: /* specially handled via swapping chroma */ case X264_CSP_YV16: /* specially handled via swapping chroma */
case X264_CSP_I422: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_YUV422P16 : PIX_FMT_YUV422P; case X264_CSP_I422: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_YUV422P16 : AV_PIX_FMT_YUV422P;
case X264_CSP_YV24: /* specially handled via swapping chroma */ case X264_CSP_YV24: /* specially handled via swapping chroma */
case X264_CSP_I444: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_YUV444P16 : PIX_FMT_YUV444P; case X264_CSP_I444: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_YUV444P16 : AV_PIX_FMT_YUV444P;
case X264_CSP_RGB: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_RGB48 : PIX_FMT_RGB24; case X264_CSP_RGB: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_RGB48 : AV_PIX_FMT_RGB24;
case X264_CSP_BGR: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_BGR48 : PIX_FMT_BGR24; case X264_CSP_BGR: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_BGR48 : AV_PIX_FMT_BGR24;
case X264_CSP_BGRA: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_BGRA64 : PIX_FMT_BGRA; case X264_CSP_BGRA: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_BGRA64 : AV_PIX_FMT_BGRA;
/* the next csp has no equivalent 16bit depth in swscale */ /* the next csp has no equivalent 16bit depth in swscale */
case X264_CSP_NV12: return csp&X264_CSP_HIGH_DEPTH ? PIX_FMT_NONE : PIX_FMT_NV12; case X264_CSP_NV12: return csp&X264_CSP_HIGH_DEPTH ? AV_PIX_FMT_NONE : AV_PIX_FMT_NV12;
/* the next csp is no supported by swscale at all */ /* the next csp is no supported by swscale at all */
case X264_CSP_NV16: case X264_CSP_NV16:
default: return PIX_FMT_NONE; default: return AV_PIX_FMT_NONE;
} }
} }
...@@ -175,12 +175,12 @@ static int pick_closest_supported_csp( int csp ) ...@@ -175,12 +175,12 @@ static int pick_closest_supported_csp( int csp )
int pix_fmt = convert_csp_to_pix_fmt( csp ); int pix_fmt = convert_csp_to_pix_fmt( csp );
// first determine the base csp // first determine the base csp
int ret = X264_CSP_NONE; int ret = X264_CSP_NONE;
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_descriptors+pix_fmt; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get( pix_fmt );
if( (unsigned)pix_fmt >= PIX_FMT_NB || !pix_desc->name ) if( !pix_desc || !pix_desc->name )
return ret; return ret;
const char *pix_fmt_name = pix_desc->name; const char *pix_fmt_name = pix_desc->name;
int is_rgb = pix_desc->flags & (PIX_FMT_RGB | PIX_FMT_PAL); int is_rgb = pix_desc->flags & (AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PAL);
int is_bgr = !!strstr( pix_fmt_name, "bgr" ); int is_bgr = !!strstr( pix_fmt_name, "bgr" );
if( is_bgr || is_rgb ) if( is_bgr || is_rgb )
{ {
...@@ -462,11 +462,11 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 ...@@ -462,11 +462,11 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2
int dst_pix_fmt_inv = convert_csp_to_pix_fmt( h->dst_csp ^ X264_CSP_HIGH_DEPTH ); int dst_pix_fmt_inv = convert_csp_to_pix_fmt( h->dst_csp ^ X264_CSP_HIGH_DEPTH );
/* confirm swscale can support this conversion */ /* confirm swscale can support this conversion */
FAIL_IF_ERROR( src_pix_fmt == PIX_FMT_NONE && src_pix_fmt_inv != PIX_FMT_NONE, FAIL_IF_ERROR( src_pix_fmt == AV_PIX_FMT_NONE && src_pix_fmt_inv != AV_PIX_FMT_NONE,
"input colorspace %s with bit depth %d is not supported\n", av_get_pix_fmt_name( src_pix_fmt_inv ), "input colorspace %s with bit depth %d is not supported\n", av_get_pix_fmt_name( src_pix_fmt_inv ),
info->csp & X264_CSP_HIGH_DEPTH ? 16 : 8 ); info->csp & X264_CSP_HIGH_DEPTH ? 16 : 8 );
FAIL_IF_ERROR( !sws_isSupportedInput( src_pix_fmt ), "input colorspace %s is not supported\n", av_get_pix_fmt_name( src_pix_fmt ) ) FAIL_IF_ERROR( !sws_isSupportedInput( src_pix_fmt ), "input colorspace %s is not supported\n", av_get_pix_fmt_name( src_pix_fmt ) )
FAIL_IF_ERROR( h->dst.pix_fmt == PIX_FMT_NONE && dst_pix_fmt_inv != PIX_FMT_NONE, FAIL_IF_ERROR( h->dst.pix_fmt == AV_PIX_FMT_NONE && dst_pix_fmt_inv != AV_PIX_FMT_NONE,
"input colorspace %s with bit depth %d is not supported\n", av_get_pix_fmt_name( dst_pix_fmt_inv ), "input colorspace %s with bit depth %d is not supported\n", av_get_pix_fmt_name( dst_pix_fmt_inv ),
h->dst_csp & X264_CSP_HIGH_DEPTH ? 16 : 8 ); h->dst_csp & X264_CSP_HIGH_DEPTH ? 16 : 8 );
FAIL_IF_ERROR( !sws_isSupportedOutput( h->dst.pix_fmt ), "output colorspace %s is not supported\n", av_get_pix_fmt_name( h->dst.pix_fmt ) ) FAIL_IF_ERROR( !sws_isSupportedOutput( h->dst.pix_fmt ), "output colorspace %s is not supported\n", av_get_pix_fmt_name( h->dst.pix_fmt ) )
......
...@@ -338,11 +338,11 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c ...@@ -338,11 +338,11 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
info->csp = X264_CSP_I420; info->csp = X264_CSP_I420;
#if HAVE_SWSCALE #if HAVE_SWSCALE
else if( avs_is_yuy2( vi ) ) else if( avs_is_yuy2( vi ) )
info->csp = PIX_FMT_YUYV422 | X264_CSP_OTHER; info->csp = AV_PIX_FMT_YUYV422 | X264_CSP_OTHER;
else if( avs_is_yv411( vi ) ) else if( avs_is_yv411( vi ) )
info->csp = PIX_FMT_YUV411P | X264_CSP_OTHER; info->csp = AV_PIX_FMT_YUV411P | X264_CSP_OTHER;
else if( avs_is_y8( vi ) ) else if( avs_is_y8( vi ) )
info->csp = PIX_FMT_GRAY8 | X264_CSP_OTHER; info->csp = AV_PIX_FMT_GRAY8 | X264_CSP_OTHER;
#endif #endif
else else
info->csp = X264_CSP_NONE; info->csp = X264_CSP_NONE;
...@@ -361,7 +361,7 @@ static int picture_alloc( cli_pic_t *pic, int csp, int width, int height ) ...@@ -361,7 +361,7 @@ static int picture_alloc( cli_pic_t *pic, int csp, int width, int height )
if( cli_csp ) if( cli_csp )
pic->img.planes = cli_csp->planes; pic->img.planes = cli_csp->planes;
#if HAVE_SWSCALE #if HAVE_SWSCALE
else if( csp == (PIX_FMT_YUV411P | X264_CSP_OTHER) ) else if( csp == (AV_PIX_FMT_YUV411P | X264_CSP_OTHER) )
pic->img.planes = 3; pic->img.planes = 3;
else else
pic->img.planes = 1; //y8 and yuy2 are one plane pic->img.planes = 1; //y8 and yuy2 are one plane
......
...@@ -69,9 +69,9 @@ static int handle_jpeg( int csp, int *fullrange ) ...@@ -69,9 +69,9 @@ static int handle_jpeg( int csp, int *fullrange )
{ {
switch( csp ) switch( csp )
{ {
case PIX_FMT_YUVJ420P: *fullrange = 1; return PIX_FMT_YUV420P; case AV_PIX_FMT_YUVJ420P: *fullrange = 1; return AV_PIX_FMT_YUV420P;
case PIX_FMT_YUVJ422P: *fullrange = 1; return PIX_FMT_YUV422P; case AV_PIX_FMT_YUVJ422P: *fullrange = 1; return AV_PIX_FMT_YUV422P;
case PIX_FMT_YUVJ444P: *fullrange = 1; return PIX_FMT_YUV444P; case AV_PIX_FMT_YUVJ444P: *fullrange = 1; return AV_PIX_FMT_YUV444P;
default: return csp; default: return csp;
} }
} }
......
...@@ -53,9 +53,9 @@ static int handle_jpeg( int csp, int *fullrange ) ...@@ -53,9 +53,9 @@ static int handle_jpeg( int csp, int *fullrange )
{ {
switch( csp ) switch( csp )
{ {
case PIX_FMT_YUVJ420P: *fullrange = 1; return PIX_FMT_YUV420P; case AV_PIX_FMT_YUVJ420P: *fullrange = 1; return AV_PIX_FMT_YUV420P;
case PIX_FMT_YUVJ422P: *fullrange = 1; return PIX_FMT_YUV422P; case AV_PIX_FMT_YUVJ422P: *fullrange = 1; return AV_PIX_FMT_YUV422P;
case PIX_FMT_YUVJ444P: *fullrange = 1; return PIX_FMT_YUV444P; case AV_PIX_FMT_YUVJ444P: *fullrange = 1; return AV_PIX_FMT_YUV444P;
default: return csp; default: return csp;
} }
} }
...@@ -162,7 +162,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c ...@@ -162,7 +162,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
if( opt->resolution ) if( opt->resolution )
{ {
av_dict_set( &options, "video_size", opt->resolution, 0 ); av_dict_set( &options, "video_size", opt->resolution, 0 );
const char *csp = opt->colorspace ? opt->colorspace : av_get_pix_fmt_name( PIX_FMT_YUV420P ); const char *csp = opt->colorspace ? opt->colorspace : av_get_pix_fmt_name( AV_PIX_FMT_YUV420P );
av_dict_set( &options, "pixel_format", csp, 0 ); av_dict_set( &options, "pixel_format", csp, 0 );
} }
...@@ -210,7 +210,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c ...@@ -210,7 +210,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
/* avisynth stores rgb data vertically flipped. */ /* avisynth stores rgb data vertically flipped. */
if( !strcasecmp( get_filename_extension( psz_filename ), "avs" ) && if( !strcasecmp( get_filename_extension( psz_filename ), "avs" ) &&
(c->pix_fmt == PIX_FMT_BGRA || c->pix_fmt == PIX_FMT_BGR24) ) (c->pix_fmt == AV_PIX_FMT_BGRA || c->pix_fmt == AV_PIX_FMT_BGR24) )
info->csp |= X264_CSP_VFLIP; info->csp |= X264_CSP_VFLIP;
*p_handle = h; *p_handle = h;
......
...@@ -437,7 +437,7 @@ static void print_csp_names( int longhelp ) ...@@ -437,7 +437,7 @@ static void print_csp_names( int longhelp )
printf( " - valid csps for `lavf' demuxer:\n" ); printf( " - valid csps for `lavf' demuxer:\n" );
printf( INDENT ); printf( INDENT );
size_t line_len = strlen( INDENT ); size_t line_len = strlen( INDENT );
for( enum PixelFormat i = PIX_FMT_NONE+1; i < PIX_FMT_NB; i++ ) for( enum PixelFormat i = AV_PIX_FMT_NONE+1; i < AV_PIX_FMT_NB; i++ )
{ {
const char *pfname = av_get_pix_fmt_name( i ); const char *pfname = av_get_pix_fmt_name( i );
if( pfname ) if( pfname )
...@@ -450,7 +450,7 @@ static void print_csp_names( int longhelp ) ...@@ -450,7 +450,7 @@ static void print_csp_names( int longhelp )
} }
printf( "%s", pfname ); printf( "%s", pfname );
line_len += name_len; line_len += name_len;
if( i+1 < PIX_FMT_NB ) if( i+1 < AV_PIX_FMT_NB )
{ {
printf( ", " ); printf( ", " );
line_len += 2; line_len += 2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment