function [ frame_out ] = decode_I_frame( frame_encoded, MB_size, B_size, Q, deblocking  )
enc_luma = frame_encoded.encoded_luma;
enc_chroma = frame_encoded.encoded_chroma;

Nmb = size(enc_luma)/MB_size;

Y_mb = mat2cell(enc_luma, repmat(MB_size,1,Nmb(1)), repmat(MB_size,1,Nmb(2)));
Y_decoded = cell(size(Y_mb));

chroma_mb = mat2cell(enc_chroma, repmat(MB_size/2,1,Nmb(1)), repmat(MB_size/2,1,Nmb(2)),2);
chroma_decoded = cell(size(chroma_mb));

for n = 1 : Nmb(1)
    for m = 1 : Nmb(2)
        Y_decoded{n,m} = inverse_quantize( Y_mb{n,m}, MB_size, B_size, Q );
        chroma_decoded{n,m} = inverse_quantize( chroma_mb{n,m}, MB_size, B_size, Q );
        if (deblocking)
            if (n>1)&&(m>1)
                [Y_decoded{n,m},Y_decoded{n,m-1},Y_decoded{n-1,m} ]= ...
                    deblocking_filter( Y_decoded{n,m}, B_size, Y_decoded{n,m-1}, Y_decoded{n-1, m} );
                [chroma_decoded{n,m},chroma_decoded{n,m-1},chroma_decoded{n-1,m} ]= ...
                    deblocking_filter( chroma_decoded{n,m}, B_size, chroma_decoded{n,m-1}, chroma_decoded{n-1, m} );
            else
            end
        end
    end
end
Y_decoded = cell2mat(Y_decoded);
chroma_decoded = cell2mat(chroma_decoded);

frame_out = YCbCr_to_RGB( Y_decoded, chroma_decoded );


end

