summaryrefslogtreecommitdiff
path: root/ext/celt
diff options
context:
space:
mode:
authorGabriel Millaire <gabriel.millaire@collabora.co.uk>2009-10-14 15:47:27 -0400
committerOlivier Crête <olivier.crete@collabora.co.uk>2009-11-04 12:05:10 -0500
commit8561568e1150571948b7db0be454a53ed4efada3 (patch)
tree1ea37b3dc7ea354d9943df9d5ec139dfc40f1ad0 /ext/celt
parentba460f587af2d5e9153ca68a043d47473ddc62ec (diff)
downloadgstreamer-plugins-bad-8561568e1150571948b7db0be454a53ed4efada3.tar.gz
celtdec : chain_parse_data : check validity of timestamp, create a new one if needed
celtenc : default framesize is 480 setcaps : gets framesize and set caps enc_chain : sets framesize in caps Added frame-size to static caps of audio/x-celt Replaced GST_DEBUG_OBJECT by GST_LOG_OBJECT in enc_chain setcaps: get frame-size from int instead of string setcaps: use default value for frame-size
Diffstat (limited to 'ext/celt')
-rw-r--r--ext/celt/gstceltdec.c14
-rw-r--r--ext/celt/gstceltenc.c24
2 files changed, 32 insertions, 6 deletions
diff --git a/ext/celt/gstceltdec.c b/ext/celt/gstceltdec.c
index 4837237f2..b700935f0 100644
--- a/ext/celt/gstceltdec.c
+++ b/ext/celt/gstceltdec.c
@@ -521,6 +521,9 @@ celt_dec_chain_parse_header (GstCeltDec * dec, GstBuffer * buf)
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, NULL);
+ GST_DEBUG_OBJECT (dec, "rate=%d channels=%d frame-size=%d",
+ dec->header.sample_rate, dec->header.nb_channels, dec->frame_size);
+
if (!gst_pad_set_caps (dec->srcpad, caps))
goto nego_failed;
@@ -679,11 +682,16 @@ celt_dec_chain_parse_data (GstCeltDec * dec, GstBuffer * buf,
GST_DEBUG_OBJECT (dec, "granulepos=%" G_GINT64_FORMAT, dec->granulepos);
}
+ if (!GST_CLOCK_TIME_IS_VALID (timestamp))
+ timestamp = gst_util_uint64_scale_int (dec->granulepos - dec->frame_size,
+ GST_SECOND, dec->header.sample_rate);
+
+ GST_DEBUG_OBJECT (dec, "timestamp=%" GST_TIME_FORMAT,
+ GST_TIME_ARGS (timestamp));
+
GST_BUFFER_OFFSET (outbuf) = dec->granulepos - dec->frame_size;
GST_BUFFER_OFFSET_END (outbuf) = dec->granulepos;
- GST_BUFFER_TIMESTAMP (outbuf) =
- gst_util_uint64_scale_int (dec->granulepos - dec->frame_size, GST_SECOND,
- dec->header.sample_rate);
+ GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = dec->frame_duration;
if (dec->discont) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
diff --git a/ext/celt/gstceltenc.c b/ext/celt/gstceltenc.c
index 116b980dd..0689e2a72 100644
--- a/ext/celt/gstceltenc.c
+++ b/ext/celt/gstceltenc.c
@@ -68,7 +68,8 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-celt, "
- "rate = (int) [ 32000, 64000 ], " "channels = (int) [ 1, 2 ]")
+ "rate = (int) [ 32000, 64000 ], "
+ "channels = (int) [ 1, 2 ], " "frame-size = (int) [ 64, 512 ]")
);
static const GstElementDetails celtenc_details =
@@ -78,7 +79,7 @@ GST_ELEMENT_DETAILS ("Celt audio encoder",
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
#define DEFAULT_BITRATE 64
-#define DEFAULT_FRAMESIZE 256
+#define DEFAULT_FRAMESIZE 480
#define DEFAULT_CBR TRUE
#define DEFAULT_COMPLEXITY 9
#define DEFAULT_MAX_BITRATE 64
@@ -202,14 +203,28 @@ gst_celt_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
{
GstCeltEnc *enc;
GstStructure *structure;
+ GstCaps *otherpadcaps;
enc = GST_CELT_ENC (GST_PAD_PARENT (pad));
enc->setup = FALSE;
+ enc->frame_size = DEFAULT_FRAMESIZE;
+ otherpadcaps = gst_pad_get_allowed_caps (pad);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "channels", &enc->channels);
gst_structure_get_int (structure, "rate", &enc->rate);
+ if (otherpadcaps) {
+ if (!gst_caps_is_empty (otherpadcaps)) {
+ GstStructure *ps = gst_caps_get_structure (otherpadcaps, 0);
+ gst_structure_get_int (ps, "frame-size", &enc->frame_size);
+ }
+ gst_caps_unref (otherpadcaps);
+ }
+
+ GST_DEBUG_OBJECT (pad, "channels=%d rate=%d frame-size=%d",
+ enc->channels, enc->rate, enc->frame_size);
+
gst_celt_enc_setup (enc);
return enc->setup;
@@ -841,10 +856,13 @@ gst_celt_enc_chain (GstPad * pad, GstBuffer * buf)
gst_caps_set_simple (caps,
"rate", G_TYPE_INT, enc->rate,
- "channels", G_TYPE_INT, enc->channels, NULL);
+ "channels", G_TYPE_INT, enc->channels,
+ "frame-size", G_TYPE_INT, enc->frame_size, NULL);
/* negotiate with these caps */
GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps);
+ GST_LOG_OBJECT (enc, "rate=%d channels=%d frame-size=%d",
+ enc->rate, enc->channels, enc->frame_size);
gst_pad_set_caps (enc->srcpad, caps);
gst_buffer_set_caps (buf1, caps);