From e9cfa88c707365e54aa75486fc8d102adf320da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 12 Oct 2005 13:54:34 +0000 Subject: [PATCH] ext/faac/gstfaac.c: Fix depth/width handling for float audio (#318659). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message from CVS: Reviewed by: Tim-Philipp Müller * ext/faac/gstfaac.c: (gst_faac_sink_setcaps): Fix depth/width handling for float audio (#318659). --- ChangeLog | 9 +++++- ext/faac/gstfaac.c | 80 +++++++++++++++++++++++++++++++--------------- 2 files changed, 63 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2bc477d01..f62c583026 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,17 @@ +2005-10-12 Josef Zlomek + + Reviewed by: Tim-Philipp Müller + + * ext/faac/gstfaac.c: (gst_faac_sink_setcaps): + Fix depth/width handling for float audio (#318659). + 2005-10-12 Josef Zlomek Reviewed by: Tim-Philipp Müller * ext/faac/gstfaac.c: (gst_faac_sink_setcaps), (gst_faac_src_setcaps), (gst_faac_chain): - Refcount fixes (#318659) + Refcount fixes (#318660) 2005-10-12 Julien MOUTTE diff --git a/ext/faac/gstfaac.c b/ext/faac/gstfaac.c index 3bd351fff1..fe3ea7ff77 100644 --- a/ext/faac/gstfaac.c +++ b/ext/faac/gstfaac.c @@ -22,21 +22,46 @@ #endif #include "gstfaac.h" +#include + +#define SINK_CAPS \ + "audio/x-raw-int, " \ + "endianness = (int) BYTE_ORDER, " \ + "signed = (boolean) true, " \ + "width = (int) 16, " \ + "depth = (int) 16, " \ + "rate = (int) [ 8000, 96000 ], " \ + "channels = (int) [ 1, 6]; " \ +\ + "audio/x-raw-int, " \ + "endianness = (int) BYTE_ORDER, " \ + "signed = (boolean) true, " \ + "width = (int) 32, " \ + "depth = (int) { 24, 32 }, " \ + "rate = (int) [ 8000, 96000], " \ + "channels = (int) [ 1, 6]; " \ +\ + "audio/x-raw-float, " \ + "endianness = (int) BYTE_ORDER, " \ + "width = (int) 32, " \ + "rate = (int) [ 8000, 96000], " \ + "channels = (int) [ 1, 6]" + +#define SRC_CAPS \ + "audio/mpeg, " \ + "mpegversion = (int) { 4, 2 }, " \ + "channels = (int) [ 1, 6 ], " \ + "rate = (int) [ 8000, 96000 ]" static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/mpeg, " - "mpegversion = (int) { 4, 2 }, " - "channels = (int) [ 1, 6 ], " "rate = (int) [ 8000, 96000 ]") - ); + GST_STATIC_CAPS (SRC_CAPS)); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16, " "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 6]; " "audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 32, " "depth = (int) 24, " "rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]; " "audio/x-raw-float, " "endianness = (int) BYTE_ORDER, " "depth = (int) 32, " /* sizeof (gfloat) */ - "rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]") - ); + GST_STATIC_CAPS (SINK_CAPS)); enum { @@ -251,7 +276,7 @@ gst_faac_sink_setcaps (GstPad * pad, GstCaps * caps) GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad)); GstStructure *structure = gst_caps_get_structure (caps, 0); faacEncHandle *handle; - gint channels, samplerate, depth; + gint channels, samplerate, width; gulong samples, bytes, fmt = 0, bps = 0; gboolean result = FALSE; @@ -267,27 +292,32 @@ gst_faac_sink_setcaps (GstPad * pad, GstCaps * caps) faac->cache = NULL; } - gst_structure_get_int (structure, "channels", &channels); - gst_structure_get_int (structure, "rate", &samplerate); - gst_structure_get_int (structure, "depth", &depth); + if (!gst_structure_get_int (structure, "channels", &channels) || + !gst_structure_get_int (structure, "rate", &samplerate)) { + goto done; + } - /* open a new handle to the encoder */ if (!(handle = faacEncOpen (samplerate, channels, &samples, &bytes))) goto done; - switch (depth) { - case 16: - fmt = FAAC_INPUT_16BIT; - bps = 2; - break; - case 24: - fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */ - bps = 4; - break; - case 32: - fmt = FAAC_INPUT_FLOAT; /* see template, this is right */ - bps = 4; - break; + if (gst_structure_has_name (structure, "audio/x-raw-int")) { + gst_structure_get_int (structure, "width", &width); + switch (width) { + case 16: + fmt = FAAC_INPUT_16BIT; + bps = 2; + break; + case 24: + case 32: + fmt = FAAC_INPUT_32BIT; + bps = 4; + break; + default: + g_return_val_if_reached (FALSE); + } + } else if (gst_structure_has_name (structure, "audio/x-raw-float")) { + fmt = FAAC_INPUT_FLOAT; + bps = 4; } if (!fmt) {