Simplify tests info.

This commit is contained in:
gb 2010-05-03 16:41:13 +00:00 committed by Gwenole Beauchesne
parent 24d918b7a3
commit 3ed5655535
8 changed files with 72 additions and 24 deletions

View file

@ -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");

35
tests/test-decode.h Normal file
View file

@ -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 */

View 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;
}

View 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 */

View 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;
}

View 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 */

View 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;
}

View 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 */