[asterisk-commits] rizzo: branch rizzo/video_v2 r85350 - /team/rizzo/video_v2/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 10 11:36:02 CDT 2007


Author: rizzo
Date: Wed Oct 10 11:36:02 2007
New Revision: 85350

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85350
Log:
avoid calling the decoder when no valid data is available

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=85350&r1=85349&r2=85350
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Wed Oct 10 11:36:02 2007
@@ -362,7 +362,7 @@
 	memcpy(dst, src, len);
 	b->used += len;
 	b->ebit = ebit;
-	b->data[b->used] = '\0';	/* always add a zero padding */
+	b->data[b->used] = 0;	/* padding */
 	return 0;
 }
 
@@ -590,25 +590,30 @@
 {
 	uint8_t *src = b->data;
 	int srclen = b->used;
+	int retval = 0;
 
 	if (!srclen)
 		return 0;
 	while (srclen) {
 		uint8_t *data;
-		int datalen;
-		int ret = av_parser_parse(v->parser, v->dec_ctx, &data, &datalen, src, srclen, 0, 0);
-		if (datalen) {
-			int dummy = 0;
-			ret = avcodec_decode_video(v->dec_ctx, v->frame, &dummy, data, datalen);
-			if (ret < 0) {
-				ast_log(LOG_NOTICE, "Error decoding\n");
-				return 0;
-			}
-			src += ret;
-			srclen -= ret;
+		int datalen, ret, dummy = 0;
+		int len = av_parser_parse(v->parser, v->dec_ctx, &data, &datalen, src, srclen, 0, 0);
+
+		src += len;
+		srclen -= len;
+		/* The parser might return something it cannot decode, so it skips
+		 * the block returning no data
+		 */
+		if (data == NULL || datalen == 0)
+			continue;
+		ret = avcodec_decode_video(v->dec_ctx, v->frame, &dummy, data, datalen);
+		if (ret < 0) {
+			ast_log(LOG_NOTICE, "Error decoding\n");
+			return 0;
 		}
-	}
-	return 1;
+		retval = 1;
+	}
+	return retval;
 }
 
 static struct video_codec_desc h263p_codec = {
@@ -929,7 +934,6 @@
 	}
 	sbit = (data[0] >> 5) & 7;
 	ebit = (data[0] >> 2) & 7;
-	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);
@@ -1642,11 +1646,10 @@
 		v->discard = 1;
 	}
 	if (f->subclass & 0x01) {	// RTP Marker
-		if (env->current_codec->dec_run(v, &v->dec_in)) {
+		if (env->current_codec->dec_run(v, &v->dec_in))
 			show_frame(env, 0);
-			v->dec_in.used = 0;
-			v->dec_in.ebit = 0;
-		}
+		v->dec_in.used = 0;
+		v->dec_in.ebit = 0;
 	}
 	return 0;
 }




More information about the asterisk-commits mailing list