Commit Diff


commit - d1b596e5014a1ae0e44bc04cf4baf5f84f69835a
commit + ac2e67265001b27ade2035feddc53b6c0b89e352
blob - 0cd209a838eff40e6c46ca4012ed4351a738fb87
blob + db7a49d32b775c302e42689af78470d0171de2d4
--- pdf.c
+++ pdf.c
@@ -915,11 +915,12 @@ init_dct_parser(struct Env *aux)
 
 	H_RULE(sof0_marker, h_ch('\xC0'));
 	/* Bits per sample */
+	H_ARULE(sof0_headerlength, h_uint16()); // 8 + 3* numcomponents
 	H_RULE(sof0_bps, h_uint8());
 	H_RULE(sof0_imgheight, h_uint16());
 	H_RULE(sof0_imgwidth, h_uint16());
 	H_RULE(sof0_numcomponents, h_uint8()); // XXX multiply by 3 in action
-	H_RULE(sof0_componentid, h_uint8()); // enum: y cb cr i q
+	H_ARULE(sof0_componentid, h_uint8()); // enum: y cb cr i q
 	H_RULE(sof0_samplingfactors, h_uint8());
 	/* Quantization table ID */
 	H_RULE(sof0_qtableid, h_uint8());
@@ -928,7 +929,7 @@ init_dct_parser(struct Env *aux)
 	/* Rule for the component itself */
 	H_RULE(sof0_component_lv, h_length_value(sof0_numcomponents, sof0_component));
 
-	H_RULE(sof0, SEQ(jpgmagic, sof0_marker, sof0_bps, sof0_imgheight, sof0_imgwidth, sof0_component_lv));
+	H_RULE(sof0, SEQ(jpgmagic, sof0_marker, sof0_headerlength, sof0_bps, sof0_imgheight, sof0_imgwidth, sof0_component_lv));
 
 	H_RULE(soi_marker, h_ch('\xD8'));
 	H_RULE(soi, SEQ(jpgmagic, soi_marker));