]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/snowdec.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / snowdec.c
index 88664dc472bd2a6afda196fca07f9f702b5561b4..7367176f07bbb9b39731acaaccb2a3a56e7be4d9 100644 (file)
@@ -369,7 +369,10 @@ static int decode_header(SnowContext *s){
                 htaps = htaps*2 + 2;
                 p->htaps= htaps;
                 for(i= htaps/2; i; i--){
-                    p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));
+                    unsigned hcoeff = get_symbol(&s->c, s->header_state, 0);
+                    if (hcoeff > 127)
+                        return AVERROR_INVALIDDATA;
+                    p->hcoeff[i]= hcoeff * (1-2*(i&1));
                     sum += p->hcoeff[i];
                 }
                 p->hcoeff[0]= 32-sum;
@@ -419,17 +422,6 @@ static int decode_header(SnowContext *s){
     return 0;
 }
 
-static av_cold int decode_init(AVCodecContext *avctx)
-{
-    int ret;
-
-    if ((ret = ff_snow_common_init(avctx)) < 0) {
-        return ret;
-    }
-
-    return 0;
-}
-
 static int decode_blocks(SnowContext *s){
     int x, y;
     int w= s->b_width;
@@ -656,13 +648,13 @@ static av_cold int decode_end(AVCodecContext *avctx)
     return 0;
 }
 
-AVCodec ff_snow_decoder = {
+const AVCodec ff_snow_decoder = {
     .name           = "snow",
     .long_name      = NULL_IF_CONFIG_SMALL("Snow"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_SNOW,
     .priv_data_size = sizeof(SnowContext),
-    .init           = decode_init,
+    .init           = ff_snow_common_init,
     .close          = decode_end,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/,