[asterisk-commits] rizzo: branch rizzo/video_v2 r85314 - /team/rizzo/video_v2/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 10 10:50:12 CDT 2007
Author: rizzo
Date: Wed Oct 10 10:50:12 2007
New Revision: 85314
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85314
Log:
now frame reassembly should be correct for h.261 as well.
However the code still dies in the ffmpeg library while decoding
incoming h261 from ekiga, still have to check why.
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=85314&r1=85313&r2=85314
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Wed Oct 10 10:50:12 2007
@@ -315,7 +315,7 @@
* Return 0 on success, != 0 on failure
*/
static int fbuf_append(struct fbuf_t *b, uint8_t *src, int len,
- int ebit, int sbit)
+ int sbit, int ebit)
{
/*
* Allocate buffer. ffmpeg wants an extra FF_INPUT_BUFFER_PADDING_SIZE,
@@ -323,6 +323,7 @@
*/
int need = len + FF_INPUT_BUFFER_PADDING_SIZE;
int i;
+ uint8_t *dst, mask;
if (b->data == NULL) {
b->size = need;
@@ -338,18 +339,30 @@
b->size);
return 1;
}
+ if (b->used == 0 && b->ebit != 0) {
+ ast_log(LOG_WARNING, "ebit not reset at start\n");
+ b->ebit = 0;
+ }
+ dst = b->data + b->used;
i = b->ebit + sbit; /* bits to ignore around */
- if (i == 0) { /* easy case, no copy to do */
- memcpy(b->data + b->used, src, len);
- b->used += len;
- b->data[b->used] = '\0';
+ if (i == 0) { /* easy case, just append */
+ /* do everything in the common block */
} else if (i == 8) { /* almost easy, just handle the overlap */
- ast_log(LOG_WARNING, "must handle unaligned %d %d\n",
- b->ebit, sbit);
- } else { /* must shift the new block */
- ast_log(LOG_WARNING, "must handle shift %d %d\n",
- b->ebit, sbit);
- }
+ mask = (1 << b->ebit) - 1;
+ /* update the last byte in the buffer */
+ dst[-1] &= ~mask; /* clear bits to ignore */
+ dst[-1] |= (*src | mask); /* append new bits */
+ src += 1; /* skip and prepare for common block */
+ len --;
+ } else { /* must shift the new block, not done yet */
+ ast_log(LOG_WARNING, "must handle shift %d %d at %d\n",
+ b->ebit, sbit, b->used);
+ return 1;
+ }
+ memcpy(dst, src, len);
+ b->used += len;
+ b->ebit = ebit;
+ b->data[b->used] = '\0'; /* always add a zero padding */
return 0;
}
@@ -834,7 +847,7 @@
*/
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);
+ // 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 */
@@ -875,7 +888,7 @@
i = found;
ebit = found_ebit;
}
- ast_log(LOG_WARNING, "found %d of %d/%d\n", i - start, start, len);
+ // ast_log(LOG_WARNING, "found %d of %d/%d\n", i - start, start, len);
/* This frame is up to offset i (not inclusive).
* We do not split it yet even if larger than MTU.
*/
@@ -910,13 +923,13 @@
{
int ebit, sbit;
- if (len < 4) {
+ if (len < 8) {
ast_log(LOG_WARNING, "invalid framesize %d\n", len);
return 1;
}
sbit = (data[0] >> 5) & 7;
ebit = (data[0] >> 2) & 7;
- ast_log(LOG_WARNING, "sbit %d ebit %d\n", sbit, ebit);
+ ast_log(LOG_WARNING, "pkt len %d sbit %d ebit %d buf used %d ebit %d\n", len, sbit, ebit, b->used, b->ebit);
len -= 4;
data += 4;
return fbuf_append(b, data, len, sbit, ebit);
@@ -1382,7 +1395,6 @@
v->enc_out.size = enc_in->size;
v->enc_out.used = 0;
-
return 0;
}
@@ -1600,6 +1612,7 @@
*/
if (f->subclass & 0x01) {
v->dec_in.used = 0;
+ v->dec_in.ebit = 0;
v->next_seq = f->seqno + 1; /* wrap at 16 bit */
v->discard = 0;
ast_log(LOG_WARNING, "out of discard mode, frame %d\n", f->seqno);
@@ -1632,6 +1645,7 @@
if (env->current_codec->dec_run(v, &v->dec_in)) {
show_frame(env, 0);
v->dec_in.used = 0;
+ v->dec_in.ebit = 0;
}
}
return 0;
More information about the asterisk-commits
mailing list