]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/loco.c
configure: Check for -no_weak_imports in ldflags on macOS
[ffmpeg] / libavcodec / loco.c
index b1ad41ae46fc3dff8fea4b159ea2f66164fb3851..fa4c5edb4097a989f781876260993f072017b427 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
 #include "golomb.h"
 #include "internal.h"
 #include "mathops.h"
@@ -45,13 +45,12 @@ enum LOCO_MODE {
 
 typedef struct LOCOContext {
     AVCodecContext *avctx;
-    AVFrame pic;
     int lossy;
     int mode;
 } LOCOContext;
 
 typedef struct RICEContext {
-    GetBitContext gb;
+    BitstreamContext bc;
     int save, run, run2; /* internal rice decoder state */
     int sum, count; /* sum and count for getting rice parameter */
     int lossy;
@@ -89,11 +88,11 @@ static inline int loco_get_rice(RICEContext *r)
         loco_update_rice_param(r, 0);
         return 0;
     }
-    v = get_ur_golomb_jpegls(&r->gb, loco_get_rice_param(r), INT_MAX, 0);
+    v = get_ur_golomb_jpegls(&r->bc, loco_get_rice_param(r), INT_MAX, 0);
     loco_update_rice_param(r, (v + 1) >> 1);
     if (!v) {
         if (r->save >= 0) {
-            r->run = get_ur_golomb_jpegls(&r->gb, 2, INT_MAX, 0);
+            r->run = get_ur_golomb_jpegls(&r->bc, 2, INT_MAX, 0);
             if (r->run > 1)
                 r->save += r->run + 1;
             else
@@ -133,7 +132,7 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
     int val;
     int i, j;
 
-    init_get_bits(&rc.gb, buf, buf_size*8);
+    bitstream_init8(&rc.bc, buf, buf_size);
     rc.save  = 0;
     rc.run   = 0;
     rc.run2  = 0;
@@ -163,7 +162,7 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
         data += stride;
     }
 
-    return (get_bits_count(&rc.gb) + 7) >> 3;
+    return (bitstream_tell(&rc.bc) + 7) >> 3;
 }
 
 static int decode_frame(AVCodecContext *avctx,
@@ -173,14 +172,10 @@ static int decode_frame(AVCodecContext *avctx,
     LOCOContext * const l = avctx->priv_data;
     const uint8_t *buf    = avpkt->data;
     int buf_size          = avpkt->size;
-    AVFrame * const p     = &l->pic;
+    AVFrame * const p     = data;
     int decoded, ret;
 
-    if (p->data[0])
-        avctx->release_buffer(avctx, p);
-
-    p->reference = 0;
-    if ((ret = ff_get_buffer(avctx, p)) < 0) {
+    if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
     }
@@ -260,7 +255,6 @@ static int decode_frame(AVCodecContext *avctx,
     }
 
     *got_frame      = 1;
-    *(AVFrame*)data = l->pic;
 
     return buf_size;
 buf_too_small:
@@ -289,7 +283,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         break;
     default:
         l->lossy = AV_RL32(avctx->extradata + 8);
-        av_log_ask_for_sample(avctx, "This is LOCO codec version %i.\n", version);
+        avpriv_request_sample(avctx, "LOCO codec version %i", version);
     }
 
     l->mode = AV_RL32(avctx->extradata + 4);
@@ -321,25 +315,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
     return 0;
 }
 
-static av_cold int decode_end(AVCodecContext *avctx)
-{
-    LOCOContext * const l = avctx->priv_data;
-    AVFrame *pic = &l->pic;
-
-    if (pic->data[0])
-        avctx->release_buffer(avctx, pic);
-
-    return 0;
-}
-
 AVCodec ff_loco_decoder = {
     .name           = "loco",
+    .long_name      = NULL_IF_CONFIG_SMALL("LOCO"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_LOCO,
     .priv_data_size = sizeof(LOCOContext),
     .init           = decode_init,
-    .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
-    .long_name      = NULL_IF_CONFIG_SMALL("LOCO"),
+    .capabilities   = AV_CODEC_CAP_DR1,
 };