]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/interplayvideo.c
Fix declaration and code thingie
[ffmpeg] / libavcodec / interplayvideo.c
index 72e0377475502feafdb46369f26426b4d6c123f7..95059c365d1a579ef4b0389befbe3d2423879c89 100644 (file)
@@ -2,19 +2,21 @@
  * Interplay MVE Video Decoder
  * Copyright (C) 2003 the ffmpeg project
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  *
  */
 
@@ -47,7 +49,7 @@
 /* debugging support */
 #define DEBUG_INTERPLAY 0
 #if DEBUG_INTERPLAY
-#define debug_interplay printf
+#define debug_interplay(x,...) av_log(NULL, AV_LOG_DEBUG, x, __VA_ARGS__)
 #else
 static inline void debug_interplay(const char *format, ...) { }
 #endif
@@ -76,7 +78,7 @@ typedef struct IpvideoContext {
 
 #define CHECK_STREAM_PTR(n) \
   if ((s->stream_ptr + n) > s->stream_end) { \
-    printf ("Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
+    av_log(s->avctx, AV_LOG_ERROR, "Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
       s->stream_ptr + n, s->stream_end); \
     return -1; \
   }
@@ -86,10 +88,10 @@ typedef struct IpvideoContext {
     motion_offset += y * s->stride; \
     motion_offset += x; \
     if (motion_offset < 0) { \
-        printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset); \
         return -1; \
     } else if (motion_offset > s->upper_motion_limit_offset) { \
-        printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n", \
             motion_offset, s->upper_motion_limit_offset); \
         return -1; \
     } \
@@ -101,10 +103,10 @@ typedef struct IpvideoContext {
     motion_offset += y * s->stride; \
     motion_offset += x; \
     if (motion_offset < 0) { \
-        printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset); \
         return -1; \
     } else if (motion_offset > s->upper_motion_limit_offset) { \
-        printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n", \
             motion_offset, s->upper_motion_limit_offset); \
         return -1; \
     } \
@@ -116,10 +118,10 @@ typedef struct IpvideoContext {
     motion_offset += y * s->stride; \
     motion_offset += x; \
     if (motion_offset < 0) { \
-        printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset); \
         return -1; \
     } else if (motion_offset > s->upper_motion_limit_offset) { \
-        printf (" Interplay video: motion offset above limit (%d >= %d)\n", \
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n", \
             motion_offset, s->upper_motion_limit_offset); \
         return -1; \
     } \
@@ -254,7 +256,7 @@ static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s)
 static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s)
 {
     /* mystery opcode? skip multiple blocks? */
-    printf ("  Interplay video: Help! Mystery opcode 0x6 seen\n");
+    av_log(s->avctx, AV_LOG_ERROR, "  Interplay video: Help! Mystery opcode 0x6 seen\n");
 
     /* report success */
     return 0;
@@ -838,7 +840,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
             s->pixel_ptr = s->current_frame.data[0] + x;
             ret = ipvideo_decode_block[opcode](s);
             if (ret != 0) {
-                printf(" Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
+                av_log(s->avctx, AV_LOG_ERROR, " Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
                     frame, x - y, y / s->stride);
                 return;
             }
@@ -846,7 +848,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
     }
     if ((s->stream_ptr != s->stream_end) &&
         (s->stream_ptr + 1 != s->stream_end)) {
-        printf (" Interplay video: decode finished with %d bytes left over\n",
+        av_log(s->avctx, AV_LOG_ERROR, " Interplay video: decode finished with %td bytes left over\n",
             s->stream_end - s->stream_ptr);
     }
 }
@@ -858,7 +860,7 @@ static int ipvideo_decode_init(AVCodecContext *avctx)
     s->avctx = avctx;
 
     if (s->avctx->palctrl == NULL) {
-        printf (" Interplay video: palette expected.\n");
+        av_log(avctx, AV_LOG_ERROR, " Interplay video: palette expected.\n");
         return -1;
     }
 
@@ -900,13 +902,18 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
     IpvideoContext *s = avctx->priv_data;
     AVPaletteControl *palette_control = avctx->palctrl;
 
+    /* compressed buffer needs to be large enough to at least hold an entire
+     * decoding map */
+    if (buf_size < s->decoding_map_size)
+        return buf_size;
+
     s->decoding_map = buf;
     s->buf = buf + s->decoding_map_size;
     s->size = buf_size - s->decoding_map_size;
 
     s->current_frame.reference = 3;
     if (avctx->get_buffer(avctx, &s->current_frame)) {
-        printf ("  Interplay Video: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  Interplay Video: get_buffer() failed\n");
         return -1;
     }