ronantakizawa/codereview-bench huggingface dataset:
Repository: xbmc/xbmc
File: xbmc/platform/win32/filesystem/Win32Directory.cpp (C++)

Code before:
  std::vector<std::shared_ptr<CFileItem>> fileItems;
  do
  {
    std::wstring itemNameW(findData.cFileName);
    if (itemNameW == L"." || itemNameW == L"..")
      continue;

    std::string itemName;
    if (!g_charsetConverter.wToUTF8(itemNameW, itemName, true) || itemName.empty())
    {
      CLog::Log(LOGERROR, "{}: Can't convert wide string name to UTF-8 encoding", __FUNCTION__);
      continue;
    }

    const bool isDir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
    const bool isHidden =
        (findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) != 0 ||
        itemName.front() == '.'; // mark files starting from dot as hidden

    std::string itemPath(pathWithSlash + itemName);
    if (isDir)
      itemPath += '\\';

    // calculation of size and date costs a little on win32
    // so DIR_FLAG_NO_FILE_INFO flag is ignored
    auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(itemName));

    item->SetFolder(isDir);
    item->SetPath(itemPath);

    if (auto entryTime = GetEntryTime(findData); entryTime.has_value())
      item->SetDateTime(entryTime.value());
    if (!isDir)
      item->SetSize(GetEntrySize(findData));
    if (isHidden)
      item->SetProperty("file:hidden", true);
  } while (FindNextFileW(hSearch, &findData));

  FindClose(hSearch);

  items.AddItems(std::move(fileItems));

  return true;
}

bool CWin32Directory::Create(const CURL& url)
{
  auto nameW(prepareWin32DirectoryName(url.Get()));
  if (nameW.empty())
    return false;


Review comment (suggestion):
```suggestion
    const auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(itemName));
```

Code after:
    if (isDir)
      itemPath.push_back('\\');

    // calculation of size and date costs a little on win32
    // so DIR_FLAG_NO_FILE_INFO flag is ignored
    const auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(itemName));

    item->SetFolder(isDir);
    item->SetPath(itemPath);

    using KODI::TIME::FileTime;
    FileTime localTime{};

    if (FileTimeToLocalFileTime(reinterpret_cast<const FileTime*>(&findData.ftLastWriteTime),
                                &localTime) == TRUE)
      item->SetDateTime(localTime);

    if (!isDir)
      item->SetSize((static_cast<int64_t>(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow);

    if (isHidden)
      item->SetProperty("file:hidden", true);

  } while (FindNextFileW(hSearch, &findData));

  items.AddItems(std::move(fileItems));

  FindClose(hSearch);

  return true;
}

bool CWin32Directory::Create(const CURL& url)
{
  auto nameW(prepareWin32DirectoryName(url.Get()));
  if (nameW.empty())
    return false;

  if (!Create(nameW))
    return Exists(url);

  return true;
}

bool CWin32Directory::Exists(const CURL& url)
{
  std::wstring nameW(prepareWin32DirectoryName(url.Get()));
  if (nameW.empty())
    return false;

  DWORD fileAttrs = GetFileAttributesW(nameW.c_str());
Repository: xbmc/xbmc
File: xbmc/platform/win32/filesystem/Win32Directory.cpp (C++)

Code before:
    if (!g_charsetConverter.wToUTF8(itemNameW, itemName, true) || itemName.empty())
    {
      CLog::Log(LOGERROR, "{}: Can't convert wide string name to UTF-8 encoding", __FUNCTION__);
      continue;
    }

    const bool isDir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
    const bool isHidden =
        (findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) != 0 ||
        itemName.front() == '.'; // mark files starting from dot as hidden

    std::string itemPath(pathWithSlash + itemName);
    if (isDir)
      itemPath += '\\';

    // calculation of size and date costs a little on win32
    // so DIR_FLAG_NO_FILE_INFO flag is ignored
    auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(itemName));

    item->SetFolder(isDir);
    item->SetPath(itemPath);

    if (auto entryTime = GetEntryTime(findData); entryTime.has_value())
      item->SetDateTime(entryTime.value());
    if (!isDir)
      item->SetSize(GetEntrySize(findData));
    if (isHidden)
      item->SetProperty("file:hidden", true);
  } while (FindNextFileW(hSearch, &findData));

  FindClose(hSearch);

  items.AddItems(std::move(fileItems));

  return true;
}

