summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Heron <phil@sanslogic.co.uk>2011-06-24 21:00:05 +0100
committerPhilip Heron <phil@sanslogic.co.uk>2011-06-24 21:00:05 +0100
commitad3f14c3c08f6b1f0dddb955f1f34a4e217ad811 (patch)
treea4cb50513ce70efb159b8471334b57fe209cfa4d
parentbe051b1ae2b2e9dd0063e00877fcaca7896a575f (diff)
Be strict with the component sampling factors
-rw-r--r--ssdv.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ssdv.c b/ssdv.c
index 56a2309..38f18ff 100644
--- a/ssdv.c
+++ b/ssdv.c
@@ -549,6 +549,18 @@ static char ssdv_have_marker_data(ssdv_t *s)
}
fprintf(stderr, "DQT table for component %i: %02X, Sampling factor: %ix%i\n", dq[0], dq[2], dq[1] & 0x0F, dq[1] >> 4);
+
+ /* The first component must have a factor of 2x2 and the rest 1x1 */
+ if(dq[0] == 1 && dq[1] != 0x22)
+ {
+ fprintf(stderr, "Error: Component 1 sampling factor must be 2x2\n");
+ return(SSDV_ERROR);
+ }
+ else if(dq[0] != 1 && dq[1] != 0x11)
+ {
+ fprintf(stderr, "Error: Component %i sampling factor must be 1x1\n", dq[0]);
+ return(SSDV_ERROR);
+ }
}
break;