[FFmpeg-cvslog] Replace any remaining avpicture function with imgutils

Vittorio Giovara git at videolan.org
Thu Oct 22 20:50:00 CEST 2015


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Oct 14 11:33:24 2015 +0200| [f890677d05bc4e8b494a73373ab4cc19791bf884] | committer: Vittorio Giovara

Replace any remaining avpicture function with imgutils

avpicture_get_size() -> av_image_get_buffer_size()

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f890677d05bc4e8b494a73373ab4cc19791bf884
---

 libavcodec/pamenc.c       |    8 +++++---
 libavcodec/pnm_parser.c   |    4 +++-
 libavcodec/pnmenc.c       |    7 ++++---
 libavcodec/targaenc.c     |    4 +++-
 libavcodec/vble.c         |    6 ++++--
 libavdevice/libdc1394.c   |    4 +++-
 libavdevice/v4l2.c        |    4 ++--
 libavformat/rawvideodec.c |    3 ++-
 libavformat/yuv4mpegdec.c |    5 ++++-
 9 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index 0be07e1..2b63af9 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/imgutils.h"
+
 #include "avcodec.h"
 #include "bytestream.h"
 #include "internal.h"
@@ -31,10 +33,10 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int i, h, w, n, linesize, depth, maxval, ret;
     const char *tuple_type;
     uint8_t *ptr;
+    int size = av_image_get_buffer_size(avctx->pix_fmt,
+                                        avctx->width, avctx->height, 1);
 
-    if ((ret = ff_alloc_packet(pkt, avpicture_get_size(avctx->pix_fmt,
-                                                       avctx->width,
-                                                       avctx->height) + 200)) < 0) {
+    if ((ret = ff_alloc_packet(pkt, size + 200)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
         return ret;
     }
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 175ca36..1b81c2a 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/imgutils.h"
+
 #include "parser.h" //for ParseContext
 #include "pnm.h"
 
@@ -66,7 +68,7 @@ retry:
         next = END_NOT_FOUND;
     } else {
         next = pnmctx.bytestream - pnmctx.bytestream_start
-               + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+               + av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
         if (pnmctx.bytestream_start != buf)
             next -= pc->index;
         if (next > buf_size)
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 791176a..f8c600f 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "bytestream.h"
@@ -31,10 +32,10 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     const AVFrame * const p = pict;
     int i, h, h1, c, n, linesize, ret;
     uint8_t *ptr, *ptr1, *ptr2;
+    int size = av_image_get_buffer_size(avctx->pix_fmt,
+                                        avctx->width, avctx->height, 1);
 
-    if ((ret = ff_alloc_packet(pkt, avpicture_get_size(avctx->pix_fmt,
-                                                       avctx->width,
-                                                       avctx->height) + 200)) < 0) {
+    if ((ret = ff_alloc_packet(pkt, size + 200)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
         return ret;
     }
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index a85400f..290054d 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -21,6 +21,7 @@
 
 #include <string.h>
 
+#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
@@ -84,7 +85,8 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n");
         return AVERROR(EINVAL);
     }
-    picsize = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+    picsize = av_image_get_buffer_size(avctx->pix_fmt,
+                                       avctx->width, avctx->height, 1);
     if ((ret = ff_alloc_packet(pkt, picsize + 45)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
         return ret;
diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index 996a984..7ce1aee 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -26,6 +26,8 @@
 
 #define BITSTREAM_READER_LE
 
+#include "libavutil/imgutils.h"
+
 #include "avcodec.h"
 #include "get_bits.h"
 #include "huffyuvdsp.h"
@@ -183,8 +185,8 @@ static av_cold int vble_decode_init(AVCodecContext *avctx)
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
     avctx->bits_per_raw_sample = 8;
 
-    ctx->size = avpicture_get_size(avctx->pix_fmt,
-                                   avctx->width, avctx->height);
+    ctx->size = av_image_get_buffer_size(avctx->pix_fmt,
+                                         avctx->width, avctx->height, 1);
 
     ctx->val = av_malloc(ctx->size * sizeof(*ctx->val));
 
diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c
index 20696f5..64c453b 100644
--- a/libavdevice/libdc1394.c
+++ b/libavdevice/libdc1394.c
@@ -41,6 +41,7 @@
 #define DC1394_FRAMERATE_240   FRAMERATE_240
 #endif
 
+#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/log.h"
 #include "libavutil/mathematics.h"
@@ -179,7 +180,8 @@ static inline int dc1394_read_common(AVFormatContext *c,
 
     /* packet init */
     av_init_packet(&dc1394->packet);
-    dc1394->packet.size = avpicture_get_size(fmt->pix_fmt, fmt->width, fmt->height);
+    dc1394->packet.size = av_image_get_buffer_size(fmt->pix_fmt,
+                                                   fmt->width, fmt->height, 1);
     dc1394->packet.stream_index = vst->index;
     dc1394->packet.flags |= AV_PKT_FLAG_KEY;
 
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 7b35682..40eabc4 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -828,8 +828,8 @@ static int v4l2_read_header(AVFormatContext *s1)
         return res;
 
     st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
-    s->frame_size =
-        avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
+    s->frame_size = av_image_get_buffer_size(st->codec->pix_fmt,
+                                             s->width, s->height, 1);
 
     if ((res = mmap_init(s1)) ||
         (res = mmap_start(s1)) < 0) {
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index 5f372c9..c7de844 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/imgutils.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
@@ -85,7 +86,7 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
     width = st->codec->width;
     height = st->codec->height;
 
-    packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
+    packet_size = av_image_get_buffer_size(st->codec->pix_fmt, width, height, 1);
     if (packet_size < 0)
         return -1;
 
diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index dd81358..0805274 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/imgutils.h"
+
 #include "avformat.h"
 #include "internal.h"
 #include "yuv4mpeg.h"
@@ -226,7 +228,8 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
     width  = st->codec->width;
     height = st->codec->height;
 
-    packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
+    packet_size = av_image_get_buffer_size(st->codec->pix_fmt,
+                                           width, height, 1);
     if (packet_size < 0)
         return packet_size;
 



More information about the ffmpeg-cvslog mailing list