]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/smc.c
Use full internal pathname in doxygen @file directives.
[ffmpeg] / libavcodec / smc.c
index 274ada3a39230496d5eb6e7282c83c5e35d4ec9f..d0102eaa9c8a6992f7369a5f5c7b0ed95ae0dc81 100644 (file)
@@ -2,24 +2,25 @@
  * Quicktime Graphics (SMC) 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
  */
 
 /**
- * @file smc.c
+ * @file libavcodec/smc.c
  * QT SMC Video Decoder by Mike Melanson (melanson@pcisys.net)
  * For more information about the SMC format, visit:
  *   http://www.pcisys.net/~melanson/codecs/
@@ -32,9 +33,8 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "common.h"
+#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
-#include "dsputil.h"
 
 #define CPAIR 2
 #define CQUAD 4
 typedef struct SmcContext {
 
     AVCodecContext *avctx;
-    DSPContext dsp;
     AVFrame frame;
 
-    unsigned char *buf;
+    const unsigned char *buf;
     int size;
 
     /* SMC color tables */
@@ -118,7 +117,7 @@ static void smc_decode_stream(SmcContext *s)
         s->avctx->palctrl->palette_changed = 0;
     }
 
-    chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+    chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
     stream_ptr += 4;
     if (chunk_size != s->size)
         av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
@@ -195,7 +194,7 @@ static void smc_decode_stream(SmcContext *s)
 
             /* sanity check */
             if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
-               av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
+                av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
                     opcode & 0xF0);
                 break;
             }
@@ -276,7 +275,7 @@ static void smc_decode_stream(SmcContext *s)
                 color_table_index = CPAIR * s->buf[stream_ptr++];
 
             while (n_blocks--) {
-                color_flags = BE_16(&s->buf[stream_ptr]);
+                color_flags = AV_RB16(&s->buf[stream_ptr]);
                 stream_ptr += 2;
                 flag_mask = 0x8000;
                 block_ptr = row_ptr + pixel_ptr;
@@ -319,7 +318,7 @@ static void smc_decode_stream(SmcContext *s)
                 color_table_index = CQUAD * s->buf[stream_ptr++];
 
             while (n_blocks--) {
-                color_flags = BE_32(&s->buf[stream_ptr]);
+                color_flags = AV_RB32(&s->buf[stream_ptr]);
                 stream_ptr += 4;
                 /* flag mask actually acts as a bit shift count here */
                 flag_mask = 30;
@@ -428,14 +427,12 @@ static void smc_decode_stream(SmcContext *s)
     }
 }
 
-static int smc_decode_init(AVCodecContext *avctx)
+static av_cold int smc_decode_init(AVCodecContext *avctx)
 {
-    SmcContext *s = (SmcContext *)avctx->priv_data;
+    SmcContext *s = avctx->priv_data;
 
     s->avctx = avctx;
     avctx->pix_fmt = PIX_FMT_PAL8;
-    avctx->has_b_frames = 0;
-    dsputil_init(&s->dsp, avctx);
 
     s->frame.data[0] = NULL;
 
@@ -444,9 +441,9 @@ static int smc_decode_init(AVCodecContext *avctx)
 
 static int smc_decode_frame(AVCodecContext *avctx,
                              void *data, int *data_size,
-                             uint8_t *buf, int buf_size)
+                             const uint8_t *buf, int buf_size)
 {
-    SmcContext *s = (SmcContext *)avctx->priv_data;
+    SmcContext *s = avctx->priv_data;
 
     s->buf = buf;
     s->size = buf_size;
@@ -468,9 +465,9 @@ static int smc_decode_frame(AVCodecContext *avctx,
     return buf_size;
 }
 
-static int smc_decode_end(AVCodecContext *avctx)
+static av_cold int smc_decode_end(AVCodecContext *avctx)
 {
-    SmcContext *s = (SmcContext *)avctx->priv_data;
+    SmcContext *s = avctx->priv_data;
 
     if (s->frame.data[0])
         avctx->release_buffer(avctx, &s->frame);
@@ -488,4 +485,5 @@ AVCodec smc_decoder = {
     smc_decode_end,
     smc_decode_frame,
     CODEC_CAP_DR1,
+    .long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"),
 };