Re: [FFmpeg-devel] [PATCH 02/11] ffserver_config: cosmetic: move line_num into FFServerConfig

2014-11-17 Thread Reynaldo H. Verdejo Pinochet
OK to push too.

-- 
Reynaldo H. Verdejo Pinochet
Open Source Group
Samsung Research America / Silicon Valley
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 02/11] ffserver_config: cosmetic: move line_num into FFServerConfig

2014-11-16 Thread Lukasz Marek
Moving line_num into FFServerConfig as parser state,
saves many passes of it aside of FFServerConfig pointer.
---
 ffserver_config.c | 114 +++---
 ffserver_config.h |   1 +
 2 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/ffserver_config.c b/ffserver_config.c
index 6b80f02..7266455 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -32,7 +32,7 @@
 #include "ffserver_config.h"
 
 static int ffserver_save_avoption(const char *opt, const char *arg, int type,
-  FFServerConfig *config, int line_num);
+  FFServerConfig *config);
 static void vreport_config_error(const char *filename, int line_num, int 
log_level,
  int *errors, const char *fmt, va_list vl);
 static void report_config_error(const char *filename, int line_num, int 
log_level,
@@ -253,12 +253,12 @@ static void add_codec(FFServerStream *stream, 
AVCodecContext *av)
 stream->streams[stream->nb_streams++] = st;
 }
 
-static int ffserver_set_codec(AVCodecContext *ctx, const char *codec_name, 
FFServerConfig *config, int line_num)
+static int ffserver_set_codec(AVCodecContext *ctx, const char *codec_name, 
FFServerConfig *config)
 {
 int ret;
 AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
 if (!codec || codec->type != ctx->codec_type) {
-report_config_error(config->filename, line_num, AV_LOG_ERROR,
+report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
 &config->errors, "Invalid codec name: %s\n", 
codec_name);
 return 0;
 }
@@ -268,13 +268,13 @@ static int ffserver_set_codec(AVCodecContext *ctx, const 
char *codec_name, FFSer
 ctx->codec = codec;
 }
 if (ctx->codec_id != codec->id)
-report_config_error(config->filename, line_num, AV_LOG_ERROR, 
&config->errors,
+report_config_error(config->filename, config->line_num, AV_LOG_ERROR, 
&config->errors,
 "Inconsistent configuration: trying to set %s 
codec option, but %s codec is used previously\n",
 codec_name, avcodec_get_name(ctx->codec_id));
 return 0;
 }
 
-static int ffserver_opt_preset(const char *arg, int type, FFServerConfig 
*config, int line_num)
+static int ffserver_opt_preset(const char *arg, int type, FFServerConfig 
*config)
 {
 FILE *f=NULL;
 char filename[1000], tmp[1000], tmp2[1000], line[1000];
@@ -313,13 +313,13 @@ static int ffserver_opt_preset(const char *arg, int type, 
FFServerConfig *config
 if ((!strcmp(tmp, "acodec") && avctx->codec_type == 
AVMEDIA_TYPE_AUDIO) ||
  !strcmp(tmp, "vcodec") && avctx->codec_type == AVMEDIA_TYPE_VIDEO)
 {
-if (ffserver_set_codec(avctx, tmp2, config, line_num) < 0)
+if (ffserver_set_codec(avctx, tmp2, config) < 0)
 break;
 } else if (!strcmp(tmp, "scodec")) {
 av_log(NULL, AV_LOG_ERROR, "Subtitles preset found.\n");
 ret = AVERROR(EINVAL);
 break;
-} else if (ffserver_save_avoption(tmp, tmp2, type, config, line_num) < 
0)
+} else if (ffserver_save_avoption(tmp, tmp2, type, config) < 0)
 break;
 }
 
@@ -364,7 +364,7 @@ static void report_config_error(const char *filename, int 
line_num, int log_leve
 }
 
 static int ffserver_set_int_param(int *dest, const char *value, int factor, 
int min, int max,
-  FFServerConfig *config, int line_num, const 
char *error_msg, ...)
+  FFServerConfig *config, const char 
*error_msg, ...)
 {
 int tmp;
 char *tailp;
@@ -388,7 +388,7 @@ static int ffserver_set_int_param(int *dest, const char 
*value, int factor, int
 if (config) {
 va_list vl;
 va_start(vl, error_msg);
-vreport_config_error(config->filename, line_num, AV_LOG_ERROR,
+vreport_config_error(config->filename, config->line_num, AV_LOG_ERROR,
 &config->errors, error_msg, vl);
 va_end(vl);
 }
@@ -396,7 +396,7 @@ static int ffserver_set_int_param(int *dest, const char 
*value, int factor, int
 }
 
 static int ffserver_set_float_param(float *dest, const char *value, float 
factor, float min, float max,
-FFServerConfig *config, int line_num, 
const char *error_msg, ...)
+FFServerConfig *config, const char 
*error_msg, ...)
 {
 double tmp;
 char *tailp;
@@ -417,14 +417,14 @@ static int ffserver_set_float_param(float *dest, const 
char *value, float factor
 if (config) {
 va_list vl;
 va_start(vl, error_msg);
-vreport_config_error(config->filename, line_num, AV_LOG_ERROR,
+vreport_config_error(config->filename, config->line_num, AV_LOG_ERROR,
 &config->errors, error_msg, vl);
 va_end(vl);