Ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_RenderCopy, SDL_RenderCopyEx modification

Hi,

I have been working on using ffmpeg to display video in SDL2. I had
everything working before 1st Jun RenderCopyEx API commit so that should
prove that ffmpeg saves pixels correctly to the SDL_Texture (Unless
SDL_Texture structure has been changed as well).

Briefly:

vp->bmp_t = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12,
SDL_TEXTUREACCESS_STREAMING, is->video_st->codec->width,
is->video_st->codec->height);

-load pixels to texture:

if(vp->bmp_t && !SDL_LockTexture(vp->bmp_t, NULL, (void **)&pixels,
&pitch)) {

     memset(&pict, 0, sizeof(AVPicture));

     if(pitch == pFrame->linesize[0]) {
         int size = pitch * is->video_st->codec->height;
         memcpy(pixels, pFrame->data[0], size);
         memcpy(pixels + size, pFrame->data[2], size / 4);
         memcpy(pixels + size * 5 / 4, pFrame->data[1], size / 4);
     }
     else
     {
         register unsigned char *y1,*y2,*y3,*i1,*i2,*i3;
         int i;
         y1 = pixels;
         y3 = pixels + pitch * is->video_st->codec->height;
         y2 = pixels + pitch * is->video_st->codec->height * 5 / 4;

         i1=pFrame->data[0];
         i2=pFrame->data[1];
         i3=pFrame->data[2];

         for (i = 0; i<(is->video_st->codec->height/2); i++) {
                 memcpy(y1,i1,pitch);
                 i1+=pFrame->linesize[0];
                 y1+=pitch;
                 memcpy(y1,i1,pitch);
                 memcpy(y2,i2,pitch / 2);
                 memcpy(y3,i3,pitch / 2);

                 y1+=pitch;
                 y2+=pitch / 2;
                 y3+=pitch / 2;
                 i1+=pFrame->linesize[0];
                 i2+=pFrame->linesize[1];
                 i3+=pFrame->linesize[2];
     }

}
SDL_UnlockTexture(vp->bmp_t);

  • display:

SDL_RenderClear(renderer);
SDL_Point* point = NULL;
SDL_RendererFlip flip = SDL_FLIP_NONE;
//SDL_RenderCopyEx( renderer, vp->bmp_t, NULL , NULL ,NULL , point, flip );
SDL_RenderCopy(renderer, vp->bmp_t,NULL,NULL);
SDL_RenderPresent(renderer);

RenderCopy displays:
http://www.freeimagehosting.net/xb5cr
RenderCopyEx does not display anything.

I need RenderCopyEx in other parts of the program as it is making things
a lot easier with rotation and flipping. I guess it is good to mention
that I tried using just using surface and then transforming it into
texture but it slows down the whole application.

Any help is very much appriciated,
Jacek

2012/6/19 Jacek Dudek

Hi,

I have been working on using ffmpeg to display video in SDL2. I had
everything working before 1st Jun RenderCopyEx API commit so that should
prove that ffmpeg saves pixels correctly to the SDL_Texture (Unless
SDL_Texture structure has been changed as well).

I need RenderCopyEx in other parts of the program as it is making things a
lot easier with rotation and flipping. I guess it is good to mention that I
tried using just using surface and then transforming it into texture but it
slows down the whole application.

Any help is very much appriciated,
Jacek

If you use a surface and then copy it to a texture (with
SDL_CreateTextureFromSurface), does it work? What renderer backend are you
using (OpenGL, Direct3D, etc) ?–
Gabriel.

When I use SDL_CreateTextureFromSurface it generates and displays a good
image but slows down the video to 7-10 fps. I use OpenGl renderer backend.

JacekOn 19/06/2012 14:18, Gabriel Jacobo wrote:

2012/6/19 Jacek Dudek <jacekgdudek at gmail.com
<mailto:jacekgdudek at gmail.com>>

Hi,

I have been working on using ffmpeg to display video in SDL2. I
had everything working before 1st Jun RenderCopyEx API commit so
that should prove that ffmpeg saves pixels correctly to the
SDL_Texture (Unless SDL_Texture structure has been changed as well).

I need RenderCopyEx in other parts of the program as it is making
things a lot easier with rotation and flipping. I guess it is good
to mention that I tried using just using surface and then
transforming it into texture but it slows down the whole application.

Any help is very much appriciated,
Jacek

If you use a surface and then copy it to a texture (with
SDL_CreateTextureFromSurface), does it work? What renderer backend are
you using (OpenGL, Direct3D, etc) ?

Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2012/6/19 Jacek Dudek > On 19/06/2012 14:18, Gabriel Jacobo wrote:

2012/6/19 Jacek Dudek

Hi,

I have been working on using ffmpeg to display video in SDL2. I had
everything working before 1st Jun RenderCopyEx API commit so that should
prove that ffmpeg saves pixels correctly to the SDL_Texture (Unless
SDL_Texture structure has been changed as well).

I need RenderCopyEx in other parts of the program as it is making things
a lot easier with rotation and flipping. I guess it is good to mention that
I tried using just using surface and then transforming it into texture but
it slows down the whole application.

Any help is very much appriciated,
Jacek

If you use a surface and then copy it to a texture (with
SDL_CreateTextureFromSurface), does it work? What renderer backend are you
using (OpenGL, Direct3D, etc) ?


Gabriel.


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

When I use SDL_CreateTextureFromSurface it generates and displays a good
image but slows down the video to 7-10 fps. I use OpenGl renderer backend.

Jacek


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m looking at the commit I made and I don’t see any changes done to the
texture creation or RenderCopy functions…does you code work fine with
this revision http://hg.libsdl.org/SDL/rev/698c98b83cbb ? (That’s one right
before the RenderCopyEx patch landed).


