]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pictordec.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / pictordec.c
index af99c486b8e42b0c7f490d6360329df33a61a029..c37c5e7106d5082f83c154d6011d337d7437d918 100644 (file)
@@ -66,15 +66,16 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
     int xl = *x;
     int yl = *y;
     int planel = *plane;
+    int pixels_per_value = 8/bits_per_plane;
     value   <<= shift;
 
+    d = frame->data[0] + yl * frame->linesize[0];
     while (run > 0) {
         int j;
         for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) {
-            d = frame->data[0] + yl * frame->linesize[0];
             d[xl] |= (value >> j) & mask;
             xl += 1;
-            if (xl == s->width) {
+            while (xl == s->width) {
                 yl -= 1;
                 xl = 0;
                 if (yl < 0) {
@@ -85,6 +86,20 @@ static void picmemset(PicContext *s, AVFrame *frame, unsigned value, int run,
                    value <<= bits_per_plane;
                    mask  <<= bits_per_plane;
                 }
+                d = frame->data[0] + yl * frame->linesize[0];
+                if (s->nb_planes == 1 &&
+                    run*pixels_per_value >= s->width &&
+                    pixels_per_value < s->width &&
+                    s->width % pixels_per_value == 0
+                    ) {
+                    for (; xl < pixels_per_value; xl ++) {
+                        j = (j < bits_per_plane ? 8 : j) - bits_per_plane;
+                        d[xl] |= (value >> j) & mask;
+                    }
+                    av_memcpy_backptr(d+xl, pixels_per_value, s->width - xl);
+                    run -= s->width / pixels_per_value;
+                    xl = s->width;
+                }
             }
         }
         run--;
@@ -266,7 +281,7 @@ finish:
     return avpkt->size;
 }
 
-AVCodec ff_pictor_decoder = {
+const AVCodec ff_pictor_decoder = {
     .name           = "pictor",
     .long_name      = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"),
     .type           = AVMEDIA_TYPE_VIDEO,