Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Zapfyr

Pages: [1] 2
1
General discussions / Re: GStreamer SDK and SFML
« on: September 27, 2013, 02:14:30 pm »
I know this is an old post but I felt that I should post about how it is going and share some code that may help others. I created a class that uses GStreamer to decode a movie and SFML to render it (trough some OpenGL). Note that the code wont work as it is now as I stopped working on it and left it a bit messy (sorry about that), it also need some libs (e.g. boost and GStreamer).

When it works it uses PBOs (Pixel Buffer Object) to copy pixel from RAM to VRAM, it also uses ping poing to speed up copying even more. I ran it on Windows 7 and Windows 8 using GStreamer SDKhttp://www.gstreamer.com/ and SFML 2.0.

http://tux.servegame.org/~zapfyr/VideoSprite.hpp
http://tux.servegame.org/~zapfyr/VideoSprite.cpp

2
Graphics / Re: Updating texture data, very slow on Intel graphics.
« on: January 31, 2013, 03:59:42 pm »
The problem is that SFML uses RGBA pixels, not BGRA or ARGB. It would really break the API too much to switch to BGRA.

Too bad. :/

This problem can be solved with a very simple fragment shader that swaps (swizzling) the components, however it feels very much like an ugly hack. :)

As a side note, sfeMovie becomes next to useless (as it uses the update function in sf::Texture) on Intel hardware because of this issue. :(

// Zap

3
Graphics / Updating texture data, very slow on Intel graphics.
« on: January 31, 2013, 10:18:19 am »
Hi,

I have been playing around with the Intel NUC (DC3217IYE to be specific) which uses Intel HD 4000 graphics. And for some reason updating a sf::Texture is painfully slow compared to Nvidia or AMD graphics. After some googling I found these:

http://www.opengl.org/discussion_boards/showthread.php/175501-glTexSubImage-still-unacceptable-slow
http://forums.inside3d.com/viewtopic.php?t=2465

This is the code that updates the actual texture in SFML:
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
 

If it were to be changed to:
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
 

it would improve performance a lot (on, some, Intel graphics). Now I do not exactly know if some thing else have to be changed to make this work, I just though I should tell you about my findings. :)

I have tried this when streaming video to a texture using GStreamer, so I know that it makes a LOT of difference on Intel hardware and that it does not impact performance on Nvidia or AMD hardware. The streaming has been done with both PBOs and just a simple glTexSubImage2D call and both methods become significantly faster when using GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV.

// Zap

4
Graphics / Re: AMD CCC 12.10/12.11 beta + RenderTexture = BSOD
« on: December 21, 2012, 04:26:46 pm »
The card is kinda rare, as it have 6 miniDisplayPorts (Eyfinity edtion 6) but at the same time it is a normal AMD HD 7870 card so yeah ...

I have 3 cards of the same type, they all have the same problems, so it is not a broken card or something like that. :/

// Zap

5
Graphics / Re: AMD CCC 12.10/12.11 beta + RenderTexture = BSOD
« on: December 21, 2012, 03:50:52 pm »
I couldn't find anything wrong with the OpenGL code.

However: As I have stated before BSODs occur often when using RenderTextures, however they still occur when not using them, but they are a lot less common.

I have experimented some with the drivers and found that the 12.8 WHQL version is the most stable, in fact it seems that doesn't suffer from the BSOD-problem. All drivers after the 12.8 version seems to get BSOD (even WHQL versions).

// Zap

6
Graphics / Re: AMD CCC 12.10/12.11 beta + RenderTexture = BSOD
« on: December 19, 2012, 09:14:35 am »
If I find the bug I would of course want to help make SFML better by sharing my findings. I just wanted to make my own rendertexture without modding the SFML source code to experiment.

This is the BSOD I get: http://tux.servegame.org/~zapfyr/temp/20121218_162006.jpg (large image).

// Zap

