diff -uNrp c/input/avs.c b/input/avs.c --- c/input/avs.c 2010-03-29 11:48:52 +0300 +++ b/input/avs.c 2010-03-29 12:44:51 +0300 @@ -35,6 +35,7 @@ #else #include "extras/avisynth_c.h" #endif +#include "extras/x264loger.h" /* AVS uses a versioned interface to control backwards compatibility */ /* YV12 support is required */ @@ -124,7 +125,7 @@ static int open_file( char *psz_filename return -1; else if( !x264_is_regular_file( fh ) ) { - fprintf( stderr, "avs [error]: AVS input is incompatible with non-regular file `%s'\n", psz_filename ); + x264_fprintf( stderr, "avs [error]: AVS input is incompatible with non-regular file `%s'\n", psz_filename ); return -1; } fclose( fh ); @@ -134,13 +135,13 @@ static int open_file( char *psz_filename return -1; if( avs_load_library( h ) ) { - fprintf( stderr, "avs [error]: failed to load avisynth\n" ); + x264_fprintf( stderr, "avs [error]: failed to load avisynth\n" ); return -1; } h->env = h->func.avs_create_script_environment( AVS_INTERFACE_YV12 ); if( !h->env ) { - fprintf( stderr, "avs [error]: failed to initiate avisynth\n" ); + x264_fprintf( stderr, "avs [error]: failed to initiate avisynth\n" ); return -1; } AVS_Value arg = avs_new_value_string( psz_filename ); @@ -152,7 +153,7 @@ static int open_file( char *psz_filename res = h->func.avs_invoke( h->env, "Import", arg, NULL ); if( avs_is_error( res ) ) { - fprintf( stderr, "avs [error]: %s\n", avs_as_string( res ) ); + x264_fprintf( stderr, "avs [error]: %s\n", avs_as_string( res ) ); return -1; } /* check if the user is using a multi-threaded script and apply distributor if necessary. @@ -175,34 +176,34 @@ static int open_file( char *psz_filename int i; for( i = 0; filter[i]; i++ ) { - fprintf( stderr, "avs [info]: trying %s... ", filter[i] ); + x264_fprintf( stderr, "avs [info]: trying %s... ", filter[i] ); if( !h->func.avs_function_exists( h->env, filter[i] ) ) { - fprintf( stderr, "not found\n" ); + x264_fprintf( stderr, "not found\n" ); continue; } if( !strncasecmp( filter[i], "FFmpegSource", 12 ) ) { - fprintf( stderr, "indexing... " ); + x264_fprintf( stderr, "indexing... " ); fflush( stderr ); } res = h->func.avs_invoke( h->env, filter[i], arg, NULL ); if( !avs_is_error( res ) ) { - fprintf( stderr, "succeeded\n" ); + x264_fprintf( stderr, "succeeded\n" ); break; } - fprintf( stderr, "failed\n" ); + x264_fprintf( stderr, "failed\n" ); } if( !filter[i] ) { - fprintf( stderr, "avs [error]: unable to find source filter to open `%s'\n", psz_filename ); + x264_fprintf( stderr, "avs [error]: unable to find source filter to open `%s'\n", psz_filename ); return -1; } } if( !avs_is_clip( res ) ) { - fprintf( stderr, "avs [error]: `%s' didn't return a video clip\n", psz_filename ); + x264_fprintf( stderr, "avs [error]: `%s' didn't return a video clip\n", psz_filename ); return -1; } h->clip = h->func.avs_take_clip( res, h->env ); @@ -210,12 +211,12 @@ static int open_file( char *psz_filename const AVS_VideoInfo *vi = h->func.avs_get_video_info( h->clip ); if( !avs_has_video( vi ) ) { - fprintf( stderr, "avs [error]: `%s' has no video data\n", psz_filename ); + x264_fprintf( stderr, "avs [error]: `%s' has no video data\n", psz_filename ); return -1; } if( vi->width&1 || vi->height&1 ) { - fprintf( stderr, "avs [error]: input clip width or height not divisible by 2 (%dx%d)\n", + x264_fprintf( stderr, "avs [error]: input clip width or height not divisible by 2 (%dx%d)\n", vi->width, vi->height ); return -1; } @@ -224,14 +225,14 @@ static int open_file( char *psz_filename if( !avs_is_yv12( vi ) || avs_version >= AVS_INTERFACE_OTHER_PLANAR ) { h->func.avs_release_clip( h->clip ); - fprintf( stderr, "avs %s\n", !avs_is_yv12( vi ) ? "[warning]: converting input clip to YV12" + x264_fprintf( stderr, "avs %s\n", !avs_is_yv12( vi ) ? "[warning]: converting input clip to YV12" : "[info]: avisynth 2.6+ detected, forcing conversion to YV12" ); const char *arg_name[2] = { NULL, "interlaced" }; AVS_Value arg_arr[2] = { res, avs_new_value_bool( info->interlaced ) }; AVS_Value res2 = h->func.avs_invoke( h->env, "ConvertToYV12", avs_new_value_array( arg_arr, 2 ), arg_name ); if( avs_is_error( res2 ) ) { - fprintf( stderr, "avs [error]: couldn't convert input clip to YV12\n" ); + x264_fprintf( stderr, "avs [error]: couldn't convert input clip to YV12\n" ); return -1; } h->clip = h->func.avs_take_clip( res2, h->env ); @@ -279,7 +280,7 @@ static int read_frame( x264_picture_t *p const char *err = h->func.avs_clip_get_error( h->clip ); if( err ) { - fprintf( stderr, "avs [error]: %s occurred while reading frame %d\n", err, i_frame ); + x264_fprintf( stderr, "avs [error]: %s occurred while reading frame %d\n", err, i_frame ); return -1; } for( i = 0; i < 3; i++ ) diff -uNrp c/input/ffms.c b/input/ffms.c --- c/input/ffms.c 2010-02-15 12:48:41 +0200 +++ b/input/ffms.c 2010-03-29 12:45:31 +0300 @@ -32,6 +32,7 @@ #else #define SetConsoleTitle(t) #endif +#include "extras/x264loger.h" typedef struct { @@ -88,24 +89,24 @@ static int open_file( char *psz_filename fprintf( stderr, " \r" ); if( !index ) { - fprintf( stderr, "ffms [error]: could not create index\n" ); + x264_fprintf( stderr, "ffms [error]: could not create index\n" ); return -1; } if( opt->index && FFMS_WriteIndex( opt->index, index, &e ) ) - fprintf( stderr, "ffms [warning]: could not write index file\n" ); + x264_fprintf( stderr, "ffms [warning]: could not write index file\n" ); } int trackno = FFMS_GetFirstTrackOfType( index, FFMS_TYPE_VIDEO, &e ); if( trackno < 0 ) { - fprintf( stderr, "ffms [error]: could not find video track\n" ); + x264_fprintf( stderr, "ffms [error]: could not find video track\n" ); return -1; } h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, index, 1, seekmode, &e ); if( !h->video_source ) { - fprintf( stderr, "ffms [error]: could not create video source\n" ); + x264_fprintf( stderr, "ffms [error]: could not create video source\n" ); return -1; } @@ -125,7 +126,7 @@ static int open_file( char *psz_filename const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, 0, &e ); if( !frame ) { - fprintf( stderr, "ffms [error]: could not read frame 0\n" ); + x264_fprintf( stderr, "ffms [error]: could not read frame 0\n" ); return -1; } @@ -135,7 +136,7 @@ static int open_file( char *psz_filename info->interlaced = frame->InterlacedFrame; if( h->cur_pix_fmt != PIX_FMT_YUV420P ) - fprintf( stderr, "ffms [warning]: converting from %s to YV12\n", + x264_fprintf( stderr, "ffms [warning]: converting from %s to YV12\n", avcodec_get_pix_fmt_name( h->cur_pix_fmt ) ); /* ffms timestamps are in milliseconds. Increasing timebase denominator could cause integer overflow. @@ -173,7 +174,7 @@ static int check_swscale( ffms_hnd_t *h, if( h->scaler ) { sws_freeContext( h->scaler ); - fprintf( stderr, "ffms [warning]: stream properties changed to %dx%d, %s at frame %d \n", frame->EncodedWidth, + x264_fprintf( stderr, "ffms [warning]: stream properties changed to %dx%d, %s at frame %d \n", frame->EncodedWidth, frame->EncodedHeight, avcodec_get_pix_fmt_name( frame->EncodedPixelFormat ), i_frame ); h->cur_width = frame->EncodedWidth; h->cur_height = frame->EncodedHeight; @@ -183,7 +184,7 @@ static int check_swscale( ffms_hnd_t *h, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL ); if( !h->scaler ) { - fprintf( stderr, "ffms [error]: could not open swscale context\n" ); + x264_fprintf( stderr, "ffms [error]: could not open swscale context\n" ); return -1; } return 0; @@ -197,7 +198,7 @@ static int read_frame( x264_picture_t *p const FFMS_Frame *frame = FFMS_GetFrame( h->video_source, i_frame, &e ); if( !frame ) { - fprintf( stderr, "ffms [error]: could not read frame %d\n", i_frame ); + x264_fprintf( stderr, "ffms [error]: could not read frame %d\n", i_frame ); return -1; } @@ -216,7 +217,7 @@ static int read_frame( x264_picture_t *p { if( info->PTS == AV_NOPTS_VALUE ) { - fprintf( stderr, "ffms [error]: invalid timestamp. " + x264_fprintf( stderr, "ffms [error]: invalid timestamp. " "Use --force-cfr and specify a framerate with --fps\n" ); return -1; } diff -uNrp c/input/lavf.c b/input/lavf.c --- c/input/lavf.c 2010-02-15 12:48:41 +0200 +++ b/input/lavf.c 2010-03-29 12:45:59 +0300 @@ -25,6 +25,7 @@ #undef DECLARE_ALIGNED #include #include +#include "extras/x264loger.h" typedef struct { @@ -59,7 +60,7 @@ static int check_swscale( lavf_hnd_t *h, if( h->scaler ) { sws_freeContext( h->scaler ); - fprintf( stderr, "lavf [warning]: stream properties changed to %dx%d, %s at frame %d \n", + x264_fprintf( stderr, "lavf [warning]: stream properties changed to %dx%d, %s at frame %d \n", c->width, c->height, avcodec_get_pix_fmt_name( c->pix_fmt ), i_frame ); h->cur_width = c->width; h->cur_height = c->height; @@ -69,7 +70,7 @@ static int check_swscale( lavf_hnd_t *h, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL ); if( !h->scaler ) { - fprintf( stderr, "lavf [error]: could not open swscale context\n" ); + x264_fprintf( stderr, "lavf [error]: could not open swscale context\n" ); return -1; } return 0; @@ -106,12 +107,12 @@ static int read_frame_internal( x264_pic { c->reordered_opaque = pkt->pts; if( avcodec_decode_video2( c, frame, &finished, pkt ) < 0 ) - fprintf( stderr, "lavf [warning]: video decoding failed on frame %d\n", h->next_frame ); + x264_fprintf( stderr, "lavf [warning]: video decoding failed on frame %d\n", h->next_frame ); } if( !finished ) { if( avcodec_decode_video2( c, frame, &finished, pkt ) < 0 ) - fprintf( stderr, "lavf [warning]: video decoding failed on frame %d\n", h->next_frame ); + x264_fprintf( stderr, "lavf [warning]: video decoding failed on frame %d\n", h->next_frame ); if( !finished ) return -1; } @@ -165,13 +166,13 @@ static int open_file( char *psz_filename if( av_open_input_file( &h->lavf, psz_filename, NULL, 0, NULL ) ) { - fprintf( stderr, "lavf [error]: could not open input file\n" ); + x264_fprintf( stderr, "lavf [error]: could not open input file\n" ); return -1; } if( av_find_stream_info( h->lavf ) < 0 ) { - fprintf( stderr, "lavf [error]: could not find input stream info\n" ); + x264_fprintf( stderr, "lavf [error]: could not find input stream info\n" ); return -1; } @@ -180,7 +181,7 @@ static int open_file( char *psz_filename i++; if( i == h->lavf->nb_streams ) { - fprintf( stderr, "lavf [error]: could not find video stream\n" ); + x264_fprintf( stderr, "lavf [error]: could not find video stream\n" ); return -1; } h->stream_id = i; @@ -204,12 +205,12 @@ static int open_file( char *psz_filename info->csp |= X264_CSP_VFLIP; if( h->cur_pix_fmt != PIX_FMT_YUV420P ) - fprintf( stderr, "lavf [warning]: converting from %s to YV12\n", + x264_fprintf( stderr, "lavf [warning]: converting from %s to YV12\n", avcodec_get_pix_fmt_name( h->cur_pix_fmt ) ); if( avcodec_open( c, avcodec_find_decoder( c->codec_id ) ) ) { - fprintf( stderr, "lavf [error]: could not find decoder for video stream\n" ); + x264_fprintf( stderr, "lavf [error]: could not find decoder for video stream\n" ); return -1; } @@ -217,7 +218,7 @@ static int open_file( char *psz_filename h->first_pic = malloc( sizeof(x264_picture_t) ); if( !h->first_pic || lavf_input.picture_alloc( h->first_pic, info->csp, info->width, info->height ) ) { - fprintf( stderr, "lavf [error]: malloc failed\n" ); + x264_fprintf( stderr, "lavf [error]: malloc failed\n" ); return -1; } else if( read_frame_internal( h->first_pic, h, 0, info ) ) diff -uNrp c/input/thread.c b/input/thread.c --- c/input/thread.c 2010-02-15 12:48:41 +0200 +++ b/input/thread.c 2010-03-29 12:46:12 +0300 @@ -22,6 +22,7 @@ *****************************************************************************/ #include "muxers.h" +#include "extras/x264loger.h" extern cli_input_t input; @@ -50,7 +51,7 @@ static int open_file( char *psz_filename thread_hnd_t *h = malloc( sizeof(thread_hnd_t) ); if( !h || input.picture_alloc( &h->pic, info->csp, info->width, info->height ) ) { - fprintf( stderr, "x264 [error]: malloc failed\n" ); + x264_fprintf( stderr, "x264 [error]: malloc failed\n" ); return -1; } h->input = input; diff -uNrp c/input/timecode.c b/input/timecode.c --- c/input/timecode.c 2010-03-29 11:48:52 +0300 +++ b/input/timecode.c 2010-03-29 12:47:05 +0300 @@ -22,6 +22,7 @@ #include "muxers.h" #include +#include "extras/x264loger.h" extern cli_input_t input; @@ -63,7 +64,7 @@ static double correct_fps( double fps, t fps_num = round( fps_den * fps_sig ) * exponent; if( fps_num < 0 ) { - fprintf( stderr, "timecode [error]: tcfile fps correction failed.\n" + x264_fprintf( stderr, "timecode [error]: tcfile fps correction failed.\n" " Specify an appropriate timebase manually or remake tcfile.\n" ); return -1; } @@ -94,7 +95,7 @@ static int try_mkv_timebase_den( double h->timebase_num = fps_den > 0 && h->timebase_num ? gcd( h->timebase_num, fps_den ) : fps_den; if( h->timebase_num <= 0 ) { - fprintf( stderr, "timecode [error]: automatic timebase generation failed.\n" + x264_fprintf( stderr, "timecode [error]: automatic timebase generation failed.\n" " Specify timebase manually.\n" ); return -1; } @@ -113,7 +114,7 @@ static int parse_tcfile( FILE *tcfile_in ret = fscanf( tcfile_in, "# timecode format v%d", &tcfv ); if( ret != 1 || (tcfv != 1 && tcfv != 2) ) { - fprintf( stderr, "timecode [error]: unsupported timecode format\n" ); + x264_fprintf( stderr, "timecode [error]: unsupported timecode format\n" ); return -1; } @@ -131,14 +132,14 @@ static int parse_tcfile( FILE *tcfile_in continue; if( sscanf( buff, "assume %lf", &h->assume_fps ) != 1 && sscanf( buff, "Assume %lf", &h->assume_fps ) != 1 ) { - fprintf( stderr, "timecode [error]: tcfile parsing error: assumed fps not found\n" ); + x264_fprintf( stderr, "timecode [error]: tcfile parsing error: assumed fps not found\n" ); return -1; } break; } if( h->assume_fps <= 0 ) { - fprintf( stderr, "timecode [error]: invalid assumed fps %.6f\n", h->assume_fps ); + x264_fprintf( stderr, "timecode [error]: invalid assumed fps %.6f\n", h->assume_fps ); return -1; } @@ -155,12 +156,12 @@ static int parse_tcfile( FILE *tcfile_in ret = sscanf( buff, "%d,%d,%lf", &start, &end, &seq_fps ); if( ret != 3 && ret != EOF ) { - fprintf( stderr, "timecode [error]: invalid input tcfile\n" ); + x264_fprintf( stderr, "timecode [error]: invalid input tcfile\n" ); return -1; } if( start > end || start <= prev_start || end <= prev_end || seq_fps <= 0 ) { - fprintf( stderr, "timecode [error]: invalid input tcfile at line %d: %s\n", num, buff ); + x264_fprintf( stderr, "timecode [error]: invalid input tcfile at line %d: %s\n", num, buff ); return -1; } prev_start = start; @@ -259,7 +260,7 @@ static int parse_tcfile( FILE *tcfile_in timecodes_num = h->stored_pts_num + h->seek; if( !timecodes_num ) { - fprintf( stderr, "timecode [error]: input tcfile doesn't have any timecodes!\n" ); + x264_fprintf( stderr, "timecode [error]: input tcfile doesn't have any timecodes!\n" ); return -1; } fseek( tcfile_in, file_pos, SEEK_SET ); @@ -272,7 +273,7 @@ static int parse_tcfile( FILE *tcfile_in ret = sscanf( buff, "%lf", &timecodes[0] ); if( ret != 1 ) { - fprintf( stderr, "timecode [error]: invalid input tcfile for frame 0\n" ); + x264_fprintf( stderr, "timecode [error]: invalid input tcfile for frame 0\n" ); goto fail; } for( num = 1; num < timecodes_num; ) @@ -284,7 +285,7 @@ static int parse_tcfile( FILE *tcfile_in timecodes[num] *= 1e-3; /* Timecode format v2 is expressed in milliseconds. */ if( ret != 1 || timecodes[num] <= timecodes[num - 1] ) { - fprintf( stderr, "timecode [error]: invalid input tcfile for frame %d\n", num ); + x264_fprintf( stderr, "timecode [error]: invalid input tcfile for frame %d\n", num ); goto fail; } ++num; @@ -338,11 +339,11 @@ static int parse_tcfile( FILE *tcfile_in if( h->auto_timebase_den || h->auto_timebase_num ) { x264_reduce_fraction( &h->timebase_num, &h->timebase_den ); - fprintf( stderr, "timecode [info]: automatic timebase generation %d/%d\n", h->timebase_num, h->timebase_den ); + x264_fprintf( stderr, "timecode [info]: automatic timebase generation %d/%d\n", h->timebase_num, h->timebase_den ); } else if( h->timebase_den <= 0 ) { - fprintf( stderr, "timecode [error]: automatic timebase generation failed.\n" + x264_fprintf( stderr, "timecode [error]: automatic timebase generation failed.\n" " Specify an appropriate timebase manually.\n" ); goto fail; } @@ -358,7 +359,7 @@ static int parse_tcfile( FILE *tcfile_in h->pts[num] -= pts_seek_offset; if( h->pts[num] <= h->pts[num - 1] ) { - fprintf( stderr, "timecode [error]: invalid timebase or timecode for frame %d\n", num ); + x264_fprintf( stderr, "timecode [error]: invalid timebase or timecode for frame %d\n", num ); goto fail; } } @@ -384,7 +385,7 @@ static int open_file( char *psz_filename timecode_hnd_t *h = malloc( sizeof(timecode_hnd_t) ); if( !h ) { - fprintf( stderr, "timecode [error]: malloc failed\n" ); + x264_fprintf( stderr, "timecode [error]: malloc failed\n" ); return -1; } h->input = input; @@ -409,12 +410,12 @@ static int open_file( char *psz_filename tcfile_in = fopen( psz_filename, "rb" ); if( !tcfile_in ) { - fprintf( stderr, "timecode [error]: can't open `%s'\n", psz_filename ); + x264_fprintf( stderr, "timecode [error]: can't open `%s'\n", psz_filename ); return -1; } else if( !x264_is_regular_file( tcfile_in ) ) { - fprintf( stderr, "timecode [error]: tcfile input incompatible with non-regular file `%s'\n", psz_filename ); + x264_fprintf( stderr, "timecode [error]: tcfile input incompatible with non-regular file `%s'\n", psz_filename ); fclose( tcfile_in ); return -1; } @@ -455,7 +456,7 @@ static int read_frame( x264_picture_t *p { if( h->pts ) { - fprintf( stderr, "timecode [info]: input timecode file missing data for frame %d and later\n" + x264_fprintf( stderr, "timecode [info]: input timecode file missing data for frame %d and later\n" " assuming constant fps %.6f\n", i_frame, h->assume_fps ); free( h->pts ); h->pts = NULL; diff -uNrp c/input/y4m.c b/input/y4m.c --- c/input/y4m.c 2010-03-29 11:48:52 +0300 +++ b/input/y4m.c 2010-03-29 13:00:28 +0300 @@ -22,6 +22,7 @@ *****************************************************************************/ #include "muxers.h" +#include "extras/x264loger.h" typedef struct { @@ -155,7 +156,7 @@ static int open_file( char *psz_filename if( colorspace != X264_CSP_I420 ) { - fprintf( stderr, "y4m [error]: colorspace unhandled\n" ); + x264_fprintf( stderr, "y4m [error]: colorspace unhandled\n" ); return -1; } @@ -195,7 +196,7 @@ static int read_frame_internal( x264_pic header[slen] = 0; if( strncmp( header, Y4M_FRAME_MAGIC, slen ) ) { - fprintf( stderr, "y4m [error]: bad header magic (%"PRIx32" <=> %s)\n", + x264_fprintf( stderr, "y4m [error]: bad header magic (%"PRIx32" <=> %s)\n", M32(header), header ); return -1; } @@ -205,7 +206,7 @@ static int read_frame_internal( x264_pic i++; if( i == MAX_FRAME_HEADER ) { - fprintf( stderr, "y4m [error]: bad frame header!\n" ); + x264_fprintf( stderr, "y4m [error]: bad frame header!\n" ); return -1; } h->frame_header_len = i+slen+1; diff -uNrp c/input/yuv.c b/input/yuv.c --- c/input/yuv.c 2010-02-15 12:48:41 +0200 +++ b/input/yuv.c 2010-03-29 13:00:45 +0300 @@ -22,6 +22,7 @@ *****************************************************************************/ #include "muxers.h" +#include "extras/x264loger.h" typedef struct { @@ -48,7 +49,7 @@ static int open_file( char *psz_filename sscanf( opt->resolution, "%ux%u", &info->width, &info->height ); if( !info->width || !info->height ) { - fprintf( stderr, "yuv [error]: rawyuv input requires a resolution.\n" ); + x264_fprintf( stderr, "yuv [error]: rawyuv input requires a resolution.\n" ); return -1; } diff -uNrp c/output/avi.c b/output/avi.c --- c/output/avi.c 2010-03-29 12:39:09 +0300 +++ b/output/avi.c 2010-03-29 13:01:00 +0300 @@ -22,6 +22,7 @@ #include "muxers.h" #include +#include "extras/x264loger.h" typedef struct { @@ -78,7 +79,7 @@ static int open_file( char *psz_filename return -1; else if( !x264_is_regular_file( fh ) ) { - fprintf( stderr, "avi [error]: AVI output is incompatible with non-regular file `%s'\n", psz_filename ); + x264_fprintf( stderr, "avi [error]: AVI output is incompatible with non-regular file `%s'\n", psz_filename ); return -1; } fclose( fh ); diff -uNrp c/output/flv.c b/output/flv.c --- c/output/flv.c 2010-03-29 11:48:52 +0300 +++ b/output/flv.c 2010-03-29 13:01:12 +0300 @@ -20,6 +20,7 @@ #include "muxers.h" #include "flv_bytestream.h" +#include "extras/x264loger.h" #define CHECK(x)\ do {\ @@ -223,13 +224,13 @@ static int write_frame( hnd_t handle, ui if( prev_dts == dts ) { double fps = ((double)p_flv->i_timebase_den / p_flv->i_timebase_num) / (p_picture->i_dts - p_flv->i_prev_dts); - fprintf( stderr, "flv [warning]: duplicate DTS %"PRId64" generated by rounding\n" + x264_fprintf( stderr, "flv [warning]: duplicate DTS %"PRId64" generated by rounding\n" " current internal decoding framerate: %.6f fps\n", dts, fps ); } if( prev_cts == cts ) { double fps = ((double)p_flv->i_timebase_den / p_flv->i_timebase_num) / (p_picture->i_pts - p_flv->i_prev_pts); - fprintf( stderr, "flv [warning]: duplicate CTS %"PRId64" generated by rounding\n" + x264_fprintf( stderr, "flv [warning]: duplicate CTS %"PRId64" generated by rounding\n" " current internal composition framerate: %.6f fps\n", cts, fps ); } } diff -uNrp c/output/mp4.c b/output/mp4.c --- c/output/mp4.c 2010-03-29 11:48:52 +0300 +++ b/output/mp4.c 2010-03-29 13:01:25 +0300 @@ -23,6 +23,7 @@ #include "muxers.h" #include +#include "extras/x264loger.h" #ifdef HAVE_GF_MALLOC #undef malloc @@ -66,7 +67,7 @@ static void recompute_bitrate_mp4( GF_IS GF_ISOSample *samp = gf_isom_get_sample_info( p_file, i_track, i+1, &di, &offset ); if( !samp ) { - fprintf( stderr, "mp4 [error]: failure reading back frame %u\n", i ); + x264_fprintf( stderr, "mp4 [error]: failure reading back frame %u\n", i ); break; } @@ -164,7 +165,7 @@ static int open_file( char *psz_filename return -1; else if( !x264_is_regular_file( fh ) ) { - fprintf( stderr, "mp4 [error]: MP4 output is incompatible with non-regular file `%s'\n", psz_filename ); + x264_fprintf( stderr, "mp4 [error]: MP4 output is incompatible with non-regular file `%s'\n", psz_filename ); return -1; } fclose( fh ); diff -uNrp c/x264.c b/x264.c --- c/x264.c 2010-03-29 12:39:13 +0300 +++ b/x264.c 2010-03-29 12:42:50 +0300 @@ -780,11 +780,11 @@ static int select_output( const char *mu param->b_repeat_headers = 0; if( param->i_nal_hrd == X264_NAL_HRD_CBR ) { - fprintf( stderr, "x264 [warning]: cbr nal-hrd is not compatible with mp4\n" ); + x264_fprintf( stderr, "x264 [warning]: cbr nal-hrd is not compatible with mp4\n" ); param->i_nal_hrd = X264_NAL_HRD_VBR; } #else - fprintf( stderr, "x264 [error]: not compiled with MP4 output support\n" ); + x264_fprintf( stderr, "x264 [error]: not compiled with MP4 output support\n" ); return -1; #endif } @@ -811,7 +811,7 @@ static int select_output( const char *mu param->b_dts_compress = 0; param->b_repeat_headers = 1; #else - fprintf( stderr, "x264 [error]: not compiled with AVI output support\n" ); + x264_fprintf( stderr, "x264 [error]: not compiled with AVI output support\n" ); return -1; #endif } @@ -845,7 +845,7 @@ static int select_input( const char *dem input = avs_input; module = "avs"; #else - fprintf( stderr, "x264 [error]: not compiled with AVS input support\n" ); + x264_fprintf( stderr, "x264 [error]: not compiled with AVS input support\n" ); return -1; #endif } @@ -891,7 +891,7 @@ static int select_input( const char *dem if( !(*p_handle) ) { - fprintf( stderr, "x264 [error]: could not open input file `%s' via any method!\n", filename ); + x264_fprintf( stderr, "x264 [error]: could not open input file `%s' via any method!\n", filename ); return -1; } } @@ -999,7 +999,7 @@ static int Parse( int argc, char **argv, i++; if( !muxer_names[i] ) { - fprintf( stderr, "x264 [error]: invalid muxer '%s'\n", optarg ); + x264_fprintf( stderr, "x264 [error]: invalid muxer '%s'\n", optarg ); return -1; } muxer = optarg; @@ -1009,7 +1009,7 @@ static int Parse( int argc, char **argv, i++; if( !demuxer_names[i] ) { - fprintf( stderr, "x264 [error]: invalid demuxer '%s'\n", optarg ); + x264_fprintf( stderr, "x264 [error]: invalid demuxer '%s'\n", optarg ); return -1; } demuxer = optarg; @@ -1021,12 +1021,12 @@ static int Parse( int argc, char **argv, opt->qpfile = fopen( optarg, "rb" ); if( !opt->qpfile ) { - fprintf( stderr, "x264 [error]: can't open qpfile `%s'\n", optarg ); + x264_fprintf( stderr, "x264 [error]: can't open qpfile `%s'\n", optarg ); return -1; } else if( !x264_is_regular_file( opt->qpfile ) ) { - fprintf( stderr, "x264 [error]: qpfile incompatible with non-regular file `%s'\n", optarg ); + x264_fprintf( stderr, "x264 [error]: qpfile incompatible with non-regular file `%s'\n", optarg ); fclose( opt->qpfile ); return -1; } @@ -1048,7 +1048,7 @@ static int Parse( int argc, char **argv, param->b_visualize = 1; b_exit_on_ctrl_c = 1; #else - fprintf( stderr, "x264 [warning]: not compiled with visualization support\n" ); + x264_fprintf( stderr, "x264 [warning]: not compiled with visualization support\n" ); #endif break; case OPT_TUNE: @@ -1077,7 +1077,7 @@ static int Parse( int argc, char **argv, opt->tcfile_out = fopen( optarg, "wb" ); if( !opt->tcfile_out ) { - fprintf( stderr, "x264 [error]: can't open `%s'\n", optarg ); + x264_fprintf( stderr, "x264 [error]: can't open `%s'\n", optarg ); return -1; } break; @@ -1089,7 +1089,7 @@ static int Parse( int argc, char **argv, i++; if( !pulldown_names[i] ) { - fprintf( stderr, "x264 [error]: invalid pulldown '%s'\n", optarg ); + x264_fprintf( stderr, "x264 [error]: invalid pulldown '%s'\n", optarg ); return -1; } opt->i_pulldown = i; @@ -1120,7 +1120,7 @@ generic_option: if( b_error ) { const char *name = long_options_index > 0 ? long_options[long_options_index].name : argv[optind-2]; - fprintf( stderr, "x264 [error]: invalid argument: %s = %s\n", name, optarg ); + x264_fprintf( stderr, "x264 [error]: invalid argument: %s = %s\n", name, optarg ); return -1; } } @@ -1136,7 +1136,7 @@ generic_option: /* Get the file name */ if( optind > argc - 1 || !output_filename ) { - fprintf( stderr, "x264 [error]: No %s file. Run x264 --help for a list of options.\n", + x264_fprintf( stderr, "x264 [error]: No %s file. Run x264 --help for a list of options.\n", optind > argc - 1 ? "input" : "output" ); return -1; } @@ -1145,7 +1145,7 @@ generic_option: return -1; if( output.open_file( output_filename, &opt->hout ) ) { - fprintf( stderr, "x264 [error]: could not open output file `%s'\n", output_filename ); + x264_fprintf( stderr, "x264 [error]: could not open output file `%s'\n", output_filename ); return -1; } @@ -1168,14 +1168,14 @@ generic_option: if( !opt->hin && input.open_file( input_filename, &opt->hin, &info, &input_opt ) ) { - fprintf( stderr, "x264 [error]: could not open input file `%s'\n", input_filename ); + x264_fprintf( stderr, "x264 [error]: could not open input file `%s'\n", input_filename ); return -1; } x264_reduce_fraction( &info.sar_width, &info.sar_height ); x264_reduce_fraction( &info.fps_num, &info.fps_den ); if( param->i_log_level >= X264_LOG_INFO ) - fprintf( stderr, "%s [info]: %dx%d%c %d:%d @ %d/%d fps (%cfr)\n", demuxername, info.width, + x264_fprintf( stderr, "%s [info]: %dx%d%c %d:%d @ %d/%d fps (%cfr)\n", demuxername, info.width, info.height, info.interlaced ? 'i' : 'p', info.sar_width, info.sar_height, info.fps_num, info.fps_den, info.vfr ? 'v' : 'c' ); @@ -1183,12 +1183,12 @@ generic_option: { if( b_user_fps ) { - fprintf( stderr, "x264 [error]: --fps + --tcfile-in is incompatible.\n" ); + x264_fprintf( stderr, "x264 [error]: --fps + --tcfile-in is incompatible.\n" ); return -1; } if( timecode_input.open_file( tcfile_name, &opt->hin, &info, &input_opt ) ) { - fprintf( stderr, "x264 [error]: timecode input failed\n" ); + x264_fprintf( stderr, "x264 [error]: timecode input failed\n" ); return -1; } else @@ -1196,7 +1196,7 @@ generic_option: } else if( !info.vfr && input_opt.timebase ) { - fprintf( stderr, "x264 [error]: --timebase is incompatible with cfr input\n" ); + x264_fprintf( stderr, "x264 [error]: --timebase is incompatible with cfr input\n" ); return -1; } @@ -1207,7 +1207,7 @@ generic_option: param->i_width = info.width; if( !b_user_interlaced && info.interlaced ) { - fprintf( stderr, "x264 [warning]: input appears to be interlaced, enabling interlaced mode.\n" + x264_fprintf( stderr, "x264 [warning]: input appears to be interlaced, enabling interlaced mode.\n" " If you want otherwise, use --no-interlaced\n" ); param->b_interlaced = 1; } @@ -1233,7 +1233,7 @@ generic_option: int ret = sscanf( input_opt.timebase, "%d/%d", &i_user_timebase_num, &i_user_timebase_den ); if( !ret ) { - fprintf( stderr, "x264 [error]: invalid argument: timebase = %s\n", input_opt.timebase ); + x264_fprintf( stderr, "x264 [error]: invalid argument: timebase = %s\n", input_opt.timebase ); return -1; } else if( ret == 1 ) @@ -1245,7 +1245,7 @@ generic_option: * ((double)param->i_timebase_num / i_user_timebase_num); if( opt->timebase_convert_multiplier < 1 ) { - fprintf( stderr, "x264 [error]: timebase you specified will generate nonmonotonic pts: %d/%d\n", + x264_fprintf( stderr, "x264 [error]: timebase you specified will generate nonmonotonic pts: %d/%d\n", i_user_timebase_num, i_user_timebase_den ); return -1; } @@ -1265,7 +1265,7 @@ generic_option: { if( thread_input.open_file( NULL, &opt->hin, &info, NULL ) ) { - fprintf( stderr, "x264 [error]: threaded input failed\n" ); + x264_fprintf( stderr, "x264 [error]: threaded input failed\n" ); return -1; } else @@ -1323,7 +1323,7 @@ static void parse_qpfile( cli_opt_t *opt else ret = 0; if( ret != 3 || qp < -1 || qp > 51 ) { - fprintf( stderr, "x264 [error]: can't parse qpfile for frame %d\n", i_frame ); + x264_fprintf( stderr, "x264 [error]: can't parse qpfile for frame %d\n", i_frame ); fclose( opt->qpfile ); opt->qpfile = NULL; pic->i_type = X264_TYPE_AUTO; @@ -1348,7 +1348,7 @@ static int Encode_frame( x264_t *h, hnd if( i_frame_size < 0 ) { - fprintf( stderr, "x264 [error]: x264_encoder_encode failed\n" ); + x264_fprintf( stderr, "x264 [error]: x264_encoder_encode failed\n" ); return -1; } @@ -1422,7 +1422,7 @@ static int Encode( x264_param_t *param, param->i_timebase_num = param->i_fps_den; if( fmod( param->i_fps_num * pulldown->fps_factor, 1 ) ) { - fprintf( stderr, "x264 [error]: unsupported framerate for chosen pulldown\n" ); + x264_fprintf( stderr, "x264 [error]: unsupported framerate for chosen pulldown\n" ); return -1; } param->i_timebase_den = param->i_fps_num * pulldown->fps_factor; @@ -1430,7 +1430,7 @@ static int Encode( x264_param_t *param, if( ( h = x264_encoder_open( param ) ) == NULL ) { - fprintf( stderr, "x264 [error]: x264_encoder_open failed\n" ); + x264_fprintf( stderr, "x264 [error]: x264_encoder_open failed\n" ); input.close_file( opt->hin ); return -1; } @@ -1441,7 +1441,7 @@ static int Encode( x264_param_t *param, if( output.set_param( opt->hout, param ) ) { - fprintf( stderr, "x264 [error]: can't set outfile param\n" ); + x264_fprintf( stderr, "x264 [error]: can't set outfile param\n" ); input.close_file( opt->hin ); output.close_file( opt->hout, largest_pts, second_largest_pts ); return -1; @@ -1450,7 +1450,7 @@ static int Encode( x264_param_t *param, /* Create a new pic */ if( input.picture_alloc( &pic, param->i_csp, param->i_width, param->i_height ) ) { - fprintf( stderr, "x264 [error]: malloc failed\n" ); + x264_fprintf( stderr, "x264 [error]: malloc failed\n" ); return -1; } @@ -1459,7 +1459,7 @@ static int Encode( x264_param_t *param, ticks_per_frame = (int64_t)param->i_timebase_den * param->i_fps_den / param->i_timebase_num / param->i_fps_num; if( ticks_per_frame < 1 ) { - fprintf( stderr, "x264 [error]: ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame ); + x264_fprintf( stderr, "x264 [error]: ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame ); return -1; } @@ -1471,7 +1471,7 @@ static int Encode( x264_param_t *param, if( x264_encoder_headers( h, &headers, &i_nal ) < 0 ) { - fprintf( stderr, "x264 [error]: x264_encoder_headers failed\n" ); + x264_fprintf( stderr, "x264 [error]: x264_encoder_headers failed\n" ); return -1; } @@ -1507,10 +1507,10 @@ static int Encode( x264_param_t *param, if( param->i_log_level >= X264_LOG_WARNING ) { if( param->i_log_level >= X264_LOG_DEBUG || pts_warning_cnt < MAX_PTS_WARNING ) - fprintf( stderr, "x264 [warning]: non-strictly-monotonic pts at frame %d (%"PRId64" <= %"PRId64")\n", + x264_fprintf( stderr, "x264 [warning]: non-strictly-monotonic pts at frame %d (%"PRId64" <= %"PRId64")\n", i_frame, output_pts, largest_pts * dts_compress_multiplier ); else if( pts_warning_cnt == MAX_PTS_WARNING ) - fprintf( stderr, "x264 [warning]: too many nonmonotonic pts warnings, suppressing further ones\n" ); + x264_fprintf( stderr, "x264 [warning]: too many nonmonotonic pts warnings, suppressing further ones\n" ); pts_warning_cnt++; } pic.i_pts = largest_pts + ticks_per_frame; @@ -1560,7 +1560,7 @@ static int Encode( x264_param_t *param, Print_status( i_start, i_frame_output, i_frame_total, i_file, param, last_pts ); } if( pts_warning_cnt >= MAX_PTS_WARNING && param->i_log_level < X264_LOG_DEBUG ) - fprintf( stderr, "x264 [warning]: %d suppressed nonmonotonic pts warnings\n", pts_warning_cnt-MAX_PTS_WARNING ); + x264_fprintf( stderr, "x264 [warning]: %d suppressed nonmonotonic pts warnings\n", pts_warning_cnt-MAX_PTS_WARNING ); /* duration algorithm fails when only 1 frame is output */ if( i_frame_output == 1 ) @@ -1579,7 +1579,7 @@ static int Encode( x264_param_t *param, fprintf( stderr, "\n" ); if( b_ctrl_c ) - fprintf( stderr, "aborted at input frame %d, output frame %d\n", opt->i_seek + i_frame, i_frame_output ); + x264_fprintf( stderr, "aborted at input frame %d, output frame %d\n", opt->i_seek + i_frame, i_frame_output ); if( opt->tcfile_out ) { @@ -1595,7 +1595,7 @@ static int Encode( x264_param_t *param, double fps = (double)i_frame_output * (double)1000000 / (double)( i_end - i_start ); - fprintf( stderr, "encoded %d frames, %.2f fps, %.2f kb/s\n", i_frame_output, fps, + x264_fprintf( stderr, "encoded %d frames, %.2f fps, %.2f kb/s\n", i_frame_output, fps, (double) i_file * 8 / ( 1000 * duration ) ); }