]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/flicvideo.c
Document ff_des_encdec
[ffmpeg] / libavcodec / flicvideo.c
index 78506eee871c66fd030bdc7fd5012c1eaa8c5dd6..6d65f6583e2ca5b293dc442d9fbe518244baddda 100644 (file)
@@ -17,7 +17,6 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
  */
 
 /**
@@ -41,7 +40,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "common.h"
 #include "avcodec.h"
 #include "bswap.h"
 
@@ -80,26 +78,28 @@ typedef struct FlicDecodeContext {
 
 static int flic_decode_init(AVCodecContext *avctx)
 {
-    FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data;
+    FlicDecodeContext *s = avctx->priv_data;
     unsigned char *fli_header = (unsigned char *)avctx->extradata;
     int depth;
 
     s->avctx = avctx;
-    avctx->has_b_frames = 0;
 
     s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
-    depth       = AV_RL16(&fli_header[12]);
-
-    if (depth == 0) {
-      depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
-    }
 
+    depth = 0;
     if (s->avctx->extradata_size == 12) {
         /* special case for magic carpet FLIs */
         s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE;
+        depth = 8;
     } else if (s->avctx->extradata_size != 128) {
         av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n");
         return -1;
+    } else {
+        depth = AV_RL16(&fli_header[12]);
+    }
+
+    if (depth == 0) {
+        depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
     }
 
     if ((s->fli_type == FLC_FLX_TYPE_CODE) && (depth == 16)) {
@@ -115,7 +115,7 @@ static int flic_decode_init(AVCodecContext *avctx)
                   return -1;
                   break;
         default :
-                  av_log(avctx, AV_LOG_ERROR, "Unkown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
+                  av_log(avctx, AV_LOG_ERROR, "Unknown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
                   return -1;
     }
 
@@ -129,7 +129,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
                                   void *data, int *data_size,
                                   uint8_t *buf, int buf_size)
 {
-    FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data;
+    FlicDecodeContext *s = avctx->priv_data;
 
     int stream_ptr = 0;
     int stream_ptr_after_color_chunk;
@@ -355,8 +355,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
                             pixels[pixel_ptr++] = palette_idx1;
                             pixel_countdown--;
                             if (pixel_countdown < 0)
-                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
-                                       pixel_countdown);
+                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
+                                       pixel_countdown, lines);
                         }
                     } else {  /* copy bytes if byte_run < 0 */
                         byte_run = -byte_run;
@@ -366,8 +366,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
                             pixels[pixel_ptr++] = palette_idx1;
                             pixel_countdown--;
                             if (pixel_countdown < 0)
-                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
-                                       pixel_countdown);
+                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
+                                       pixel_countdown, lines);
                         }
                     }
                 }
@@ -431,7 +431,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
 {
     /* Note, the only difference between the 15Bpp and 16Bpp */
     /* Format is the pixel format, the packets are processed the same. */
-    FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data;
+    FlicDecodeContext *s = avctx->priv_data;
 
     int stream_ptr = 0;
     int pixel_ptr;
@@ -563,8 +563,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
                             pixels[pixel_ptr++] = palette_idx1;
                             pixel_countdown--;
                             if (pixel_countdown < 0)
-                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
-                                       pixel_countdown);
+                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) (linea%d)\n",
+                                       pixel_countdown, lines);
                         }
                     } else {  /* copy bytes if byte_run < 0 */
                         byte_run = -byte_run;
@@ -574,27 +574,25 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
                             pixels[pixel_ptr++] = palette_idx1;
                             pixel_countdown--;
                             if (pixel_countdown < 0)
-                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
-                                       pixel_countdown);
+                                av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
+                                       pixel_countdown, lines);
                         }
                     }
                 }
 
                 /* Now FLX is strange, in that it is "byte" as opposed to "pixel" run length compressed.
-                 * This doesnt give us any good oportunity to perform word endian conversion
-                 * during decompression. So if its requried (ie, this isnt a LE target, we do
+                 * This does not give us any good oportunity to perform word endian conversion
+                 * during decompression. So if it is required (i.e., this is not a LE target, we do
                  * a second pass over the line here, swapping the bytes.
                  */
-                pixel = 0xFF00;
-                if (0xFF00 != AV_RL16(&pixel)) /* Check if its not an LE Target */
-                {
-                  pixel_ptr = y_ptr;
-                  pixel_countdown = s->avctx->width;
-                  while (pixel_countdown > 0) {
+#ifdef WORDS_BIGENDIAN
+                pixel_ptr = y_ptr;
+                pixel_countdown = s->avctx->width;
+                while (pixel_countdown > 0) {
                     *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[pixel_ptr]);
                     pixel_ptr += 2;
-                  }
                 }
+#endif
                 y_ptr += s->frame.linesize[0];
             }
             break;
@@ -718,11 +716,11 @@ static int flic_decode_frame(AVCodecContext *avctx,
                                      buf, buf_size);
     }
 
-    /* Shouldnt get  here, ever as the pix_fmt is processed */
+    /* Should not get  here, ever as the pix_fmt is processed */
     /* in flic_decode_init and the above if should deal with */
     /* the finite set of possibilites allowable by here. */
-    /* but in case we do, just error out. */
-    av_log(avctx, AV_LOG_ERROR, "Unknown Format of FLC. My Science cant explain how this happened\n");
+    /* But in case we do, just error out. */
+    av_log(avctx, AV_LOG_ERROR, "Unknown FLC format, my science cannot explain how this happened.\n");
     return -1;
 }