changeset 3862:c11ff84634b2 libavformat

create a separate codec_id for E-AC-3
author jbr
date Mon, 01 Sep 2008 14:33:54 +0000
parents a0098594ab90
children 9c384a47085f
files Makefile allformats.c raw.c
diffstat 3 files changed, 59 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Sep 01 13:51:24 2008 +0000
+++ b/Makefile	Mon Sep 01 14:33:54 2008 +0000
@@ -44,6 +44,8 @@
 OBJS-$(CONFIG_DXA_DEMUXER)               += dxa.o riff.o
 OBJS-$(CONFIG_EA_CDATA_DEMUXER)          += eacdata.o
 OBJS-$(CONFIG_EA_DEMUXER)                += electronicarts.o
+OBJS-$(CONFIG_EAC3_DEMUXER)              += raw.o
+OBJS-$(CONFIG_EAC3_MUXER)                += raw.o
 OBJS-$(CONFIG_FFM_DEMUXER)               += ffmdec.o
 OBJS-$(CONFIG_FFM_MUXER)                 += ffmenc.o
 OBJS-$(CONFIG_FLAC_DEMUXER)              += raw.o
--- a/allformats.c	Mon Sep 01 13:51:24 2008 +0000
+++ b/allformats.c	Mon Sep 01 14:33:54 2008 +0000
@@ -76,6 +76,7 @@
     REGISTER_DEMUXER  (DXA, dxa);
     REGISTER_DEMUXER  (EA, ea);
     REGISTER_DEMUXER  (EA_CDATA, ea_cdata);
+    REGISTER_MUXDEMUX (EAC3, eac3);
     REGISTER_MUXDEMUX (FFM, ffm);
     REGISTER_MUXDEMUX (FLAC, flac);
     REGISTER_DEMUXER  (FLIC, flic);
--- a/raw.c	Mon Sep 01 13:51:24 2008 +0000
+++ b/raw.c	Mon Sep 01 14:33:54 2008 +0000
@@ -487,8 +487,8 @@
 }
 #endif
 
-#ifdef CONFIG_AC3_DEMUXER
-static int ac3_probe(AVProbeData *p)
+#if (CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER)
+static int ac3_eac3_probe(AVProbeData *p, int *codec_id)
 {
     int max_frames, first_frames = 0, frames;
     uint8_t *buf, *buf2, *end;
@@ -499,6 +499,7 @@
     buf = p->buf;
     end = buf + p->buf_size;
 
+    *codec_id = CODEC_ID_AC3;
     for(; buf < end; buf++) {
         buf2 = buf;
 
@@ -509,6 +510,8 @@
             if(buf2 + hdr.frame_size > end ||
                av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
                 break;
+            if (hdr.bitstream_id > 10)
+                *codec_id = CODEC_ID_EAC3;
             buf2 += hdr.frame_size;
         }
         max_frames = FFMAX(max_frames, frames);
@@ -522,6 +525,28 @@
 }
 #endif
 
+#ifdef CONFIG_AC3_DEMUXER
+static int ac3_probe(AVProbeData *p)
+{
+    int codec_id = CODEC_ID_NONE;
+    int score = ac3_eac3_probe(p, &codec_id);
+    if(codec_id == CODEC_ID_AC3)
+        return score;
+    return 0;
+}
+#endif
+
+#ifdef CONFIG_EAC3_DEMUXER
+static int eac3_probe(AVProbeData *p)
+{
+    int codec_id = CODEC_ID_NONE;
+    int score = ac3_eac3_probe(p, &codec_id);
+    if(codec_id == CODEC_ID_EAC3)
+        return score;
+    return 0;
+}
+#endif
+
 #ifdef CONFIG_FLAC_DEMUXER
 static int flac_probe(AVProbeData *p)
 {
@@ -633,6 +658,35 @@
 };
 #endif
 
+#ifdef CONFIG_EAC3_DEMUXER
+AVInputFormat eac3_demuxer = {
+    "eac3",
+    NULL_IF_CONFIG_SMALL("raw E-AC-3"),
+    0,
+    eac3_probe,
+    audio_read_header,
+    raw_read_partial_packet,
+    .flags= AVFMT_GENERIC_INDEX,
+    .extensions = "eac3",
+    .value = CODEC_ID_EAC3,
+};
+#endif
+
+#ifdef CONFIG_EAC3_MUXER
+AVOutputFormat eac3_muxer = {
+    "eac3",
+    NULL_IF_CONFIG_SMALL("raw E-AC-3"),
+    "audio/x-eac3",
+    "eac3",
+    0,
+    CODEC_ID_EAC3,
+    CODEC_ID_NONE,
+    NULL,
+    raw_write_packet,
+    .flags= AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #ifdef CONFIG_FLAC_DEMUXER
 AVInputFormat flac_demuxer = {
     "flac",