]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/svq3.c
fix linking on systems with a function name prefix (10l in r20287)
[ffmpeg] / libavcodec / svq3.c
index a2f533c01ff238bc7bf487053f971c4b52eb48de..9598a14db41dd63944b5af7fb0fbc279d3a5d282 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The FFmpeg Project.
+ * Copyright (c) 2003 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
  *
  * You will know you have these parameters passed correctly when the decoder
  * correctly decodes this file:
- *  ftp://ftp.mplayerhq.hu/MPlayer/samples/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov
+ *  http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov
  */
 
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
 #include <zlib.h>
 #endif
 
 #include "svq1.h"
 
 /**
- * @file svq3.c
+ * @file libavcodec/svq3.c
  * svq3 decoder.
  */
 
@@ -681,6 +681,7 @@ static int svq3_decode_mb(H264Context *h, unsigned int mb_type)
         }
     }
 
+    h->cbp= cbp;
     s->current_picture.mb_type[mb_xy] = mb_type;
 
     if (IS_INTRA(mb_type)) {
@@ -723,6 +724,7 @@ static int svq3_decode_slice_header(H264Context *h)
             memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3],
                    &s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1));
         }
+        skip_bits_long(&s->gb, 0);
     }
 
     if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3){
@@ -774,19 +776,26 @@ static int svq3_decode_slice_header(H264Context *h)
     return 0;
 }
 
-static int svq3_decode_frame(AVCodecContext *avctx,
-                             void *data, int *data_size,
-                             const uint8_t *buf, int buf_size)
+static av_cold int svq3_decode_init(AVCodecContext *avctx)
 {
     MpegEncContext *const s = avctx->priv_data;
     H264Context *const h = avctx->priv_data;
-    int m, mb_type;
+    int m;
     unsigned char *extradata;
     unsigned int size;
 
+    if(avctx->thread_count > 1){
+        av_log(avctx, AV_LOG_ERROR, "SVQ3 does not support multithreaded decoding, patch welcome! (check latest SVN too)\n");
+        return -1;
+    }
+
+    if (decode_init(avctx) < 0)
+        return -1;
+
     s->flags  = avctx->flags;
     s->flags2 = avctx->flags2;
     s->unrestricted_mv = 1;
+    h->is_complex=1;
 
     if (!s->context_initialized) {
         s->width  = avctx->width;
@@ -815,14 +824,25 @@ static int svq3_decode_frame(AVCodecContext *avctx,
         if (extradata && !memcmp(extradata, "SEQH", 4)) {
 
             GetBitContext gb;
+            int frame_size_code;
 
             size = AV_RB32(&extradata[4]);
             init_get_bits(&gb, extradata + 8, size*8);
 
             /* 'frame size code' and optional 'width, height' */
-            if (get_bits(&gb, 3) == 7) {
-                skip_bits(&gb, 12);
-                skip_bits(&gb, 12);
+            frame_size_code = get_bits(&gb, 3);
+            switch (frame_size_code) {
+                case 0: avctx->width = 160; avctx->height = 120; break;
+                case 1: avctx->width = 128; avctx->height =  96; break;
+                case 2: avctx->width = 176; avctx->height = 144; break;
+                case 3: avctx->width = 352; avctx->height = 288; break;
+                case 4: avctx->width = 704; avctx->height = 576; break;
+                case 5: avctx->width = 240; avctx->height = 180; break;
+                case 6: avctx->width = 320; avctx->height = 240; break;
+                case 7:
+                    avctx->width  = get_bits(&gb, 12);
+                    avctx->height = get_bits(&gb, 12);
+                    break;
             }
 
             h->halfpel_flag  = get_bits1(&gb);
@@ -846,7 +866,7 @@ static int svq3_decode_frame(AVCodecContext *avctx,
             h->unknown_svq3_flag = get_bits1(&gb);
             avctx->has_b_frames = !s->low_delay;
             if (h->unknown_svq3_flag) {
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
                 unsigned watermark_width  = svq3_get_ue_golomb(&gb);
                 unsigned watermark_height = svq3_get_ue_golomb(&gb);
                 int u1 = svq3_get_ue_golomb(&gb);
@@ -880,6 +900,19 @@ static int svq3_decode_frame(AVCodecContext *avctx,
         }
     }
 
+    return 0;
+}
+
+static int svq3_decode_frame(AVCodecContext *avctx,
+                             void *data, int *data_size,
+                             AVPacket *avpkt)
+{
+    const uint8_t *buf = avpkt->data;
+    int buf_size = avpkt->size;
+    MpegEncContext *const s = avctx->priv_data;
+    H264Context *const h = avctx->priv_data;
+    int m, mb_type;
+
     /* special case for last picture */
     if (buf_size == 0) {
         if (s->next_picture_ptr && !s->low_delay) {
@@ -1014,8 +1047,6 @@ static int svq3_decode_frame(AVCodecContext *avctx,
         *(AVFrame *) data = *(AVFrame *) &s->last_picture;
     }
 
-    avctx->frame_number = s->picture_number - 1;
-
     /* Do not output the last pic after seeking. */
     if (s->last_picture_ptr || s->low_delay) {
         *data_size = sizeof(AVFrame);
@@ -1030,10 +1061,11 @@ AVCodec svq3_decoder = {
     CODEC_TYPE_VIDEO,
     CODEC_ID_SVQ3,
     sizeof(H264Context),
-    decode_init,
+    svq3_decode_init,
     NULL,
     decode_end,
     svq3_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_DELAY,
     .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3"),
+    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUVJ420P, PIX_FMT_NONE},
 };