bool CWin32Directory::Create(const CURL& url)
{
  auto nameW(prepareWin32DirectoryName(url.Get()));
  if (nameW.empty())
    return false;

  if (!Create(nameW))
    return Exists(url);

  return true;
}

bool CWin32Directory::Exists(const CURL& url)
{

Review comment (suggestion):
Same here, I think is better use directly:

```c++
item->SetSize((static_cast<int64_t>(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow);
```

Code after:
    item->SetPath(itemPath);

    using KODI::TIME::FileTime;
    FileTime localTime{};

    if (FileTimeToLocalFileTime(reinterpret_cast<const FileTime*>(&findData.ftLastWriteTime),
                                &localTime) == TRUE)
      item->SetDateTime(localTime);

    if (!isDir)
      item->SetSize((static_cast<int64_t>(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow);

    if (isHidden)
      item->SetProperty("file:hidden", true);

  } while (FindNextFileW(hSearch, &findData));

  items.AddItems(std::move(fileItems));

  FindClose(hSearch);

  return true;
}

bool CWin32Directory::Create(const CURL& url)
{
  auto nameW(prepareWin32DirectoryName(url.Get()));
  if (nameW.empty())
    return false;

  if (!Create(nameW))
    return Exists(url);

  return true;
}

bool CWin32Directory::Exists(const CURL& url)
{
  std::wstring nameW(prepareWin32DirectoryName(url.Get()));
  if (nameW.empty())
    return false;

  DWORD fileAttrs = GetFileAttributesW(nameW.c_str());
  if (fileAttrs == INVALID_FILE_ATTRIBUTES || (fileAttrs & FILE_ATTRIBUTE_DIRECTORY) == 0)
    return false;

  return true;
}

bool CWin32Directory::Remove(const CURL& url)
{
Repository: xbmc/xbmc
File: xbmc/utils/Set.h (C/C++)

Code before:

/*
 *  Copyright (C) 2025 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <algorithm>
#include <array>
#include <cassert>
#include <concepts>
#include <initializer_list>
#include <iterator>
#include <ranges>

/*!
 * \brief A `constexpr` set, like `std::set` but at compile time
 *
 * This class is designed to implement a `constexpr` version of std::set.
 *
 * When using this class, "class template argument deduction" will figure the typ
 * ans size out for you:
 *
 * ```
 * constexpr CMap magicNumber{ 5738, 573942, 5832}; // --> CSet<int, 3>
 * ```
 *
 * If you want to force a type, but not the size, use the
 * `make_set` helper function like:
 *
 * ```
 * constexpr auto mySet = make_set<std::string_view>({"one", "two", "three"});
 * ```
 *
 * The elements in CSet need to be totally ordered, this allows for log(n)
 * complexity when looking up values.
 */
template<std::totally_ordered Key, size_t Size>
class CSet
{
public:
  consteval CSet(std::initializer_list<Key> keys) : CSet(keys.begin(), keys.end()) {}

  template<std::forward_iterator Iter>
  consteval CSet(Iter begin, Iter end)
  {
    std::ranges::subrange keys(begin, end);

Review comment (suggestion):
```suggestion
 * When using this class, "class template argument deduction" will figure the type
 * and size out for you:
```

Code after:
/*
 *  Copyright (C) 2025 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <algorithm>
#include <array>
#include <concepts>
#include <initializer_list>
#include <iterator>
#include <ranges>
#include <stdexcept>

/*!
 * \brief A `constexpr` set, like `std::set` but at compile time
 *
 * This class is designed to implement a `constexpr` version of std::set.
 *
 * When using this class, "class template argument deduction" will figure out
 * the type and size for you:
 *
 * ```
 * constexpr CSet magicNumber{5738, 573942, 5832}; // --> CSet<int, 3>
 * ```
 *
 * If you want to force a type, but not the size, use the
 * `make_set` helper function like:
 *
 * ```
 * constexpr auto mySet = make_set<std::string_view>({"one", "two", "three"});
 * ```
 *
 * The elements in CSet need to be totally ordered, this allows for O(log n)
 * complexity when looking up values.
 */
template<std::totally_ordered Key, size_t Size>
class CSet
{
public:
  consteval CSet(std::initializer_list<Key> keys) : CSet(keys.begin(), keys.end()) {}

  template<std::forward_iterator Iter>
  consteval CSet(Iter begin, Iter end)
  {
    std::ranges::subrange keys(begin, end);
    std::ranges::move(keys, m_keys.begin());
Repository: xbmc/xbmc
File: xbmc/windowing/osx/OpenGL/WindowControllerMacOS.mm (Objective-C++)

Code before:
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(false);
  }
}

- (void)windowDidEndLiveResize:(NSNotification*)notification
{
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(true);
  }
}

- (void)windowDidMiniaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = false;

  // Disable GUI rendering when window is miniaturized to reduce CPU usage
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(false);
  }
}

- (void)windowDidDeminiaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;

  // Re-enable GUI rendering when window is deminiaturized
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(true);
  }
}

