[Ffmpeg-devel] Image width converted from 320 to 352 pixels
Ramiro Polla
ramiro86
Fri Jun 9 05:26:10 CEST 2006
Hello,
I'm trying to add the libmimic codec to libavcodec, and its file format to
libavformat. I'm just making a wrapper around its functions, and the format
is pretty simple (struct with size and timestamp + payload[size]... on and
on). Everything decodes fine. The width is 320, height is 240, and the
pix_fmt is PIX_FMT_RGB24.
If I take the output from the decoder and save it to a 320x240 bitmap right
before I leave the decode function, I get the image I wanted (well, almost,
I just have to invert it). But inside ffmpeg, the image goes weird.
I noticed the buffer is for 352x240 pixels. With my 320x240 image, I simply
lose 32 pixels every line. So every line starts shifted by another 32
pixels, and the image goes short at the end. It's like if I took a
[320][240] array and made it [352][240], not displaying 32 pixels per line.
Like this:
line 1: 320 pixels from buffer line 1 | 32 pixels from buffer line 2 not
shown
line 2: 288 pixels from buffer line 2 (starting at pixel 33) + 32 pixels
from buffer line 3 | 32 pixels from line 3 not shown
line 3: 256 pixels from buffer line 3 (starting at pixel 65) + 64 pixels
from buffer line 4 | 32 pixels from line 4 not shown
line 4: 224 pixels from buffer line 4 (starting at pixel 97) + 96 pixels
from buffer line 5 | 32 pixels from line 5 not shown
and so on...
If I use this function after decoding, I get the image I want:
int nwidth = 352;
int k, o;
for( k = (height-1) ; k >= 0 ; k-- )
{
for( o = 0 ; o < width ; o++ )
{
output_rgb[(((k*nwidth)+o)*3)+0] = output_rgb[(((k*width)+o)*3)+0];
output_rgb[(((k*nwidth)+o)*3)+1] = output_rgb[(((k*width)+o)*3)+1];
output_rgb[(((k*nwidth)+o)*3)+2] = output_rgb[(((k*width)+o)*3)+2];
}
}
Can anyone shed some light on this subject for me?
I know the problem is not with the decoder. I think I might be passing some
information wrong either at the libavformat level or at libavcodec level.
Is there something I'm missing from withing libavcodec about buffer sizes or
something like that?
Thanks,
Ramiro Polla
More information about the ffmpeg-devel
mailing list