]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/idcinvideo.c
Remove a NAL unit's trailing zero bytes even when dst_length is 1.
[ffmpeg] / libavcodec / idcinvideo.c
index b3a658296a06b468074a5b373f9763da00da00b3..38f330c2e38034ba75e0c7a0281a25529f1c1acd 100644 (file)
@@ -2,19 +2,21 @@
  * Id Quake II CIN 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
  *
  */
 
@@ -147,18 +149,17 @@ static void huff_build_tree(IdcinContext *s, int prev) {
 
 static int idcin_decode_init(AVCodecContext *avctx)
 {
-    IdcinContext *s = (IdcinContext *)avctx->priv_data;
+    IdcinContext *s = avctx->priv_data;
     int i, j, histogram_index = 0;
     unsigned char *histograms;
 
     s->avctx = avctx;
     avctx->pix_fmt = PIX_FMT_PAL8;
-    avctx->has_b_frames = 0;
     dsputil_init(&s->dsp, avctx);
 
     /* make sure the Huffman tables make it */
     if (s->avctx->extradata_size != HUFFMAN_TABLE_SIZE) {
-        printf("  Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
+        av_log(s->avctx, AV_LOG_ERROR, "  Id CIN video: expected extradata size of %d\n", HUFFMAN_TABLE_SIZE);
         return -1;
     }
 
@@ -192,8 +193,8 @@ static void idcin_decode_vlcs(IdcinContext *s)
 
             while(node_num >= HUF_TOKENS) {
                 if(!bit_pos) {
-                    if(dat_pos > s->size) {
-                        printf("Huffman decode error.\n");
+                    if(dat_pos >= s->size) {
+                        av_log(s->avctx, AV_LOG_ERROR, "Huffman decode error.\n");
                         return;
                     }
                     bit_pos = 8;
@@ -215,7 +216,7 @@ static int idcin_decode_frame(AVCodecContext *avctx,
                               void *data, int *data_size,
                               uint8_t *buf, int buf_size)
 {
-    IdcinContext *s = (IdcinContext *)avctx->priv_data;
+    IdcinContext *s = avctx->priv_data;
     AVPaletteControl *palette_control = avctx->palctrl;
 
     s->buf = buf;
@@ -225,7 +226,7 @@ static int idcin_decode_frame(AVCodecContext *avctx,
         avctx->release_buffer(avctx, &s->frame);
 
     if (avctx->get_buffer(avctx, &s->frame)) {
-        printf ("  Id CIN Video: get_buffer() failed\n");
+        av_log(avctx, AV_LOG_ERROR, "  Id CIN Video: get_buffer() failed\n");
         return -1;
     }
 
@@ -248,7 +249,7 @@ static int idcin_decode_frame(AVCodecContext *avctx,
 
 static int idcin_decode_end(AVCodecContext *avctx)
 {
-    IdcinContext *s = (IdcinContext *)avctx->priv_data;
+    IdcinContext *s = avctx->priv_data;
 
     if (s->frame.data[0])
         avctx->release_buffer(avctx, &s->frame);