7
Graphics / Re: AMD CCC 12.10/12.11 beta + RenderTexture = BSOD
« on: December 13, 2012, 07:30:54 pm »
Thanks, I will try to render stuff to my own FBO. However I tried to that before but as I use sf::Sprite and sf::Text a lot, which needs a rendertarget to be able to render, I couldn't figure out how to render everything to an FBO and than render the texture that is bound to that FBO in the window. Is that possible without modifying the sfml source code?

// Zap

8
Graphics / Re: AMD CCC 12.10/12.11 beta + RenderTexture = BSOD
« on: December 13, 2012, 12:51:22 pm »
Yeah it is definitely a driver issue, the problem is that all other games and similar applications I have test doesn't get BSOD. This has not been an issue when I have tested my program on computers with Nvidia cards. So I will be happy if someone knows a way to avoid the BSOD, as it is not only annoying, it destroys some settings in CCC (namely the Eyefinity settings). :/

9
Graphics / AMD CCC 12.10/12.11 beta + RenderTexture = BSOD
« on: December 13, 2012, 10:47:48 am »
Hi,

I'm using a AMD HD7870 Eyefinity edtion card with the 12.11 beta driver. I have built the latest version of SFML for Win32 and I am using Visual Studio 2010 Pro.

The problem:
While things work pretty nice while running the actual program (execpt for the issue when clearing it http://en.sfml-dev.org/forums/index.php?topic=9350.msg63358#msg63358, which I still got) I get some BSOD when exiting the application, it some times happens many times in a row and some time very infrequently. This seems to happen more often when using the 12.10 driver than the 12.11 beta driver and it seems that it never happens when not using a RenderTexture. I would roll back the driver even further but I want to make use of Eyefinity, for 6 screens, (I get BSOD with and without Eyefinity enabled) which doesn't work that great with older drivers.

Test program:
static bool useRenderTexture = true;

main(int argc, char *argv[])
{
    sf::VideoMode desktopVideoMode = sf::VideoMode::getDesktopMode();
    sf::VideoMode selectedMode     = desktopVideoMode;

    sf::ContextSettings contextSettings;
    contextSettings.antialiasingLevel = 8;

    sf::RenderWindow window(selectedMode, "Test", sf::Style::Fullscreen, contextSettings);
    window.setFramerateLimit(60);

    sf::Sprite        renderSprite;
    sf::RenderTexture renderTexture;
    if (useRenderTexture)
    {
        renderTexture.create(selectedMode.width, selectedMode.height);
        renderSprite.setTexture(renderTexture.getTexture(), true);
    }

    sf::RectangleShape rectangeShape;
    rectangeShape.setSize(sf::Vector2f(selectedMode.width / 2.0f, selectedMode.height / 2.0f));
    rectangeShape.setPosition(50.f, 50.f);
    rectangeShape.setFillColor(sf::Color::Red);

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed ||
                sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
                window.close();
        }

        if (useRenderTexture)
        {
            renderTexture.clear();
            renderTexture.draw(rectangeShape);
            renderTexture.display();

            window.clear();
            window.draw(renderSprite);
            window.display();
        }
        else
        {
            window.clear();
            window.draw(rectangeShape);
            window.display();
        }
    }
}
 

// Zap

10
General discussions / Re: GStreamer SDK and SFML
« on: November 14, 2012, 06:59:02 pm »
Yeah, I do not expect an answer either, not only because my question is large (and vague) but because the few similar questions I bumped into when googling about the error didn't have any solutions. Debugging a general streaming error is not easy. :) I even tried to get it to work by destroying the pipeline and clean up everything when I got the EOS message and rebuild it again afterwards, this resulted in very similar (if not exact) results as seeking to the beginning. It seems to be some kind of memory problem, e.g. that I do not free something and that gstreamer runs out of some kind of internal buffer, but that is just speculation and as the actual setup of the pipeline as well as the handling (and seeking) are all in the GStreamer SDK tutorials my code should be correct ...

About sfeMovie; I have built it on Windows with everything that ffmpeg gives us. I got it to loop (not perfect but good enough, by stopping and playing when the movie reaches its end) and run it for about 26 hours (before I turned it off), which is great. :) I would love to help out with the project, I just need to find the time. Performance is probably the most important thing right now and after that looping, I am not that interested in seeking. When I did the texture upload code from GStreamer to OpenGL I got a pretty nice performance boost when I switched from using sfml textures, using the update function, to using PBO ping ponging which makes it possible to stream texture data asynchronously without blocking the CPU. Is that something that may help the sfeMovie project or do you want me to look into something else?

// Zap

11
General discussions / Re: GStreamer SDK and SFML
« on: November 14, 2012, 10:57:53 am »
I tried posting about it on one of their mailing-lists. Haven't got a response from anyone yet tho. As far as I know there are no "normal" forums or similar that I can turn to, which kinda makes it hard to find any good answers to what is happening inside gstreamer. :(

I haven't asked about it on sites like stackoverflow, yet.

// Zap

12
General discussions / Re: GStreamer SDK and SFML
« on: November 12, 2012, 09:22:44 am »
Hi (again).

Since I last wrote much testing using GStreamer have been done. It seems to be working great .... on Linux ....  on Windows it SEEMS to be not that mature. I have run into trouble when trying to run a looped movie for a long time, it loops for maybe half a day (4 - 12 hours) and then something inside GStreamer breaks and I get a general streaming error. I have tested it both with the GStreamer SDK and OSSBuild and with multiple movies coded in a number of different ways. Now this may of course be my fault, but as I can't find much when googling and can't see anything wrong with my code I will now look for other solutions.

As for GStreamer SDK vs. OSSBuild, in many cases GStreamer SDK gives at lot less choppy playback and seems to get better performance (not that surprising as the SDK uses someting like 0.10.36 and OSSBuild 0.10.28 of GStreamer).

GStreamer SDK using GStreamer 1.0 is about to be release some time this month (Nov. 2012) which may make it more stable for Windows.

As of now I will be looking into sfeMovie instead. :)

// Zap

13
General discussions / Re: GStreamer SDK and SFML
« on: October 26, 2012, 10:00:12 am »
Hi,

Just reporting on how the project is working out. I have given up on using the OpenGL plugin for GStreamer. However I have successfully drawn a full HD movie to a texture using an other pipeline (a modified playbin2). Using PBOs (2 actually) and preforming a kinda buffer ping-ponging to make use of the DMA (async coping etc. that does not block the CPU) I have managed to get pretty good performance. What remains now is to properly subclass SFMLs Drawable and Transformable so that my "VideoSprite" works similar to SFMLs sprite.

This is my system info (graphics: AMD HD7870 Eyefinity Edition):


When running two 1080p movies at the same time on a windows that is 3840x1080:


// Zap

14
General discussions / Re: GStreamer SDK and SFML
« on: October 19, 2012, 08:46:47 pm »
The sfeMovie project seems awesome, and I do not doubt that I could use it. However trying out the tutorials for GStreamer SDK I found it good performance-wise as well as quite easy to use and install, for being a very flexible, large and complex SDK. Which that is why I will try to use it in my project. However if that fails miserably I will probably try to use sfeMovie instead.

