Skip to content

Instantly share code, notes, and snippets.

@rcombs

rcombs/stdin Secret

Created December 22, 2016 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcombs/788e0485572441e4520e17e5565868ec to your computer and use it in GitHub Desktop.
Save rcombs/788e0485572441e4520e17e5565868ec to your computer and use it in GitHub Desktop.
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6fd8aa609b..3f105f8b31 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -189,6 +189,7 @@ void av_register_all(void)
REGISTER_DEMUXER (MM, mm);
REGISTER_MUXDEMUX(MMF, mmf);
REGISTER_MUXDEMUX(MOV, mov);
+ REGISTER_MUXDEMUX(MP1, mp1);
REGISTER_MUXDEMUX(MP2, mp2);
REGISTER_MUXDEMUX(MP3, mp3);
REGISTER_MUXER (MP4, mp4);
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 499aa45fd4..f530d69ee8 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -105,7 +105,8 @@ static int mpa_read_probe(AVProbeData *p, int layer)
if (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1;
else if(max_frames>200)return AVPROBE_SCORE_EXTENSION;
else if(max_frames>=4 && max_frames >= p->buf_size/10000) return AVPROBE_SCORE_EXTENSION / 2;
- else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size)
+ else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size &&
+ (p->buf_size < PROBE_BUF_MAX || layer == 3))
return p->buf_size < PROBE_BUF_MAX ? AVPROBE_SCORE_EXTENSION / 4 : AVPROBE_SCORE_EXTENSION - 2;
else if(first_frames > 1 && whole_used) return 5;
else if(max_frames>=1 && max_frames >= p->buf_size/10000) return 1;
@@ -615,5 +616,6 @@ AVInputFormat ff_mp##l##_demuxer = { \
.priv_class = &demuxer_class_##l, \
};
+DECLARE_LAYER(1, "mp1,mpa")
DECLARE_LAYER(2, "mp2,m2a,mpa")
DECLARE_LAYER(3, "mp3,mpa")
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 0edcd1cf99..76022563fa 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -337,6 +337,19 @@ AVOutputFormat ff_mlp_muxer = {
};
#endif
+#if CONFIG_MP1_MUXER
+AVOutputFormat ff_mp1_muxer = {
+ .name = "mp1",
+ .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
+ .mime_type = "audio/mpeg",
+ .extensions = "mp1,m1a,mups",
+ .audio_codec = AV_CODEC_ID_MP1,
+ .video_codec = AV_CODEC_ID_NONE,
+ .write_packet = ff_raw_write_packet,
+ .flags = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
#if CONFIG_MP2_MUXER
AVOutputFormat ff_mp2_muxer = {
.name = "mp2",
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 738211dd54..a071a3ec7d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -596,8 +596,8 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
goto fail;
if (id3v2_extra_meta) {
- if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
- !strcmp(s->iformat->name, "tta")) {
+ if (!strcmp(s->iformat->name, "mp1") || !strcmp(s->iformat->name, "mp2") || !strcmp(s->iformat->name, "mp3") ||
+ !strcmp(s->iformat->name, "aac") || !strcmp(s->iformat->name, "tta")) {
if ((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0)
goto fail;
} else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment