ronantakizawa/codereview-bench huggingface dataset:
Repository: xbmc/xbmc
File: xbmc/utils/HevcSei.cpp (C++)

Code before:
/*
 *  Copyright (C) 2024 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.
 */

#include "HevcSei.h"

void hevc_add_start_code_emulation_prevention_3_byte(std::vector<uint8_t>& buf)
{
  auto count = buf.size();
  size_t i = 0;

  while (i < count)
  {
    if (i > 2 && buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] <= 3)
    {
      buf.insert(buf.begin() + i, 3);
      count += 1;
    }

    i += 1;
  }
}

void hevc_clear_start_code_emulation_prevention_3_byte(const uint8_t* buf,
                                                       const size_t len,
                                                       std::vector<uint8_t>& out)
{
  size_t i = 0;

  if (len > 2)
  {
    out.reserve(len);

    out.push_back(buf[0]);
    out.push_back(buf[1]);

    for (i = 2; i < len; i++)
    {
      if (!(buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] == 3))
        out.push_back(buf[i]);
    }
  }

Review comment (suggestion):
`count` variable seems redundant as is increased at same time as `buf.insert`

Use directly `while (i < buf.size())` should be equivalent.

Code after:
/*
 *  Copyright (C) 2024 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.
 */

#include "HevcSei.h"

void HevcAddStartCodeEmulationPrevention3Byte(std::vector<uint8_t>& buf)
{
  size_t i = 0;

  while (i < buf.size())
  {
    if (i > 2 && buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] <= 3)
      buf.insert(buf.begin() + i, 3);

    i += 1;
  }
}

void HevcClearStartCodeEmulationPrevention3Byte(const uint8_t* buf,
                                                const size_t len,
                                                std::vector<uint8_t>& out)
{
  size_t i = 0;

  if (len > 2)
  {
    out.reserve(len);

    out.emplace_back(buf[0]);
    out.emplace_back(buf[1]);

    for (i = 2; i < len; i++)
    {
      if (!(buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] == 3))
        out.emplace_back(buf[i]);
    }
  }
  else
  {
    out.assign(buf, buf + len);
  }
Repository: xbmc/xbmc
File: xbmc/utils/BitstreamConverter.cpp (C++)

Code before:
    case AVC_NAL_PPS:
      break;
    default:
      break;
    }
  }

  return rtn;
}

////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
CBitstreamConverter::CBitstreamConverter()
{
  m_convert_bitstream = false;
  m_convertBuffer     = NULL;
  m_convertSize       = 0;
  m_inputBuffer       = NULL;
  m_inputSize         = 0;
  m_to_annexb = false;
  m_convert_3byteTo4byteNALSize = false;
  m_convert_bytestream = false;
  m_sps_pps_context.sps_pps_data = NULL;
  m_start_decode = true;
  m_convert_dovi = false;
  m_remove_dovi = false;
  m_remove_hdr10plus = false;
}

CBitstreamConverter::~CBitstreamConverter()
{
  Close();
}

bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb)
{
  m_to_annexb = to_annexb;

  m_codec = codec;
  switch(m_codec)
  {
    case AV_CODEC_ID_H264:
      if (in_extrasize < 7 || in_extradata == NULL)
      {
        CLog::Log(LOGERROR, "CBitstreamConverter::Open avcC data too small or missing");
        return false;
      }
      // valid avcC data (bitstream) always starts with the value 1 (version)
      if(m_to_annexb)
      {
        if ( in_extradata[0] == 1 )

Review comment (bug):
Use camel case for newly introduced variables. There's a couple more variables that have wrong naming.

Code after:
    case AVC_NAL_PPS:
      break;
    default:
      break;
    }
  }

  return rtn;
}

////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
CBitstreamConverter::CBitstreamConverter()
{
  m_convert_bitstream = false;
  m_convertBuffer     = NULL;
  m_convertSize       = 0;
  m_inputBuffer       = NULL;
  m_inputSize         = 0;
  m_to_annexb = false;
  m_convert_3byteTo4byteNALSize = false;
  m_convert_bytestream = false;
  m_sps_pps_context.sps_pps_data = NULL;
  m_start_decode = true;
  m_convert_dovi = false;
  m_removeDovi = false;
  m_removeHdr10Plus = false;
}

CBitstreamConverter::~CBitstreamConverter()
{
  Close();
}

bool CBitstreamConverter::Open(enum AVCodecID codec, uint8_t *in_extradata, int in_extrasize, bool to_annexb)
{
  m_to_annexb = to_annexb;

  m_codec = codec;
  switch(m_codec)
  {
    case AV_CODEC_ID_H264:
      if (in_extrasize < 7 || in_extradata == NULL)
      {
        CLog::Log(LOGERROR, "CBitstreamConverter::Open avcC data too small or missing");
        return false;
      }
      // valid avcC data (bitstream) always starts with the value 1 (version)
      if(m_to_annexb)
      {
        if ( in_extradata[0] == 1 )
Repository: xbmc/xbmc
File: xbmc/utils/HevcSei.cpp (C++)

Code before:
  while (i < buf.size())
  {
    if (i > 2 && buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] <= 3)
      buf.insert(buf.begin() + i, 3);

    i += 1;
  }
}

void hevc_clear_start_code_emulation_prevention_3_byte(const uint8_t* buf,
                                                       const size_t len,
                                                       std::vector<uint8_t>& out)
{
  size_t i = 0;

  if (len > 2)
  {
    out.reserve(len);

    out.push_back(buf[0]);
    out.push_back(buf[1]);

    for (i = 2; i < len; i++)
    {
      if (!(buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] == 3))
        out.push_back(buf[i]);
    }
  }
  else
  {
    out.assign(buf, buf + len);
  }
}

int CHevcSei::ParseSeiMessage(CBitstreamReader& br, std::vector<CHevcSei>& messages)
{
  CHevcSei sei{};
  uint8_t last_payload_type_byte{0};
  uint8_t last_payload_size_byte{0};

  sei.msg_offset = br.Position() / 8;

  last_payload_type_byte = br.ReadBits(8);
  while (last_payload_type_byte == 0xFF)
  {
    last_payload_type_byte = br.ReadBits(8);
    sei.payload_type += 255;
  }

  sei.payload_type += last_payload_type_byte;


Review comment (suggestion):
```suggestion
        out.emplace_back(buf[i]);
```

Code after:
  while (i < buf.size())
  {
    if (i > 2 && buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] <= 3)
      buf.insert(buf.begin() + i, 3);

    i += 1;
  }
}

void HevcClearStartCodeEmulationPrevention3Byte(const uint8_t* buf,
                                                const size_t len,
                                                std::vector<uint8_t>& out)
{
  size_t i = 0;

  if (len > 2)
  {
    out.reserve(len);

    out.emplace_back(buf[0]);
    out.emplace_back(buf[1]);

    for (i = 2; i < len; i++)
    {
      if (!(buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] == 3))
        out.emplace_back(buf[i]);
    }
  }
  else
  {
    out.assign(buf, buf + len);
  }
}

int CHevcSei::ParseSeiMessage(CBitstreamReader& br, std::vector<CHevcSei>& messages)
{
  CHevcSei sei;
  uint8_t lastPayloadTypeByte{0};
  uint8_t lastPayloadSizeByte{0};

  sei.m_msgOffset = br.Position() / 8;

  lastPayloadTypeByte = br.ReadBits(8);
  while (lastPayloadTypeByte == 0xFF)
  {
    lastPayloadTypeByte = br.ReadBits(8);
    sei.m_payloadType += 255;
  }

  sei.m_payloadType += lastPayloadTypeByte;
Repository: xbmc/xbmc
File: xbmc/utils/HevcSei.cpp (C++)

Code before:
                                                       std::vector<uint8_t>& out)
{
  size_t i = 0;

  if (len > 2)
  {
    out.reserve(len);

    out.push_back(buf[0]);
    out.push_back(buf[1]);

    for (i = 2; i < len; i++)
    {
      if (!(buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] == 3))
        out.push_back(buf[i]);
    }
  }
  else
  {
    out.assign(buf, buf + len);
  }
}

int CHevcSei::ParseSeiMessage(CBitstreamReader& br, std::vector<CHevcSei>& messages)
{
  CHevcSei sei{};
  uint8_t last_payload_type_byte{0};
  uint8_t last_payload_size_byte{0};

  sei.msg_offset = br.Position() / 8;

  last_payload_type_byte = br.ReadBits(8);
  while (last_payload_type_byte == 0xFF)
  {
    last_payload_type_byte = br.ReadBits(8);
    sei.payload_type += 255;
  }

  sei.payload_type += last_payload_type_byte;

  last_payload_size_byte = br.ReadBits(8);
  while (last_payload_size_byte == 0xFF)
  {
    last_payload_size_byte = br.ReadBits(8);
    sei.payload_size += 255;
  }

  sei.payload_size += last_payload_size_byte;
  sei.payload_offset = br.Position() / 8;

  // Invalid size

Review comment (suggestion):
```suggestion
  CHevcSei sei;
```

As now class is self-initialized is not necessary here

Code after:
                                                std::vector<uint8_t>& out)
{
  size_t i = 0;

  if (len > 2)
  {
    out.reserve(len);

    out.emplace_back(buf[0]);
    out.emplace_back(buf[1]);

    for (i = 2; i < len; i++)
    {
      if (!(buf[i - 2] == 0 && buf[i - 1] == 0 && buf[i] == 3))
        out.emplace_back(buf[i]);
    }
  }
  else
  {
    out.assign(buf, buf + len);
  }
}

