From: Martin Storsjö Date: Mon, 19 Mar 2012 18:37:10 +0000 (+0200) Subject: libavformat: Set the default for the max_delay option to -1 X-Git-Tag: v9_beta1~2317 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4fa57d524f16524e9735f99b387167149dbf5a7b;p=platform%2Fupstream%2Flibav.git libavformat: Set the default for the max_delay option to -1 Make the muxers/demuxers that use the field handle the default -1 in the same way as 0. This allows distinguishing an intentionally set 0 from the default value where the user hasn't set it. Signed-off-by: Martin Storsjö --- diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 852b3f1..bda8d83 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -318,6 +318,8 @@ static int mpeg_mux_init(AVFormatContext *ctx) s->packet_size = ctx->packet_size; } else s->packet_size = 2048; + if (ctx->max_delay < 0) /* Not set by the caller */ + ctx->max_delay = 0; s->vcd_padding_bytes_written = 0; s->vcd_padding_bitrate=0; diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 493ae2e..a594ca2 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -460,6 +460,9 @@ static int mpegts_write_header(AVFormatContext *s) const char *provider_name; int *pids; + if (s->max_delay < 0) /* Not set by the caller */ + s->max_delay = 0; + // round up to a whole number of TS packets ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14; diff --git a/libavformat/options_table.h b/libavformat/options_table.h index 7aee448..683596c 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -41,7 +41,7 @@ static const AVOption options[]={ {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ {"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, {"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, -{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, +{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, E|D}, {"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D}, /* this is a crutch for avconv, since it cannot deal with identically named options in different contexts. * to be removed when avconv is fixed */ diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 6a1be49..78121ed 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -126,7 +126,7 @@ static int rtp_write_header(AVFormatContext *s1) s->max_payload_size = s1->packet_size - 12; s->max_frames_per_packet = 0; - if (s1->max_delay) { + if (s1->max_delay > 0) { if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { int frame_size = av_get_audio_frame_duration(st->codec, 0); if (!frame_size) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 56deed3..7afd106 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1426,6 +1426,9 @@ int ff_rtsp_connect(AVFormatContext *s) if (!ff_network_init()) return AVERROR(EIO); + if (s->max_delay < 0) /* Not set by the caller */ + s->max_delay = 0; + rt->control_transport = RTSP_MODE_PLAIN; if (rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_HTTP)) { rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP; @@ -1866,6 +1869,9 @@ static int sdp_read_header(AVFormatContext *s) if (!ff_network_init()) return AVERROR(EIO); + if (s->max_delay < 0) /* Not set by the caller */ + s->max_delay = 0; + /* read the whole sdp file */ /* XXX: better loading */ content = av_malloc(SDP_MAX_SIZE);