[media] pwc: Avoid unnecessarily rebuilding the decoder tables
authorHans de Goede <hdegoede@redhat.com>
Tue, 10 Jan 2012 16:23:34 +0000 (13:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 16 Jan 2012 13:09:20 +0000 (11:09 -0200)
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/pwc/pwc-dec23.c
drivers/media/video/pwc/pwc-dec23.h

index 6d48c1f9068393ad8a32e4eff9a52335c862b578..98772efc5bdefbf0467e673c75ac374bdc179003 100644 (file)
@@ -301,6 +301,9 @@ void pwc_dec23_init(struct pwc_device *pdev, unsigned char *cmd)
 
        mutex_init(&pdec->lock);
 
+       if (pdec->last_cmd_valid && pdec->last_cmd == cmd[2])
+               return;
+
        if (DEVICE_USE_CODEC3(pdev->type)) {
                flags = cmd[2] & 0x18;
                if (flags == 8)
@@ -347,6 +350,9 @@ void pwc_dec23_init(struct pwc_device *pdev, unsigned char *cmd)
        for (i=0; i<MAX_OUTER_CROP_VALUE; i++)
                pwc_crop_table[MAX_OUTER_CROP_VALUE+256+i] = 255;
 #endif
+
+       pdec->last_cmd = cmd[2];
+       pdec->last_cmd_valid = 1;
 }
 
 /*
index a29068ee428b536d8e2770c27e908bbc48c4c396..af31d6047bb200e3e24e9a30bbce717ea6dfa8b0 100644 (file)
@@ -31,11 +31,14 @@ struct pwc_dec23_private
 {
        struct mutex lock;
 
+       unsigned char last_cmd, last_cmd_valid;
+
   unsigned int scalebits;
   unsigned int nbitsmask, nbits; /* Number of bits of a color in the compressed stream */
 
   unsigned int reservoir;
   unsigned int nbits_in_reservoir;
+
   const unsigned char *stream;
   int temp_colors[16];