summaryrefslogtreecommitdiff
path: root/src/libXvMC/block.c
diff options
context:
space:
mode:
authorYounes Manton <younes.m@gmail.com>2008-06-08 03:04:14 -0400
committerYounes Manton <younes.m@gmail.com>2008-06-08 03:04:14 -0400
commitc11a7ec821d41b91a3825c5abfb4687c98b5bf98 (patch)
treecca76bb6d30d3da0b6bd49a9dd1c61ea6feb3cf2 /src/libXvMC/block.c
parent996b549fdbfe772ee56a51858e81e93bccaae5c5 (diff)
Initial commit for g3dvl.
Initial commit for g3dvl, contains support for basic XvMC features. - Context, surface, block, macroblock creation and deletion - Surface rendering - Frame pictures - Frame based motion compensation - Intra-coded macroblocks - Predicted macroblocks - Bi-directionally predicted macroblocks - Surface display - Color conversion - Scaling
Diffstat (limited to 'src/libXvMC/block.c')
-rw-r--r--src/libXvMC/block.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/libXvMC/block.c b/src/libXvMC/block.c
new file mode 100644
index 0000000000..b56348d464
--- /dev/null
+++ b/src/libXvMC/block.c
@@ -0,0 +1,85 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/XvMC.h>
+#include <vl_context.h>
+
+/*
+ * XvMC defines 64 element blocks (8x8 elements).
+ * Elements are 8 bits when they represent color values,
+ * 9 bits when they reprecent DCT coefficients, we
+ * store them in 2 bytes in either case. DCT coefficients
+ * can be signed or unsigned, at our option.
+ */
+#define BLOCK_SIZE (64 * 2)
+
+Status XvMCCreateBlocks(Display *display, XvMCContext *context, unsigned int num_blocks, XvMCBlockArray *blocks)
+{
+ struct vl_context *vl_ctx;
+
+ assert(display);
+
+ if (!context)
+ return XvMCBadContext;
+ if (num_blocks == 0)
+ return BadValue;
+
+ assert(blocks);
+
+ vl_ctx = context->privData;
+ assert(display == vl_ctx->display);
+
+ blocks->context_id = context->context_id;
+ blocks->num_blocks = num_blocks;
+ blocks->blocks = malloc(BLOCK_SIZE * num_blocks);
+ /* Since we don't have a VL type for blocks, set privData to the display so we can catch mismatches */
+ blocks->privData = display;
+
+ return Success;
+}
+
+Status XvMCDestroyBlocks(Display *display, XvMCBlockArray *blocks)
+{
+ assert(display);
+ assert(blocks);
+ assert(display == blocks->privData);
+ free(blocks->blocks);
+
+ return Success;
+}
+
+Status XvMCCreateMacroBlocks(Display *display, XvMCContext *context, unsigned int num_blocks, XvMCMacroBlockArray *blocks)
+{
+ struct vl_context *vl_ctx;
+
+ assert(display);
+
+ if (!context)
+ return XvMCBadContext;
+ if (num_blocks == 0)
+ return BadValue;
+
+ assert(blocks);
+
+ vl_ctx = context->privData;
+ assert(display == vl_ctx->display);
+
+ blocks->context_id = context->context_id;
+ blocks->num_blocks = num_blocks;
+ blocks->macro_blocks = malloc(sizeof(XvMCMacroBlock) * num_blocks);
+ /* Since we don't have a VL type for blocks, set privData to the display so we can catch mismatches */
+ blocks->privData = display;
+
+ return Success;
+}
+
+Status XvMCDestroyMacroBlocks(Display *display, XvMCMacroBlockArray *blocks)
+{
+ assert(display);
+ assert(blocks);
+ assert(display == blocks->privData);
+ free(blocks->macro_blocks);
+
+ return Success;
+}
+