Hi,
I’m trying to convert Arjan Houben’s SDL_ffmpeg to work directly with SDL1.3 Textures. I have previously used his library using SDL 1.2 and Overlays. I have found that using Surfaces is far too slow for my hardware. Therefore I can’t really use the SDL_CreateTextureFromSurface ( Too bad there is no SDL_CreateTextureFromOverlay )
First I created a texture with,
Code:
videoFrame->texture = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_YUY2, SDL_TEXTUREACCESS_STREAMING, w, h ); //3plane
And then I attempted to modify Arjan’s library with,
Code:
if ( frame->texture )
{
void *pixels;
int tpitch[3];
SDL_LockTexture(frame->texture, NULL, &pixels, &tpitch[0]);
sws_scale( getContext( &file->videoStream->conversionContext,
file->videoStream->_ffmpeg->codec->width,
file->videoStream->_ffmpeg->codec->height,
file->videoStream->_ffmpeg->codec->pix_fmt,
frame->tempw, frame->temph,
PIX_FMT_YUYV422 ),
( const uint8_t* const* )file->videoStream->decodeFrame->data,
file->videoStream->decodeFrame->linesize,
0,
file->videoStream->_ffmpeg->codec->height,
( uint8_t* const* )pixels,
tpitch );
SDL_UnlockTexture( frame->texture );
}
Below is similar code, except with the pixles of an SDL Overlay (SDL 1.2) being written to,
Code:
/* convert YUV 420 to YUYV 422 data */
else if ( frame->overlay && frame->overlay->format == SDL_YUY2_OVERLAY )
{
int pitch[] =
{
frame->overlay->pitches[ 0 ],
frame->overlay->pitches[ 1 ],
frame->overlay->pitches[ 2 ]
};
sws_scale( getContext( &file->videoStream->conversionContext,
file->videoStream->_ffmpeg->codec->width,
file->videoStream->_ffmpeg->codec->height,
file->videoStream->_ffmpeg->codec->pix_fmt,
frame->overlay->w, frame->overlay->h,
PIX_FMT_YUYV422 ),
( const uint8_t* const* )file->videoStream->decodeFrame->data,
file->videoStream->decodeFrame->linesize,
0,
file->videoStream->_ffmpeg->codec->height,
( uint8_t* const* )frame->overlay->pixels,
pitch );
}
Writing the pixels to the Texture Segment Faults, but writing to the Overlay works great. Anyone with any insight / examples or other help? I’d be happy to hear of more straight forward ways to do this but I do like ffmpeg.
Unfortunately it looks like Arjan has stopped working / supporting SDL_ffmpeg.
Thanks in advance.