]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/photocd.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / photocd.c
index 057c9d33d41029c8368ec3de31388a597cf3a875..f95d5a8eb87a809761141b0bf3a0ae55cc443c08 100644 (file)
@@ -245,21 +245,20 @@ static av_noinline int decode_huff(AVCodecContext *avctx, AVFrame *frame,
         int x2, idx;
 
         for (; get_bits_left(&g) > 0;) {
-            if ((show_bits(&g, 24) & 0xfff000) == 0xfff000)
+            if (show_bits(&g, 12) == 0xfff)
                 break;
             skip_bits(&g, 8);
         }
 
-        shiftreg = show_bits_long(&g, 32) & 0xffffff00;
-        while (shiftreg != 0xfffffe00) {
+        shiftreg = show_bits(&g, 24);
+        while (shiftreg != 0xfffffe) {
             if (get_bits_left(&g) <= 0)
                 return AVERROR_INVALIDDATA;
             skip_bits(&g, 1);
-            shiftreg = show_bits_long(&g, 32) & 0xffffff00;
+            shiftreg = show_bits(&g, 24);
         }
-        skip_bits(&g, 16);
-        y = show_bits_long(&g, 23) & 0x1fff;
-        skip_bits(&g, 8);
+        skip_bits(&g, 24);
+        y = show_bits(&g, 15) & 0x1fff;
         if (y >= height)
             break;
         type = get_bits(&g, 2);
@@ -324,8 +323,9 @@ static int photocd_decode_frame(AVCodecContext *avctx, void *data,
     else
         s->resolution = av_clip(4 - s->lowres, 0, 4);
 
-    avctx->width  = img_info[s->resolution].width;
-    avctx->height = img_info[s->resolution].height;
+    ret = ff_set_dimensions(avctx, img_info[s->resolution].width, img_info[s->resolution].height);
+    if (ret < 0)
+        return ret;
 
     if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
         return ret;
@@ -458,7 +458,7 @@ static const AVClass photocd_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-AVCodec ff_photocd_decoder = {
+const AVCodec ff_photocd_decoder = {
     .name           = "photocd",
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_PHOTOCD,
@@ -469,4 +469,5 @@ AVCodec ff_photocd_decoder = {
     .decode         = photocd_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
     .long_name      = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };