[Mplayer-cvslog] CVS: main/libmpcodecs ad_liba52.c,1.12,1.13

Alex Beregszaszi syncmail at mplayerhq.hu
Mon Apr 26 10:53:44 CEST 2004


CVS change done by Alex Beregszaszi

Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv18257/libmpcodecs

Modified Files:
	ad_liba52.c 
Log Message:
a52 dynamic range compression support by Peter Gansterer

Index: ad_liba52.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_liba52.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ad_liba52.c	2 Oct 2003 14:13:52 -0000	1.12
+++ ad_liba52.c	26 Apr 2004 08:53:41 -0000	1.13
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <math.h>
 
 #include "config.h"
 #ifdef USE_LIBA52
@@ -19,6 +20,13 @@
 static a52_state_t a52_state;
 static uint32_t a52_flags=0;
 
+#define DRC_NO_ACTION      0
+#define DRC_NO_COMPRESSION 1
+#define DRC_CALLBACK       2
+
+float a52_drc_level = 1.0;
+static int a52_drc_action = DRC_NO_ACTION;
+
 #include "bswap.h"
 
 static ad_info_t info = 
@@ -95,6 +103,11 @@
   return (flags&A52_LFE) ? (channels+1) : channels;
 }
 
+sample_t dynrng_call (sample_t c, void *data) {
+//	fprintf(stderr, "(%lf, %lf): %lf\n", (double)c, (double)a52_drc_level, (double)pow((double)c, a52_drc_level));
+	return pow((double)c, a52_drc_level);
+}
+
 
 static int preinit(sh_audio_t *sh)
 {
@@ -126,6 +139,21 @@
 	mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
 	return 0;
   }
+
+
+  /* Init a52 dynrng */
+  if (a52_drc_level < 0.001) {
+	  /* level == 0 --> no compression, init library without callback */
+	  a52_drc_action = DRC_NO_COMPRESSION;
+  } else if (a52_drc_level > 0.999) {
+	  /* level == 1 --> full compression, do nothing at all (library default = full compression) */
+	  a52_drc_action = DRC_NO_ACTION;
+  } else {
+	  a52_drc_action = DRC_CALLBACK;
+  }
+  /* Library init for dynrng has to be done for each frame, see decode_audio() */
+
+
   /* 'a52 cannot upmix' hotfix:*/
   a52_printinfo(sh_audio);
   sh_audio->channels=audio_output_channels;
@@ -186,6 +214,15 @@
 	    mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error decoding frame\n");
 	    return len;
 	}
+
+	/* handle dynrng */
+	if (a52_drc_action != DRC_NO_ACTION) {
+	    if (a52_drc_action == DRC_NO_COMPRESSION)
+		a52_dynrng(&a52_state, NULL, NULL);
+	    else
+		a52_dynrng(&a52_state, dynrng_call, NULL);
+	}
+
 	len=0;
 	for (i = 0; i < 6; i++) {
 	    if (a52_block (&a52_state, a52_samples)){




More information about the MPlayer-cvslog mailing list