Pixel value mapping method
Embodiments of the present disclosure provide a pixel value mapping method, including: determining a to-be-processed image and a mapping table corresponding to the to-be-processed image; performing a table lookup on pixel values of multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain mapped values each corresponding to a pixel of the multiple pixels; and determining a mapped image corresponding to the to-be-processed image according to the mapped values obtained based on the table lookup.
1 . A method for encoding a video sequence, the method comprising:
receiving a video sequence; and
encoding the video sequence by:
determining a to-be-processed image and a mapping table corresponding to the to-be-processed image;
performing a table lookup on pixel values of multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain mapped values each corresponding to a pixel of the multiple pixels; and
determining a mapped image corresponding to the to-be-processed image according to the mapped values obtained based on the table lookup;
comparing the pixel values of the multiple pixels to determine a maximum pixel value and a minimum pixel value; wherein performing the table lookup on the pixel values of the multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
determining a first sub-table of a pixel value range corresponding to the maximum pixel value and the minimum pixel value from the mapping table; and
performing the table lookup on the pixel values of the multiple pixels according to the first sub-table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels.
2 . The method according to claim 1 , wherein the number of the multiple pixels is m times of a degree of parallelism of the table lookup, m being a positive integer, and performing the table lookup on the pixel values of the multiple pixels according to the first sub-table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
dividing the pixel values of the multiple pixels into m groups of to-be-queried pixel values according to the degree of parallelism; and
performing a NEON-based parallel table lookup on the to-be-queried pixel values according to the first sub-table by groups to obtain the mapped values each corresponding to a pixel of the multiple pixels.
3 . The method according to claim 2 , wherein performing the NEON-based parallel table lookup on the to-be-queried pixel values according to the first sub-table by groups to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
segmenting the first sub-table to obtain multiple second sub-tables;
performing the NEON-based parallel table lookup on the to-be-queried pixel values according to the multiple second sub-tables by groups to obtain multiple sets of query results corresponding to respective groups of the to-be-queried pixel values; and
merging the multiple sets of query results to obtain respective mapped values corresponding to respective groups of the to-be-queried pixel values.
4 . The method according to claim 1 , wherein comparing the pixel values of the multiple pixels to determine the maximum pixel value and the minimum pixel value comprises:
initializing a maximum value register and a minimum value register, where the number of pixel values stored in the maximum value register or the minimum value register is i, and the number of the multiple pixels is n times the number of the pixel values i, n being a positive integer;
dividing the pixel values of the multiple pixels into n groups of to-be-compared pixel values, where each group of the to-be-compared pixel values comprises i pixel values;
comparing each group of the to-be-compared pixel values with the pixel values stored in the maximum value register bit by bit, and updating the i pixel values stored in the maximum value register according to the maximum value in the comparison result;
comparing each group of the to-be-compared pixel values with the pixel values stored in the minimum value register bit by bit, and updating the i pixel values stored in the minimum value register according to the minimum value in the comparison result; and
determining the maximum pixel value from the i pixel values stored in the maximum value register, and determining the minimum pixel value from the i pixel values stored in the minimum value register.
5 . The method according to claim 1 , wherein determining the first sub-table of the pixel value range corresponding to the maximum pixel value and the minimum pixel value from the mapping table comprises:
determining the number of pixel values of the first sub-table according to a difference between the maximum pixel value and the minimum pixel value; and
determining the first sub-table from the mapping table according to the number of pixel values starting from the minimum pixel value.
6 . The method according to claim 1 , wherein performing the table lookup on the pixel values of the multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
segmenting the mapping table to obtain multiple third sub-tables;
performing parallel table lookups on the pixel values of the multiple pixels in the multiple third sub-tables respectively to obtain multiple sets of query results; and
merging the multiple sets of query results to obtain respective mapped values each corresponding to a pixel of the multiple pixels.
7 . The method according to claim 1 , further comprising:
storing a bitstream that is generated based on the encoding.
8 . A method for decoding a bitstream, the method comprising:
receiving a bitstream; and
decoding the bitstream to generate a video sequence, the decoding comprising:
determining a to-be-processed image and a mapping table corresponding to the to-be-processed image;
performing a table lookup on pixel values of multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain mapped values each corresponding to a pixel of the multiple pixels; and
determining a mapped image corresponding to the to-be-processed image according to the mapped values obtained based on the table lookup;
comparing the pixel values of the multiple pixels to determine a maximum pixel value and a minimum pixel value; wherein performing the table lookup on the pixel values of the multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
determining a first sub-table of a pixel value range corresponding to the maximum pixel value and the minimum pixel value from the mapping table; and
performing the table lookup on the pixel values of the multiple pixels according to the first sub-table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels.
9 . The method according to claim 8 , wherein the number of the multiple pixels is m times of a degree of parallelism of the table lookup, m being a positive integer, and performing the table lookup on the pixel values of the multiple pixels according to the first sub-table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
dividing the pixel values of the multiple pixels into m groups of to-be-queried pixel values according to the degree of parallelism; and
performing a NEON-based parallel table lookup on the to-be-queried pixel values according to the first sub-table by groups to obtain the mapped values each corresponding to a pixel of the multiple pixels.
10 . The method according to claim 9 , wherein performing the NEON-based parallel table lookup on the to-be-queried pixel values according to the first sub-table by groups to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
segmenting the first sub-table to obtain multiple second sub-tables;
performing the NEON-based parallel table lookup on the to-be-queried pixel values according to the multiple second sub-tables by groups to obtain multiple sets of query results corresponding to respective groups of the to-be-queried pixel values; and
merging the multiple sets of query results to obtain respective mapped values corresponding to respective groups of the to-be-queried pixel values.
11 . The method according to claim 8 , wherein comparing the pixel values of the multiple pixels to determine the maximum pixel value and the minimum pixel value comprises:
initializing a maximum value register and a minimum value register, where the number of pixel values stored in the maximum value register or the minimum value register is i, and the number of the multiple pixels is n times the number of the pixel values i, n being a positive integer;
dividing the pixel values of the multiple pixels into n groups of to-be-compared pixel values, where each group of the to-be-compared pixel values comprises i pixel values;
comparing each group of the to-be-compared pixel values with the pixel values stored in the maximum value register bit by bit, and updating the i pixel values stored in the maximum value register according to the maximum value in the comparison result;
comparing each group of the to-be-compared pixel values with the pixel values stored in the minimum value register bit by bit, and updating the i pixel values stored in the minimum value register according to the minimum value in the comparison result; and
determining the maximum pixel value from the i pixel values stored in the maximum value register, and determining the minimum pixel value from the i pixel values stored in the minimum value register.
12 . The method according to claim 8 , wherein determining the first sub-table of the pixel value range corresponding to the maximum pixel value and the minimum pixel value from the mapping table comprises:
determining the number of pixel values of the first sub-table according to a difference between the maximum pixel value and the minimum pixel value; and
determining the first sub-table from the mapping table according to the number of pixel values starting from the minimum pixel value.
13 . The method according to claim 8 , wherein performing the table lookup on the pixel values of the multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
segmenting the mapping table to obtain multiple third sub-tables;
performing parallel table lookups on the pixel values of the multiple pixels in the multiple third sub-tables respectively to obtain multiple sets of query results; and
merging the multiple sets of query results to obtain respective mapped values each corresponding to a pixel of the multiple pixels.
14 . A method for signaling a bitstream, the method comprising:
receiving a video sequence;
encoding the video sequence by:
determining a to-be-processed image and a mapping table corresponding to the to-be-processed image;
performing a table lookup on pixel values of multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain mapped values each corresponding to a pixel of the multiple pixels; and
determining a mapped image corresponding to the to-be-processed image according to the mapped values obtained based on the table lookup;
comparing the pixel values of the multiple pixels to determine a maximum pixel value and a minimum pixel value; wherein performing the table lookup on the pixel values of the multiple pixels in the to-be-processed image according to the mapping table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
determining a first sub-table of a pixel value range corresponding to the maximum pixel value and the minimum pixel value from the mapping table; and
performing the table lookup on the pixel values of the multiple pixels according to the first sub-table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels; and
signaling a bitstream that is generated based on the encoding.
15 . The method according to claim 14 , wherein the number of the multiple pixels is m times of a degree of parallelism of the table lookup, m being a positive integer, and performing the table lookup on the pixel values of the multiple pixels according to the first sub-table in parallel to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
dividing the pixel values of the multiple pixels into m groups of to-be-queried pixel values according to the degree of parallelism; and
performing a NEON-based parallel table lookup on the to-be-queried pixel values according to the first sub-table by groups to obtain the mapped values each corresponding to a pixel of the multiple pixels.
16 . The method according to claim 15 , wherein performing the NEON-based parallel table lookup on the to-be-queried pixel values according to the first sub-table by groups to obtain the mapped values each corresponding to a pixel of the multiple pixels comprises:
segmenting the first sub-table to obtain multiple second sub-tables;
performing the NEON-based parallel table lookup on the to-be-queried pixel values according to the multiple second sub-tables by groups to obtain multiple sets of query results corresponding to respective groups of the to-be-queried pixel values; and
merging the multiple sets of query results to obtain respective mapped values corresponding to respective groups of the to-be-queried pixel values.
17 . The method according to claim 14 , wherein comparing the pixel values of the multiple pixels to determine the maximum pixel value and the minimum pixel value comprises:
initializing a maximum value register and a minimum value register, where the number of pixel values stored in the maximum value register or the minimum value register is i, and the number of the multiple pixels is n times the number of the pixel values i, n being a positive integer;
dividing the pixel values of the multiple pixels into n groups of to-be-compared pixel values, where each group of the to-be-compared pixel values comprises i pixel values;
comparing each group of the to-be-compared pixel values with the pixel values stored in the maximum value register bit by bit, and updating the i pixel values stored in the maximum value register according to the maximum value in the comparison result;
comparing each group of the to-be-compared pixel values with the pixel values stored in the minimum value register bit by bit, and updating the i pixel values stored in the minimum value register according to the minimum value in the comparison result; and
determining the maximum pixel value from the i pixel values stored in the maximum value register, and determining the minimum pixel value from the i pixel values stored in the minimum value register.
18 . The method according to claim 14 , wherein determining the first sub-table of the pixel value range corresponding to the maximum pixel value and the minimum pixel value from the mapping table comprises:
determining the number of pixel values of the first sub-table according to a difference between the maximum pixel value and the minimum pixel value; and
determining the first sub-table from the mapping table according to the number of pixel values starting from the minimum pixel value.