int CHevcSei::ParseSeiMessage(CBitstreamReader& br, std::vector<CHevcSei>& messages)
{
  CHevcSei sei;
  uint8_t lastPayloadTypeByte{0};
  uint8_t lastPayloadSizeByte{0};

  sei.m_msgOffset = br.Position() / 8;

  lastPayloadTypeByte = br.ReadBits(8);
  while (lastPayloadTypeByte == 0xFF)
  {
    lastPayloadTypeByte = br.ReadBits(8);
    sei.m_payloadType += 255;
  }

  sei.m_payloadType += lastPayloadTypeByte;

  lastPayloadSizeByte = br.ReadBits(8);
  while (lastPayloadSizeByte == 0xFF)
  {
    lastPayloadSizeByte = br.ReadBits(8);
    sei.m_payloadSize += 255;
  }

  sei.m_payloadSize += lastPayloadSizeByte;
  sei.m_payloadOffset = br.Position() / 8;

  // Invalid size
Repository: xbmc/xbmc
File: xbmc/pvr/PVRPlaybackState.h (C/C++)

Code before:
/*
 *  Copyright (C) 2012-2019 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 "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h"
#include "threads/CriticalSection.h"
#include "utils/ContentUtils.h"

#include <memory>
#include <string>

class CDateTime;
class CFileItem;

namespace PVR
{
class CPVRChannel;
class CPVRChannelGroup;
class CPVRChannelGroupMember;
class CPVREpgInfoTag;
class CPVRRecording;
class CPVRStreamProperties;

class CPVRPlaybackState
{
public:
  /*!
   * @brief ctor.
   */
  CPVRPlaybackState();

Review comment (suggestion):
Including `pvr_general.h` should be sufficient. `pvr.h` includes everything from the c-API and you only need `PVR_SOURCE`here.

Code after:
/*
 *  Copyright (C) 2012-2019 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 "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h"
#include "pvr/PVRConstants.h" // PVR_CLIENT_INVALID_UID
#include "threads/CriticalSection.h"
#include "utils/ContentUtils.h"

#include <memory>
#include <string>

class CDateTime;
class CFileItem;

namespace PVR
{
class CPVRChannel;
class CPVRChannelGroup;
class CPVRChannelGroupMember;
class CPVREpgInfoTag;
class CPVRRecording;
class CPVRStreamProperties;

class CPVRPlaybackState
{
public:
  /*!
   * @brief ctor.
   */
Repository: xbmc/xbmc
File: xbmc/rendering/dx/DeviceResources.cpp (C++)

Code before:
/*
 *  Copyright (C) 2005-2018 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.
 */

#include "DeviceResources.h"

#include "DirectXHelper.h"
#include "RenderContext.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "messaging/ApplicationMessenger.h"
#include "rendering/dx/DirectXHelper.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/SystemInfo.h"
#include "utils/log.h"
#include "windowing/GraphicContext.h"

#include "platform/win32/CharsetConverter.h"
#include "platform/win32/WIN32Util.h"
#include "platform/win32/WinRtUtil.h"

#ifdef TARGET_WINDOWS_STORE
#include <winrt/Windows.Graphics.Display.Core.h>

extern "C"
{
#include <libavutil/rational.h>
}
#endif

#ifdef _DEBUG
#include <dxgidebug.h>
#pragma comment(lib, "dxgi.lib")
#endif // _DEBUG

using namespace DirectX;
using namespace Microsoft::WRL;
using namespace Concurrency;
namespace winrt
{
  using namespace Windows::Foundation;
}

#ifdef _DEBUG
#define breakOnDebug __debugbreak()

Review comment (suggestion):
After remove `CWinRtUtil::GetWindowsHDRStatus()` call this header is not needed

Code after:
/*
 *  Copyright (C) 2005-2018 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.
 */

#include "DeviceResources.h"

#include "DirectXHelper.h"
#include "RenderContext.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "messaging/ApplicationMessenger.h"
#include "rendering/dx/DirectXHelper.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/SystemInfo.h"
#include "utils/log.h"
#include "windowing/GraphicContext.h"

#include "platform/win32/CharsetConverter.h"
#include "platform/win32/WIN32Util.h"

#ifdef TARGET_WINDOWS_STORE
#include <winrt/Windows.Graphics.Display.Core.h>

extern "C"
{
#include <libavutil/rational.h>
}
#endif

#ifdef _DEBUG
#include <dxgidebug.h>
#pragma comment(lib, "dxgi.lib")
#endif // _DEBUG

using namespace DirectX;
using namespace Microsoft::WRL;
using namespace Concurrency;
namespace winrt
{
  using namespace Windows::Foundation;
}

#ifdef _DEBUG
#define breakOnDebug __debugbreak()
#else
Repository: xbmc/xbmc
File: xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h (C/C++)

Code before:

  /// @brief <b>`157`</b>: Filter SMS8.
  ADDON_ACTION_FILTER_SMS8 = 157,

  /// @brief <b>`158`</b>: Filter SMS9.
  ADDON_ACTION_FILTER_SMS9 = 158,

  /// @brief <b>`159`</b>: First page.
  ADDON_ACTION_FIRST_PAGE = 159,

  /// @brief <b>`160`</b>: Last page.
  ADDON_ACTION_LAST_PAGE = 160,

  /// @brief <b>`161`</b>: Audio delay.
  ADDON_ACTION_AUDIO_DELAY = 161,

  /// @brief <b>`162`</b>: Subtitle delay.
  ADDON_ACTION_SUBTITLE_DELAY = 162,

  /// @brief <b>`163`</b>: Menu.
  ADDON_ACTION_MENU = 163,

  /// @brief <b>`164`</b>: Set rating.
  ADDON_ACTION_SET_RATING = 164,

  /// @brief <b>`165`</b>: Switch to previous subtitle of movie. Can b used in videoFullScreen.xml window id=2005
  ADDON_ACTION_PREV_SUBTITLE = 165,

  /// @brief <b>`170`</b>: Record.
  ADDON_ACTION_RECORD = 170,

  /// @brief <b>`180`</b>: Paste.
  ADDON_ACTION_PASTE = 180,

  /// @brief <b>`181`</b>: Next control.
  ADDON_ACTION_NEXT_CONTROL = 181,

  /// @brief <b>`182`</b>: Previous control.
  ADDON_ACTION_PREV_CONTROL = 182,

  /// @brief <b>`183`</b>: Channel switch.
  ADDON_ACTION_CHANNEL_SWITCH = 183,

  /// @brief <b>`184`</b>: Channel up.
  ADDON_ACTION_CHANNEL_UP = 184,

  /// @brief <b>`185`</b>: Channel down.
  ADDON_ACTION_CHANNEL_DOWN = 185,

  /// @brief <b>`186`</b>: Next channel group.
  ADDON_ACTION_NEXT_CHANNELGROUP = 186,

Review comment (suggestion):
Because this gets rendered in our docs, I would suggest:

```
  /// @brief <b>`165`</b>: Switch to previous subtitle of movie. Can be used in
  /// the VideoFullScreen.xml window (with ID 2005).
```

Code after:

  /// @brief <b>`157`</b>: Filter SMS8.
  ADDON_ACTION_FILTER_SMS8 = 157,

  /// @brief <b>`158`</b>: Filter SMS9.
  ADDON_ACTION_FILTER_SMS9 = 158,

  /// @brief <b>`159`</b>: First page.
  ADDON_ACTION_FIRST_PAGE = 159,

  /// @brief <b>`160`</b>: Last page.
  ADDON_ACTION_LAST_PAGE = 160,

  /// @brief <b>`161`</b>: Audio delay.
  ADDON_ACTION_AUDIO_DELAY = 161,

  /// @brief <b>`162`</b>: Subtitle delay.
  ADDON_ACTION_SUBTITLE_DELAY = 162,

  /// @brief <b>`163`</b>: Menu.
  ADDON_ACTION_MENU = 163,

  /// @brief <b>`164`</b>: Set rating.
  ADDON_ACTION_SET_RATING = 164,

  /// @brief <b>`165`</b>: Switch to previous subtitle of movie. Can be used in
  /// the VideoFullScreen.xml window (with ID 2005).
  ADDON_ACTION_PREV_SUBTITLE = 165,

  /// @brief <b>`170`</b>: Record.
  ADDON_ACTION_RECORD = 170,

  /// @brief <b>`180`</b>: Paste.
  ADDON_ACTION_PASTE = 180,

  /// @brief <b>`181`</b>: Next control.
  ADDON_ACTION_NEXT_CONTROL = 181,

  /// @brief <b>`182`</b>: Previous control.
  ADDON_ACTION_PREV_CONTROL = 182,

  /// @brief <b>`183`</b>: Channel switch.
  ADDON_ACTION_CHANNEL_SWITCH = 183,

  /// @brief <b>`184`</b>: Channel up.
  ADDON_ACTION_CHANNEL_UP = 184,

  /// @brief <b>`185`</b>: Channel down.
  ADDON_ACTION_CHANNEL_DOWN = 185,

  /// @brief <b>`186`</b>: Next channel group.
Repository: xbmc/xbmc
File: xbmc/application/ApplicationPowerHandling.cpp (C++)

Code before:

  // screen saver timer is reset only if we're not already in screensaver or
  // DPMS mode
  if ((!m_screensaverActive && m_iScreenSaveLock == 0) && !m_dpmsIsActive)
    ResetScreenSaverTimer();
}

