aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/imgconvert.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-03-21 10:25:20 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-03-21 10:25:20 +0000
commit899a8fa1cb1a102cc0dd3089a870c3af83d3bf81 (patch)
tree4c0f1f08df824e3ab591af38795bd6fa1021534c /libavcodec/imgconvert.c
parent6f348086914992ca739eb57d2233593ef766218d (diff)
downloadffmpeg-899a8fa1cb1a102cc0dd3089a870c3af83d3bf81.tar.gz
Fix avpicture_get_size for non-paletted formats with a helper palette
to not include the size of that palette. Also clarify its documentation. Originally committed as revision 18106 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r--libavcodec/imgconvert.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index f68105e54b..576da86ae5 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -786,6 +786,17 @@ int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
int avpicture_get_size(int pix_fmt, int width, int height)
{
AVPicture dummy_pict;
+ if(avcodec_check_dimensions(NULL, width, height))
+ return -1;
+ switch (pix_fmt) {
+ case PIX_FMT_RGB8:
+ case PIX_FMT_BGR8:
+ case PIX_FMT_RGB4_BYTE:
+ case PIX_FMT_BGR4_BYTE:
+ case PIX_FMT_GRAY8:
+ // do not include palette for these pseudo-paletted formats
+ return width * height;
+ }
return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
}
@@ -1125,7 +1136,7 @@ int avpicture_alloc(AVPicture *picture,
int size;
void *ptr;
- size = avpicture_get_size(pix_fmt, width, height);
+ size = avpicture_fill(picture, NULL, pix_fmt, width, height);
if(size<0)
goto fail;
ptr = av_malloc(size);