[asterisk-commits] rizzo: branch rizzo/video_v2 r85354 - /team/rizzo/video_v2/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 10 15:36:53 CDT 2007
Author: rizzo
Date: Wed Oct 10 15:36:53 2007
New Revision: 85354
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85354
Log:
more code cleanup
Modified:
team/rizzo/video_v2/channels/console_video.c
Modified: team/rizzo/video_v2/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/console_video.c?view=diff&rev=85354&r1=85353&r2=85354
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Wed Oct 10 15:36:53 2007
@@ -512,23 +512,6 @@
return first;
}
-#define MAKE_MASK(bits) ( (1<<(bits)) -1 )
-
-/*
- * Get the P flag from the H.263+ header from the RTP payload (see RFC 2429).
- */
-static inline unsigned int rfc2429_get_P(const uint8_t *header){
- return (header[0]>>2) & 0x1;
-}
-
-/*
- * Get the PLEN variable from the H.263+ header from the RTP payload (see RFC 2429).
- */
-static inline unsigned int rfc2429_get_PLEN(const uint8_t *header){
- unsigned short *p=(unsigned short*)header;
- return (ntohs(p[0])>>3) & MAKE_MASK(6);
-}
-
/*! \brief extract the bitstreem from the RTP payload.
* This is format dependent.
* For h263+, the format is defined in RFC 2429
@@ -546,26 +529,24 @@
static int h263p_decap(struct fbuf_t *b, uint8_t *data, int len)
{
int PLEN;
- int P;
if (len < 2) {
ast_log(LOG_WARNING, "invalid framesize %d\n", len);
return 1;
}
- PLEN = rfc2429_get_PLEN(data);
- P = rfc2429_get_P(data);
+ PLEN = ( (data[0] & 1) << 5 ) | ( (data[1] & 0xf8) >> 3);
if (PLEN > 0) {
data += PLEN;
len -= PLEN;
}
- if (P)
+ if (data[0] & 4) /* bit P */
data[0] = data[1] = 0;
else {
data += 2;
len -= 2;
}
- return fbuf_append(b, data, len, 0, 0); /* XXX no bit alignment support */
+ return fbuf_append(b, data, len, 0, 0); /* ignore trail bits */
}
/*
@@ -843,15 +824,14 @@
bzero(h261_hdr, sizeof(h261_hdr));
- /* This is the same code we have in h263, but the maker there is longer.
- * We start a few bytes within the bitstream to avoid hitting the marker
- * twice. We stop at len-1 because when there are bits to ignore we move
- * back the 'start' pointer by 1, and this would cause us to enter the loop
- * one more time.
+ /* Similar to the code in h263_encap, but the marker there is longer.
+ * Start a few bytes within the bitstream to avoid hitting the marker
+ * twice. Stop at len-1 because when there are bits to ignore we move
+ * back the 'start' pointer by 1, and this would cause us to enter
+ * the loop one more time.
*/
for (i = H261_MIN_LEN, start = 0; start < len - 1; start = i, i += 4) {
int found = 0, found_ebit = 0; /* last GBSC position found */
- // ast_log(LOG_WARNING, "search at %d of %d/%d\n", i, start, len);
for (; i < len ; i++) {
uint8_t x, rpos, lpos;
if (d[i] != 0) /* cannot be in a GBSC */
@@ -861,7 +841,7 @@
x = d[i+1];
if (x == 0) /* next is equally good */
continue;
- /* see if around us we can make 15 '0' bits for the GBSC.
+ /* See if around us we find 15 '0' bits for the GBSC.
* Look for the first bit set on the right, and then
* see if we have enough 0 on the left.
* We are guaranteed to end before rpos == 0
@@ -878,7 +858,7 @@
/* now we have a GBSC starting somewhere in d[i-1],
* but it might be not byte-aligned. Just remember it.
*/
- if (i - start > out->mtu) /* too large, stop now */
+ if (i - start > out->mtu) /* too large, stop now */
break;
found_ebit = ebit;
found = i;
@@ -888,7 +868,8 @@
i = len;
ebit = 0; /* hopefully... should ask the bitstream ? */
}
- if (i - start > out->mtu && found) { /* hope the previous one is still ok */
+ if (i - start > out->mtu && found) {
+ /* use the previous GBSC, hope is within the mtu */
i = found;
ebit = found_ebit;
}
@@ -903,7 +884,7 @@
/* recompute header with I=0, V=1 */
h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1;
bcopy(h, f->data, 4); /* copy the h261 header */
- if (ebit) { /* not aligned, so restart from previous byte */
+ if (ebit) { /* not aligned, restart from previous byte */
sbit = 8 - ebit;
ebit = 0;
i--;
@@ -1609,10 +1590,8 @@
}
#if defined(DROP_PACKETS) && DROP_PACKETS > 0
- /*
- * Fragment of code to simulate lost/delayed packets
- */
- if((random() % 10000) <= 100*DROP_PACKETS) {
+ /* Simulate lost/delayed packets */
+ if ((random() % 10000) <= 100*DROP_PACKETS) {
ast_log(LOG_NOTICE, "Packet lost [%d]\n", f->seqno);
return 0;
}
More information about the asterisk-commits
mailing list