mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 23:48:53 +00:00
tests: use common decoder helpers for subpicture test.
Use common decoder helpers for subpicture test, thus allowing to decode sample images in an alternate format.
This commit is contained in:
parent
d9111eeaf5
commit
886f6d9f11
2 changed files with 13 additions and 84 deletions
|
@ -90,7 +90,7 @@ test_surfaces_LDADD = libutils.la $(TEST_LIBS)
|
||||||
|
|
||||||
test_subpicture_SOURCES = test-subpicture.c test-subpicture-data.c
|
test_subpicture_SOURCES = test-subpicture.c test-subpicture-data.c
|
||||||
test_subpicture_CFLAGS = $(TEST_CFLAGS)
|
test_subpicture_CFLAGS = $(TEST_CFLAGS)
|
||||||
test_subpicture_LDADD = libutils.la $(TEST_LIBS)
|
test_subpicture_LDADD = libutils.la libutils_dec.la $(TEST_LIBS)
|
||||||
|
|
||||||
test_windows_SOURCES = test-windows.c
|
test_windows_SOURCES = test-windows.c
|
||||||
test_windows_CFLAGS = $(TEST_CFLAGS)
|
test_windows_CFLAGS = $(TEST_CFLAGS)
|
||||||
|
|
|
@ -22,38 +22,11 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/vaapi/gstvaapidecoder.h>
|
|
||||||
#include <gst/vaapi/gstvaapidecoder_mpeg2.h>
|
|
||||||
#include <gst/vaapi/gstvaapisurface.h>
|
#include <gst/vaapi/gstvaapisurface.h>
|
||||||
|
#include "decoder.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "test-mpeg2.h"
|
|
||||||
#include "test-subpicture-data.h"
|
#include "test-subpicture-data.h"
|
||||||
|
|
||||||
typedef void (*GetVideoInfoFunc)(VideoDecodeInfo *info);
|
|
||||||
|
|
||||||
typedef struct _CodecDefs CodecDefs;
|
|
||||||
struct _CodecDefs {
|
|
||||||
const gchar *codec_str;
|
|
||||||
GetVideoInfoFunc get_video_info;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const CodecDefs g_codec_defs[] = {
|
|
||||||
#define INIT_FUNCS(CODEC) { #CODEC, CODEC##_get_video_info }
|
|
||||||
INIT_FUNCS(mpeg2),
|
|
||||||
#undef INIT_FUNCS
|
|
||||||
{ NULL, }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const CodecDefs *
|
|
||||||
get_codec_defs(const gchar *codec_str)
|
|
||||||
{
|
|
||||||
const CodecDefs *c;
|
|
||||||
for (c = g_codec_defs; c->codec_str; c++)
|
|
||||||
if (strcmp(codec_str, c->codec_str) == 0)
|
|
||||||
return c;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void pause(void)
|
static inline void pause(void)
|
||||||
{
|
{
|
||||||
g_print("Press any key to continue...\n");
|
g_print("Press any key to continue...\n");
|
||||||
|
@ -88,15 +61,9 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
GstVaapiWindow *window;
|
GstVaapiWindow *window;
|
||||||
GstVaapiDecoder *decoder = NULL;
|
GstVaapiDecoder *decoder;
|
||||||
GstCaps *decoder_caps;
|
|
||||||
GstStructure *structure;
|
|
||||||
GstVaapiDecoderStatus status;
|
|
||||||
const CodecDefs *codec;
|
|
||||||
GstBuffer *buffer;
|
|
||||||
GstVaapiSurfaceProxy *proxy;
|
|
||||||
GstVaapiSurface *surface;
|
GstVaapiSurface *surface;
|
||||||
VideoDecodeInfo info;
|
GstBuffer *buffer;
|
||||||
VideoSubpictureInfo subinfo;
|
VideoSubpictureInfo subinfo;
|
||||||
GstVaapiImage *subtitle_image;
|
GstVaapiImage *subtitle_image;
|
||||||
GstVaapiSubpicture *subpicture;
|
GstVaapiSubpicture *subpicture;
|
||||||
|
@ -110,13 +77,7 @@ main(int argc, char *argv[])
|
||||||
if (!video_output_init(&argc, argv, g_options))
|
if (!video_output_init(&argc, argv, g_options))
|
||||||
g_error("failed to initialize video output subsystem");
|
g_error("failed to initialize video output subsystem");
|
||||||
|
|
||||||
if (!g_codec_str)
|
g_print("Test subpicture\n");
|
||||||
g_codec_str = g_strdup("mpeg2");
|
|
||||||
|
|
||||||
g_print("Test %s decode\n", g_codec_str);
|
|
||||||
codec = get_codec_defs(g_codec_str);
|
|
||||||
if (!codec)
|
|
||||||
g_error("no %s codec data found", g_codec_str);
|
|
||||||
|
|
||||||
display = video_output_create_display(NULL);
|
display = video_output_create_display(NULL);
|
||||||
if (!display)
|
if (!display)
|
||||||
|
@ -126,44 +87,16 @@ main(int argc, char *argv[])
|
||||||
if (!window)
|
if (!window)
|
||||||
g_error("could not create window");
|
g_error("could not create window");
|
||||||
|
|
||||||
codec->get_video_info(&info);
|
decoder = decoder_new(display, g_codec_str);
|
||||||
decoder_caps = gst_vaapi_profile_get_caps(info.profile);
|
|
||||||
if (!decoder_caps)
|
|
||||||
g_error("could not create decoder caps");
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure(decoder_caps, 0);
|
|
||||||
if (info.width > 0 && info.height > 0)
|
|
||||||
gst_structure_set(
|
|
||||||
structure,
|
|
||||||
"width", G_TYPE_INT, info.width,
|
|
||||||
"height", G_TYPE_INT, info.height,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
decoder = gst_vaapi_decoder_mpeg2_new(display, decoder_caps);
|
|
||||||
if (!decoder)
|
if (!decoder)
|
||||||
g_error("could not create video decoder");
|
g_error("could not create decoder");
|
||||||
gst_caps_unref(decoder_caps);
|
|
||||||
|
|
||||||
buffer = gst_buffer_new();
|
if (!decoder_put_buffers(decoder))
|
||||||
if (!buffer)
|
g_error("could not fill decoder with sample data");
|
||||||
g_error("could not create encoded data buffer");
|
|
||||||
gst_buffer_set_data(buffer, (guchar *)info.data, info.data_size);
|
|
||||||
|
|
||||||
if (!gst_vaapi_decoder_put_buffer(decoder, buffer))
|
surface = decoder_get_surface(decoder);
|
||||||
g_error("could not send video data to the decoder");
|
|
||||||
gst_buffer_unref(buffer);
|
|
||||||
|
|
||||||
if (!gst_vaapi_decoder_put_buffer(decoder, NULL))
|
|
||||||
g_error("could not send EOS to the decoder");
|
|
||||||
|
|
||||||
status = gst_vaapi_decoder_get_surface(decoder, &proxy);
|
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
|
||||||
g_error("could not get decoded surface (decoder status %d)", status);
|
|
||||||
|
|
||||||
surface = gst_vaapi_surface_proxy_get_surface(proxy);
|
|
||||||
if (!surface)
|
if (!surface)
|
||||||
g_error("could not get underlying surface");
|
g_error("could not get decoded surface");
|
||||||
|
|
||||||
gst_vaapi_surface_get_size(surface, &surf_width, &surf_height);
|
gst_vaapi_surface_get_size(surface, &surf_width, &surf_height);
|
||||||
printf("surface size %dx%d\n", surf_width, surf_height);
|
printf("surface size %dx%d\n", surf_width, surf_height);
|
||||||
|
@ -209,17 +142,13 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
gst_vaapi_window_show(window);
|
gst_vaapi_window_show(window);
|
||||||
|
|
||||||
if (!gst_vaapi_window_put_surface(window,
|
if (!gst_vaapi_window_put_surface(window, surface, NULL, NULL,
|
||||||
GST_VAAPI_SURFACE_PROXY_SURFACE(proxy),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
||||||
g_error("could not render surface");
|
g_error("could not render surface");
|
||||||
|
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
gst_buffer_unref(buffer);
|
gst_buffer_unref(buffer);
|
||||||
gst_vaapi_surface_proxy_unref(proxy);
|
|
||||||
g_object_unref(decoder);
|
g_object_unref(decoder);
|
||||||
g_object_unref(window);
|
g_object_unref(window);
|
||||||
g_object_unref(display);
|
g_object_unref(display);
|
||||||
|
|
Loading…
Reference in a new issue