Luca Abeni wrote:
>
> Are you saying that the "width" field in AVCodecContext is now filled
> with a different value?
>
> Can you reproduce the problem with the "ffmpeg" program? Or, can you
> post some code that reproduces the problem?
>
I've only tested the newer library with MPEG2, so whatever changes I make
should work across all formats. In my code, I did dump out the decoded
images and they are being padded on the right side. As my code has not
changed, something must have changed in the library. The width and height
fields in the AVCodecContext do show the correct dimensions of 704x480, but
the decoded frame is 736x480 with the linesize[0] field equal to 736.
When I test playback using ffplay, the video window is shown in a larger
resolution with padding, half of the padding on the left and half of the
padding on the right. I used the following command line to dump the decoded
video to a series of images "ffmpeg -i sample.mp2 -f image2 samples%d.ppm".
The resultant images were created at the correct dimensions of 704x480.
Here's the code that has been working correctly with r12279:
int nBytesDecoded = avcodec_decode_video(pCodecContext, pFrame,
&nFrameFinished, packet.data, packet.size);
if(nVideoFrameFinished > 0 && nBytesDecoded > 0)
{
if(nWidth == nReqWidth)
{
// Use sws_scale for resizing and/or colorspace conversion
if(pSwsContextOut == NULL)
{
pSwsContextOut = sws_getContext(nSourceWidth, nSourceHeight,
pCodecContext->pix_fmt, nWidth, nHeight, outputPixelFormat, nSwsFlags, NULL,
NULL, NULL);
}
nResult = sws_scale(pSwsContextOut, pFrame->data, pFrame->linesize, 0,
0, pDestFrame->data, pDestFrame->linesize);
ATLASSERT(nResult >= 0);
}
else
{
// Perform the required padding to account for stride requirements
nResult = av_picture_pad((AVPicture*)pPaddedFrame, (AVPicture*)pFrame,
nHeight, nWidth, pCodecContext->pix_fmt, 0, 0, 0, (nReqWidth - nWidth),
padcolor);
ATLASSERT(nResult >= 0);
// Perform the final colorspace conversion for the desired output
if(pSwsContextOut == NULL)
{
pSwsContextOut = sws_getContext(nReqWidth, nHeight,
pCodecContext->pix_fmt, nReqWidth, nHeight, outputPixelFormat, nSwsFlags,
NULL, NULL, NULL);
}
nResult = sws_scale(pSwsContextOut, pPaddedFrame->data,
pPaddedFrame->linesize, 0, 0, pDestFrame->data, pDestFrame->linesize);
ATLASSERT(nResult >= 0);
}
}
In an attempt to resolve the problem, I tried adding another 32 pixels of
padding to the decoded image to get a 768x408 image and then did the final
YUYV422 colorspace conversion on it. The result was a series of solid pink
images.
--
View this message in context:
http://www.nabble.com/Padding-tp18793448p18803818.html
Sent from the libav-users mailing list archive at Nabble.com.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user