]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wnv1.c
doc/APIchanges: add hashes and version numbers for recent entries
[ffmpeg] / libavcodec / wnv1.c
index f8a9b94746a895cbba20531fbc3cadff48a2b5c9..5d6c91d2d29f753cb337b7aa92d97a7ed8472dd0 100644 (file)
@@ -24,6 +24,8 @@
  * Winnov WNV1 codec.
  */
 
+#include "libavutil/thread.h"
+
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "get_bits.h"
@@ -43,10 +45,10 @@ static inline int wnv1_get_code(GetBitContext *gb, int shift, int base_value)
 {
     int v = get_vlc2(gb, code_vlc.table, CODE_VLC_BITS, 1);
 
-    if (v == 15)
+    if (v == 8)
         return get_bits(gb, 8 - shift) << shift;
     else
-        return base_value + ((v - 7U) << shift);
+        return base_value + v * (1 << shift);
 }
 
 static int decode_frame(AVCodecContext *avctx,
@@ -112,18 +114,26 @@ static int decode_frame(AVCodecContext *avctx,
     return buf_size;
 }
 
-static av_cold int decode_init(AVCodecContext *avctx)
+static av_cold void wnv1_init_static(void)
 {
-    avctx->pix_fmt = AV_PIX_FMT_YUV422P;
-
     INIT_VLC_STATIC_FROM_LENGTHS(&code_vlc, CODE_VLC_BITS, 16,
                                  &code_tab[0][1], 2,
                                  &code_tab[0][0], 2, 1,
-                                 0, INIT_VLC_OUTPUT_LE, 1 << CODE_VLC_BITS);
+                                 -7, INIT_VLC_OUTPUT_LE, 1 << CODE_VLC_BITS);
+}
+
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+    static AVOnce init_static_once = AV_ONCE_INIT;
+
+    avctx->pix_fmt = AV_PIX_FMT_YUV422P;
+
+    ff_thread_once(&init_static_once, wnv1_init_static);
+
     return 0;
 }
 
-AVCodec ff_wnv1_decoder = {
+const AVCodec ff_wnv1_decoder = {
     .name           = "wnv1",
     .long_name      = NULL_IF_CONFIG_SMALL("Winnov WNV1"),
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -131,4 +141,5 @@ AVCodec ff_wnv1_decoder = {
     .init           = decode_init,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };