summaryrefslogtreecommitdiff
path: root/encoders/encoder_lame.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoders/encoder_lame.c')
-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,
+};