AJ_Status AJ_ASN1DecodeElement(DER_Element* der, uint8_t tag, DER_Element* out) { uint8_t tmp; AJ_InfoPrintf(("AJ_ASN1DecodeElement(der=%p, tag=%x, out=%p)\n", der, tag, out)); if ((NULL == der) || (NULL == out)) { return AJ_ERR_INVALID; } if ((NULL == der->data) || (0 == der->size)) { return AJ_ERR_INVALID; } /* * Decode tag and check it is what we expect */ tmp = *(der->data)++; der->size--; if (ASN_CONTEXT_SPECIFIC != (tmp & ASN_CONTEXT_SPECIFIC)) { tmp &= 0x1F; } if (tmp != tag) { return AJ_ERR_INVALID; } /* * Decode size */ if (AJ_OK != DecodeLength(der, out)) { return AJ_ERR_INVALID; } der->data += out->size; der->size -= out->size; return AJ_OK; }
void DecodeAPP0(void) { int length; length = DecodeLength(); if(length < 14) { if(debug>-1) fprintf(stderr,"APP0 marker too short\n"); } else { if(buf[0] == 0x4A && buf[1] == 0x46 && buf[2] == 0x49 && buf[3] == 0x46 && buf[4] == 0) { found_jfif = 1; } } SKIP(length-2); }
void DecodeAPP14(void) { int length; length = DecodeLength(); if(length < 12) { if(debug>-1) fprintf(stderr,"APP14 marker too short\n"); } else { if(buf[0] == 0x41 && buf[1] == 0x64 && buf[2] == 0x6F && buf[3] == 0x62 && buf[4] == 0x65) { found_adobe = 1; adobe_transform = buf[11]; } } SKIP(length-2); }
void DecodeSOF(void) { int length; int i; length = DecodeLength(); imgh = Decode16(buf+1); imgw = Decode16(buf+3); comp = buf[5]; if(comp*3+8 != length) { if(debug>-1) fprintf(stderr,"SOF marker length mismatch\n"); } else { for(i=0; i<__MIN(comp,4); i++) { compid[i] = *(buf+6+i*3); // -2 bytes for length field } } SKIP(length-2); }
void SkipMarker(void) { int length; length = DecodeLength(); SKIP(length-2); }