media coverage is parsed like this:

void initialize_media_coverage_region(
        short *media_coverage_region,
        int media_coverage_region_size)
{
    int mesh_texture_height= mesh_height*SUBMESH_CELL_TEXTURE_WIDTH;
    int mesh_texture_width= mesh_width*SUBMESH_CELL_TEXTURE_WIDTH;
    
    int region_index= 0;

    assert(!media_coverage_row_addresses);
    media_coverage_row_addresses= malloc(mesh_texture_height*sizeof(short *));
    if (media_coverage_row_addresses)
    {
        int y;
        
        for (y= 0; y<mesh_texture_height; ++y)
        {
            int x, last_x;
            
            media_coverage_row_addresses[y]= media_coverage_region + region_index;
            
            last_x= -1;
            do
            {
                assert(region_index*sizeof(short)<media_coverage_region_size);
                x= media_coverage_region[region_index++];
                
                vassert(x>last_x && x<=mesh_texture_width,
                        csprintf(temporary, "media region y==#%d @%p has x-coordinate #%d 
							not in (#%d,#%d]", y, media_coverage_row_addresses[y], x, last_x, mesh_texture_width));
                    last_x= x;
            }
            while (x<mesh_texture_width);
        }
        
        assert(region_index*sizeof(short)==media_coverage_region_size);
    }
    else
    {
        error_message(_error_out_of_memory, -1, "couldn't allocate #%d bytes 
			for media coverage row addresses", mesh_texture_height*sizeof(short *));
    }
    
    return;
}

and used like this:

boolean mesh_texture_pixel_is_media(
        int x,
        int y)
{
        boolean media= FALSE;

        assert(media_coverage_row_addresses);
        vassert(x>=0 && y>=0 && x<mesh_width*SUBMESH_CELL_TEXTURE_WIDTH && 
y<mesh_height*SUBMESH_CELL_TEXTURE_WIDTH,
                csprintf(temporary, "mesh texture pixel (#%d,#%d) not in (#%d,#%d)", x, 
y,
                        mesh_width*SUBMESH_CELL_TEXTURE_WIDTH, 
mesh_height*SUBMESH_CELL_TEXTURE_WIDTH));
        
        {
                short *media_coverage= media_coverage_row_addresses[y];
                
                while (*media_coverage<x) media= !media, media_coverage+= 1;
        }