]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rv10.c
PPC fixes & clean-up patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
[ffmpeg] / libavcodec / rv10.c
index 4907c2347865f4745d3b5e0fdcdc3f45ee1f424a..4b351ea1eabf87e5f9bd557445e48381478869ac 100644 (file)
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
+/**
+ * @file rv10.c
+ * RV10 codec.
+ */
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
@@ -24,7 +30,7 @@
 
 #define DC_VLC_BITS 14 //FIXME find a better solution
 
-static const UINT16 rv_lum_code[256] =
+static const uint16_t rv_lum_code[256] =
 {
  0x3e7f, 0x0f00, 0x0f01, 0x0f02, 0x0f03, 0x0f04, 0x0f05, 0x0f06,
  0x0f07, 0x0f08, 0x0f09, 0x0f0a, 0x0f0b, 0x0f0c, 0x0f0d, 0x0f0e,
@@ -60,7 +66,7 @@ static const UINT16 rv_lum_code[256] =
  0x0f78, 0x0f79, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f7e, 0x0f7f,
 };
 
-static const UINT8 rv_lum_bits[256] = 
+static const uint8_t rv_lum_bits[256] = 
 {
  14, 12, 12, 12, 12, 12, 12, 12,
  12, 12, 12, 12, 12, 12, 12, 12,
@@ -96,7 +102,7 @@ static const UINT8 rv_lum_bits[256] =
  12, 12, 12, 12, 12, 12, 12, 12,
 };
 
-static const UINT16 rv_chrom_code[256] =
+static const uint16_t rv_chrom_code[256] =
 {
  0xfe7f, 0x3f00, 0x3f01, 0x3f02, 0x3f03, 0x3f04, 0x3f05, 0x3f06,
  0x3f07, 0x3f08, 0x3f09, 0x3f0a, 0x3f0b, 0x3f0c, 0x3f0d, 0x3f0e,
@@ -132,7 +138,7 @@ static const UINT16 rv_chrom_code[256] =
  0x3f78, 0x3f79, 0x3f7a, 0x3f7b, 0x3f7c, 0x3f7d, 0x3f7e, 0x3f7f,
 };
 
-static const UINT8 rv_chrom_bits[256] =
+static const uint8_t rv_chrom_bits[256] =
 {
  16, 14, 14, 14, 14, 14, 14, 14,
  14, 14, 14, 14, 14, 14, 14, 14,
@@ -182,14 +188,14 @@ int rv_decode_dc(MpegEncContext *s, int n)
                if they had thought about it !!! */
             code = get_bits(&s->gb, 7);
             if (code == 0x7c) {
-                code = (INT8)(get_bits(&s->gb, 7) + 1);
+                code = (int8_t)(get_bits(&s->gb, 7) + 1);
             } else if (code == 0x7d) {
                 code = -128 + get_bits(&s->gb, 7);
             } else if (code == 0x7e) {
                 if (get_bits(&s->gb, 1) == 0)
-                    code = (INT8)(get_bits(&s->gb, 8) + 1);
+                    code = (int8_t)(get_bits(&s->gb, 8) + 1);
                 else
-                    code = (INT8)(get_bits(&s->gb, 8));
+                    code = (int8_t)(get_bits(&s->gb, 8));
             } else if (code == 0x7f) {
                 get_bits(&s->gb, 11);
                 code = 1;
@@ -203,7 +209,7 @@ int rv_decode_dc(MpegEncContext *s, int n)
         if (code < 0) {
             code = get_bits(&s->gb, 9);
             if (code == 0x1fc) {
-                code = (INT8)(get_bits(&s->gb, 7) + 1);
+                code = (int8_t)(get_bits(&s->gb, 7) + 1);
             } else if (code == 0x1fd) {
                 code = -128 + get_bits(&s->gb, 7);
             } else if (code == 0x1fe) {
@@ -220,6 +226,8 @@ int rv_decode_dc(MpegEncContext *s, int n)
     return -code;
 }
 
+#ifdef CONFIG_ENCODERS
+
 /* write RV 1.0 compatible frame header */
 void rv10_encode_picture_header(MpegEncContext *s, int picture_number)
 {
@@ -262,6 +270,8 @@ static int get_num(GetBitContext *gb)
     }
 }
 
+#endif //CONFIG_ENCODERS
+
 /* read RV 1.0 compatible frame header */
 static int rv10_decode_picture_header(MpegEncContext *s)
 {
@@ -330,7 +340,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
 static int rv10_decode_init(AVCodecContext *avctx)
 {
     MpegEncContext *s = avctx->priv_data;
-    static int done;
+    static int done=0;
 
     s->avctx= avctx;
     s->out_format = FMT_H263;
@@ -377,6 +387,8 @@ static int rv10_decode_init(AVCodecContext *avctx)
                  rv_chrom_code, 2, 2);
         done = 1;
     }
+    
+    avctx->pix_fmt = PIX_FMT_YUV420P;
 
     return 0;
 }
@@ -390,12 +402,12 @@ static int rv10_decode_end(AVCodecContext *avctx)
 }
 
 static int rv10_decode_packet(AVCodecContext *avctx, 
-                             UINT8 *buf, int buf_size)
+                             uint8_t *buf, int buf_size)
 {
     MpegEncContext *s = avctx->priv_data;
     int i, mb_count, mb_pos, left;
 
-    init_get_bits(&s->gb, buf, buf_size);
+    init_get_bits(&s->gb, buf, buf_size*8);
     
     mb_count = rv10_decode_picture_header(s);
     if (mb_count < 0) {
@@ -468,7 +480,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
 
 static int rv10_decode_frame(AVCodecContext *avctx, 
                              void *data, int *data_size,
-                             UINT8 *buf, int buf_size)
+                             uint8_t *buf, int buf_size)
 {
     MpegEncContext *s = avctx->priv_data;
     int i;