summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-08-17 18:18:27 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-08-17 18:18:27 +0200
commit63ce7ed7a6849e85d3a87f1b6a4eab43720d705e (patch)
tree8636e5c9a4116c3ac9eee0446bf12744ed0bafde
parentb0ac9c1ffb46aa06541b276f209d80eba24e99df (diff)
Added LAME encoder.
-rw-r--r--encoders/encoder_lame.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/encoders/encoder_lame.c b/encoders/encoder_lame.c
new file mode 100644
index 0000000..5c48913
--- /dev/null
+++ b/encoders/encoder_lame.c
@@ -0,0 +1,35 @@
+#include "encoder.h"
+
+#include <lame/lame.h>
+
+static gboolean lame_encoder_init(gpointer *data) {
+ lame_global_flags *gfp;
+
+ gfp = lame_init();
+ int ret = lame_init_params(gfp);
+ *data = gfp;
+
+ return (ret >= 0 ? TRUE : FALSE);
+}
+
+static gssize lame_encoder_encode(gpointer data, const guchar *inbuf, gsize inbuf_size,
+ guchar *outbuf, gsize outbuf_size) {
+ lame_global_flags *gfp = data;
+
+ int ret = lame_encode_buffer_interleaved(gfp, (short*)inbuf, inbuf_size / 4,
+ outbuf, outbuf_size);
+
+ return ret;
+}
+
+static void lame_encoder_close(gpointer data) {
+ lame_global_flags *gfp = data;
+ lame_close(gfp);
+}
+
+const struct encoder_plugin encoder_lame_encoder = {
+ .name = "lame encoder",
+ .init = lame_encoder_init,
+ .encode = lame_encoder_encode,
+ .close = lame_encoder_close,
+};