summaryrefslogtreecommitdiff
path: root/contrib/ffmpeg/vhook/null.c
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2006-12-02 01:19:48 +0000
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2006-12-02 01:19:48 +0000
commit0ea721f7ce81357bc4ec6eea609cd50482c3d15b (patch)
tree25a0871cb3c06f9716acf9c204192d548f214048 /contrib/ffmpeg/vhook/null.c
parentd8ec380876e7f697ba609546d61757ab3f2d8715 (diff)
downloadxine-lib-0ea721f7ce81357bc4ec6eea609cd50482c3d15b.tar.gz
xine-lib-0ea721f7ce81357bc4ec6eea609cd50482c3d15b.tar.bz2
Start working on a branch where FFmpeg is not copied, patched and carved to be built with automake but instead imported inline and built using its own build system. This is an import of a slightly modified FFmpeg current tree. xine-lib builds, install and run fine with it, but there are of course plenty of things that needs to be fixed before it can even be considered for a 1.2.x series. Work will continue in the next days of course.
CVS patchset: 8397 CVS date: 2006/12/02 01:19:48
Diffstat (limited to 'contrib/ffmpeg/vhook/null.c')
-rw-r--r--contrib/ffmpeg/vhook/null.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/contrib/ffmpeg/vhook/null.c b/contrib/ffmpeg/vhook/null.c
new file mode 100644
index 000000000..041e5abda
--- /dev/null
+++ b/contrib/ffmpeg/vhook/null.c
@@ -0,0 +1,116 @@
+/*
+ * Null Video Hook
+ * Copyright (c) 2002 Philip Gladstone
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <stdio.h>
+
+#include "framehook.h"
+#include "swscale.h"
+
+static int sws_flags = SWS_BICUBIC;
+
+typedef struct {
+ int dummy;
+
+ // This vhook first converts frame to RGB ...
+ struct SwsContext *toRGB_convert_ctx;
+
+ // ... and later converts back frame from RGB to initial format
+ struct SwsContext *fromRGB_convert_ctx;
+
+} ContextInfo;
+
+void Release(void *ctx)
+{
+ ContextInfo *ci;
+ ci = (ContextInfo *) ctx;
+
+ if (ctx) {
+ sws_freeContext(ci->toRGB_convert_ctx);
+ sws_freeContext(ci->fromRGB_convert_ctx);
+ av_free(ctx);
+ }
+}
+
+int Configure(void **ctxp, int argc, char *argv[])
+{
+ fprintf(stderr, "Called with argc=%d\n", argc);
+
+ *ctxp = av_mallocz(sizeof(ContextInfo));
+ return 0;
+}
+
+void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
+{
+ ContextInfo *ci = (ContextInfo *) ctx;
+ char *buf = 0;
+ AVPicture picture1;
+ AVPicture *pict = picture;
+
+ (void) ci;
+
+ if (pix_fmt != PIX_FMT_RGB24) {
+ int size;
+
+ size = avpicture_get_size(PIX_FMT_RGB24, width, height);
+ buf = av_malloc(size);
+
+ avpicture_fill(&picture1, buf, PIX_FMT_RGB24, width, height);
+
+ // if we already got a SWS context, let's realloc if is not re-useable
+ ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
+ width, height, pix_fmt,
+ width, height, PIX_FMT_RGB24,
+ sws_flags, NULL, NULL, NULL);
+ if (ci->toRGB_convert_ctx == NULL) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Cannot initialize the toRGB conversion context\n");
+ exit(1);
+ }
+// img_convert parameters are 2 first destination, then 4 source
+// sws_scale parameters are context, 4 first source, then 2 destination
+ sws_scale(ci->toRGB_convert_ctx,
+ picture->data, picture->linesize, 0, height,
+ picture1.data, picture1.linesize);
+
+ pict = &picture1;
+ }
+
+ /* Insert filter code here */
+
+ if (pix_fmt != PIX_FMT_RGB24) {
+ ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
+ width, height, PIX_FMT_RGB24,
+ width, height, pix_fmt,
+ sws_flags, NULL, NULL, NULL);
+ if (ci->fromRGB_convert_ctx == NULL) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Cannot initialize the fromRGB conversion context\n");
+ exit(1);
+ }
+// img_convert parameters are 2 first destination, then 4 source
+// sws_scale parameters are context, 4 first source, then 2 destination
+ sws_scale(ci->fromRGB_convert_ctx,
+ picture1.data, picture1.linesize, 0, height,
+ picture->data, picture->linesize);
+ }
+
+ av_free(buf);
+}
+