The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_
Jacek Dudek
Guest

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



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2012/6/19 Jacek Dudek
Quote:
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.
ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_
Jacek Dudek
Guest

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


2012/6/19 Jacek Dudek
Quote:
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.


Quote:
_______________________________________________
SDL mailing list

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
ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2012/6/19 Jacek Dudek
Quote:
On 19/06/2012 14:18, Gabriel Jacobo wrote:
Quote:


2012/6/19 Jacek Dudek
Quote:
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.


Quote:
_______________________________________________
SDL mailing list

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

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.
ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_
Jacek Dudek
Guest

On 19/06/2012 14:52, Gabriel Jacobo wrote:
Quote:


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


2012/6/19 Jacek Dudek
Quote:
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.


Quote:
_______________________________________________
SDL mailing list

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

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.


Quote:
_______________________________________________
SDL mailing list

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,
Jacek
ffmpeg || SDL_TEXTUREACCESS_STREAMING issue with latest SDL_
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2012/6/19 Jacek Dudek
Quote:
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

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.