]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/photocd.c
avfilter/avfilter: Remove compatibility code for old filter options
[ffmpeg] / libavcodec / photocd.c
index 6f8426b5d250f1b7773efbd8805428f1ef3f45e6..408ddeaac8561e2bb47fb1e0e8f11873b2ed0d89 100644 (file)
@@ -227,9 +227,9 @@ static av_noinline int decode_huff(AVCodecContext *avctx, AVFrame *frame,
     PhotoCDContext *s = avctx->priv_data;
     GetBitContext g;
     GetByteContext *gb = &s->gb;
-    int ret, y = 0, type, height, y2;
+    int ret, y = 0, type, height;
     int start = s->streampos;
-    unsigned shiftreg, bit;
+    unsigned shiftreg;
     const int scaling = target_res - curr_res;
     const uint8_t type2idx[] = { 0, 0xff, 1, 2 };
 
@@ -239,29 +239,26 @@ static av_noinline int decode_huff(AVCodecContext *avctx, AVFrame *frame,
         return ret;
 
     height = img_info[curr_res].height;
-    y2 = avctx->height >> scaling;
 
     while (y < height) {
         uint8_t *data;
         int x2, idx;
 
-        bit = 0;
         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);
@@ -326,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;
@@ -471,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,
 };