mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-30 04:47:37 +08:00
Use av_image_alloc() in avpicture_alloc(), simplify.
Originally committed as revision 25920 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@ -813,25 +813,14 @@ void ff_shrink88(uint8_t *dst, int dst_wrap,
|
|||||||
int avpicture_alloc(AVPicture *picture,
|
int avpicture_alloc(AVPicture *picture,
|
||||||
enum PixelFormat pix_fmt, int width, int height)
|
enum PixelFormat pix_fmt, int width, int height)
|
||||||
{
|
{
|
||||||
int size;
|
if (av_image_alloc(picture->data, picture->linesize, width, height, pix_fmt, 0) < 0) {
|
||||||
void *ptr;
|
|
||||||
|
|
||||||
size = avpicture_fill(picture, NULL, pix_fmt, width, height);
|
|
||||||
if(size<0)
|
|
||||||
goto fail;
|
|
||||||
ptr = av_malloc(size);
|
|
||||||
if (!ptr)
|
|
||||||
goto fail;
|
|
||||||
avpicture_fill(picture, ptr, pix_fmt, width, height);
|
|
||||||
if(picture->data[1] && !picture->data[2])
|
|
||||||
ff_set_systematic_pal2((uint32_t*)picture->data[1], pix_fmt);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
fail:
|
|
||||||
memset(picture, 0, sizeof(AVPicture));
|
memset(picture, 0, sizeof(AVPicture));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void avpicture_free(AVPicture *picture)
|
void avpicture_free(AVPicture *picture)
|
||||||
{
|
{
|
||||||
av_free(picture->data[0]);
|
av_free(picture->data[0]);
|
||||||
|
Reference in New Issue
Block a user