mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-27 09:38:17 +00:00
ext/faac/gstfaac.c: Fix depth/width handling for float audio (#318659).
Original commit message from CVS: Reviewed by: Tim-Philipp Müller <tim at centricular dot net> * ext/faac/gstfaac.c: (gst_faac_sink_setcaps): Fix depth/width handling for float audio (#318659).
This commit is contained in:
parent
085fdc272d
commit
e9cfa88c70
2 changed files with 63 additions and 26 deletions
|
@ -1,10 +1,17 @@
|
||||||
|
2005-10-12 Josef Zlomek <josef dot zlomek at xeris dot cz>
|
||||||
|
|
||||||
|
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* ext/faac/gstfaac.c: (gst_faac_sink_setcaps):
|
||||||
|
Fix depth/width handling for float audio (#318659).
|
||||||
|
|
||||||
2005-10-12 Josef Zlomek <josef dot zlomek at xeris dot cz>
|
2005-10-12 Josef Zlomek <josef dot zlomek at xeris dot cz>
|
||||||
|
|
||||||
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
|
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* ext/faac/gstfaac.c: (gst_faac_sink_setcaps),
|
* ext/faac/gstfaac.c: (gst_faac_sink_setcaps),
|
||||||
(gst_faac_src_setcaps), (gst_faac_chain):
|
(gst_faac_src_setcaps), (gst_faac_chain):
|
||||||
Refcount fixes (#318659)
|
Refcount fixes (#318660)
|
||||||
|
|
||||||
2005-10-12 Julien MOUTTE <julien@moutte.net>
|
2005-10-12 Julien MOUTTE <julien@moutte.net>
|
||||||
|
|
||||||
|
|
|
@ -22,21 +22,46 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gstfaac.h"
|
#include "gstfaac.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#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",
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/mpeg, "
|
GST_STATIC_CAPS (SRC_CAPS));
|
||||||
"mpegversion = (int) { 4, 2 }, "
|
|
||||||
"channels = (int) [ 1, 6 ], " "rate = (int) [ 8000, 96000 ]")
|
|
||||||
);
|
|
||||||
|
|
||||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
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) */
|
GST_STATIC_CAPS (SINK_CAPS));
|
||||||
"rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]")
|
|
||||||
);
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -251,7 +276,7 @@ gst_faac_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
|
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
|
||||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||||
faacEncHandle *handle;
|
faacEncHandle *handle;
|
||||||
gint channels, samplerate, depth;
|
gint channels, samplerate, width;
|
||||||
gulong samples, bytes, fmt = 0, bps = 0;
|
gulong samples, bytes, fmt = 0, bps = 0;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
@ -267,27 +292,32 @@ gst_faac_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
faac->cache = NULL;
|
faac->cache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_structure_get_int (structure, "channels", &channels);
|
if (!gst_structure_get_int (structure, "channels", &channels) ||
|
||||||
gst_structure_get_int (structure, "rate", &samplerate);
|
!gst_structure_get_int (structure, "rate", &samplerate)) {
|
||||||
gst_structure_get_int (structure, "depth", &depth);
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* open a new handle to the encoder */
|
|
||||||
if (!(handle = faacEncOpen (samplerate, channels, &samples, &bytes)))
|
if (!(handle = faacEncOpen (samplerate, channels, &samples, &bytes)))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
switch (depth) {
|
if (gst_structure_has_name (structure, "audio/x-raw-int")) {
|
||||||
case 16:
|
gst_structure_get_int (structure, "width", &width);
|
||||||
fmt = FAAC_INPUT_16BIT;
|
switch (width) {
|
||||||
bps = 2;
|
case 16:
|
||||||
break;
|
fmt = FAAC_INPUT_16BIT;
|
||||||
case 24:
|
bps = 2;
|
||||||
fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
|
break;
|
||||||
bps = 4;
|
case 24:
|
||||||
break;
|
case 32:
|
||||||
case 32:
|
fmt = FAAC_INPUT_32BIT;
|
||||||
fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
|
bps = 4;
|
||||||
bps = 4;
|
break;
|
||||||
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) {
|
if (!fmt) {
|
||||||
|
|
Loading…
Reference in a new issue