A moving picture coding device for encoding moving picture data comprising: an image input unit for dividing an image frame to be subjected to prediction coding into macroblocks; an image encoding unit (120,104,105) for performing prediction coding by obtaining a difference between each macroblock and a reference image; a local decode generation unit for generating the reference image based on an encoding result of the macroblock; a compression unit for losslessly compressing the reference image to generate compressed data per macroblock; an allowable data amount setting unit for setting in advance an allowable data amount of compressed data stored in a memory for each of a plurality of macroblock lines forming the image frame; and a reference image storage determination unit for determining whether or not to store the compressed data per macroblock in the memory; a memory control unit; and an inter-prediction unit for performing motion vector search for inter-coding based on the reference image stored in the memory, wherein the reference image storage determination unit is configured to: receive the compressed data for a macroblock from the compression unit, determine whether or not to store the received compressed data for said macroblock in the memory based on a comparison result of the allowable data amount with a total data amount that will be stored for the corresponding macroblock line when the compressed data for said macroblock is stored in the memory, and request, when it is determined that the allowable data amount is equal to or greater than the total data amount that will be stored, the memory control unit to write the received compressed data per macroblock to the memory, wherein when the reference image storage determination unit determines that the allowable data amount is smaller than the total data amount that will be stored, the compressed data for said macroblock and subsequent macroblocks, if any, with respect to the corresponding macroblock line are not stored in the memory, and wherein the inter-prediction unit is configured to search for the reference image corresponding to the compressed data stored in the memory as a search range of motion vector search. an image input unit for dividing an image frame to be subjected to prediction coding into macroblocks; an image encoding unit (120,104,105) for performing prediction coding by obtaining a difference between each macroblock and a reference image; a local decode generation unit for generating the reference image based on an encoding result of the macroblock; a compression unit for losslessly compressing the reference image to generate compressed data per macroblock; an allowable data amount setting unit for setting in advance an allowable data amount of compressed data stored in a memory for each of a plurality of macroblock lines forming the image frame; and a reference image storage determination unit for determining whether or not to store the compressed data per macroblock in the memory; a memory control unit; and an inter-prediction unit for performing motion vector search for inter-coding based on the reference image stored in the memory, wherein the reference image storage determination unit is configured to: receive the compressed data for a macroblock from the compression unit, determine whether or not to store the received compressed data for said macroblock in the memory based on a comparison result of the allowable data amount with a total data amount that will be stored for the corresponding macroblock line when the compressed data for said macroblock is stored in the memory, and request, when it is determined that the allowable data amount is equal to or greater than the total data amount that will be stored, the memory control unit to write the received compressed data per macroblock to the memory, wherein when the reference image storage determination unit determines that the allowable data amount is smaller than the total data amount that will be stored, the compressed data for said macroblock and subsequent macroblocks, if any, with respect to the corresponding macroblock line are not stored in the memory, and wherein the inter-prediction unit is configured to search for the reference image corresponding to the compressed data stored in the memory as a search range of motion vector search. receive the compressed data for a macroblock from the compression unit, determine whether or not to store the received compressed data for said macroblock in the memory based on a comparison result of the allowable data amount with a total data amount that will be stored for the corresponding macroblock line when the compressed data for said macroblock is stored in the memory, and request, when it is determined that the allowable data amount is equal to or greater than the total data amount that will be stored, the memory control unit to write the received compressed data per macroblock to the memory, wherein when the reference image storage determination unit determines that the allowable data amount is smaller than the total data amount that will be stored, the compressed data for said macroblock and subsequent macroblocks, if any, with respect to the corresponding macroblock line are not stored in the memory, and wherein the inter-prediction unit is configured to search for the reference image corresponding to the compressed data stored in the memory as a search range of motion vector search.