Gabriel.

2012/6/19 Jacek Dudek <@Jacek_Dudek mailto:Jacek_Dudek>

2012/6/19 Jacek Dudek <jacekgdudek at gmail.com
<mailto:jacekgdudek at gmail.com>>

    Hi,

    I have been working on using ffmpeg to display video in SDL2.
    I had everything working before 1st Jun RenderCopyEx API
    commit so that should prove that ffmpeg saves pixels
    correctly to the SDL_Texture (Unless SDL_Texture structure
    has been changed as well).

    I need RenderCopyEx in other parts of the program as it is
    making things a lot easier with rotation and flipping. I
    guess it is good to mention that I tried using just using
    surface and then transforming it into texture but it slows
    down the whole application.

    Any help is very much appriciated,
    Jacek



If you use a surface and then copy it to a texture (with
SDL_CreateTextureFromSurface), does it work? What renderer
backend are you using (OpenGL, Direct3D, etc) ?
-- 
Gabriel.


_______________________________________________
SDL mailing list
SDL at lists.libsdl.org  <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
When I use SDL_CreateTextureFromSurface it generates and displays
a good image but slows down the video to 7-10 fps. I use OpenGl
renderer backend.

Jacek

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m looking at the commit I made and I don’t see any changes done to
the texture creation or RenderCopy functions…does you code work fine
with this revision http://hg.libsdl.org/SDL/rev/698c98b83cbb ? (That’s
one right before the RenderCopyEx patch landed).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I looked throught the diff briefly as well but could not find any
changes to SDL_RenderCopy. Just tested again and video texture renders
fine at commit 6319 but fails at commit 6320. Under thing I noticed is
that when I use RenderCopy to draw other textures generated from
surfaces on the same windows the “stripes” would change color.

Thanks,
JacekOn 19/06/2012 14:52, Gabriel Jacobo wrote:

On 19/06/2012 14:18, Gabriel Jacobo wrote:

2012/6/19 Jacek Dudek

I looked throught the diff briefly as well but could not find any
changes to SDL_RenderCopy. Just tested again and video texture renders fine
at commit 6319 but fails at commit 6320. Under thing I noticed is that when
I use RenderCopy to draw other textures generated from surfaces on the same
windows the “stripes” would change color.

Thanks,
Jacek


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It’s strange indeed…can you make a minimal test case that fails and file
a bug? (Probably without using ffmpeg) With a test case it’ll be easier for
me to figure it out.–
Gabriel.

Hi,

Attaching a ffmpeg+SDL2 project with different builds of SDL library
6319 works fine. any newer does not. Any help is well apreciated.

Jacek

I’ve linked 1 file to this email:
Blink_error.7z
https://www.yousendit.com/download/QlVpQk05RkVTSURIRHRVag(8.4
MB)YouSendIt
https://www.yousendit.comhttps://www.yousendit.com/download/QlVpQk05RkVTSURIRHRVag
Mozilla Thunderbird http://www.getthunderbird.com makes it easy to
share large files over email.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: attachment-24.png
Type: image/png
Size: 641 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120705/be6415e8/attachment.png
-------------- next part --------------
A non-text attachment was scrubbed…
Name: yousendit.png
Type: image/png
Size: 403 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120705/be6415e8/attachment-0001.pngOn 19/06/2012 16:20, Gabriel Jacobo wrote:

2012/6/19 Jacek Dudek <@Jacek_Dudek mailto:Jacek_Dudek>

I looked throught the diff briefly as well but could not find any
changes to SDL_RenderCopy. Just tested again and video texture
renders fine at commit 6319 but fails at commit 6320. Under thing
I noticed is that when I use RenderCopy to draw other textures
generated from surfaces on the same windows the "stripes" would
change color.

Thanks,
Jacek



_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It’s strange indeed…can you make a minimal test case that fails and
file a bug? (Probably without using ffmpeg) With a test case it’ll be
easier for me to figure it out.


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org