From: Steven Walters Date: Sun, 25 Jul 2010 23:45:27 +0000 (-0400) Subject: Filtering system-related fixes X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b476e0583896124e6ec33ccf7756b240deae0d96;p=x264 Filtering system-related fixes Fix configure to check for outdated libavutil in resize filter support. Do not print an explicit error message in ffms when requesting a frame beyond the number of frames in the source. Mention in --*help that filtering options can be specified as name=value. Fix the shadowing warning in the resize filter on posix systems. --- diff --git a/configure b/configure index aeb215af..565eb985 100755 --- a/configure +++ b/configure @@ -549,8 +549,13 @@ if [ "$swscale" = "auto" ] ; then error="swscale must be at least version 0.9.0" if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_getContext(0,0,0,0,0,0,0,0,0,0);" ; then if cpp_check "libswscale/swscale.h" "$SWSCALE_CFLAGS" "LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)" "$error"; then - define HAVE_SWSCALE - swscale="yes" + # we use colorspaces that were defined in libavutil r19775 + if cc_check "libavutil/pixfmt.h" "$SWSCALE_CFLAGS" "enum PixelFormat pixfmt = PIX_FMT_YUV422P16LE;" ; then + define HAVE_SWSCALE + swscale="yes" + else + echo "Warning: libavutil is too old, update to ffmpeg r19775+" + fi else echo "Warning: ${error}" fi diff --git a/filters/video/resize.c b/filters/video/resize.c index 3a2faa44..60c66937 100644 --- a/filters/video/resize.c +++ b/filters/video/resize.c @@ -178,10 +178,10 @@ static int pick_closest_supported_csp( int csp ) } } -static int round_dbl( double val, int precision, int truncate ) +static int round_dbl( double val, int precision, int b_truncate ) { int ret = (int)(val / precision) * precision; - if( !truncate && (val - ret) >= (precision/2) ) // use the remainder if we're not truncating it + if( !b_truncate && (val - ret) >= (precision/2) ) // use the remainder if we're not truncating it ret += precision; return ret; } diff --git a/input/ffms.c b/input/ffms.c index 84118d53..0472cc64 100644 --- a/input/ffms.c +++ b/input/ffms.c @@ -41,6 +41,7 @@ typedef struct FFMS_Track *track; int reduce_pts; int vfr_input; + int num_frames; } ffms_hnd_t; static int FFMS_CC update_progress( int64_t current, int64_t total, void *private ) @@ -92,7 +93,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c FFMS_DestroyIndex( idx ); const FFMS_VideoProperties *videop = FFMS_GetVideoProperties( h->video_source ); - info->num_frames = videop->NumFrames; + info->num_frames = h->num_frames = videop->NumFrames; info->sar_height = videop->SARDen; info->sar_width = videop->SARNum; info->fps_den = videop->FPSDenominator; @@ -144,10 +145,12 @@ static int picture_alloc( cli_pic_t *pic, int csp, int width, int height ) static int read_frame( cli_pic_t *pic, hnd_t handle, int i_frame ) { ffms_hnd_t *h = handle; + if( i_frame >= h->num_frames ) + return -1; FFMS_ErrorInfo e; e.BufferSize = 0; const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, i_frame, &e ); - FAIL_IF_ERROR( !frame, "could not read frame %d\n", i_frame ) + FAIL_IF_ERROR( !frame, "could not read frame %d \n", i_frame ) memcpy( pic->img.stride, frame->Linesize, sizeof(pic->img.stride) ); memcpy( pic->img.plane, frame->Data, sizeof(pic->img.plane) ); diff --git a/x264.c b/x264.c index 2f4263e1..530ad4a8 100644 --- a/x264.c +++ b/x264.c @@ -697,6 +697,7 @@ static void Help( x264_param_t *defaults, int longhelp ) H0( "\n" ); H0( "Filtering:\n" ); H0( "\n" ); + H0( " Filter options may be specified in the name=value format\n" ); H0( "--vf, --video-filter //... Apply video filtering to the input file\n" ); H0( " Available filters:\n" ); x264_register_vid_filters();