The image quality value of the code block currently processed is monitored, and when it falls below a threshold, encoding of the code block is terminated (in other words, encoding in the subsequent passes is omitted for the code block) to shift to encoding of the next code block.