mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
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
This commit is contained in:
parent
ba460f587a
commit
8561568e11
2 changed files with 32 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue