Skip to content

Commit 9ee8433

Browse files
committed
Return more compact & Applesque codec names.
1 parent 4dd2a17 commit 9ee8433

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

mdimporter/GetMetadataForFile.m

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attribute
229229
{
230230
AVStream *stream = fmt_ctx->streams[stream_idx];
231231
AVCodecContext *dec_ctx = stream->codec;
232-
AVCodec *codec;
233232

234233
if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO)
235234
{
@@ -286,9 +285,54 @@ Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attribute
286285
}
287286

288287
// All recognised types
289-
if ((codec = avcodec_find_decoder(dec_ctx->codec_id)))
288+
AVCodec *codec = avcodec_find_decoder(dec_ctx->codec_id);
289+
if (codec)
290290
{
291-
const char *name = (codec->long_name ? codec->long_name : codec->name);
291+
// Some of AVCodec.long_name can be too wordy (but .name too cryptic), so special-case some common
292+
// codecs to give more compact & Applesque names
293+
const char *name;
294+
switch (codec->id)
295+
{
296+
case AV_CODEC_ID_H263:
297+
name = "H.263"; break;
298+
case AV_CODEC_ID_H263P:
299+
name = "H.263+"; break;
300+
case AV_CODEC_ID_H264:
301+
name = "H.264"; break;
302+
case AV_CODEC_ID_HEVC:
303+
name = "H.265"; break;
304+
case AV_CODEC_ID_MJPEG:
305+
name = "Motion JPEG"; break;
306+
case AV_CODEC_ID_FLV1:
307+
name = "Sorenson Spark"; break;
308+
case AV_CODEC_ID_SVQ1:
309+
name = "Sorenson Video"; break;
310+
case AV_CODEC_ID_SVQ3:
311+
name = "Sorenson Video 3"; break;
312+
case AV_CODEC_ID_AAC:
313+
name = "AAC"; break;
314+
case AV_CODEC_ID_AC3:
315+
name = "AC-3"; break;
316+
case AV_CODEC_ID_DTS:
317+
name = "DTS"; break;
318+
case AV_CODEC_ID_FLAC:
319+
name = "FLAC"; break;
320+
case AV_CODEC_ID_MP2:
321+
name = "MPEG Layer 2"; break;
322+
case AV_CODEC_ID_MP3:
323+
name = "MPEG Layer 3"; break;
324+
case AV_CODEC_ID_ASS:
325+
name = "Advanced SubStation Alpha"; break;
326+
case AV_CODEC_ID_SSA:
327+
name = "SubStation Alpha"; break;
328+
case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
329+
name = "PGS subtitle"; break;
330+
case AV_CODEC_ID_SRT:
331+
name = "SubRip subtitle"; break;
332+
default:
333+
name = codec->long_name ? codec->long_name : codec->name;
334+
}
335+
292336
if (name)
293337
{
294338
const char *profile = av_get_profile_name(codec, dec_ctx->profile);

0 commit comments

Comments
 (0)