Skip to content

Commit

Permalink
tidy: Clean up control flow jumps followed by else statements. (libmy…
Browse files Browse the repository at this point in the history
…thtv)

If the last statement in an "if" block unconditional changes the
control flow, then there is no need to follow that statement with an
else block.  Omitting the "else" statement and the indentation of the
subsequent block makes the code easier to follow.  These changes can
be easier to read using the "-b" flag to diff.

https://clang.llvm.org/extra/clang-tidy/checks/readability-else-after-return.html
  • Loading branch information
linuxdude42 committed Nov 23, 2019
1 parent 7c363a0 commit 25227da
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 63 deletions.
14 changes: 5 additions & 9 deletions mythtv/libs/libmythtv/channelscan/channelimporter.cpp
Expand Up @@ -211,16 +211,12 @@ uint ChannelImporter::DeleteChannels(
}

if (off_air_list.empty())
{
return 0;
}
else
{
// List of off-air channels (in database but not in the scan)
cout << endl << "Off-air channels (" << SimpleCountChannels(off_air_transports) << "):" << endl;
ChannelImporterBasicStats infoA = CollectStats(off_air_transports);
cout << FormatChannels(off_air_transports, &infoA).toLatin1().constData() << endl;
}

// List of off-air channels (in database but not in the scan)
cout << endl << "Off-air channels (" << SimpleCountChannels(off_air_transports) << "):" << endl;
ChannelImporterBasicStats infoA = CollectStats(off_air_transports);
cout << FormatChannels(off_air_transports, &infoA).toLatin1().constData() << endl;

// Ask user whether to delete all or some of these stale channels
// if some is selected ask about each individually
Expand Down
14 changes: 6 additions & 8 deletions mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp
Expand Up @@ -533,14 +533,12 @@ static bool parse_extinf(const QString &line,
nextChanNum = channel_number + 1;
return true;
}
else
{
// no valid channel number found use the default next one
LOG(VB_GENERAL, LOG_ERR, QString("No channel number found, using next available: %1 for channel: %2").arg(nextChanNum).arg(name));
channum = QString::number(nextChanNum);
nextChanNum++;
return true;
}

// no valid channel number found use the default next one
LOG(VB_GENERAL, LOG_ERR, QString("No channel number found, using next available: %1 for channel: %2").arg(nextChanNum).arg(name));
channum = QString::number(nextChanNum);
nextChanNum++;
return true;
}

