Adaptive film grain synthesis
Systems and techniques are described herein for processing video data. For instance, a process can include obtaining video data including a picture. The process can also include determining a width of a film grain synthesis block of the picture based on at least one of a width and a height of the picture. The process can further include determining a height of the film grain synthesis block of the picture is one. The process may also include determining a block size of the film grain synthesis block based on the determined width and height. The process may further include selecting a grain block based on the determined block size.
1. An apparatus for processing video data, comprising:
at least one memory; and
at least one processor coupled to the at least one memory, the at least one processor being configured to:
obtain video data including a picture;
set a height of a film grain synthesis block of the picture to a height value of one pixel;
determine a width of the film grain synthesis block of the picture based on at least one of a width or a height of the picture, wherein a width value of the determined width is greater than the height value of one pixel and is in a range of 8 to W, inclusive, where W is a maximum width of a corresponding grain pattern;
determine a block size of the film grain synthesis block based on the determined width and the height value of one pixel; and
select a grain block based on the determined block size.
2. The apparatus of claim 1 , wherein the at least one processor is configured to:
determine the width of the film grain synthesis block of the picture based on the width and the height of the picture.
3. The apparatus of claim 1 , wherein the at least one processor is further configured to:
obtain a current block of samples from the picture;
obtain a set of pixels from the current block of samples based on the determined block size;
determine an average luma value for the set of pixels; and
select the grain block based on the average luma value.
4. The apparatus of claim 3 , wherein the set of pixels comprises a line of pixels from the current block of samples, and wherein the at least one processor is configured to:
determine a respective average luma value for each line of pixels for the current block of samples;
determine an overall average luma value for the current block of samples based on the respective average luma value for each line of pixels; and
determine an intensity level based on the overall average luma value.
5. The apparatus of claim 4 , wherein the at least one processor is configured to:
select a grain pattern based on the intensity level;
randomly select at least a vertical offset; and
select the grain block from the grain pattern based on the vertical offset.
6. The apparatus of claim 5 , wherein the at least one processor comprises a video decoder and is configured to:
decode the current block of samples;
add the selected grain block to the decoded current block of samples to generate an output current block; and
output the output current block.
7. The apparatus of claim 6 , further comprising a display configured to display one or more pictures that include the current block.
8. The apparatus of claim 1 , wherein the at least one processor is configured to:
determine the width of the film grain synthesis block is equal to a width of a corresponding grain pattern; and
set a horizontal offset used to select a block of the corresponding grain pattern to 0.
9. The apparatus of claim 1 , wherein the apparatus includes an encoder.
10. The apparatus of claim 1 , further comprising a camera configured to capture one or more pictures.
11. A method for processing video data, the method comprising:
obtaining video data including a picture;
setting a height of a film grain synthesis block of the picture to a height value of one pixel; determining a width of the film grain synthesis block of the picture based on at least one of a width or a height of the picture, wherein a width value of the determined width is greater than the height value of one pixel and is in a range of 8 to W, inclusive, where W is a maximum width of a corresponding grain pattern;
determining a block size of the film grain synthesis block based on the determined width and the height value of one pixel; and
selecting a grain block based on the determined block size.
12. The method of claim 11 , further comprising:
obtaining a current block of samples from the picture;
obtaining a set of pixels from the current block of samples based on the determined block size; and
determining an average luma value for the set of pixels, wherein selecting the grain block comprises selecting the grain block based on the average luma value.
13. The method of claim 12 , wherein the set of pixels comprises a line of pixels from the current block of samples, and wherein the method further comprises:
determining a respective average luma value for each line of pixels for the current block of samples;
determining an overall average luma value for the current block of samples based on the respective average luma value for each line of pixels; and
determining an intensity level based on the overall average luma value.
14. The method of claim 13 , further comprising:
selecting a grain pattern based on the intensity level; and
randomly selecting at least a vertical offset, wherein selecting the grain block comprises selecting the grain block from the grain pattern based on the vertical offset.
15. The method of claim 14 , further comprising:
decoding the current block of samples;
adding the selected grain block to the decoded current block of samples to generate an output current block; and
outputting the output current block.
16. The method of claim 11 , further comprising:
determining the width of the film grain synthesis block is equal to a width of a corresponding grain pattern; and
setting a horizontal offset used to select a block of the corresponding grain pattern to 0.