Skip to content

Commit

Permalink
AvFormatDecoder::GetFrame(): add local codec_id variable
Browse files Browse the repository at this point in the history
The context returned by MythCodecMap::GetCodecContext() would have its codec_id
and codec_type set equal to those of curstream and it makes more sense to
reference them directly.

The context will be passed to the various Process.*Packet() functions in a later
change.

No functional change.
  • Loading branch information
ulmus-scott authored and bennettpeter committed Jan 6, 2025
1 parent 1dec1d0 commit 36b5d4f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4781,6 +4781,7 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)
}

enum AVMediaType codec_type = curstream->codecpar->codec_type;
const AVCodecID codec_id = curstream->codecpar->codec_id;

if (storevideoframes && codec_type == AVMEDIA_TYPE_VIDEO)
{
Expand All @@ -4806,15 +4807,15 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)
}

if (codec_type == AVMEDIA_TYPE_SUBTITLE &&
curstream->codecpar->codec_id == AV_CODEC_ID_TEXT)
codec_id == AV_CODEC_ID_TEXT)
{
ProcessRawTextPacket(pkt);
av_packet_unref(pkt);
continue;
}

if (codec_type == AVMEDIA_TYPE_SUBTITLE &&
curstream->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT)
codec_id == AV_CODEC_ID_DVB_TELETEXT)
{
ProcessDVBDataPacket(curstream, pkt);
av_packet_unref(pkt);
Expand All @@ -4828,17 +4829,20 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)
continue;
}

AVCodecContext *ctx = m_codecMap.GetCodecContext(curstream);
if (!ctx)
// ensure there is an AVCodecContext for this stream
AVCodecContext *context = m_codecMap.GetCodecContext(curstream);
if (context == nullptr)
{
if (codec_type != AVMEDIA_TYPE_VIDEO)
{
LOG(VB_PLAYBACK, LOG_ERR, LOC +
QString("No codec for stream index %1, type(%2) id(%3:%4)")
.arg(pkt->stream_index)
.arg(AVMediaTypeToString(codec_type),
avcodec_get_name(curstream->codecpar->codec_id))
.arg(curstream->codecpar->codec_id));
.arg(QString::number(pkt->stream_index),
AVMediaTypeToString(codec_type),
avcodec_get_name(codec_id),
QString::number(codec_id)
)
);
// Process Stream Change in case we have no audio
if (codec_type == AVMEDIA_TYPE_AUDIO && !m_audio->HasAudioIn())
m_streamsChanged = true;
Expand Down Expand Up @@ -4896,8 +4900,8 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)
{
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Decoding - id(%1) type(%2)")
.arg(avcodec_get_name(ctx->codec_id),
AVMediaTypeToString(ctx->codec_type)));
.arg(avcodec_get_name(codec_id),
AVMediaTypeToString(codec_type)));
have_err = true;
break;
}
Expand Down

0 comments on commit 36b5d4f

Please sign in to comment.