From 48f01398ba30d8d921b27558df0029033e2d4402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 22 Oct 2012 15:54:25 +0300 Subject: rtpdec: Cosmetic cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mainly clean up the RTP statistics code, plus a few other obviously misindentend lines. Remove some useless comments, de-doxygenize some comments, add spacing around operators and fix a typo. Signed-off-by: Martin Storsjö --- libavformat/rtpdec.c | 106 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 9a1c497..d16122d 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -166,71 +166,67 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l #define RTP_SEQ_MOD (1<<16) -/** -* called on parse open packet -*/ -static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence) // called on parse open packet. +static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence) { memset(s, 0, sizeof(RTPStatistics)); - s->max_seq= base_sequence; - s->probation= 1; + s->max_seq = base_sequence; + s->probation = 1; } -/** +/* * called whenever there is a large jump in sequence numbers, or when they get out of probation... */ static void rtp_init_sequence(RTPStatistics *s, uint16_t seq) { - s->max_seq= seq; - s->cycles= 0; - s->base_seq= seq -1; - s->bad_seq= RTP_SEQ_MOD + 1; - s->received= 0; - s->expected_prior= 0; - s->received_prior= 0; - s->jitter= 0; - s->transit= 0; + s->max_seq = seq; + s->cycles = 0; + s->base_seq = seq - 1; + s->bad_seq = RTP_SEQ_MOD + 1; + s->received = 0; + s->expected_prior = 0; + s->received_prior = 0; + s->jitter = 0; + s->transit = 0; } -/** +/* * returns 1 if we should handle this packet. */ static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) { - uint16_t udelta= seq - s->max_seq; - const int MAX_DROPOUT= 3000; - const int MAX_MISORDER = 100; + uint16_t udelta = seq - s->max_seq; + const int MAX_DROPOUT = 3000; + const int MAX_MISORDER = 100; const int MIN_SEQUENTIAL = 2; /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */ - if(s->probation) - { - if(seq==s->max_seq + 1) { + if (s->probation) { + if (seq == s->max_seq + 1) { s->probation--; - s->max_seq= seq; - if(s->probation==0) { + s->max_seq = seq; + if (s->probation == 0) { rtp_init_sequence(s, seq); s->received++; return 1; } } else { - s->probation= MIN_SEQUENTIAL - 1; + s->probation = MIN_SEQUENTIAL - 1; s->max_seq = seq; } } else if (udelta < MAX_DROPOUT) { // in order, with permissible gap - if(seq < s->max_seq) { - //sequence number wrapped; count antother 64k cycles + if (seq < s->max_seq) { + // sequence number wrapped; count another 64k cycles s->cycles += RTP_SEQ_MOD; } - s->max_seq= seq; + s->max_seq = seq; } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) { // sequence made a large jump... - if(seq==s->bad_seq) { + if (seq == s->bad_seq) { // two sequential packets-- assume that the other side restarted without telling us; just resync. rtp_init_sequence(s, seq); } else { - s->bad_seq= (seq + 1) & (RTP_SEQ_MOD-1); + s->bad_seq = (seq + 1) & (RTP_SEQ_MOD - 1); return 0; } } else { @@ -246,7 +242,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) uint8_t *buf; int len; int rtcp_bytes; - RTPStatistics *stats= &s->statistics; + RTPStatistics *stats = &s->statistics; uint32_t lost; uint32_t extended_max; uint32_t expected_interval; @@ -254,7 +250,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) uint32_t lost_interval; uint32_t expected; uint32_t fraction; - uint64_t ntp_time= s->last_rtcp_ntp_time; // TODO: Get local ntp time? + uint64_t ntp_time = s->last_rtcp_ntp_time; // TODO: Get local ntp time? if (!s->rtp_ctx || (count < 1)) return -1; @@ -281,31 +277,32 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) avio_wb32(pb, s->ssrc); // server SSRC // some placeholders we should really fill... // RFC 1889/p64 - extended_max= stats->cycles + stats->max_seq; - expected= extended_max - stats->base_seq + 1; - lost= expected - stats->received; - lost= FFMIN(lost, 0xffffff); // clamp it since it's only 24 bits... - expected_interval= expected - stats->expected_prior; - stats->expected_prior= expected; - received_interval= stats->received - stats->received_prior; - stats->received_prior= stats->received; - lost_interval= expected_interval - received_interval; - if (expected_interval==0 || lost_interval<=0) fraction= 0; - else fraction = (lost_interval<<8)/expected_interval; - - fraction= (fraction<<24) | lost; + extended_max = stats->cycles + stats->max_seq; + expected = extended_max - stats->base_seq + 1; + lost = expected - stats->received; + lost = FFMIN(lost, 0xffffff); // clamp it since it's only 24 bits... + expected_interval = expected - stats->expected_prior; + stats->expected_prior = expected; + received_interval = stats->received - stats->received_prior; + stats->received_prior = stats->received; + lost_interval = expected_interval - received_interval; + if (expected_interval == 0 || lost_interval <= 0) + fraction = 0; + else + fraction = (lost_interval << 8) / expected_interval; + + fraction = (fraction << 24) | lost; avio_wb32(pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */ avio_wb32(pb, extended_max); /* max sequence received */ - avio_wb32(pb, stats->jitter>>4); /* jitter */ + avio_wb32(pb, stats->jitter >> 4); /* jitter */ - if(s->last_rtcp_ntp_time==AV_NOPTS_VALUE) - { + if (s->last_rtcp_ntp_time == AV_NOPTS_VALUE) { avio_wb32(pb, 0); /* last SR timestamp */ avio_wb32(pb, 0); /* delay since last SR */ } else { - uint32_t middle_32_bits= s->last_rtcp_ntp_time>>16; // this is valid, right? do we need to handle 64 bit values special? - uint32_t delay_since_last= ntp_time - s->last_rtcp_ntp_time; + uint32_t middle_32_bits = s->last_rtcp_ntp_time >> 16; // this is valid, right? do we need to handle 64 bit values special? + uint32_t delay_since_last = ntp_time - s->last_rtcp_ntp_time; avio_wb32(pb, middle_32_bits); /* last SR timestamp */ avio_wb32(pb, delay_since_last); /* delay since last SR */ @@ -431,9 +428,8 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext return s; } -void -ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, - RTPDynamicProtocolHandler *handler) +void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, + RTPDynamicProtocolHandler *handler) { s->dynamic_protocol_context = ctx; s->parse_packet = handler->parse_packet; @@ -671,7 +667,7 @@ static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt) } static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, - uint8_t **bufptr, int len) + uint8_t **bufptr, int len) { uint8_t* buf = bufptr ? *bufptr : NULL; int ret, flags = 0; -- cgit v1.1 From f174fbac3cb127273b8f3df8e05d7156ec1d7658 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 17 Oct 2012 21:39:04 +0200 Subject: lavc: add CODEC_CAP_DR1 to all video decoders missing them --- libavcodec/bink.c | 1 + libavcodec/dpx.c | 1 + libavcodec/indeo3.c | 1 + libavcodec/indeo4.c | 1 + libavcodec/indeo5.c | 1 + libavcodec/kgv1dec.c | 1 + libavcodec/sgidec.c | 1 + libavcodec/vb.c | 1 + libavcodec/yop.c | 1 + 9 files changed, 9 insertions(+) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index b6c8c4b..636bb20 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1336,4 +1336,5 @@ AVCodec ff_bink_decoder = { .close = decode_end, .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Bink video"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index f1a4e86..55f71c9 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -243,4 +243,5 @@ AVCodec ff_dpx_decoder = { .close = decode_end, .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("DPX image"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index fc0d2bc..322d360 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -1114,4 +1114,5 @@ AVCodec ff_indeo3_decoder = { .decode = decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c index b837ffb..2eebc26 100644 --- a/libavcodec/indeo4.c +++ b/libavcodec/indeo4.c @@ -607,4 +607,5 @@ AVCodec ff_indeo4_decoder = { .close = ff_ivi_decode_close, .decode = ff_ivi_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 4"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index e9f7733..dc5f6f0 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -642,4 +642,5 @@ AVCodec ff_indeo5_decoder = { .close = ff_ivi_decode_close, .decode = ff_ivi_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 8f32943..bd362bf 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -191,4 +191,5 @@ AVCodec ff_kgv1_decoder = { .decode = decode_frame, .flush = decode_flush, .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index c220452..412709c 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -267,4 +267,5 @@ AVCodec ff_sgi_decoder = { .close = sgi_end, .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("SGI image"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/vb.c b/libavcodec/vb.c index 39e14a0..13f965d 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -275,4 +275,5 @@ AVCodec ff_vb_decoder = { .close = decode_end, .decode = decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Beam Software VB"), + .capabilities = CODEC_CAP_DR1, }; diff --git a/libavcodec/yop.c b/libavcodec/yop.c index cda9cad..f1ab525 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -256,4 +256,5 @@ AVCodec ff_yop_decoder = { .close = yop_decode_close, .decode = yop_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Video"), + .capabilities = CODEC_CAP_DR1, }; -- cgit v1.1