void CApplicationPowerHandling::ResetScreenSaverTimer()
{
  m_screenSaverTimer.StartZero();
}

void CApplicationPowerHandling::ResetSystemIdleTimer()
{
  // reset system idle timer
  m_idleTimer.StartZero();
}

void CApplicationPowerHandling::ResetNavigationTimer()
{
  m_navigationTimer.StartZero();
}

void CApplicationPowerHandling::SetRenderGUI(bool renderGUI)
{
  if (renderGUI && !m_renderGUI)
  {
    CGUIComponent* gui = CServiceBroker::GetGUI();
    if (gui)
      CServiceBroker::GetGUI()->GetWindowManager().MarkDirty();
  }
  m_renderGUI = renderGUI;
}

void CApplicationPowerHandling::StopScreenSaverTimer()
{
  m_screenSaverTimer.Stop();
}

bool CApplicationPowerHandling::ToggleDPMS(bool manual)
{
  auto winSystem = CServiceBroker::GetWinSystem();
  if (!winSystem)
    return false;

  std::shared_ptr<CDPMSSupport> dpms = winSystem->GetDPMSManager();
  if (!dpms)
    return false;

  if (manual || (m_dpmsIsManual == manual))
  {

Review comment (suggestion):
Rather than polling every cycle in the main thread, wouldn't it be better to dispatch a message instead? Something like `CServiceBroker::GetAppMessenger()->PostMsg(TMSG_RESTART_RENDERING);`.

And in https://github.com/xbmc/xbmc/blob/08948981a77af5856b9a6d925e718e2277e75688/xbmc/application/Application.cpp#L1391

```
  case TMSG_RESTART_RENDERING:
    CServiceBroker::GetGUI()->GetWindowManager().MarkDirty();
    break;
```

I don't have much experience in threading, but I'm curious if it could be done like this. It seems a lot cleaner to me.

Code after:

  // screen saver timer is reset only if we're not already in screensaver or
  // DPMS mode
  if ((!m_screensaverActive && m_iScreenSaveLock == 0) && !m_dpmsIsActive)
    ResetScreenSaverTimer();
}

void CApplicationPowerHandling::ResetScreenSaverTimer()
{
  m_screenSaverTimer.StartZero();
}

void CApplicationPowerHandling::ResetSystemIdleTimer()
{
  // reset system idle timer
  m_idleTimer.StartZero();
}

void CApplicationPowerHandling::ResetNavigationTimer()
{
  m_navigationTimer.StartZero();
}

void CApplicationPowerHandling::SetRenderGUI(bool renderGUI)
{
  m_renderGUI = renderGUI;
}

void CApplicationPowerHandling::StopScreenSaverTimer()
{
  m_screenSaverTimer.Stop();
}

bool CApplicationPowerHandling::ToggleDPMS(bool manual)
{
  auto winSystem = CServiceBroker::GetWinSystem();
  if (!winSystem)
    return false;

  std::shared_ptr<CDPMSSupport> dpms = winSystem->GetDPMSManager();
  if (!dpms)
    return false;

  if (manual || (m_dpmsIsManual == manual))
  {
    if (m_dpmsIsActive)
    {
      m_dpmsIsActive = false;
      m_dpmsIsManual = false;
      SetRenderGUI(true);
      CheckOSScreenSaverInhibitionSetting();
Repository: xbmc/xbmc
File: xbmc/CueDocument.cpp (C++)

Code before:
#include "utils/CharsetConverter.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/log.h"

#include <cstdlib>
#include <set>

using namespace XFILE;

// Stuff for read CUE data from different sources.
class CueReader
{
public:
  virtual bool ready() const = 0;
  virtual bool ReadLine(std::string &line) = 0;
  virtual ~CueReader() = default;
private:
  std::string m_sourcePath;
};

class FileReader
  : public CueReader
{
public:
  explicit FileReader(const std::string &strFile) : m_szBuffer{}
  {
    m_opened = m_file.Open(strFile);
  }
  bool ReadLine(std::string &line) override
  {
    // Read the next line.
    while (m_file.ReadString(m_szBuffer, 1023)) // Bigger than MAX_PATH_SIZE, for usage with relax!
    {
      // Remove the white space at the beginning and end of the line.
      line = m_szBuffer;
      StringUtils::Trim(line);
      if (!line.empty())
        return true;
      // If we are here, we have an empty line so try the next line
    }
    return false;
  }
  bool ready() const override
  {
    return m_opened;
  }
  ~FileReader() override
  {
    if (m_opened)
      m_file.Close();

Review comment (suggestion):
one question, better to init `m_opened` in the member initializer list?
```cpp
explicit FileReader(const std::string& strFile) : m_opened(m_file.Open(strFile)) {}
```

Code after:
#include "utils/CharsetConverter.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/log.h"

#include <cstdlib>
#include <set>

using namespace XFILE;

// Stuff for read CUE data from different sources.
class CueReader
{
public:
  virtual bool ready() const = 0;
  virtual bool ReadLine(std::string &line) = 0;
  virtual ~CueReader() = default;
private:
  std::string m_sourcePath;
};

class FileReader
  : public CueReader
{
public:
  explicit FileReader(const std::string& strFile) { m_opened = m_file.Open(strFile); }
  bool ReadLine(std::string &line) override
  {
    // Read the next line.
    while (m_file.ReadString(m_szBuffer, 1023)) // Bigger than MAX_PATH_SIZE, for usage with relax!
    {
      // Remove the white space at the beginning and end of the line.
      line = m_szBuffer;
      StringUtils::Trim(line);
      if (!line.empty())
        return true;
      // If we are here, we have an empty line so try the next line
    }
    return false;
  }
  bool ready() const override
  {
    return m_opened;
  }
  ~FileReader() override
  {
    if (m_opened)
      m_file.Close();

  }
private:
Repository: xbmc/xbmc
File: xbmc/cores/EdlEdit.h (C/C++)

Code before:
#pragma once

namespace EDL
{

constexpr int EDL_ACTION_NONE = -1;

enum class Action
{
  CUT = 0,
  MUTE = 1,
  SCENE = 2,
  COMM_BREAK = 3
};

struct Edit
{
  int start = 0; // ms
  int end = 0; // ms
  Action action = Action::CUT;
};

/*!
 * @brief Specify the search direction for an EDL edit
*/
enum class EditDirection
{
  FORWARD, /*!< Search forward */
  BACKWARD /*!< Search backwards */
};

} // namespace EDL


Review comment (suggestion):
```suggestion
enum class EditDirection : bool
```
instead the default `int`

Code after:
/*
 *  Copyright (C) 2019 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

namespace EDL
{

constexpr int EDL_ACTION_NONE = -1;

enum class Action
{
  CUT = 0,
  MUTE = 1,
  SCENE = 2,
  COMM_BREAK = 3
};

struct Edit
{
  int start = 0; // ms
  int end = 0; // ms
  Action action = Action::CUT;
};

} // namespace EDL