[FFmpeg-devel] [PATCH] lavc: remove reset to zero of the AVPicture fields in case of avpicture_alloc() failure
Stefano Sabatini
stefasab at gmail.com
Tue Jun 19 13:07:56 CEST 2012
This behavior is not documented, and seems not required in the few places
where avpicture_alloc() is used.
Make the behavior of avpicture_alloc() equivalent to that of
av_image_alloc(), allowing for the function deprecation and API
simplification.
---
libavcodec/avcodec.h | 11 +++--------
libavcodec/imgconvert.c | 9 +--------
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f802e1f..9a8c5ac 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4228,15 +4228,10 @@ void av_resample_close(struct AVResampleContext *c);
*/
/**
- * Allocate memory for a picture. Call avpicture_free() to free it.
+ * Allocate memory for a picture, always assumes a linesize alignment
+ * of 1.
*
- * @see avpicture_fill()
- *
- * @param picture the picture to be filled in
- * @param pix_fmt the format of the picture
- * @param width the width of the picture
- * @param height the height of the picture
- * @return zero if successful, a negative value if not
+ * @see av_image_alloc()
*/
int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 50d2aa1..8b630ba 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -564,14 +564,7 @@ void ff_shrink88(uint8_t *dst, int dst_wrap,
int avpicture_alloc(AVPicture *picture,
enum PixelFormat pix_fmt, int width, int height)
{
- int ret;
-
- if ((ret = av_image_alloc(picture->data, picture->linesize, width, height, pix_fmt, 1)) < 0) {
- memset(picture, 0, sizeof(AVPicture));
- return ret;
- }
-
- return 0;
+ return av_image_alloc(picture->data, picture->linesize, width, height, pix_fmt, 1);
}
void avpicture_free(AVPicture *picture)
--
1.7.5.4
More information about the ffmpeg-devel
mailing list