- (void)windowDidBecomeKey:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::GUI, "WindowFocused");

  // Re-enable GUI rendering when window regains focus
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(true);
  }

Review comment (refactor):
This code is (almost) duplicated 5 times. Could you please create a small helper function like `void SetRenderGUI(bool enable)` in an unnamed namespace in this cpp file. This would reduce number of changed code lines and improve overall readability and maintainability of the code.

In addition, I think the comments are not actually adding value, as a call to a function with a speaking name should be self-explaining. 

Code after:
      std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
      if (appPort)
        appPort->OnEvent(newEvent);
    }
  }
}

- (void)windowWillStartLiveResize:(NSNotification*)notification
{
  EnableRenderGUI(false);
}

- (void)windowDidEndLiveResize:(NSNotification*)notification
{
  EnableRenderGUI(true);
}

- (void)windowDidMiniaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = false;

  EnableRenderGUI(false);
}

- (void)windowDidDeminiaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;

  EnableRenderGUI(true);
}

- (void)windowDidBecomeKey:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::GUI, "WindowFocused");

  EnableRenderGUI(true);

  auto winSystem = dynamic_cast<CWinSystemOSX*>(CServiceBroker::GetWinSystem());
  if (winSystem)
  {
    winSystem->enableInputEvents();
  }
}

- (void)windowDidResignKey:(NSNotification*)aNotification
{
  g_application.m_AppFocused = false;
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::GUI, "WindowUnfocused");

  EnableRenderGUI(false);
Repository: xbmc/xbmc
File: xbmc/windowing/osx/OpenGL/WindowControllerMacOS.mm (Objective-C++)

Code before:
{
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(true);
  }
}

- (void)windowDidMiniaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = false;

  // Disable GUI rendering when window is miniaturized to reduce CPU usage
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(false);
  }
}

- (void)windowDidDeminiaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;

  // Re-enable GUI rendering when window is deminiaturized
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(true);
  }
}

- (void)windowDidBecomeKey:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::GUI, "WindowFocused");

  // Re-enable GUI rendering when window regains focus
  std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
  {
    appPort->SetRenderGUI(true);
  }

  auto winSystem = dynamic_cast<CWinSystemOSX*>(CServiceBroker::GetWinSystem());
  if (winSystem)
  {
    winSystem->enableInputEvents();
  }
}


Review comment (suggestion):
This should be changed to `const std:.shared_ptr<...`

Code after:
{
  EnableRenderGUI(false);
}

- (void)windowDidEndLiveResize:(NSNotification*)notification
{
  EnableRenderGUI(true);
}

- (void)windowDidMiniaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = false;

  EnableRenderGUI(false);
}

- (void)windowDidDeminiaturize:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;

  EnableRenderGUI(true);
}

- (void)windowDidBecomeKey:(NSNotification*)aNotification
{
  g_application.m_AppFocused = true;
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::GUI, "WindowFocused");

  EnableRenderGUI(true);

  auto winSystem = dynamic_cast<CWinSystemOSX*>(CServiceBroker::GetWinSystem());
  if (winSystem)
  {
    winSystem->enableInputEvents();
  }
}

- (void)windowDidResignKey:(NSNotification*)aNotification
{
  g_application.m_AppFocused = false;
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::GUI, "WindowUnfocused");

  EnableRenderGUI(false);

  auto winSystem = dynamic_cast<CWinSystemOSX*>(CServiceBroker::GetWinSystem());
  if (winSystem)
  {
    winSystem->disableInputEvents();
  }
}
Repository: xbmc/xbmc
File: xbmc/utils/i18n/Iso639_1.cpp (C++)

Code before:
        { return StringUtils::CompareNoCase(a, b) < 0; }, &LCENTRY::name);
    if (it != TableISO639_1ByName.end() && StringUtils::EqualsNoCase(it->name, name))
      return LongCodeToString(it->code);
  }
  {
    auto it = std::ranges::lower_bound(
        TableISO639_1_DeprByName, name, [](std::string_view a, std::string_view b)
        { return StringUtils::CompareNoCase(a, b) < 0; }, &LCENTRY::name);
    if (it != TableISO639_1_DeprByName.end() && StringUtils::EqualsNoCase(it->name, name))
      return LongCodeToString(it->code);
  }
  return std::nullopt;
}

