[FFmpeg-devel] [RFC/PATCH 6/8] tidsp: add mp4v configuration

Felipe Contreras felipe.contreras
Mon Sep 6 00:15:33 CEST 2010


Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
 libavcodec/Makefile        |    2 +-
 libavcodec/tidsp/td_mp4v.c |  128 ++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/tidsp/tidsp.h   |    2 +
 3 files changed, 131 insertions(+), 1 deletions(-)
 create mode 100644 libavcodec/tidsp/td_mp4v.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 501747e..cb66086 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -246,7 +246,7 @@ OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpegvideo_enc.o \
                                           mpeg12.o mpeg12data.o       \
                                           mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL)     += vaapi_mpeg4.o
-OBJS-$(CONFIG_MPEG4_TIDSP_HWACCEL)     += tidsp_mpeg4.o
+OBJS-$(CONFIG_MPEG4_TIDSP_HWACCEL)     += tidsp_mpeg4.o tidsp/td_mp4v.o
 OBJS-$(CONFIG_MSMPEG4V1_DECODER)       += msmpeg4.o msmpeg4data.o
 OBJS-$(CONFIG_MSMPEG4V1_ENCODER)       += msmpeg4.o msmpeg4data.o h263dec.o \
                                           h263.o ituh263dec.o mpeg4videodec.o
diff --git a/libavcodec/tidsp/td_mp4v.c b/libavcodec/tidsp/td_mp4v.c
new file mode 100644
index 0000000..86fb8ee
--- /dev/null
+++ b/libavcodec/tidsp/td_mp4v.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009-2010 Felipe Contreras
+ *
+ * Author: Felipe Contreras <felipe.contreras at gmail.com>
+ *
+ * This file may be used under the terms of the GNU Lesser General Public
+ * License version 2.1, a copy of which is found in COPYING.LGPLv2.1 included
+ * in the packaging of this file.
+ */
+
+#include "tidsp.h"
+#include "dsp_bridge.h"
+#include "dmm_buffer.h"
+
+struct mp4vdec_args {
+	uint32_t size;
+	uint16_t num_streams;
+
+	uint16_t in_id;
+	uint16_t in_type;
+	uint16_t in_count;
+
+	uint16_t out_id;
+	uint16_t out_type;
+	uint16_t out_count;
+
+	uint16_t reserved;
+
+	uint32_t max_width;
+	uint32_t max_height;
+	uint32_t color_format;
+	uint32_t max_framerate;
+	uint32_t max_bitrate;
+	uint32_t endianness;
+	uint32_t profile;
+	int32_t max_level;
+	uint32_t mode;
+	int32_t preroll;
+	uint32_t display_width;
+};
+
+static void create_args(struct td_context *ctx, unsigned *profile_id, void **arg_data)
+{
+	struct mp4vdec_args args = {
+		.size = sizeof(args),
+		.num_streams = 2,
+		.in_id = 0,
+		.in_type = 0,
+		.in_count = ctx->ports[0]->nr_buffers,
+		.out_id = 1,
+		.out_type = 0,
+		.out_count = ctx->ports[1]->nr_buffers,
+		.max_width = ctx->width,
+		.max_height = ctx->height,
+		.color_format = 1,
+		.max_framerate = 1,
+		.max_bitrate = 1,
+		.endianness = 1,
+		.max_level = -1,
+	};
+
+	if (ctx->width * ctx->height > 640 * 480)
+		*profile_id = 4;
+	else if (ctx->width * ctx->height > 352 * 288)
+		*profile_id = 3;
+	else if (ctx->width * ctx->height > 176 * 144)
+		*profile_id = 2;
+	else
+		*profile_id = 1;
+
+	*arg_data = malloc(sizeof(args));
+	memcpy(*arg_data, &args, sizeof(args));
+}
+
+struct mp4vdec_in_params {
+	uint32_t frame_index;
+	int32_t buf_count;
+	uint32_t ring_io_block_size;
+	int32_t performance_mode;
+};
+
+struct mp4vdec_out_params {
+	uint32_t frame_index;
+	uint32_t bytes_consumed;
+	int32_t error_code;
+	uint32_t frame_type;
+	uint32_t qp[(720 * 576) / 256];
+	int32_t mb_error_buf_flag;
+	uint8_t mb_error_buf[(720 * 576) / 256];
+};
+
+static void mp4vdec_out_recv_cb(struct td_context *ctx, struct td_buffer *b)
+{
+	struct mp4vdec_out_params *param = b->params->data;
+
+	pr_debug(ctx->client, "error: 0x%x, frame number: %u, frame type: %u",
+			param->error_code, param->frame_index, param->frame_type);
+}
+
+static void setup_mp4vparams_in(struct td_context *ctx, struct dmm_buffer *tmp)
+{
+	struct mp4vdec_in_params *in_param;
+
+	in_param = tmp->data;
+	in_param->performance_mode = 2;
+}
+
+static void setup_params(struct td_context *ctx)
+{
+	struct mp4vdec_in_params *in_param;
+	struct mp4vdec_out_params *out_param;
+	struct td_port *p;
+
+	p = ctx->ports[0];
+	td_port_setup_params(ctx, p, sizeof(*in_param), setup_mp4vparams_in);
+
+	p = ctx->ports[1];
+	td_port_setup_params(ctx, p, sizeof(*out_param), NULL);
+	p->recv_cb = mp4vdec_out_recv_cb;
+}
+
+struct td_codec td_mp4v_codec = {
+	.uuid = &(const struct dsp_uuid) { 0x7e4b8541, 0x47a1, 0x11d6, 0xb1, 0x56,
+		{ 0x00, 0xb0, 0xd0, 0x17, 0x67, 0x4b } },
+	.filename = DSP_DIR "mp4vdec_sn.dll64P",
+	.setup_params = setup_params,
+	.create_args = create_args,
+};
diff --git a/libavcodec/tidsp/tidsp.h b/libavcodec/tidsp/tidsp.h
index de75abb..653886d 100644
--- a/libavcodec/tidsp/tidsp.h
+++ b/libavcodec/tidsp/tidsp.h
@@ -74,4 +74,6 @@ typedef void (*usn_setup_params_func)(struct td_context *ctx, struct dmm_buffer
 void td_port_setup_params(struct td_context *ctx, struct td_port *p, size_t size,
 		usn_setup_params_func func);
 
+extern struct td_codec td_mp4v_codec;
+
 #endif /* TIDSP_H */
-- 
1.7.2.2




More information about the ffmpeg-devel mailing list