Skip to content

Commit

Permalink
libmythtv: Remove PrivateDecoder
Browse files Browse the repository at this point in the history
Refs #259
  • Loading branch information
mark-kendall committed Oct 5, 2020
1 parent eda12d7 commit c1178fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 155 deletions.
124 changes: 33 additions & 91 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -13,7 +13,6 @@
#include "mythtvexp.h"
#include "mythconfig.h"
#include "avformatdecoder.h"
#include "privatedecoder.h"
#include "audiooutput.h"
#include "audiooutpututil.h"
#include "io/mythmediabuffer.h"
Expand Down Expand Up @@ -309,9 +308,7 @@ void AvFormatDecoder::GetDecoders(RenderOptions &opts)
{
opts.decoders->append("ffmpeg");
(*opts.equiv_decoders)["ffmpeg"].append("dummy");

MythCodecContext::GetDecoders(opts);
PrivateDecoder::GetDecoders(opts);
}

AvFormatDecoder::AvFormatDecoder(MythPlayer *parent,
Expand Down Expand Up @@ -359,7 +356,6 @@ AvFormatDecoder::~AvFormatDecoder()
delete m_ccd608;
delete m_ccd708;
delete m_ttd;
delete m_privateDec;
delete m_avcParser;
delete m_mythCodecCtx;

Expand Down Expand Up @@ -413,9 +409,6 @@ void AvFormatDecoder::CloseContext()
m_ic = nullptr;
fmt->flags &= ~AVFMT_NOFILE;
}

delete m_privateDec;
m_privateDec = nullptr;
m_avcParser->Reset();
}

Expand Down Expand Up @@ -736,8 +729,6 @@ void AvFormatDecoder::SeekReset(long long newKey, uint skipFrames,
if (enc && enc->internal)
avcodec_flush_buffers(enc);
}
if (m_privateDec)
m_privateDec->Reset();

// Free up the stored up packets
while (!m_storedPackets.isEmpty())
Expand Down Expand Up @@ -2335,8 +2326,6 @@ int AvFormatDecoder::ScanStreams(bool novideo)
.arg(get_decoder_name(m_videoCodecId)).arg(m_streamsChanged));
}

delete m_privateDec;
m_privateDec = nullptr;
m_avcParser->Reset();

QSize dim = get_video_dim(*enc);
Expand Down Expand Up @@ -2425,12 +2414,6 @@ int AvFormatDecoder::ScanStreams(bool novideo)
m_videoCodecId = kCodec_MPEG2;
}

// Use a PrivateDecoder if allowed in playerFlags AND matched
// via the decoder name
//m_privateDec = PrivateDecoder::Create(dec, m_playerFlags, enc);
//if (m_privateDec)
// thread_count = 1;

break;
}

Expand Down Expand Up @@ -3170,9 +3153,6 @@ void AvFormatDecoder::MpegPreProcessPkt(AVStream *stream, AVPacket *pkt)