bool CIso639_1::ListLanguages(std::map<std::string, std::string>& langMap)
{
  std::ranges::transform(TableISO639_1ByName, std::inserter(langMap, langMap.end()),
                         [](const LCENTRY& e)
                         { return std::make_pair(LongCodeToString(e.code), std::string{e.name}); });

  std::ranges::transform(TableISO639_1_DeprByName, std::inserter(langMap, langMap.end()),
                         [](const LCENTRY& e)
                         {
                           std::string c = LongCodeToString(e.code);
                           return std::make_pair(c, std::string{e.name} + " \"" + c +
                                                        "\" (Deprecated)");
                         });

  return true;
}


Review comment (suggestion):
IMO "deprecated" and also the "non-preferred"  (below on 6392) texts should be fully removed
has no real meaning for end-users
if an audio or subtitle track really use these, what does it matter if these are old language codes?

also take in account that these lists can be used by python addons for their use cases
so add the missing language code on description to distinguish from the regular lang code should be sufficient


Code after:
        { return StringUtils::CompareNoCase(a, b) < 0; }, &LCENTRY::name);
    if (it != TableISO639_1ByName.end() && StringUtils::EqualsNoCase(it->name, name))
      return LongCodeToString(it->code);
  }
  {
    auto it = std::ranges::lower_bound(
        TableISO639_1_DeprByName, name, [](std::string_view a, std::string_view b)
        { return StringUtils::CompareNoCase(a, b) < 0; }, &LCENTRY::name);
    if (it != TableISO639_1_DeprByName.end() && StringUtils::EqualsNoCase(it->name, name))
      return LongCodeToString(it->code);
  }
  return std::nullopt;
}

bool CIso639_1::ListLanguages(std::map<std::string, std::string>& langMap)
{
  std::ranges::transform(TableISO639_1ByName, std::inserter(langMap, langMap.end()),
                         [](const LCENTRY& e)
                         { return std::make_pair(LongCodeToString(e.code), std::string{e.name}); });

  std::ranges::transform(TableISO639_1_DeprByName, std::inserter(langMap, langMap.end()),
                         [](const LCENTRY& e)
                         { return std::make_pair(LongCodeToString(e.code), std::string{e.name}); });

  return true;
}
Repository: xbmc/xbmc
File: xbmc/interfaces/python/XBPython.cpp (C++)

Code before:
  PyList tmpvec;
  std::unique_lock lock(m_vecPyList);
  for (PyList::iterator it = m_vecPyList.begin(); it != m_vecPyList.end();)
  {
    if (it->bDone)
    {
      tmpvec.push_back(*it);
      it = m_vecPyList.erase(it);
      m_vecPyList.hadSomethingRemoved = true;
    }
    else
      ++it;
  }
  lock.unlock();

  //delete scripts which are done
  tmpvec.clear();
}

bool XBPython::OnScriptInitialized(ILanguageInvoker* invoker)
{
  if (invoker == NULL)
    return false;

  XBMC_TRACE;
  CLog::Log(LOGDEBUG, "initializing script");
  std::unique_lock lock(m_critSection);
  m_iDllScriptCounter++;

  return true;
}

void XBPython::OnScriptStarted(ILanguageInvoker* invoker)
{
  if (invoker == NULL)
    return;

  PyElem inf;
  inf.id = invoker->GetId();
  inf.bDone = false;
  inf.pyThread = static_cast<CPythonInvoker*>(invoker);
  std::unique_lock lock(m_vecPyList);
  m_vecPyList.push_back(inf);
}

void XBPython::NotifyScriptAborting(ILanguageInvoker* invoker)
{
  XBMC_TRACE;

  long invokerId(-1);
  if (invoker != NULL)

Review comment (bug):
can you keep "python" just for clarity in log
```suggestion
  CLog::Log(LOGDEBUG, "initializing python script");
```

Code after:
  PyList tmpvec;
  std::unique_lock lock(m_vecPyList);
  for (PyList::iterator it = m_vecPyList.begin(); it != m_vecPyList.end();)
  {
    if (it->bDone)
    {
      tmpvec.push_back(*it);
      it = m_vecPyList.erase(it);
      m_vecPyList.hadSomethingRemoved = true;
    }
    else
      ++it;
  }
  lock.unlock();

  //delete scripts which are done
  tmpvec.clear();
}