My (initial) plan is to use GStreamers playbin2 and the gst-plugin-gl (OpenGL plugin for GStreamer, which is included in the OSSBuild) to draw video as a sprite (or at least on a textured quad). As the plugin will give you an actual OpenGL-texture-id when a frame has been decoded. The plugin enables the current frame to be uploaded to the GPU without any work, except for the actual setup of the pipeline . Decoding a 1080p h264 movie with the help of playbin2 works very nice, getting a very similar preformenc as VLC and similar media-players on Windows (haven't tried it on *nix just yet).

Quote
If you still want to make your own player, here are some points you should have a close look at:
- audio/video syncing
- audio/video decoding latency handling
- video stream structure: especially the fact that most frames in a video file are incomplete frames, which prevents you from simply seeking to a specific time
As far as I know GStreamer does all this for you.

Some interesting links:
GStreamer SDK tutorials: http://docs.gstreamer.com/display/GstSDK/Tutorials
OSSBuild, GStreamer that includes the OpenGL plugin and a lot more. http://code.google.com/p/ossbuild/

GStreamer SDK and the OSSBuild works nicely on Windows in VS2010.

Here is a very simple example (from gst-plugin-gl) of how to use the OpenGL plugin, drawing a test video on the sides of a cube:
#include <GL/glew.h>
#include <gst/gst.h>

#include <iostream>
#include <string>

static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
    GMainLoop *loop = (GMainLoop*)data;

    switch (GST_MESSAGE_TYPE (msg))
    {
        case GST_MESSAGE_EOS:
              g_print ("End-of-stream\n");
              g_main_loop_quit (loop);
              break;
        case GST_MESSAGE_ERROR:
          {
              gchar *debug = NULL;
              GError *err = NULL;

              gst_message_parse_error (msg, &err, &debug);

              g_print ("Error: %s\n", err->message);
              g_error_free (err);

              if (debug)
              {
                  g_print ("Debug deails: %s\n", debug);
                  g_free (debug);
              }

              g_main_loop_quit (loop);
              break;
          }
        default:
          break;
    }

    return TRUE;
}

//client reshape callback
void reshapeCallback (GLuint width, GLuint height, gpointer data)
{
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100);
    glMatrixMode(GL_MODELVIEW);
}

