[MPlayer-dev-eng] [PATCH] To Play TTA in MKA

zo came camezo at gmail.com
Tue Nov 21 11:09:56 CET 2006


> this is not valid c code, __attribute__((__packed__)) will only work with
> gcc and compatible compilers, yes i know mplayer is full of this shit but
> IMHO we shouldnt add more especially as ita trivial to do this portably

Okay, I made a code that removed it.
And, I fixed a bug about samples data length with ceil().

[TEST]
Download from http://www.matroska.org/tta/
sample_44_2_16.tta and sample_44_2_16_TTA.mka

mplayer -ao pcm:file=tta sample_44_2_16.tta
mplayer -ao pcm:file=mka sample_44_2_16_TTA.mka
diff tta mka
"tta" and "mka" became the same data.

thanks
-------------- next part --------------
Index: libmpdemux/matroska.h
===================================================================
--- libmpdemux/matroska.h	(revision 21118)
+++ libmpdemux/matroska.h	(working copy)
@@ -35,6 +35,7 @@
 #define MKV_A_QDMC       "A_QUICKTIME/QDMC"
 #define MKV_A_QDMC2      "A_QUICKTIME/QDM2"
 #define MKV_A_FLAC       "A_FLAC"
+#define MKV_A_TTA        "A_TTA1"
 
 #define MKV_V_MSCOMP     "V_MS/VFW/FOURCC"
 #define MKV_V_REALV10    "V_REAL/RV10"
Index: libmpdemux/demux_mkv.c
===================================================================
--- libmpdemux/demux_mkv.c	(revision 21118)
+++ libmpdemux/demux_mkv.c	(working copy)
@@ -2068,6 +2068,10 @@
             }
           track->a_formattag = mmioFOURCC ('f', 'L', 'a', 'C');
         }
+      else if (!strcmp(track->codec_id, MKV_A_TTA))
+        {
+		track->a_formattag = 0x77A1;
+        }
       else if (track->private_size >= sizeof (real_audio_v4_props_t))
         {
           if (!strcmp(track->codec_id, MKV_A_REAL28))
@@ -2307,6 +2311,31 @@
       dp->flags = 0;
       ds_add_packet (demuxer->audio, dp);
     }
+  else if (track->a_formattag == 0x77A1)  /* TTA */
+    {
+      /* Create TTA Header. not sure */
+      enum { TTAH_FORMAT=0, TTAH_AFORMAT=4, TTAH_CHANNELS=6, TTAH_BPS=8,
+      TTAH_SFREQ=10, TTAH_SLEN=14, TTAH_CRC=18, TTAH_SEEKTABLE=22,
+      TTAH_SEEKTABLE2=26, TTAH_SIZE=30 };
+      sh_a->wf->nAvgBytesPerSec = sh_a->channels * sh_a->samplerate*2;
+      sh_a->wf->nBlockAlign = sh_a->wf->nAvgBytesPerSec;
+      sh_a->format = mmioFOURCC('T', 'T', 'A', '1');
+      sh_a->wf->cbSize = TTAH_SIZE; /* need over 30 */
+      sh_a->wf = realloc (sh_a->wf,
+                          sizeof (WAVEFORMATEX) + sh_a->wf->cbSize);
+#define TTAH_SET16(a,b) {uint16_t w16=le2me_16(b); memcpy((char *)(sh_a->wf + 1)+(a),&w16,2);}
+#define TTAH_SET32(a,b) {uint32_t w32=le2me_32(b); memcpy((char *)(sh_a->wf + 1)+(a),&w32,4);}
+      memcpy((char *)(sh_a->wf + 1)+TTAH_FORMAT,&(sh_a->format),4);
+#define FORMAT_INT 1
+      TTAH_SET16(TTAH_AFORMAT,FORMAT_INT);
+      TTAH_SET16(TTAH_CHANNELS,track->a_channels);
+      TTAH_SET16(TTAH_BPS,track->a_bps);
+      TTAH_SET32(TTAH_SFREQ,track->a_sfreq);
+      TTAH_SET32(TTAH_SLEN,(uint32_t)ceil(mkv_d->duration * track->a_sfreq));
+      TTAH_SET32(TTAH_CRC,0); /*dummy*/
+      TTAH_SET32(TTAH_SEEKTABLE,0); /*dummy*/
+      TTAH_SET32(TTAH_SEEKTABLE2,0); /*dummy*/
+    }
   else if (!track->ms_compat || (track->private_size < sizeof(WAVEFORMATEX)))
     {
       free_sh_audio(demuxer, track->tnum);


More information about the MPlayer-dev-eng mailing list