From 3ed565553517954893c7062e6e199b04fe7b6e38 Mon Sep 17 00:00:00 2001 From: gb Date: Mon, 3 May 2010 16:41:13 +0000 Subject: [PATCH] Simplify tests info. --- tests/test-decode.c | 23 ++++++++++++----------- tests/test-decode.h | 35 +++++++++++++++++++++++++++++++++++ tests/test-h264.c | 9 ++++++--- tests/test-h264.h | 3 ++- tests/test-mpeg2.c | 9 ++++++--- tests/test-mpeg2.h | 3 ++- tests/test-vc1.c | 11 +++++++---- tests/test-vc1.h | 3 ++- 8 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 tests/test-decode.h diff --git a/tests/test-decode.c b/tests/test-decode.c index f4b56b9..0fea750 100644 --- a/tests/test-decode.c +++ b/tests/test-decode.c @@ -28,19 +28,20 @@ #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 index 0000000..0ef55cc --- /dev/null +++ b/tests/test-decode.h @@ -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 + +typedef struct _VideoDecodeInfo VideoDecodeInfo; +struct _VideoDecodeInfo { + GstVaapiProfile profile; + guint width; + guint height; + const guchar *data; + guint data_size; +}; + +#endif /* TEST_DECODE_H */ diff --git a/tests/test-h264.c b/tests/test-h264.c index e4c0f37..c00c275 100644 --- a/tests/test-h264.c +++ b/tests/test-h264.c @@ -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; } diff --git a/tests/test-h264.h b/tests/test-h264.h index ee02298..ae94bcd 100644 --- a/tests/test-h264.h +++ b/tests/test-h264.h @@ -22,7 +22,8 @@ #define TEST_H264_H #include +#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 */ diff --git a/tests/test-mpeg2.c b/tests/test-mpeg2.c index 2817b30..e12b259 100644 --- a/tests/test-mpeg2.c +++ b/tests/test-mpeg2.c @@ -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; } diff --git a/tests/test-mpeg2.h b/tests/test-mpeg2.h index 8b3e43e..0825155 100644 --- a/tests/test-mpeg2.h +++ b/tests/test-mpeg2.h @@ -22,7 +22,8 @@ #define TEST_MPEG2_H #include +#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 */ diff --git a/tests/test-vc1.c b/tests/test-vc1.c index 80a56fc..79e2cca 100644 --- a/tests/test-vc1.c +++ b/tests/test-vc1.c @@ -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; } diff --git a/tests/test-vc1.h b/tests/test-vc1.h index ac35d2b..05927b6 100644 --- a/tests/test-vc1.h +++ b/tests/test-vc1.h @@ -22,7 +22,8 @@ #define TEST_VC1_H #include +#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 */ -- 2.7.4