Skip to content

Commit

Permalink
Merge pull request #178 from InterDigitalInc/vfgs
Browse files Browse the repository at this point in the history
Add film grain synthesis (based on VFGS)
  • Loading branch information
adamjw24 committed Jun 3, 2024
2 parents ffe3010 + d57f963 commit aaeea8f
Show file tree
Hide file tree
Showing 10 changed files with 1,320 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
* X Rayleigh, @xrayleigh2000,
* Matthieu Sauer, ,
* Florian Eisenreich, , Fraunhofer HHI
* Philippe de Lagrange, @delagrangep, InterDigital
1 change: 1 addition & 0 deletions include/vvdec/sei.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ typedef struct vvdecCompModel
{
bool presentFlag;
uint8_t numModelValues;
uint16_t numIntensityIntervals;
vvdecCompModelIntensityValues intensityValues[256];
}vvdecCompModel;

Expand Down
9 changes: 4 additions & 5 deletions source/Lib/DecoderLib/SEIread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,14 +1238,13 @@ void SEIReader::xParseSEIFilmGrainCharacteristics(vvdecSEI* s, uint32_t payloadS
vvdecCompModel &cm = sei->compModel[c];
if (cm.presentFlag)
{
uint32_t numIntensityIntervals;
sei_read_code(pDecodedMessageOutputStream, 8, code, "nuintensity_intervals_minus1[c]"); numIntensityIntervals = code + 1;
sei_read_code(pDecodedMessageOutputStream, 8, code, "nuintensity_intervals_minus1[c]"); cm.numIntensityIntervals = code + 1;
sei_read_code(pDecodedMessageOutputStream, 3, code, "numodel_values_minus1[c]"); cm.numModelValues = code + 1;

CHECK ( numIntensityIntervals > 256, "nuintensity_intervals_minus1[c] out of range" );
CHECK ( cm.numModelValues > 5, "numodel_values_minus1[c] out of range" );
CHECK ( cm.numIntensityIntervals > 256, "nuintensity_intervals_minus1[c] out of range" );
CHECK ( cm.numModelValues > 6, "numodel_values_minus1[c] out of range" );

for (uint32_t interval = 0; interval < numIntensityIntervals; interval++)
for (uint32_t interval = 0; interval < cm.numIntensityIntervals; interval++)
{
vvdecCompModelIntensityValues &cmiv = cm.intensityValues[interval];
sei_read_code(pDecodedMessageOutputStream, 8, code, "intensity_interval_lower_bound[c][i]"); cmiv.intensityIntervalLowerBound = code;
Expand Down
2 changes: 1 addition & 1 deletion source/Lib/vvdec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else()
endif()

# get source files
file( GLOB BASE_SRC_FILES "*.cpp" "../CommonLib/*.cpp" "../Utilities/*.cpp" "../DecoderLib/*.cpp")
file( GLOB BASE_SRC_FILES "*.c" "*.cpp" "../CommonLib/*.cpp" "../Utilities/*.cpp" "../DecoderLib/*.cpp")

# get include files
file( GLOB BASE_INC_FILES "*.h" "../CommonLib/*.h" "../Utilities/*.h" "../DecoderLib/*.h" )
Expand Down
635 changes: 635 additions & 0 deletions source/Lib/vvdec/vfgs_fw.c

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions source/Lib/vvdec/vfgs_fw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* -----------------------------------------------------------------------------
The copyright in this software is being made available under the Clear BSD
License, included below. No patent rights, trademark rights and/or
other Intellectual Property Rights other than the copyrights concerning
the Software are granted under this license.
The Clear BSD License
Copyright (c) 2018-2024, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC Authors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted (subject to the limitations in the disclaimer below) provided that
the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------------------- */

/* This file is based on VFGS, available on
* https://github.com/InterDigitalInc/VersatileFilmGrain
*
* VFGS implements film grain synthesis as a hardware model: it simulates the
* output of a cost-effective hardware implementation in a video display
* pipeline. Also, the C code is split into "fw" (firmware) and "hw" (hardware)
* parts, and as self-explanatory as possible. See VFGS github repository for
* more details.
*
* The VFGS github repository also contains other tools to experiment with film
* grain synthesis (e.g. a graphical display and tuning tool for FGC SEI
* message).
*/

#ifndef _VFGS_FW_H_
#define _VFGS_FW_H_

#ifndef int32
#define int32 signed int
#define uint32 unsigned int
#define int16 signed short
#define uint16 unsigned short
#define int8 signed char
#define uint8 unsigned char
#endif

#define SEI_MAX_MODEL_VALUES 6

typedef struct fgs_sei_s {
uint8 model_id;
uint8 log2_scale_factor;
uint8 comp_model_present_flag[3];
uint16 num_intensity_intervals[3];
uint8 num_model_values[3];
uint8 intensity_interval_lower_bound[3][256];
uint8 intensity_interval_upper_bound[3][256];
int16 comp_model_value[3][256][SEI_MAX_MODEL_VALUES];
} fgs_sei;

void vfgs_init_sei(fgs_sei* cfg);

#endif // _VFGS_FW_H_

Loading

0 comments on commit aaeea8f

Please sign in to comment.