[FFmpeg-cvslog] iff: remove get_image_data() and get_image_size() wrappers

Stefano Sabatini git at videolan.org
Wed May 11 00:20:14 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Mon May  9 23:58:20 2011 +0200| [70b10db24cb4e65e3b7a97e7f9bedbf67a6c4373] | committer: Stefano Sabatini

iff: remove get_image_data() and get_image_size() wrappers

Remove one level of indirection, simplify code.

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

 libavcodec/iff.c |   37 ++++++++-----------------------------
 1 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 3ca8233..195ef10 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -38,29 +38,6 @@ typedef enum {
     MASK_LASSO
 } mask_type;
 
-/**
- * Gets the actual raw image data after video properties which
- * contains the raw image data beyond the IFF extra context.
- *
- * @param avpkt the AVPacket where to extract raw image data from
- * @return pointer to raw image data
- */
-static av_always_inline uint8_t *get_image_data(const AVPacket *const avpkt) {
-    return avpkt->data + AV_RB16(avpkt->data);
-}
-
-/**
- * Gets the size of raw image data beyond the IFF extra context.
- * Please note that any value < 2 of either IFF extra context
- * or raw image data is considered as an illegal packet.
- *
- * @param avpkt the AVPacket where to extract image data size from
- * @return size of raw image data in bytes
- */
-static av_always_inline int get_image_size(const AVPacket *const avpkt) {
-    return avpkt->size - AV_RB16(avpkt->data);
-}
-
 typedef struct {
     AVFrame frame;
     int planesize;
@@ -202,14 +179,16 @@ static int extract_header(AVCodecContext *const avctx,
     int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
 
     if (avpkt) {
+        int image_size;
         if (avpkt->size < 2)
             return AVERROR_INVALIDDATA;
+        image_size = avpkt->size - AV_RB16(avpkt->data);
         buf = avpkt->data;
         buf_size = bytestream_get_be16(&buf);
-        if (buf_size <= 1 || get_image_size(avpkt) <= 1) {
+        if (buf_size <= 1 || image_size <= 1) {
             av_log(avctx, AV_LOG_ERROR,
                    "Invalid image size received: %u -> image data offset: %d\n",
-                   buf_size, get_image_size(avpkt));
+                   buf_size, image_size);
             return AVERROR_INVALIDDATA;
         }
     } else {
@@ -439,8 +418,8 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
                             AVPacket *avpkt)
 {
     IffContext *s = avctx->priv_data;
-    const uint8_t *buf = avpkt->size >= 2 ? get_image_data(avpkt) : NULL;
-    const int buf_size = avpkt->size >= 2 ? get_image_size(avpkt) : 0;
+    const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL;
+    const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0;
     const uint8_t *buf_end = buf+buf_size;
     int y, plane, res;
 
@@ -516,8 +495,8 @@ static int decode_frame_byterun1(AVCodecContext *avctx,
                             AVPacket *avpkt)
 {
     IffContext *s = avctx->priv_data;
-    const uint8_t *buf = avpkt->size >= 2 ? get_image_data(avpkt) : NULL;
-    const int buf_size = avpkt->size >= 2 ? get_image_size(avpkt) : 0;
+    const uint8_t *buf = avpkt->size >= 2 ? avpkt->data + AV_RB16(avpkt->data) : NULL;
+    const int buf_size = avpkt->size >= 2 ? avpkt->size - AV_RB16(avpkt->data) : 0;
     const uint8_t *buf_end = buf+buf_size;
     int y, plane, res;
 



More information about the ffmpeg-cvslog mailing list