if (changed || forceaspectchange)
{
if (m_privateDec)
m_privateDec->Reset();

// N.B. We now set the default scan to kScan_Ignore as interlaced detection based on frame
// size and rate is extremely error prone and FFmpeg gets it right far more often.
// As for H.264, if a decoder deinterlacer is in operation - the stream must be progressive
Expand Down Expand Up @@ -3282,9 +3262,6 @@ int AvFormatDecoder::H264PreProcessPkt(AVStream *stream, AVPacket *pkt)

if (fps_changed || res_changed || forcechange)
{
if (m_privateDec)
m_privateDec->Reset();

// N.B. we now set the default scan to kScan_Ignore as interlaced detection based on frame
// size and rate is extremely error prone and FFmpeg gets it right far more often.
// N.B. if a decoder deinterlacer is in use - the stream must be progressive
Expand Down Expand Up @@ -3411,56 +3388,44 @@ bool AvFormatDecoder::ProcessVideoPacket(AVStream *curstream, AVPacket *pkt, boo

bool sentPacket = false;
int ret2 = 0;
if (m_privateDec)
{
if (QString(m_ic->iformat->name).contains("avi") || !m_ptsDetected)
pkt->pts = pkt->dts;
// TODO disallow private decoders for dvd playback
// N.B. we do not reparse the frame as it breaks playback for
// everything but libmpeg2
ret = m_privateDec->GetFrame(curstream, mpa_pic, &gotpicture, pkt);
sentPacket = true;
}

m_avCodecLock.lock();
if (!m_useFrameTiming)
context->reordered_opaque = pkt->pts;

// SUGGESTION
// Now that avcodec_decode_video2 is deprecated and replaced
// by 2 calls (receive frame and send packet), this could be optimized
// into separate routines or separate threads.
// Also now that it always consumes a whole buffer some code
// in the caller may be able to be optimized.

// FilteredReceiveFrame will call avcodec_receive_frame and
// apply any codec-dependent filtering
ret = m_mythCodecCtx->FilteredReceiveFrame(context, mpa_pic);

if (ret == 0)
gotpicture = 1;
else
gotpicture = 0;
if (ret == AVERROR(EAGAIN))
ret = 0;
// If we got a picture do not send the packet until we have
// all available pictures
if (ret==0 && !gotpicture)
{
m_avCodecLock.lock();
if (!m_useFrameTiming)
context->reordered_opaque = pkt->pts;

// SUGGESTION
// Now that avcodec_decode_video2 is deprecated and replaced
// by 2 calls (receive frame and send packet), this could be optimized
// into separate routines or separate threads.
// Also now that it always consumes a whole buffer some code
// in the caller may be able to be optimized.

// FilteredReceiveFrame will call avcodec_receive_frame and
// apply any codec-dependent filtering
ret = m_mythCodecCtx->FilteredReceiveFrame(context, mpa_pic);

if (ret == 0)
gotpicture = 1;
ret2 = avcodec_send_packet(context, pkt);
if (ret2 == AVERROR(EAGAIN))
{
Retry = true;
ret2 = 0;
}
else
gotpicture = 0;
if (ret == AVERROR(EAGAIN))
ret = 0;
// If we got a picture do not send the packet until we have
// all available pictures
if (ret==0 && !gotpicture)
{
ret2 = avcodec_send_packet(context, pkt);
if (ret2 == AVERROR(EAGAIN))
{
Retry = true;
ret2 = 0;
}
else
{
sentPacket = true;
}
{
sentPacket = true;
}
m_avCodecLock.unlock();
}
m_avCodecLock.unlock();

if (ret < 0 || ret2 < 0)
{
Expand Down Expand Up @@ -3546,12 +3511,6 @@ bool AvFormatDecoder::ProcessVideoPacket(AVStream *curstream, AVPacket *pkt, boo
pts = pkt->dts;
m_ptsSelected = false;
}
else if (m_privateDec && m_privateDec->NeedsReorderedPTS() &&
mpa_pic->reordered_opaque != AV_NOPTS_VALUE)
{
pts = mpa_pic->reordered_opaque;
m_ptsSelected = true;
}
else if (m_faultyPts <= m_faultyDts && m_reorderedPtsDetected)
{
if (mpa_pic->reordered_opaque != AV_NOPTS_VALUE)
Expand Down Expand Up @@ -4860,21 +4819,6 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)

m_allowedQuit = m_audio->IsBufferAlmostFull();

if (m_privateDec && m_privateDec->HasBufferedFrames() &&
(m_selectedTrack[kTrackTypeVideo].m_av_stream_index > -1))
{
int got_picture = 0;
AVStream *stream = m_ic->streams[m_selectedTrack[kTrackTypeVideo]
.m_av_stream_index];
MythAVFrame mpa_pic;
if (!mpa_pic)
return false;

m_privateDec->GetFrame(stream, mpa_pic, &got_picture, nullptr);
if (got_picture)
ProcessVideoFrame(stream, mpa_pic);
}

while (!m_allowedQuit)
{
if (decodetype & kDecodeAudio)
Expand Down Expand Up @@ -5225,8 +5169,6 @@ bool AvFormatDecoder::GenerateDummyVideoFrames(void)

QString AvFormatDecoder::GetCodecDecoderName(void) const
{
if (m_privateDec)
return m_privateDec->GetName();
return get_decoder_name(m_videoCodecId);
}

Expand Down
3 changes: 0 additions & 3 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.h
Expand Up @@ -11,7 +11,6 @@
#include "programinfo.h"
#include "format.h"
#include "decoderbase.h"
#include "privatedecoder.h"
#include "audiooutputsettings.h"
#include "audiooutpututil.h"
#include "spdifencoder.h"
Expand Down Expand Up @@ -259,8 +258,6 @@ class AvFormatDecoder : public DecoderBase

virtual int ReadPacket(AVFormatContext *ctx, AVPacket *pkt, bool &storePacket);

PrivateDecoder *m_privateDec {nullptr};

bool m_isDbIgnored;

AVCParser *m_avcParser {nullptr};
Expand Down
16 changes: 0 additions & 16 deletions mythtv/libs/libmythtv/decoders/privatedecoder.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions mythtv/libs/libmythtv/decoders/privatedecoder.h

This file was deleted.

2 changes: 0 additions & 2 deletions mythtv/libs/libmythtv/libmythtv.pro
Expand Up @@ -410,12 +410,10 @@ using_frontend {
# A/V decoders
HEADERS += decoders/decoderbase.h
HEADERS += decoders/avformatdecoder.h
HEADERS += decoders/privatedecoder.h
HEADERS += decoders/mythcodeccontext.h
HEADERS += decoders/mythdecoderthread.h
SOURCES += decoders/decoderbase.cpp
SOURCES += decoders/avformatdecoder.cpp
SOURCES += decoders/privatedecoder.cpp
SOURCES += decoders/mythcodeccontext.cpp
SOURCES += decoders/mythdecoderthread.cpp

Expand Down

0 comments on commit c1178fb

Please sign in to comment.