/* Write a special marker. This is only recommended for writing COM or APPn markers. Must be called after jpeg_start_compress() and before first call to jpeg_write_scanlines() or jpeg_write_raw_data().  */
jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen)
/* Write a special marker. This is only recommended for writing COM or APPn markers. Must be called after jpeg_start_compress() and before first call to jpeg_write_scanlines() or jpeg_write_raw_data().  */
jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen)
{
    JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val));
    if (cinfo->next_scanline != 0 ||
        (cinfo->global_state != CSTATE_SCANNING &&
            cinfo->global_state != CSTATE_RAW_OK &&
            cinfo->global_state != CSTATE_WRCOEFS))
        ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
    (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
    write_marker_byte = cinfo->marker->write_marker_byte;
    while (datalen--) {
        (*write_marker_byte) (cinfo, *dataptr);
        dataptr++;
    }
}