[MPlayer-dev-eng] PATCH 2/5: pl_invert

Tobias Diedrich td at informatik.uni-hannover.de
Sun Dec 9 04:01:33 CET 2001


This adds a plugin which will invert one channel of a stereo signal.
Usefull for playing Rurouni Kenshin DVD 1, where due to a mastering
error one stereo channel is inverted, resulting in spoken dialogue
mostly coming from the rear without this patch (On a surround amplifier,
that is).

Depends on pl_multi because it patches the Makefile too.

-- 
Tobias								PGP: 0x9AC7E0BC
Hannover Fantreffen ML: mailto:fantreffen-request at mantrha.de?subject=subscribe
Manga & Anime Treff Hannover: http://www.mantrha.de/
-------------- next part --------------
diff -urN main-current/libao2/Makefile main-multi/libao2/Makefile
--- main-current/libao2/Makefile	Tue Dec  4 16:43:08 2001
+++ main-multi/libao2/Makefile	Sun Dec  9 03:07:14 2001
@@ -4,7 +4,7 @@
 LIBNAME = libao2.a
 
 # TODO: moveout ao_sdl.c so it's only used when SDL is detected
-SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_multi.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c $(OPTIONAL_SRCS)
+SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_multi.c ao_plugin.c pl_delay.c pl_invert.c pl_format.c pl_surround.c $(OPTIONAL_SRCS)
 OBJS=$(SRCS:.c=.o)
 
 CFLAGS  = $(OPTFLAGS) -I. -I.. $(SDL_INC) $(X11_INC) $(EXTRA_INC)
diff -urN main-current/libao2/audio_plugin.h main-multi/libao2/audio_plugin.h
--- main-current/libao2/audio_plugin.h	Wed Dec  5 11:31:10 2001
+++ main-multi/libao2/audio_plugin.h	Sun Dec  9 03:09:26 2001
@@ -48,17 +48,19 @@
 // This block should not be available in the pl_xxxx files
 // due to compilation issues
 #ifndef PLUGIN
-#define NPL 3+1 // Number of PLugins ( +1 list ends with NULL )
+#define NPL 4+1 // Number of PLugins ( +1 list ends with NULL )
 // List of plugins 
 extern ao_plugin_functions_t audio_plugin_delay;
 extern ao_plugin_functions_t audio_plugin_format; 
 extern ao_plugin_functions_t audio_plugin_surround;
+extern ao_plugin_functions_t audio_plugin_invert;
 
 
 #define AO_PLUGINS { \
    &audio_plugin_delay, \
    &audio_plugin_format, \
    &audio_plugin_surround, \
+   &audio_plugin_invert, \
    NULL \
 }
 #endif /* PLUGIN */
diff -urN main-current/libao2/pl_invert.c main-multi/libao2/pl_invert.c
--- main-current/libao2/pl_invert.c	Thu Jan  1 01:00:00 1970
+++ main-multi/libao2/pl_invert.c	Sun Dec  9 03:18:54 2001
@@ -0,0 +1,64 @@
+/* Derived from the delay plugin.
+   This plugin inverts one audio channel of a 2 channel AFMT_S16_LE
+   audio stream. What for ?
+   I happen to have a DVD with a mastering error, where one channel
+   is inverted. On a dolby surround amplifier this means the voices
+   will come from your surround boxes... Doh!
+   This does fix that...
+*/
+#define PLUGIN
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "audio_out.h"
+#include "audio_plugin.h"
+#include "audio_plugin_internal.h"
+#include "afmt.h"
+
+static ao_info_t info =
+{
+        "Invert audio plugin",
+        "invert",
+        "Tobias Diedrich",
+        ""
+};
+
+LIBAO_PLUGIN_EXTERN(invert)
+
+// to set/get/query special features/parameters
+static int control(int cmd,int arg){
+  return -1;
+}
+
+// open & setup audio device
+// return: 1=success 0=fail
+static int init(){
+  if (ao_plugin_data.format != AFMT_S16_LE) {
+    printf("[pl_invert] Sorry, this audio format is unsupported :-(\n");
+    return 0;
+  }
+
+  return 1;
+}
+
+// close plugin
+static void uninit(){
+}
+
+// empty buffers
+static void reset(){
+}
+
+// processes 'ao_plugin_data.len' bytes of 'data'
+// called for every block of data
+static int play(){
+  int i=0;
+
+  int16_t *data = ao_plugin_data.data;
+  while (i<ao_plugin_data.len) {
+    data[i >> 1] = -data[i >> 1];
+    i+=4;
+  }
+  return 1;
+}


More information about the MPlayer-dev-eng mailing list