1. An image encoding apparatus that divides images composing a moving image into multiple areas to perform encoding for divided areas, and performs hierarchical encoding of images with a plurality of layers, the image encoding apparatus comprising: a generating unit configured to generate a second image for a second layer different from a first layer, the second image having a resolution different from that of a first image for the first layer; an encoding unit configured to encode at least one of a part of the first image and a part of the second image; and a setting unit configured to set a first independent area in the first image and a second independent area in the second image, wherein the encoding unit is capable of encoding the first independent area and the second independent area, in accordance with constraint, wherein the encoding unit is capable of encoding the first independent area by referring to a first reference area in the first image, in accordance with the constraint that the first reference area is constrained to the first independent area thereof, wherein the encoding unit is capable of encoding the second independent area by referring to a second reference area in the second image, in accordance with the constraint that the second reference area is constrained to the second independent area thereof, wherein the encoding unit is capable of encoding the first independent area by referring to the second reference area in the second image, in accordance with the constraint that the second reference area is constrained to the second independent area, and wherein the encoding unit is configured to encode information indicating the constraint.