History

In libx264 wrapper, correctly support 2pass log filename option.

Baptiste Coudurier committed 15 years ago

Commit 2c188931 parent b9553cf2 files · +22 −3Browse files

Unified · Split

2 files
  1. ffmpeg.c +9 −3
  2. libavcodec/libx264.c +13 −0
ffmpeg.c+9−3
@@ -207,7 +207,7 @@ static int do_hex_dump = 0; · 206 unmodified lines
207static int do_pkt_dump = 0;207static int do_pkt_dump = 0;
208static int do_psnr = 0;208static int do_psnr = 0;
209static int do_pass = 0;209static int do_pass = 0;
210static char *pass_logfilename_prefix = NULL;210static const char *pass_logfilename_prefix;
211static int audio_stream_copy = 0;211static int audio_stream_copy = 0;
212static int video_stream_copy = 0;212static int video_stream_copy = 0;
213static int subtitle_stream_copy = 0;213static int subtitle_stream_copy = 0;
@@ -2331,7 +2331,7 @@ static int transcode(AVFormatContext **output_files, · 2117 unmodified lines
2331 break;2331 break;
2332 }2332 }
2333 /* two pass mode */2333 /* two pass mode */
2334 if (ost->encoding_needed &&2334 if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 &&
2335 (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {2335 (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {
2336 char logfilename[1024];2336 char logfilename[1024];
2337 FILE *f;2337 FILE *f;
@@ -4268,6 +4268,12 @@ static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) · 1930 unmodified lines
4268{4268{
4269}4269}
4270 4270
4271static void opt_passlogfile(const char *arg)
4272{
4273 pass_logfilename_prefix = arg;
4274 opt_default("passlogfile", arg);
4275}
4276
4271static const OptionDef options[] = {4277static const OptionDef options[] = {
4272 /* main options */4278 /* main options */
4273#include "cmdutils_common_opts.h"4279#include "cmdutils_common_opts.h"
@@ -4341,7 +4347,7 @@ static const OptionDef options[] = { · 67 unmodified lines
4341 { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality},4347 { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality},
4342 "use same quantizer as source (implies VBR)" },4348 "use same quantizer as source (implies VBR)" },
4343 { "pass", HAS_ARG | OPT_FUNC2 | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" },4349 { "pass", HAS_ARG | OPT_FUNC2 | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" },
4344 { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" },4350 { "passlogfile", HAS_ARG | OPT_VIDEO, {(void*)&opt_passlogfile}, "select two pass log file name prefix", "prefix" },
4345 { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace},4351 { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace},
4346 "deinterlace pictures" },4352 "deinterlace pictures" },
4347 { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" },4353 { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" },
libavcodec/libx264.c+13−0
@@ -40,6 +40,7 @@ typedef struct X264Context { · 39 unmodified lines
40 const char *profile;40 const char *profile;
41 const char *level;41 const char *level;
42 int fastfirstpass;42 int fastfirstpass;
43 const char *stats;
43} X264Context;44} X264Context;
44 45
45static void X264_log(void *p, int level, const char *fmt, va_list args)46static void X264_log(void *p, int level, const char *fmt, va_list args)
@@ -164,6 +165,15 @@ static av_cold int X264_close(AVCodecContext *avctx) · 118 unmodified lines
164 return 0;165 return 0;
165}166}
166 167
168#define OPT_STR(opt, param) \
169 do { \
170 if (param && x264_param_parse(&x4->params, opt, param) < 0) { \
171 av_log(avctx, AV_LOG_ERROR, \
172 "bad value for '%s': '%s'\n", opt, param); \
173 return -1; \
174 } \
175 } while (0); \
176
167#define OPT_STR(opt, param) \177#define OPT_STR(opt, param) \
168 do { \178 do { \
169 if (param && x264_param_parse(&x4->params, opt, param) < 0) { \179 if (param && x264_param_parse(&x4->params, opt, param) < 0) { \
@@ -291,6 +301,8 @@ static av_cold int X264_init(AVCodecContext *avctx) · 121 unmodified lines
291 }301 }
292 }302 }
293 303
304 OPT_STR("stats", x4->stats);
305
294 // if neither crf nor cqp modes are selected we have to enable the RC306 // if neither crf nor cqp modes are selected we have to enable the RC
295 // we do it this way because we cannot check if the bitrate has been set307 // we do it this way because we cannot check if the bitrate has been set
296 if (!(avctx->crf || (avctx->cqp > -1)))308 if (!(avctx->crf || (avctx->cqp > -1)))
@@ -371,6 +383,7 @@ static const AVOption options[] = { · 74 unmodified lines
371 {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE},383 {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE},
372 {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE},384 {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
373 {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, 0, 0, 0, VE},385 {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
386 {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
374 { NULL },387 { NULL },
375};388};
376 389

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t