static const char *lookup_tag(int type, uint32_t tag) { for (int n = 0; mp_codec_tags[n].codec; n++) { if (mp_codec_tags[n].tag == tag) return mp_codec_tags[n].codec; } const struct AVCodecTag *av_tags[3] = {0}; switch (type) { case STREAM_VIDEO: { av_tags[0] = avformat_get_riff_video_tags(); #if HAVE_QT_TAGS av_tags[1] = avformat_get_mov_video_tags(); #endif break; } case STREAM_AUDIO: { av_tags[0] = avformat_get_riff_audio_tags(); #if HAVE_QT_TAGS av_tags[1] = avformat_get_mov_audio_tags(); #endif break; } } int id = av_codec_get_id(av_tags, tag); return id == AV_CODEC_ID_NONE ? NULL : mp_codec_from_av_codec_id(id); }
static void add_decoders(struct mp_decoder_list *list) { for (int n = 0; codecs[n] != AV_CODEC_ID_NONE; n++) { const char *format = mp_codec_from_av_codec_id(codecs[n]); if (format) { mp_add_decoder(list, "spdif", format, format, "libavformat/spdifenc audio pass-through decoder"); } } }
static const char *lookup_tag(const struct mp_codec_tag *mp_table, const struct AVCodecTag *av_table, uint32_t tag) { for (int n = 0; mp_table[n].codec; n++) { if (mp_table[n].tag == tag) return mp_table[n].codec; } const struct AVCodecTag *av_tags[] = {av_table, NULL}; int id = av_codec_get_id(av_tags, tag); return id == AV_CODEC_ID_NONE ? NULL : mp_codec_from_av_codec_id(id); }
// (Abuses the decoder list data structures.) void mp_add_lavc_encoders(struct mp_decoder_list *list) { AVCodec *cur = NULL; for (;;) { cur = av_codec_next(cur); if (!cur) break; if (av_codec_is_encoder(cur)) { mp_add_decoder(list, "lavc", mp_codec_from_av_codec_id(cur->id), cur->name, cur->long_name); } } }
void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type) { AVCodec *cur = NULL; for (;;) { cur = av_codec_next(cur); if (!cur) break; if (av_codec_is_decoder(cur) && cur->type == type && !is_crap(cur)) { mp_add_decoder(list, "lavc", mp_codec_from_av_codec_id(cur->id), cur->name, cur->long_name); } } }
static void add_codecs(struct mp_decoder_list *list, enum AVMediaType type, bool decoders) { void *iter = NULL; for (;;) { const AVCodec *cur = av_codec_iterate(&iter); if (!cur) break; if (av_codec_is_decoder(cur) == decoders && (type == AVMEDIA_TYPE_UNKNOWN || cur->type == type)) { mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id), cur->name, cur->long_name); } } }