//client draw callback
gboolean drawCallback (GLuint texture, GLuint width, GLuint height, gpointer data)
{
    static GLfloat      xrot = 0;
    static GLfloat      yrot = 0;
    static GLfloat      zrot = 0;
    static GTimeVal current_time;
    static glong last_sec = current_time.tv_sec;
    static gint nbFrames = 0;

    g_get_current_time (&current_time);
    nbFrames++ ;

    if ((current_time.tv_sec - last_sec) >= 1)
    {
        std::cout << "GRPHIC FPS = " << nbFrames << std::endl;
        nbFrames = 0;
        last_sec = current_time.tv_sec;
    }

    glEnable(GL_DEPTH_TEST);

    glEnable (GL_TEXTURE_RECTANGLE_ARB);
    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(0.0f,0.0f,-5.0f);

    glRotatef(xrot,1.0f,0.0f,0.0f);
    glRotatef(yrot,0.0f,1.0f,0.0f);
    glRotatef(zrot,0.0f,0.0f,1.0f);

    glBegin(GL_QUADS);
              // Front Face
              glTexCoord2f((gfloat)width, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
              glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
              glTexCoord2f(0.0f, (gfloat)height); glVertex3f( 1.0f,  1.0f,  1.0f);
              glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f(-1.0f,  1.0f,  1.0f);
              // Back Face
              glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
              glTexCoord2f(0.0f, (gfloat)height); glVertex3f(-1.0f,  1.0f, -1.0f);
              glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f( 1.0f,  1.0f, -1.0f);
              glTexCoord2f((gfloat)width, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
              // Top Face
              glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f(-1.0f,  1.0f, -1.0f);
              glTexCoord2f((gfloat)width, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
              glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
              glTexCoord2f(0.0f, (gfloat)height); glVertex3f( 1.0f,  1.0f, -1.0f);
              // Bottom Face
              glTexCoord2f((gfloat)width, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
              glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
              glTexCoord2f(0.0f, (gfloat)height); glVertex3f( 1.0f, -1.0f,  1.0f);
              glTexCoord2f((gfloat)width,(gfloat)height); glVertex3f(-1.0f, -1.0f,  1.0f);
              // Right face
              glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
              glTexCoord2f(0.0f, (gfloat)height); glVertex3f( 1.0f,  1.0f, -1.0f);
              glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f( 1.0f,  1.0f,  1.0f);
              glTexCoord2f((gfloat)width, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
              // Left Face
              glTexCoord2f((gfloat)width, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
              glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
              glTexCoord2f(0.0f, (gfloat)height); glVertex3f(-1.0f,  1.0f,  1.0f);
              glTexCoord2f((gfloat)width, (gfloat)height); glVertex3f(-1.0f,  1.0f, -1.0f);
    glEnd();

    xrot+=0.3f;
    yrot+=0.2f;
    zrot+=0.4f;

    //return TRUE causes a postRedisplay
    return TRUE;
}


//gst-launch-0.10 videotestsrc num_buffers=400 ! video/x-raw-rgb, width=320, height=240 !
//glgraphicmaker ! glfiltercube ! video/x-raw-gl, width=800, height=600 ! glimagesink
gint main (gint argc, gchar *argv[])
{
    GstStateChangeReturn ret;
    GstElement *pipeline, *videosrc, *glupload, *glimagesink;

    GMainLoop *loop;
    GstBus *bus;

    /* initialization */
    gst_init (&argc, &argv);
    loop = g_main_loop_new (NULL, FALSE);

    /* create elements */
    pipeline = gst_pipeline_new ("pipeline");

    /* watch for messages on the pipeline's bus (note that this will only
     * work like this when a GLib main loop is running) */

    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    gst_bus_add_watch (bus, bus_call, loop);
    gst_object_unref (bus);

    /* create elements */
    videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc0");
    glupload  = gst_element_factory_make ("glupload", "glupload0");
    glimagesink  = gst_element_factory_make ("glimagesink", "glimagesink0");


    if (!videosrc || !glupload || !glimagesink)
    {
        g_print ("one element could not be found \n");
        return -1;
    }

    /* change video source caps */
    GstCaps *caps = gst_caps_new_simple("video/x-raw-rgb",
                                        "width", G_TYPE_INT, 320,
                                        "height", G_TYPE_INT, 240,
                                        "framerate", GST_TYPE_FRACTION, 25, 1,
                                        NULL) ;


    GstCaps *outcaps = gst_caps_new_simple("video/x-raw-gl",
                                        "width", G_TYPE_INT, 800,
                                        "height", G_TYPE_INT, 600,
                                        NULL) ;

    /* configure elements */
    g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL);
    g_object_set(G_OBJECT(glimagesink), "client-reshape-callback", reshapeCallback, NULL);
    g_object_set(G_OBJECT(glimagesink), "client-draw-callback", drawCallback, NULL);
    g_object_set(G_OBJECT(glimagesink), "client-data", NULL, NULL);

    /* add elements */
    gst_bin_add_many (GST_BIN (pipeline), videosrc, glupload, glimagesink, NULL);

    /* link elements */
    gboolean link_ok = gst_element_link_filtered(videosrc, glupload, caps) ;
    gst_caps_unref(caps) ;
    if(!link_ok)
    {
        g_warning("Failed to link videosrc to glupload!\n") ;
        return -1 ;
    }
    link_ok = gst_element_link_filtered(glupload, glimagesink, outcaps) ;
    gst_caps_unref(outcaps) ;
    if(!link_ok)
    {
        g_warning("Failed to link glupload to glimagesink!\n") ;
        return -1 ;
    }


    /* run */
    ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE)
    {
        g_print ("Failed to start up pipeline!\n");

        /* check if there is an error message with details on the bus */
        GstMessage* msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
        if (msg)
        {
          GError *err = NULL;

          gst_message_parse_error (msg, &err, NULL);
          g_print ("ERROR: %s\n", err->message);
          g_error_free (err);
          gst_message_unref (msg);
        }
        return -1;
    }

    g_main_loop_run (loop);

    /* clean up */
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    return 0;

}
 

I do not yet know exacly how I will setup the actual rendering of the quad in SFML, I might try to sub-class the Drawable(?) class or draw the thing in "pure" OpenGL.

The goal is to be able to draw at-least 3 (hopefully more) 1080p movies at the same time. :P

// Zap

15
General discussions / Re: GStreamer SDK and SFML
« on: October 19, 2012, 01:23:12 pm »
Thanks, man! :)

I, however, started building my own, based on OSSBuild, as GStreamer SDK doesn't include the OpenGL plugin (which OSSBuild does).

I will report back how it goes, later. ;)

// Zap

Pages: [1] 2
anything