now handles arbitrary frame paddings.