Simplify tests info.
authorgb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Mon, 3 May 2010 16:41:13 +0000 (16:41 +0000)
committerGwenole Beauchesne <gbeauchesne@splitted-desktop.com>
Mon, 20 Sep 2010 10:55:43 +0000 (12:55 +0200)
tests/test-decode.c
tests/test-decode.h [new file with mode: 0644]
tests/test-h264.c
tests/test-h264.h
tests/test-mpeg2.c
tests/test-mpeg2.h
tests/test-vc1.c
tests/test-vc1.h

index f4b56b9..0fea750 100644 (file)
 #include "test-h264.h"
 #include "test-vc1.h"
 
-typedef void (*GetVideoDataFunc)(const guchar **data, guint *size);
+typedef void (*GetVideoInfoFunc)(VideoDecodeInfo *info);
 
 typedef struct _CodecDefs CodecDefs;
 struct _CodecDefs {
     const gchar        *codec_str;
-    GstVaapiCodec       codec;
-    GetVideoDataFunc    get_video_data;
+    GetVideoInfoFunc    get_video_info;
 };
 
 static const CodecDefs g_codec_defs[] = {
-    { "mpeg2",  GST_VAAPI_CODEC_MPEG2,  mpeg2_get_video_data    },
-    { "h264",   GST_VAAPI_CODEC_H264,   h264_get_video_data     },
-    { "vc1",    GST_VAAPI_CODEC_VC1,    vc1_get_video_data      },
+#define INIT_FUNCS(CODEC) { #CODEC, CODEC##_get_video_info }
+    INIT_FUNCS(mpeg2),
+    INIT_FUNCS(h264),
+    INIT_FUNCS(vc1),
+#undef INIT_FUNCS
     { NULL, }
 };
 
@@ -77,11 +78,11 @@ main(int argc, char *argv[])
     GstVaapiDisplay      *display;
     GstVaapiWindow       *window;
     GstVaapiDecoder      *decoder;
+    GstCaps              *decoder_caps;
     GstVaapiDecoderStatus status;
     const CodecDefs      *codec;
     GstVaapiSurfaceProxy *proxy;
-    const guchar         *vdata;
-    guint                 vdata_size;
+    VideoDecodeInfo       info;
 
     static const guint win_width  = 640;
     static const guint win_height = 480;
@@ -109,12 +110,12 @@ main(int argc, char *argv[])
     if (!window)
         g_error("could not create window");
 
-    codec->get_video_data(&vdata, &vdata_size);
-    decoder = gst_vaapi_decoder_ffmpeg_new(display, codec->codec, NULL);
+    codec->get_video_info(&info);
+    decoder = gst_vaapi_decoder_ffmpeg_new(display, gst_vaapi_profile_get_codec(info.profile), NULL);
     if (!decoder)
         g_error("could not create FFmpeg decoder");
 
-    if (!gst_vaapi_decoder_put_buffer_data(decoder, vdata, vdata_size))
+    if (!gst_vaapi_decoder_put_buffer_data(decoder, info.data, info.data_size))
         g_error("could not send video data to the decoder");
     if (!gst_vaapi_decoder_put_buffer(decoder, NULL))
         g_error("could not send EOS to the decoder");
diff --git a/tests/test-decode.h b/tests/test-decode.h
new file mode 100644 (file)
index 0000000..0ef55cc
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  test-decode.h - Test GstVaapiDecoder
+ *
+ *  gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+#ifndef TEST_DECODE_H
+#define TEST_DECODE_H
+
+#include <gst/vaapi/gstvaapiprofile.h>
+
+typedef struct _VideoDecodeInfo VideoDecodeInfo;
+struct _VideoDecodeInfo {
+    GstVaapiProfile     profile;
+    guint               width;
+    guint               height;
+    const guchar       *data;
+    guint               data_size;
+};
+
+#endif /* TEST_DECODE_H */
index e4c0f37..c00c275 100644 (file)
@@ -1038,8 +1038,11 @@ static const guchar h264_clip[H264_CLIP_DATA_SIZE] = {
     0x00, 0x01, 0x0a
 };
 
-void h264_get_video_data(const guchar **data, guint *size)
+void h264_get_video_info(VideoDecodeInfo *info)
 {
-    *data = h264_clip;
-    *size = H264_CLIP_DATA_SIZE;
+    info->profile   = GST_VAAPI_PROFILE_H264_MAIN;
+    info->width     = H264_CLIP_WIDTH;
+    info->height    = H264_CLIP_HEIGHT;
+    info->data      = h264_clip;
+    info->data_size = H264_CLIP_DATA_SIZE;
 }
index ee02298..ae94bcd 100644 (file)
@@ -22,7 +22,8 @@
 #define TEST_H264_H
 
 #include <glib.h>
+#include "test-decode.h"
 
-void h264_get_video_data(const guchar **data, guint *size);
+void h264_get_video_info(VideoDecodeInfo *info);
 
 #endif /* TEST_H264_H */
index 2817b30..e12b259 100644 (file)
@@ -1638,8 +1638,11 @@ static const guchar mpeg2_clip[MPEG2_CLIP_DATA_SIZE] = {
     0x00, 0x01, 0xb7
 };
 
-void mpeg2_get_video_data(const guchar **data, guint *size)
+void mpeg2_get_video_info(VideoDecodeInfo *info)
 {
-    *data = mpeg2_clip;
-    *size = MPEG2_CLIP_DATA_SIZE;
+    info->profile   = GST_VAAPI_PROFILE_MPEG2_SIMPLE;
+    info->width     = MPEG2_CLIP_WIDTH;
+    info->height    = MPEG2_CLIP_HEIGHT;
+    info->data      = mpeg2_clip;
+    info->data_size = MPEG2_CLIP_DATA_SIZE;
 }
index 8b3e43e..0825155 100644 (file)
@@ -22,7 +22,8 @@
 #define TEST_MPEG2_H
 
 #include <glib.h>
+#include "test-decode.h"
 
-void mpeg2_get_video_data(const guchar **data, guint *size);
+void mpeg2_get_video_info(VideoDecodeInfo *info);
 
 #endif /* TEST_MPEG2_H */
index 80a56fc..79e2cca 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "test-vc1.h"
 
-#define VC1_CLIP_WIDTH            320
+#define VC1_CLIP_WIDTH            293
 #define VC1_CLIP_HEIGHT           240
 #define VC1_CLIP_DATA_SIZE      20864
 
@@ -1767,8 +1767,11 @@ static const guchar vc1_clip[VC1_CLIP_DATA_SIZE] = {
     0x0f, 0x55, 0xbf, 0x40, 0x00, 0x00, 0x01, 0x0a
 };
 
-void vc1_get_video_data(const guchar **data, guint *size)
+void vc1_get_video_info(VideoDecodeInfo *info)
 {
-    *data = vc1_clip;
-    *size = VC1_CLIP_DATA_SIZE;
+    info->profile   = GST_VAAPI_PROFILE_VC1_ADVANCED;
+    info->width     = VC1_CLIP_WIDTH;
+    info->height    = VC1_CLIP_HEIGHT;
+    info->data      = vc1_clip;
+    info->data_size = VC1_CLIP_DATA_SIZE;
 }
index ac35d2b..05927b6 100644 (file)
@@ -22,7 +22,8 @@
 #define TEST_VC1_H
 
 #include <glib.h>
+#include "test-decode.h"
 
-void vc1_get_video_data(const guchar **data, guint *size);
+void vc1_get_video_info(VideoDecodeInfo *info);
 
 #endif /* TEST_VC1_H */