acmenc: fix whitespace

Convert to unix newlines, and reindent in some broken places.
This commit is contained in:
Michael Smith 2009-02-28 15:23:07 -08:00
parent ed72bba6a2
commit c475d9c012

View File

@ -21,7 +21,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* */
#endif
#include <windows.h>
#include <mmreg.h>
@ -36,7 +36,9 @@
*/
#define ACM_BUFFER_SIZE (64 * 1024)
enum
{ ARG_0, ARG_BITRATE
{
ARG_0,
ARG_BITRATE
};
#define DEFAULT_BITRATE 128000
@ -45,21 +47,27 @@
#define GST_CAT_DEFAULT acmenc_debug
GST_DEBUG_CATEGORY_STATIC (acmenc_debug);
static GstStaticPadTemplate acmenc_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, " "depth = (int)16, "
"width = (int)16, " "endianness = (int)" G_STRINGIFY (G_BYTE_ORDER)
", " "signed = (boolean)TRUE, " "channels = (int) [1,2], "
"rate = (int)[1, MAX]") );
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-int, "
"depth = (int)16, "
"width = (int)16, "
"endianness = (int)" G_STRINGIFY (G_BYTE_ORDER) ", "
"signed = (boolean)TRUE, "
"channels = (int) [1,2], " "rate = (int)[1, MAX]"));
static GstStaticPadTemplate acmenc_src_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static GstElementClass *parent_class = NULL;
typedef struct _ACMEncClass
{
GstElementClass parent_class;
HACMDRIVERID driverId;
} ACMEncClass;
typedef struct _ACMEnc
{
GstElement parent;
@ -86,12 +94,14 @@
int selected_bitrate;
GstCaps *output_caps;
} ACMEnc;
typedef struct _ACMEncParams
{
HACMDRIVERID driverId;
HMODULE dll;
gchar *name;
} ACMEncParams;
static GstCaps *
acmenc_caps_from_format (WAVEFORMATEX * fmt)
{
@ -99,7 +109,8 @@ acmenc_caps_from_format (WAVEFORMATEX * fmt)
(gst_riff_strf_auds *) fmt, NULL, NULL, NULL);
}
gboolean acmenc_set_input_format (ACMEnc * enc, WAVEFORMATEX * infmt)
gboolean
acmenc_set_input_format (ACMEnc * enc, WAVEFORMATEX * infmt)
{
infmt->wFormatTag = WAVE_FORMAT_PCM;
infmt->nChannels = enc->channels;
@ -111,7 +122,8 @@ acmenc_caps_from_format (WAVEFORMATEX * fmt)
return TRUE;
}
BOOL CALLBACK acmenc_format_enum (HACMDRIVERID driverId, LPACMFORMATDETAILS fd,
BOOL CALLBACK
acmenc_format_enum (HACMDRIVERID driverId, LPACMFORMATDETAILS fd,
DWORD_PTR dwInstance, DWORD fdwSupport)
{
ACMEnc *enc = (ACMEnc *) dwInstance;
@ -137,8 +149,7 @@ acmenc_caps_from_format (WAVEFORMATEX * fmt)
newbrdiff = abs (enc->selected_bitrate - fd->pwfx->nAvgBytesPerSec * 8);
oldbrdiff = abs (enc->selected_bitrate - enc->outfmt->nAvgBytesPerSec * 8);
if ((newmatch && (!oldmatch || (newbrdiff < oldbrdiff))) ||
(!newmatch && !oldmatch && (newbrdiff < oldbrdiff)))
{
(!newmatch && !oldmatch && (newbrdiff < oldbrdiff))) {
g_free (enc->outfmt);
enc->outfmt =
(WAVEFORMATEX *) g_malloc (fd->pwfx->cbSize + sizeof (WAVEFORMATEX));
@ -149,7 +160,8 @@ acmenc_caps_from_format (WAVEFORMATEX * fmt)
return TRUE;
}
gboolean acmenc_set_format (ACMEnc * enc)
gboolean
acmenc_set_format (ACMEnc * enc)
{
WAVEFORMATEX *in = NULL;
ACMFORMATDETAILS details;
@ -189,6 +201,7 @@ acmenc_caps_from_format (WAVEFORMATEX * fmt)
}
return TRUE;
}
static gboolean
acmenc_setup (ACMEnc * enc)
{
@ -236,6 +249,7 @@ acmenc_setup (ACMEnc * enc)
enc->is_setup = TRUE;
return TRUE;
}
static void
acmenc_teardown (ACMEnc * enc)
{
@ -264,6 +278,7 @@ acmenc_teardown (ACMEnc * enc)
enc->offset = 0;
enc->is_setup = FALSE;
}
static gboolean
acmenc_sink_setcaps (GstPad * pad, GstCaps * caps)
{
@ -278,13 +293,13 @@ acmenc_sink_setcaps (GstPad * pad, GstCaps * caps)
ret = acmenc_setup (enc);
return ret;
}
static GstFlowReturn
acmenc_push_output (ACMEnc * enc)
{
GstFlowReturn ret = GST_FLOW_OK;
if (enc->header.cbDstLengthUsed > 0) {
GstBuffer * outbuf =
gst_buffer_new_and_alloc (enc->header.cbDstLengthUsed);
GstBuffer *outbuf = gst_buffer_new_and_alloc (enc->header.cbDstLengthUsed);
memcpy (GST_BUFFER_DATA (outbuf), enc->header.pbDst,
enc->header.cbDstLengthUsed);
if (enc->outfmt->nAvgBytesPerSec > 0) {
@ -301,6 +316,7 @@ acmenc_push_output (ACMEnc * enc)
}
return ret;
}
static GstFlowReturn
acmenc_chain (GstPad * pad, GstBuffer * buf)
{
@ -325,8 +341,7 @@ acmenc_chain (GstPad * pad, GstBuffer * buf)
GST_WARNING_OBJECT (enc, "Failed to encode data");
break;
}
if (enc->header.cbSrcLengthUsed > 0)
{
if (enc->header.cbSrcLengthUsed > 0) {
if (enc->header.cbSrcLengthUsed != enc->header.cbSrcLength) {
/* Only part of input consumed */
@ -346,7 +361,8 @@ acmenc_chain (GstPad * pad, GstBuffer * buf)
return ret;
}
GstFlowReturn acmenc_finish_stream (ACMEnc * enc)
GstFlowReturn
acmenc_finish_stream (ACMEnc * enc)
{
MMRESULT res;
GstFlowReturn ret = GST_FLOW_OK;
@ -365,6 +381,7 @@ acmenc_chain (GstPad * pad, GstBuffer * buf)
ret = acmenc_push_output (enc);
return ret;
}
static gboolean
acmenc_sink_event (GstPad * pad, GstEvent * event)
{
@ -381,6 +398,7 @@ acmenc_sink_event (GstPad * pad, GstEvent * event)
}
return res;
}
static void
acmenc_dispose (GObject * obj)
{
@ -399,11 +417,11 @@ acmenc_init (ACMEnc * enc)
gst_pad_set_event_function (enc->sinkpad,
GST_DEBUG_FUNCPTR (acmenc_sink_event));
gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
enc->srcpad =
gst_pad_new_from_static_template (&acmenc_src_template, "src");
enc->srcpad = gst_pad_new_from_static_template (&acmenc_src_template, "src");
gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad);
enc->selected_bitrate = DEFAULT_BITRATE;
} static void
acmenc_set_property (GObject * obj, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
@ -416,6 +434,7 @@ acmenc_set_property (GObject * obj, guint prop_id, const GValue * value,
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
}
}
static void
acmenc_get_property (GObject * obj, guint prop_id, GValue * value,
GParamSpec * pspec)
@ -429,6 +448,7 @@ acmenc_get_property (GObject * obj, guint prop_id, GValue * value,
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
}
}
static void
acmenc_class_init (ACMEncClass * klass)
{
@ -464,8 +484,7 @@ acmenc_base_init (ACMEncClass * klass)
if (res) {
GST_WARNING ("Could not get driver details: %d", res);
}
shortname =
g_utf16_to_utf8 (driverdetails.szShortName, -1, NULL, NULL, NULL);
shortname = g_utf16_to_utf8 (driverdetails.szShortName, -1, NULL, NULL, NULL);
longname = g_utf16_to_utf8 (driverdetails.szLongName, -1, NULL, NULL, NULL);
details.longname = g_strdup_printf ("ACM Encoder: %s", (shortname
&& *shortname) ? shortname : params->name);
@ -480,6 +499,7 @@ acmenc_base_init (ACMEncClass * klass)
g_free (details.description);
klass->driverId = params->driverId;
}
static ACMEncParams *
acmenc_open_driver (wchar_t * filename)
{
@ -515,6 +535,7 @@ acmenc_open_driver (wchar_t * filename)
FreeLibrary (mod);
return NULL;
}
static gboolean
acmenc_register_file (GstPlugin * plugin, wchar_t * filename)
{
@ -525,7 +546,8 @@ acmenc_register_file (GstPlugin * plugin, wchar_t * filename)
sizeof (ACMEncClass),
(GBaseInitFunc) acmenc_base_init, NULL,
(GClassInitFunc) acmenc_class_init, NULL, NULL, sizeof (ACMEnc),
0, (GInstanceInitFunc) acmenc_init, };
0, (GInstanceInitFunc) acmenc_init,
};
params = acmenc_open_driver (filename);
if (!params)
return FALSE;
@ -553,6 +575,7 @@ acmenc_register_file (GstPlugin * plugin, wchar_t * filename)
g_free (type_name);
return TRUE;
}
static gboolean
acmenc_register (GstPlugin * plugin)
{
@ -573,8 +596,7 @@ acmenc_register (GstPlugin * plugin)
}
do {
char *filename =
g_utf16_to_utf8 (filedata.cFileName, -1, NULL, NULL, NULL);
char *filename = g_utf16_to_utf8 (filedata.cFileName, -1, NULL, NULL, NULL);
GST_INFO ("Registering ACM filter from file %s", filename);
if (acmenc_register_file (plugin, filedata.cFileName))
GST_INFO ("Loading filter from ACM '%s' succeeded", filename);
@ -586,6 +608,7 @@ acmenc_register (GstPlugin * plugin)
FindClose (find);
return TRUE;
}
static gboolean
plugin_init (GstPlugin * plugin)
{