bool XBPython::OnScriptInitialized(ILanguageInvoker* invoker)
{
  if (invoker == NULL)
    return false;

  XBMC_TRACE;
  CLog::Log(LOGDEBUG, "initializing python script");
  std::unique_lock lock(m_critSection);
  m_iDllScriptCounter++;

  return true;
}

void XBPython::OnScriptStarted(ILanguageInvoker* invoker)
{
  if (invoker == NULL)
    return;

  PyElem inf;
  inf.id = invoker->GetId();
  inf.bDone = false;
  inf.pyThread = static_cast<CPythonInvoker*>(invoker);
  std::unique_lock lock(m_vecPyList);
  m_vecPyList.push_back(inf);
}

void XBPython::NotifyScriptAborting(ILanguageInvoker* invoker)
{
  XBMC_TRACE;

  long invokerId(-1);
  if (invoker != NULL)
Repository: xbmc/xbmc
File: xbmc/utils/BitstreamConverter.cpp (C++)

Code before:
          fpsrate = 60000;
          fpsscale = 1000;
          break;
      }

      if (fpsscale != sequence->fps_scale || fpsrate != sequence->fps_rate)
      {
        changed = true;
        sequence->fps_rate = fpsrate;
        sequence->fps_scale = fpsscale;
      }
    }
    nal_start = nal_end;
  }

  return changed;
}

#ifdef HAVE_LIBDOVI
// Processes Dolby Vision RPU
//   - Converts to profile 8.1 if `m_convert_dovi` is enabled
//   - Sets level 5 metadata to 0 offsets if `m_setDoviZeroLevel5` is enabled
//
// The returned data must be freed with `dovi_data_free`
// May be NULL if no processing was done or if parsing errored
const DoviData* CBitstreamConverter::processDoviRpu(uint8_t* buf, uint32_t nal_size)
{
  // early exit if no processing option is enabled
  if (!m_convert_dovi && !m_setDoviZeroLevel5)
    return NULL;

  DoviRpuOpaque* rpu = dovi_parse_unspec62_nalu(buf, nal_size);
  const DoviRpuDataHeader* header = dovi_rpu_get_header(rpu);
  const DoviData* rpu_data = NULL;

  int ret = 0;
  bool processed = false;

  if (!header)
  {
    dovi_rpu_free(rpu);
    return rpu_data;
  }

  if (m_convert_dovi && header->guessed_profile == 7)
  {
    ret = dovi_convert_rpu_with_mode(rpu, 2);
    processed = true;
  }

  if (ret == 0 && m_setDoviZeroLevel5)

Review comment (suggestion):
```suggestion
const DoviData* CBitstreamConverter::processDoviRpu(uint8_t* buf, uint32_t nalSize)
```

Code after:
          fpsrate = 60000;
          fpsscale = 1000;
          break;
      }

      if (fpsscale != sequence->fps_scale || fpsrate != sequence->fps_rate)
      {
        changed = true;
        sequence->fps_rate = fpsrate;
        sequence->fps_scale = fpsscale;
      }
    }
    nal_start = nal_end;
  }

  return changed;
}

#ifdef HAVE_LIBDOVI
// Processes Dolby Vision RPU
//   - Converts to profile 8.1 if `m_convert_dovi` is enabled
//   - Sets level 5 metadata to 0 offsets if `m_setDoviZeroLevel5` is enabled
//
// The returned data must be freed with `dovi_data_free`
// May be NULL if no processing was done or if parsing errored
const DoviData* CBitstreamConverter::processDoviRpu(uint8_t* buf, uint32_t nalSize)
{
  // early exit if no processing option is enabled
  if (!m_convert_dovi && !m_setDoviZeroLevel5)
    return NULL;

  DoviRpuOpaque* rpu = dovi_parse_unspec62_nalu(buf, nalSize);
  const DoviRpuDataHeader* header = dovi_rpu_get_header(rpu);
  const DoviData* rpuData = NULL;

  int ret = 0;
  bool processed = false;

  if (!header)
  {
    dovi_rpu_free(rpu);
    return rpuData;
  }

  if (m_convert_dovi && header->guessed_profile == 7)
  {
    ret = dovi_convert_rpu_with_mode(rpu, 2);
    processed = true;
  }

  if (ret == 0 && m_setDoviZeroLevel5)