summaryrefslogtreecommitdiff
path: root/sys/dxr3/ac3_padder.h
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-05-29 14:35:24 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-05-29 14:35:24 +0000
commit2c98438c994b119256ded007808f153a4a5b6f6a (patch)
treecec3d0eb0bc69a3aa6bdfd5cafab8fa81de69b93 /sys/dxr3/ac3_padder.h
parentbbd6f9804b1465a921dfe9c141ae511f1ebcb3e4 (diff)
downloadgstreamer-plugins-bad-2c98438c994b119256ded007808f153a4a5b6f6a.tar.gz
I'm too lazy to comment this
Original commit message from CVS: New dxr3 plugins from Martin Soto <soto@informatik.uni-kl.de>
Diffstat (limited to 'sys/dxr3/ac3_padder.h')
-rw-r--r--sys/dxr3/ac3_padder.h129
1 files changed, 129 insertions, 0 deletions
diff --git a/sys/dxr3/ac3_padder.h b/sys/dxr3/ac3_padder.h
new file mode 100644
index 000000000..c9a7447e0
--- /dev/null
+++ b/sys/dxr3/ac3_padder.h
@@ -0,0 +1,129 @@
+/* GStreamer
+ * Copyright (C) 2003 Martin Soto <martinsoto@users.sourceforge.net>
+ *
+ * ac3_padder.h: Pad AC3 frames for use with an SPDIF interface.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef AC3_PADDER_INC
+#define AC3_PADDER_INC
+
+#include <glib.h>
+
+
+/* Size of an IEC958 padded AC3 frame. */
+#define AC3P_IEC_FRAME_SIZE 6144
+/* Size of the IEC958 header. */
+#define AC3P_IEC_HEADER_SIZE 8
+/* Size of the AC3 header. */
+#define AC3P_AC3_HEADER_SIZE 7
+
+
+/* An IEC958 padded AC3 frame. */
+typedef struct {
+ /* IEC header. */
+ guchar header[AC3P_IEC_HEADER_SIZE];
+
+ /* Begin of AC3 header. */
+ guchar sync_byte1;
+ guchar sync_byte2;
+
+ guchar crc1[2];
+ guchar code;
+ guchar bsidmod;
+ guchar acmod;
+ /* End of AC3 header. */
+
+ unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE
+ - AC3P_AC3_HEADER_SIZE];
+} ac3p_iec958_burst_frame;
+
+
+/* Possible states for the reading automaton: */
+
+/* Searching for sync byte 1. */
+#define AC3P_STATE_SYNC1 1
+/* Searching for sync byte 2. */
+#define AC3P_STATE_SYNC2 2
+/* Reading AC3 header. */
+#define AC3P_STATE_HEADER 3
+/* Reading packet contents.*/
+#define AC3P_STATE_CONTENT 4
+
+
+/* Events generated by the parse function: */
+
+/* The parser needs new data to be pushed. */
+#define AC3P_EVENT_PUSH 1
+/* There is a new padded frame ready to read from the padder structure. */
+#define AC3P_EVENT_FRAME 2
+
+
+/* The internal state for the padder. */
+typedef struct {
+ guint state; /* State of the reading automaton. */
+
+ guchar *in_ptr; /* Input pointer, marking the current
+ postion in the input buffer. */
+ guint remaining; /* The number of bytes remaining in the current
+ reading buffer. */
+
+ guchar *out_ptr; /* Output pointer, marking the current
+ position in the output frame. */
+ guint bytes_to_copy;
+ /* Number of bytes that still must be copied
+ to the output frame *during this reading
+ stage*. */
+
+ guint ac3_frame_size;
+ /* The size in bytes of the pure AC3 portion
+ of the current frame. */
+
+ ac3p_iec958_burst_frame frame;
+ /* The current output frame. */
+} ac3_padder;
+
+
+
+extern void
+ac3p_init(ac3_padder *padder);
+
+extern void
+ac3p_push_data(ac3_padder *padder, guchar *data, guint size);
+
+extern int
+ac3p_parse(ac3_padder *padder);
+
+
+/**
+ * ac3p_frame
+ * @padder The padder structure.
+ *
+ * Returns a pointer to the padded frame contained in the padder.
+ */
+#define ac3p_frame(padder) ((guint *) &((padder)->frame))
+
+/**
+ * ac3p_frame_size
+ * @padder The padder structure.
+ *
+ * Returns the length in bytes of the last read raw AC3 frame.
+ */
+#define ac3p_frame_size(padder) ((padder)->ac3_frame_size)
+
+
+#endif