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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 12 04:25:06 CDT 2007


Author: rizzo
Date: Fri Oct 12 04:25:05 2007
New Revision: 85510

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85510
Log:
add mpeg4 support. That was easy.


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=85510&r1=85509&r2=85510
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Fri Oct 12 04:25:05 2007
@@ -293,12 +293,11 @@
 	SDL_Rect		rect[2];	/* loc. of images */
 };
 
-/*!
- * The list of video formats we support. You can OR the formats, and
- * provide corresponding ffmpeg mappings in the table below.
- */
-#define CONSOLE_FORMAT_VIDEO	(AST_FORMAT_H263_PLUS | AST_FORMAT_H263 | \
-		AST_FORMAT_H264 | AST_FORMAT_H261)
+/*! The list of video formats we support. */
+#define CONSOLE_FORMAT_VIDEO	(			\
+	AST_FORMAT_H263_PLUS | AST_FORMAT_H263 |	\
+	AST_FORMAT_MP4_VIDEO |				\
+	AST_FORMAT_H264 | AST_FORMAT_H261)
 
 static AVPicture *fill_pict(struct fbuf_t *b, AVPicture *p);
 
@@ -1065,6 +1064,59 @@
 	.dec_run = ffmpeg_decode
 };
 
+/* mpeg4 support */
+static int mpeg4_enc_init(struct video_out_desc *v)
+{
+	//v->enc_ctx->flags |= CODEC_FLAG_LOW_DELAY; /*don't use b frames ?*/
+	v->enc_ctx->flags |= CODEC_FLAG_AC_PRED;
+	v->enc_ctx->flags |= CODEC_FLAG_H263P_UMV;
+	v->enc_ctx->flags |= CODEC_FLAG_QPEL;
+	v->enc_ctx->flags |= CODEC_FLAG_4MV;
+	v->enc_ctx->flags |= CODEC_FLAG_GMC;
+	v->enc_ctx->flags |= CODEC_FLAG_LOOP_FILTER;
+	v->enc_ctx->flags |= CODEC_FLAG_H263P_SLICE_STRUCT;
+	return 0;
+}
+
+/* simplistic encapsulation - just split frames in mtu-size units */
+static struct ast_frame *mpeg4_encap(struct  video_out_desc *out,
+	struct ast_frame **tail)
+{
+	struct ast_frame *f, *cur = NULL, *first = NULL;
+	uint8_t *d = out->enc_out.data;
+	uint8_t *end = d+out->enc_out.used;
+	int len;
+
+	for (;d < end; d += len, cur = f) {
+		len = MIN(out->mtu, end-d);
+		f = create_video_frame(d, d+len, AST_FORMAT_MP4_VIDEO, 0, cur);
+		if (!f)
+			break;
+		if (!first)
+			first = f;
+	}
+	if (cur)
+		cur->subclass |= 1;
+	*tail = cur;
+	return first;
+}
+
+static int mpeg4_decap(struct fbuf_t *b, uint8_t *data, int len)
+{
+	return fbuf_append(b, data, len, 0, 0);
+}
+
+static struct video_codec_desc mpeg4_codec = {
+	.name = "mpeg4",
+	.format = AST_FORMAT_MP4_VIDEO,
+	.enc_init = mpeg4_enc_init,
+	.enc_encap = mpeg4_encap,
+	.enc_run = ffmpeg_encode,
+	.dec_init = NULL,
+	.dec_decap = mpeg4_decap,
+	.dec_run = ffmpeg_decode
+};
+
 /*------ end codec specific code -----*/
 
 
@@ -1277,12 +1329,13 @@
 };
 
 static struct _cm video_formats[] = {
-	{ AST_FORMAT_H263_PLUS,	CODEC_ID_H263, CM_RD }, /* incoming H263P ? */
+	{ AST_FORMAT_H263_PLUS,	CODEC_ID_H263,  CM_RD }, /* incoming H263P ? */
 	{ AST_FORMAT_H263_PLUS,	CODEC_ID_H263P, CM_WR },
-	{ AST_FORMAT_H263,	CODEC_ID_H263, CM_RD },
-	{ AST_FORMAT_H263,	CODEC_ID_H263, CM_WR },
-	{ AST_FORMAT_H261,	CODEC_ID_H261, CM_RDWR },
-	{ AST_FORMAT_H264,	CODEC_ID_H264, CM_RDWR },
+	{ AST_FORMAT_H263,	CODEC_ID_H263,  CM_RD },
+	{ AST_FORMAT_H263,	CODEC_ID_H263,  CM_WR },
+	{ AST_FORMAT_H261,	CODEC_ID_H261,  CM_RDWR },
+	{ AST_FORMAT_H264,	CODEC_ID_H264,  CM_RDWR },
+	{ AST_FORMAT_MP4_VIDEO,	CODEC_ID_MPEG4, CM_RDWR },
 	{ 0,			0, 0 },
 };
 
@@ -1316,6 +1369,7 @@
 	&h264_codec,
 	&h263_codec,
 	&h261_codec,
+	&mpeg4_codec,
 	NULL
 };
 




More information about the asterisk-commits mailing list