// not one of the formats we support
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/decoders/mythnvdeccontext.cpp
Expand Up @@ -223,7 +223,7 @@ int MythNVDECContext::HwDecoderInit(AVCodecContext *Context)
return MythCodecContext::InitialiseDecoder2(Context, MythNVDECContext::InitialiseDecoder,
"Create NVDEC decoder");
}
else if (codec_is_nvdec_dec(m_codecID))
if (codec_is_nvdec_dec(m_codecID))
{
AVBufferRef *context = MythCodecContext::CreateDevice(AV_HWDEVICE_TYPE_CUDA, nullptr,
gCoreContext->GetSetting("NVDECDevice"));
Expand Down Expand Up @@ -387,7 +387,7 @@ bool MythNVDECContext::RetrieveFrame(AVCodecContext *Context, VideoFrame *Frame,
return false;
if (codec_is_nvdec_dec(m_codecID))
return RetrieveHWFrame(Frame, AvFrame);
else if (codec_is_nvdec(m_codecID))
if (codec_is_nvdec(m_codecID))
return GetBuffer(Context, Frame, AvFrame, 0);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/decoders/mythvaapicontext.cpp
Expand Up @@ -521,7 +521,7 @@ void MythVAAPIContext::InitVideoCodec(AVCodecContext *Context, bool SelectedStre
Context->get_format = MythVAAPIContext::GetFormat;
return;
}
else if (codec_is_vaapi_dec(m_codecID))
if (codec_is_vaapi_dec(m_codecID))
{
Context->get_format = MythVAAPIContext::GetFormat2;
DirectRendering = false;
Expand Down Expand Up @@ -625,8 +625,8 @@ void MythVAAPIContext::PostProcessFrame(AVCodecContext* Context, VideoFrame *Fra
Frame->deinterlace_allowed = Frame->deinterlace_allowed & ~DEINT_DRIVER;
return;
}
else if (kCodec_HEVC_VAAPI_DEC == m_codecID || kCodec_VP9_VAAPI_DEC == m_codecID ||
kCodec_VP8_VAAPI_DEC == m_codecID)
if (kCodec_HEVC_VAAPI_DEC == m_codecID || kCodec_VP9_VAAPI_DEC == m_codecID ||
kCodec_VP8_VAAPI_DEC == m_codecID)
{
// enabling VPP deinterlacing with these codecs breaks decoding for some reason.
// HEVC interlacing is not currently detected by FFmpeg and I can't find
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/mythvdpaucontext.cpp
Expand Up @@ -248,7 +248,7 @@ void MythVDPAUContext::InitVideoCodec(AVCodecContext *Context, bool SelectedStre
Context->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
return;
}
else if (codec_is_vdpau_dechw(m_codecID))
if (codec_is_vdpau_dechw(m_codecID))
{
Context->get_format = MythVDPAUContext::GetFormat2;
Context->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
Expand Down
28 changes: 14 additions & 14 deletions mythtv/libs/libmythtv/mythcodecid.cpp
Expand Up @@ -643,33 +643,33 @@ QString get_decoder_name(MythCodecID codec_id)
{
if (codec_is_vdpau(codec_id))
return "vdpau";
else if (codec_is_vdpau_dec(codec_id))
if (codec_is_vdpau_dec(codec_id))
return "vdpau-dec";
else if (codec_is_vaapi(codec_id))
if (codec_is_vaapi(codec_id))
return "vaapi";
else if (codec_is_vaapi_dec(codec_id))
if (codec_is_vaapi_dec(codec_id))
return "vaapi-dec";
else if (codec_is_dxva2(codec_id))
if (codec_is_dxva2(codec_id))
return "dxva2";
else if (codec_is_mediacodec(codec_id))
if (codec_is_mediacodec(codec_id))
return "mediacodec";
else if (codec_is_mediacodec_dec(codec_id))
if (codec_is_mediacodec_dec(codec_id))
return "mediacodec-dec";
else if (codec_is_nvdec(codec_id))
if (codec_is_nvdec(codec_id))
return "nvdec";
else if (codec_is_nvdec_dec(codec_id))
if (codec_is_nvdec_dec(codec_id))
return "nvdec-dec";
else if (codec_is_vtb(codec_id))
if (codec_is_vtb(codec_id))
return "vtb";
else if (codec_is_vtb_dec(codec_id))
if (codec_is_vtb_dec(codec_id))
return "vtb-dec";
else if (codec_is_v4l2(codec_id))
if (codec_is_v4l2(codec_id))
return "v4l2";
else if (codec_is_v4l2_dec(codec_id))
if (codec_is_v4l2_dec(codec_id))
return "v4l2-dec";
else if (codec_is_mmal(codec_id))
if (codec_is_mmal(codec_id))
return "mmal";
else if (codec_is_mmal_dec(codec_id))
if (codec_is_mmal_dec(codec_id))
return "mmal-dec";
return "ffmpeg";
}
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/opengl/mythegldmabuf.cpp
Expand Up @@ -235,8 +235,7 @@ vector<MythVideoTexture*> MythEGLDMABUF::CreateTextures(AVDRMFrameDescriptor* De
if (numlayers == 1)
return CreateComposed(Desc, Context, Frame);
// X layers with one plane each
else
return CreateSeparate(Desc, Context, Frame);
return CreateSeparate(Desc, Context, Frame);

LOG(VB_PLAYBACK, LOG_ERR, LOC + "Unknown DRM frame format");
return result;
Expand Down
5 changes: 1 addition & 4 deletions mythtv/libs/libmythtv/opengl/mythnvdecinterop.cpp
Expand Up @@ -293,10 +293,7 @@ vector<MythVideoTexture*> MythNVDECInterop::Acquire(MythRenderOpenGL *Context,
result.push_back(tex);
return result;
}
else
{
m_referenceFrames.clear();
}
m_referenceFrames.clear();
m_discontinuityCounter = Frame->frameCounter;

return result;
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/opengl/mythvaapidrminterop.cpp
Expand Up @@ -253,8 +253,7 @@ vector<MythVideoTexture*> MythVAAPIInteropDRM::Acquire(MythRenderOpenGL *Context
{
if (needreferenceframes)
return GetReferenceFrames();
else
return m_openglTextures[id];
return m_openglTextures[id];
}

OpenGLLocker locker(m_context);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/opengl/mythvaapiinterop.cpp
Expand Up @@ -46,9 +46,9 @@ MythOpenGLInterop::Type MythVAAPIInterop::GetInteropType(MythCodecID CodecId,
// best first
if (egl && MythVAAPIInteropDRM::IsSupported(Context)) // zero copy
return VAAPIEGLDRM;
else if (!egl && !wayland && MythVAAPIInteropGLXPixmap::IsSupported(Context)) // copy
if (!egl && !wayland && MythVAAPIInteropGLXPixmap::IsSupported(Context)) // copy
return VAAPIGLXPIX;
else if (!egl && !opengles && !wayland) // 2 * copy
if (!egl && !opengles && !wayland) // 2 * copy
return VAAPIGLXCOPY;
return Unsupported;
}
Expand Down Expand Up @@ -440,7 +440,7 @@ VASurfaceID MythVAAPIInterop::Deinterlace(VideoFrame *Frame, VASurfaceID Current
m_firstField = true;
break;
}
else if (ret != AVERROR(EAGAIN))
if (ret != AVERROR(EAGAIN))
break;
}

Expand Down
7 changes: 2 additions & 5 deletions mythtv/libs/libmythtv/opengl/mythvdpauinterop.cpp
Expand Up @@ -134,11 +134,8 @@ bool MythVDPAUInterop::InitNV(AVVDPAUDeviceContext* DeviceContext)
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Ready");
return true;
}
else
{
delete m_helper;
m_helper = nullptr;
}
delete m_helper;
m_helper = nullptr;
}

LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to retrieve procs");
Expand Down
12 changes: 6 additions & 6 deletions mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp
Expand Up @@ -380,17 +380,17 @@ bool MythVideoOutputOpenGL::CreateBuffers(MythCodecID CodecID, QSize Size)

if (codec_is_mediacodec(CodecID))
return m_videoBuffers.CreateBuffers(FMT_MEDIACODEC, Size, false, 1, 2, 2);
else if (codec_is_vaapi(CodecID))
if (codec_is_vaapi(CodecID))
return m_videoBuffers.CreateBuffers(FMT_VAAPI, Size, false, 2, 1, 4, m_maxReferenceFrames);
else if (codec_is_vtb(CodecID))
if (codec_is_vtb(CodecID))
return m_videoBuffers.CreateBuffers(FMT_VTB, Size, false, 1, 4, 2);
else if (codec_is_vdpau(CodecID))
if (codec_is_vdpau(CodecID))
return m_videoBuffers.CreateBuffers(FMT_VDPAU, Size, false, 2, 1, 4, m_maxReferenceFrames);
else if (codec_is_nvdec(CodecID))
if (codec_is_nvdec(CodecID))
return m_videoBuffers.CreateBuffers(FMT_NVDEC, Size, false, 2, 1, 4);
else if (codec_is_mmal(CodecID))
if (codec_is_mmal(CodecID))
return m_videoBuffers.CreateBuffers(FMT_MMAL, Size, false, 2, 1, 4);
else if (codec_is_v4l2(CodecID))
if (codec_is_v4l2(CodecID))
return m_videoBuffers.CreateBuffers(FMT_DRMPRIME, Size, false, 2, 1, 4);

return m_videoBuffers.CreateBuffers(FMT_YV12, Size, false, 1, 8, 4, m_maxReferenceFrames);
Expand Down
6 changes: 2 additions & 4 deletions mythtv/libs/libmythtv/videobuffers.cpp
Expand Up @@ -625,8 +625,7 @@ frame_queue_t::iterator VideoBuffers::BeginLock(BufferType Type)
frame_queue_t *queue = Queue(Type);
if (queue)
return queue->begin();
else
return m_available.begin();
return m_available.begin();
}

void VideoBuffers::EndLock(void)
Expand Down Expand Up @@ -1067,8 +1066,7 @@ const QString& DebugString(const VideoFrame *Frame, bool Short)
{
if (Short)
return dbg_str_arr_short[DebugNum(Frame) % DBG_STR_ARR_SIZE];
else
return dbg_str_arr[DebugNum(Frame) % DBG_STR_ARR_SIZE];
return dbg_str_arr[DebugNum(Frame) % DBG_STR_ARR_SIZE];
}

const QString& DebugString(uint FrameNum, bool Short)
Expand Down

0 comments on commit 25227da

Please sign in to comment.