[FFmpeg-cvslog] ffserver_config: set defaults basing on absence of set value

Lukasz Marek git at videolan.org
Tue Dec 2 22:12:30 CET 2014


ffmpeg | branch: master | Lukasz Marek <lukasz.m.luki2 at gmail.com> | Wed Nov 26 19:08:18 2014 +0100| [2f4233614a7fbe176b81de0ef14bf38bad8e6693] | committer: Lukasz Marek

ffserver_config: set defaults basing on absence of set value

This prevents the situation when user set option to 0 and ffserver
threats it as not set value, so applies the default.

Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f4233614a7fbe176b81de0ef14bf38bad8e6693
---

 ffserver_config.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/ffserver_config.c b/ffserver_config.c
index 7773e3c..053ab39 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -200,51 +200,51 @@ static void add_codec(FFServerStream *stream, AVCodecContext *av,
     /* compute default parameters */
     switch(av->codec_type) {
     case AVMEDIA_TYPE_AUDIO:
-        if (av->bit_rate == 0) {
+        if (!av_dict_get(recommended, "ab", NULL, 0)) {
             av->bit_rate = 64000;
             av_dict_set_int(&recommended, "ab", av->bit_rate, 0);
         }
-        if (av->sample_rate == 0) {
+        if (!av_dict_get(recommended, "ar", NULL, 0)) {
             av->sample_rate = 22050;
             av_dict_set_int(&recommended, "ar", av->sample_rate, 0);
         }
-        if (av->channels == 0) {
+        if (!av_dict_get(recommended, "ac", NULL, 0)) {
             av->channels = 1;
             av_dict_set_int(&recommended, "ac", av->channels, 0);
         }
         break;
     case AVMEDIA_TYPE_VIDEO:
-        if (av->bit_rate == 0) {
+        if (!av_dict_get(recommended, "b", NULL, 0)) {
             av->bit_rate = 64000;
             av_dict_set_int(&recommended, "b", av->bit_rate, 0);
         }
-        if (av->time_base.num == 0){
+        if (!av_dict_get(recommended, "time_base", NULL, 0)){
             av->time_base.den = 5;
             av->time_base.num = 1;
             av_dict_set(&recommended, "time_base", "1/5", 0);
         }
-        if (av->width == 0 || av->height == 0) {
+        if (!av_dict_get(recommended, "video_size", NULL, 0)) {
             av->width = 160;
             av->height = 128;
             av_dict_set(&recommended, "video_size", "160x128", 0);
         }
         /* Bitrate tolerance is less for streaming */
-        if (av->bit_rate_tolerance == 0) {
+        if (!av_dict_get(recommended, "bt", NULL, 0)) {
             av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,
                       (int64_t)av->bit_rate*av->time_base.num/av->time_base.den);
             av_dict_set_int(&recommended, "bt", av->bit_rate_tolerance, 0);
         }
 
-        if (!av->rc_eq) {
+        if (!av_dict_get(recommended, "rc_eq", NULL, 0)) {
             av->rc_eq = av_strdup("tex^qComp");
             av_dict_set(&recommended, "rc_eq", "tex^qComp", 0);
         }
-        if (!av->rc_max_rate) {
+        if (!av_dict_get(recommended, "maxrate", NULL, 0)) {
             av->rc_max_rate = av->bit_rate * 2;
             av_dict_set_int(&recommended, "maxrate", av->rc_max_rate, 0);
         }
 
-        if (av->rc_max_rate && !av->rc_buffer_size) {
+        if (av->rc_max_rate && !av_dict_get(recommended, "bufsize", NULL, 0)) {
             av->rc_buffer_size = av->rc_max_rate;
             av_dict_set_int(&recommended, "bufsize", av->rc_buffer_size, 0);
         }



More information about the ffmpeg-cvslog mailing list