Skip to content

Commit

Permalink
remove FFmpeg addition ff_codec_type_string()
Browse files Browse the repository at this point in the history
replace with av_get_media_type_string in ffmpeg and copy to only
user as AVMediaTypeToString: libs/libmythtv/decoders/avformatdecoder.cpp
  • Loading branch information
ulmus-scott authored and bennettpeter committed Jul 1, 2022
1 parent 0102a80 commit 83e4cdb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
1 change: 0 additions & 1 deletion mythtv/external/FFmpeg/libavcodec/avcodec.h
Expand Up @@ -4183,7 +4183,6 @@ int avcodec_is_open(AVCodecContext *s);

/* MythTV */
const char *ff_codec_id_string(enum AVCodecID codec_id);
const char *ff_codec_type_string(enum AVMediaType codec_type);
const uint8_t *avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);


Expand Down
1 change: 0 additions & 1 deletion mythtv/external/FFmpeg/libavcodec/libavcodec.v
Expand Up @@ -4,7 +4,6 @@ LIBAVCODEC_MAJOR {
ff_ue_golomb_vlc_code;
ff_golomb_vlc_len;
ff_se_golomb_vlc_code;
ff_codec_type_string;
ff_codec_id_string;
ff_zigzag_direct;
avpriv_find_start_code;
Expand Down
18 changes: 0 additions & 18 deletions mythtv/external/FFmpeg/libavcodec/utils-mythtv.c
Expand Up @@ -224,21 +224,3 @@ const char *ff_codec_id_string(enum AVCodecID codec_id)
}
return "Unknown Codec ID";
}

/** \fn codec_type_string(enum CodecType)
* returns a human readable string for the CodecType enum.
*/
const char *ff_codec_type_string(enum AVMediaType codec_type)
{
switch (codec_type)
{
case AVMEDIA_TYPE_UNKNOWN: return "Unknown";
case AVMEDIA_TYPE_VIDEO: return "Video";
case AVMEDIA_TYPE_AUDIO: return "Audio";
case AVMEDIA_TYPE_DATA: return "Data";
case AVMEDIA_TYPE_SUBTITLE: return "Subtitle";
case AVMEDIA_TYPE_ATTACHMENT: return "Attachment";
}
return "Invalid Codec Type";
};

4 changes: 2 additions & 2 deletions mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c
Expand Up @@ -2104,7 +2104,7 @@ static void mpegts_add_stream(MpegTSContext *ts, int id, pmt_entry_t* item,
av_log(NULL, AV_LOG_DEBUG, "mpegts_add_stream: "
"stream #%d, has id 0x%x and codec %s, type %s at 0x%x\n",
st->index, st->id, ff_codec_id_string(st->codecpar->codec_id),
ff_codec_type_string(st->codecpar->codec_type), st);
av_get_media_type_string(st->codecpar->codec_type), st);
} else {
PESContext *pes = NULL;

Expand Down Expand Up @@ -2167,7 +2167,7 @@ static void mpegts_add_stream(MpegTSContext *ts, int id, pmt_entry_t* item,
av_log(NULL, AV_LOG_DEBUG, "mpegts_add_stream: "
"stream #%d, has id 0x%x and codec %s, type %s at 0x%x\n",
st->index, st->id, ff_codec_id_string(st->codecpar->codec_id),
ff_codec_type_string(st->codecpar->codec_type), st);
av_get_media_type_string(st->codecpar->codec_type), st);
}
add_pid_to_pmt(ts, id, pid);
av_program_add_stream_index(ts->stream, id, st->index);
Expand Down
43 changes: 31 additions & 12 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -332,6 +332,25 @@ static int get_canonical_lang(const char *lang_cstr)
return iso639_key_to_canonical_key(lang);
}

/** @brief returns a human readable string for the AVMediaType enum.
av_get_media_type_string() from <libavutil/avutil.h> returns NULL for unknown or
invalid codec_type, so use this instead.
*/
static const char* AVMediaTypeToString(enum AVMediaType codec_type)
{
switch (codec_type)
{
case AVMEDIA_TYPE_UNKNOWN: return "Unknown";
case AVMEDIA_TYPE_VIDEO: return "Video";
case AVMEDIA_TYPE_AUDIO: return "Audio";
case AVMEDIA_TYPE_DATA: return "Data";
case AVMEDIA_TYPE_SUBTITLE: return "Subtitle";
case AVMEDIA_TYPE_ATTACHMENT: return "Attachment";
default: return "Invalid Codec Type";
}
}

AvFormatDecoder::AvFormatDecoder(MythPlayer *parent,
const ProgramInfo &pginfo,
PlayerFlags flags)
Expand Down Expand Up @@ -1479,7 +1498,7 @@ void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc,
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("InitVideoCodec ID:%1 Type:%2 Size:%3x%4")
.arg(ff_codec_id_string(enc->codec_id),
ff_codec_type_string(enc->codec_type))
AVMediaTypeToString(enc->codec_type))
.arg(enc->width).arg(enc->height));

if (m_ringBuffer && m_ringBuffer->IsDVD())
Expand Down Expand Up @@ -1989,7 +2008,7 @@ int AvFormatDecoder::ScanStreams(bool novideo)
AVCodecParameters *par = m_ic->streams[strm]->codecpar;
AVCodecContext *enc = nullptr;

QString codectype(ff_codec_type_string(par->codec_type));
QString codectype(AVMediaTypeToString(par->codec_type));
if (par->codec_type == AVMEDIA_TYPE_VIDEO)
codectype += QString("(%1x%2)").arg(par->width).arg(par->height);
LOG(VB_PLAYBACK, LOG_INFO, LOC +
Expand Down Expand Up @@ -2057,7 +2076,7 @@ int AvFormatDecoder::ScanStreams(bool novideo)
"type (%3) already open, leaving it alone.")
.arg(reinterpret_cast<unsigned long long>(enc), 0, 16)
.arg(ff_codec_id_string(enc->codec_id),
ff_codec_type_string(enc->codec_type)));
AVMediaTypeToString(enc->codec_type)));
}
LOG(VB_GENERAL, LOG_INFO, LOC +
QString("codec %1 has %2 channels")
Expand All @@ -2076,15 +2095,15 @@ int AvFormatDecoder::ScanStreams(bool novideo)
m_bitrate += par->bit_rate;

LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("subtitle codec (%1)")
.arg(ff_codec_type_string(par->codec_type)));
.arg(AVMediaTypeToString(par->codec_type)));
break;
}
case AVMEDIA_TYPE_DATA:
{
ScanTeletextCaptions(static_cast<int>(strm));
m_bitrate += par->bit_rate;
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("data codec (%1)")
.arg(ff_codec_type_string(par->codec_type)));
.arg(AVMediaTypeToString(par->codec_type)));
break;
}
case AVMEDIA_TYPE_ATTACHMENT:
Expand All @@ -2095,15 +2114,15 @@ int AvFormatDecoder::ScanStreams(bool novideo)
m_bitrate += par->bit_rate;
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("Attachment codec (%1)")
.arg(ff_codec_type_string(par->codec_type)));
.arg(AVMediaTypeToString(par->codec_type)));
break;
}
default:
{
m_bitrate += par->bit_rate;
LOG(VB_PLAYBACK, LOG_ERR, LOC +
QString("Unknown codec type (%1)")
.arg(ff_codec_type_string(par->codec_type)));
.arg(AVMediaTypeToString(par->codec_type)));
break;
}
}
Expand Down Expand Up @@ -2313,7 +2332,7 @@ int AvFormatDecoder::ScanStreams(bool novideo)
m_tracks[kTrackTypeVideo].push_back(si);
m_selectedTrack[kTrackTypeVideo] = si;

QString codectype(ff_codec_type_string(enc->codec_type));
QString codectype(AVMediaTypeToString(enc->codec_type));
if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
codectype += QString("(%1x%2)").arg(enc->width).arg(enc->height);
LOG(VB_PLAYBACK, LOG_INFO, LOC +
Expand Down Expand Up @@ -2536,7 +2555,7 @@ bool AvFormatDecoder::OpenAVCodec(AVCodecContext *avctx, const AVCodec *codec)
QString("Could not open codec 0x%1, id(%2) type(%3) "
"ignoring. reason %4").arg((uint64_t)avctx,0,16)
.arg(ff_codec_id_string(avctx->codec_id),
ff_codec_type_string(avctx->codec_type),
AVMediaTypeToString(avctx->codec_type),
av_make_error_stdstring(error, ret)));
return false;
}
Expand All @@ -2545,7 +2564,7 @@ bool AvFormatDecoder::OpenAVCodec(AVCodecContext *avctx, const AVCodec *codec)
QString("Opened codec 0x%1, id(%2) type(%3)")
.arg((uint64_t)avctx,0,16)
.arg(ff_codec_id_string(avctx->codec_id),
ff_codec_type_string(avctx->codec_type)));
AVMediaTypeToString(avctx->codec_type)));
return true;
}

Expand Down Expand Up @@ -5030,7 +5049,7 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)
LOG(VB_PLAYBACK, LOG_ERR, LOC +
QString("No codec for stream index %1, type(%2) id(%3:%4)")
.arg(pkt->stream_index)
.arg(ff_codec_type_string(codec_type),
.arg(AVMediaTypeToString(codec_type),
ff_codec_id_string(curstream->codecpar->codec_id))
.arg(curstream->codecpar->codec_id));
// Process Stream Change in case we have no audio
Expand Down Expand Up @@ -5091,7 +5110,7 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype, bool &Retry)
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Decoding - id(%1) type(%2)")
.arg(ff_codec_id_string(ctx->codec_id),
ff_codec_type_string(ctx->codec_type)));
AVMediaTypeToString(ctx->codec_type)));
have_err = true;
break;
}
Expand Down

0 comments on commit 83e4cdb

Please sign in to comment.