An encoding method and apparatus, a decoding method and apparatus, a device, and a storage medium, related to the field of encoding and decoding technologies. In the encoding method, a data set is obtained, where the data set includes N pieces of data, and N is greater than or equal to 2. If an occurrence frequency of first data of the N pieces of data in the N pieces of data is greater than or equal to a reference threshold, run-length encoding is performed on the first data. The reference threshold is determined based on N, a quantity of bit occupied by a first element, and a quantity of bit occupied by a second element, the first element is determined based on the first data, and the second element is a consecutive occurrence count of the first data.
Full Text
What is claimed is: