[MPlayer-dev-eng] [PATCH] Support for AAC in RealMedia files

Moritz Bunkus moritz at bunkus.org
Sat Jan 24 15:12:58 CET 2004


Heya,

here's a patch that adds support for AAC in RealMedia files. Those have
a fourcc of 'raac' (both normal or HE AAC) or 'racp' (HE AAC
only). Samples can be found at Karl Lillevold's site:
http://www.lillevold.com/files/aac_samples/

Please note that rm_he-aac96_51.rm does not play which is probably due
to libfaad being too old.

Mosu

-- 
If Darl McBride was in charge, he'd probably make marriage
unconstitutional too, since clearly it de-emphasizes the commercial
nature of normal human interaction, and probably is a major impediment
to the commercial growth of prostitution. - Linus Torvalds
-------------- next part --------------
Index: demux_real.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_real.c,v
retrieving revision 1.52
diff -u -r1.52 demux_real.c
--- demux_real.c	16 Jan 2004 22:38:55 -0000	1.52
+++ demux_real.c	24 Jan 2004 14:08:06 -0000
@@ -581,6 +581,26 @@
 	    static int cnt=0;
 	    static int cnt2=CRACK_MATRIX;
 #endif
+	    if (((sh_audio_t *)ds->sh)->format == mmioFOURCC('M', 'P', '4', 'A')) {
+		uint16_t *sub_packet_lengths, sub_packets, i;
+		/* AAC in Real: several AAC frames in one Real packet. */
+		/* Second byte, upper four bits: number of AAC frames */
+		/* next n * 2 bytes: length of the AAC frames in bytes, BE */
+		sub_packets = (stream_read_word(demuxer->stream) & 0xf0) >> 4;
+		sub_packet_lengths = calloc(sub_packets, sizeof(uint16_t));
+		for (i = 0; i < sub_packets; i++)
+		    sub_packet_lengths[i] = stream_read_word(demuxer->stream);
+		for (i = 0; i < sub_packets; i++) {
+		    demux_packet_t *dp = new_demux_packet(sub_packet_lengths[i]);
+		    stream_read(demuxer->stream, dp->buffer, sub_packet_lengths[i]);
+		    dp->pts = (priv->a_pts == timestamp) ? 0 : (timestamp / 1000.0f);
+		    priv->a_pts = timestamp;
+		    dp->pos = demuxer->filepos;
+		    ds_add_packet(ds, dp);
+		}
+		free(sub_packet_lengths);
+		return 1;
+	    }
             demux_packet_t *dp = new_demux_packet(len);
 	    stream_read(demuxer->stream, dp->buffer, len);
 #ifdef CRACK_MATRIX
@@ -1184,6 +1204,23 @@
 //			    stream_read(demuxer->stream, ((char*)(sh->wf+1))+6, 24); // extras
 			    stream_read(demuxer->stream, ((char*)(sh->wf+1))+10, codecdata_length); // extras
 			    break;
+			case MKTAG('r', 'a', 'a', 'c'):
+			case MKTAG('r', 'a', 'c', 'p'):
+			    /* This is just AAC. The two or five bytes of */
+			    /* config data needed for libfaad are stored */
+			    /* after the audio headers. */
+			    stream_skip(demuxer->stream,3);  // Skip 3 unknown bytes 
+			    if (version==5)
+				stream_skip(demuxer->stream,1);  // Skip 1 additional unknown byte 
+			    codecdata_length=stream_read_dword(demuxer->stream);
+			    if (codecdata_length>=1) {
+				sh->codecdata_len = codecdata_length - 1;
+				sh->codecdata = calloc(sh->codecdata_len, 1);
+				stream_skip(demuxer->stream, 1);
+				stream_read(demuxer->stream, sh->codecdata, sh->codecdata_len);
+			    }
+			    sh->format = mmioFOURCC('M', 'P', '4', 'A');
+			    break;
 			default:
 			    mp_msg(MSGT_DEMUX,MSGL_V,"Audio: Unknown (%s)\n", buf);
 		    }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20040124/105d13e4/attachment.pgp>


More information about the MPlayer-dev-eng mailing list