On Nov 12, 2009, at 8:11 AM, Leonardo Farage Freitas wrote:
For about a month now, I've been trying to play a video in a LCD TV
through
a Blackmagic card on a video Component input, I decided to use
ffmpeg to
extract the frames and put into the buffer of the card. All I can do
right
now is play the video in b&w.
So the code below makes B&W video? That's a big clue.
img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height,
PIX_FMT_RGB32, pCodecCtx->width, pCodecCtx->height, PIX_FMT_RGB32,
SWS_BILINEAR, NULL, NULL, 0);
sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0,
pCodecCtx->height, pFrameRGB->data, FrameRGB->linesize);
.
.
.
for(int h = 0; h < height; h++){
for(int w = 0; w<width*3; w++){
int index = h * width + w;
aux = (unsigned int) pFrameRGB->data[0][index];
aux2 = aux;
nextWord[index] =((255<< 24) | (aux2 << 16) | (aux2 << 8) |
aux2);
Sheesh. This is a bit odd. First, if you're doing all the shifting,
you might as well use bytes (and your shifting looks wrong). If you
asked me to guess what this should look like, I would guess (off the
top of my head, easier to read and debug version)
for (int y = 0; y < height; ++y)
{
uint8* dstPtr = (uint8*)bmdDestPtr + (y * bmdDestStride);
uint8* scrcPtr = (uint8*)pFrameRGB->data + (y * pFrameRGB->lineSize);
// If RGBA formats match, do a memcpy instead of 'x' loop
for (int x = 0; x < width; ++x) // Why was this *3? RGBx data would
be *4 is anything, is width in bytes not pixels??
{
*destPtr++ = scrcPtr[0]; // Switch around indexes to get RGBA
correctly
*destPtr++ = scrcPtr[1];
*destPtr++ = scrcPtr[2];
*destPtr++ = scrcPtr[3];
scrPtr += 4;
}
}
You can step through this and see what's going on and you can easily
change what you set destination pixels to to see red, green and blue
screens, or even check the value of x and make color bars.
But to be honest, if you get B&W, something might be yuv data still,
like the decklink isn't expecting RGB.
Bruce Wheaton
I'm doing this to put the frame into the Blackmagic buffer (unsigned
int*
nextWord).
The Blackmagic card uses an 8BitBGRA pixel format. From the
Blackmagic API
manual:
"bmdFormat8BitBGRA : BGRA (or RGB32) 4:4:4:x raw
Four 8-bit unsigned components are packed into one 32-bit little-
endian
word.
The alpha channel may be valid."
Hope somebody can help me.
Thanks in advance.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user