summaryrefslogtreecommitdiff
path: root/ext/opus
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-03-29 17:41:53 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-03-29 17:41:53 +0200
commit860ccd414dbb313fabf065b92838f0f39037584b (patch)
tree0d5c0d3510db3ca3d7e6487420e8d09f74ae1961 /ext/opus
parenta9ec4d62a89dd53aa295af02c7d5f57ef936359b (diff)
parentd84d98943af42ce645ee022207bcf04e747d2d4a (diff)
downloadgstreamer-plugins-bad-860ccd414dbb313fabf065b92838f0f39037584b.tar.gz
Merge remote-tracking branch 'origin/0.10'
Conflicts: NEWS RELEASE common configure.ac docs/libs/gst-plugins-bad-libs-sections.txt docs/plugins/gst-plugins-bad-plugins.args docs/plugins/gst-plugins-bad-plugins.hierarchy docs/plugins/gst-plugins-bad-plugins.interfaces docs/plugins/inspect/plugin-adpcmdec.xml docs/plugins/inspect/plugin-adpcmenc.xml docs/plugins/inspect/plugin-assrender.xml docs/plugins/inspect/plugin-audiovisualizers.xml docs/plugins/inspect/plugin-autoconvert.xml docs/plugins/inspect/plugin-bayer.xml docs/plugins/inspect/plugin-bz2.xml docs/plugins/inspect/plugin-camerabin2.xml docs/plugins/inspect/plugin-celt.xml docs/plugins/inspect/plugin-dataurisrc.xml docs/plugins/inspect/plugin-debugutilsbad.xml docs/plugins/inspect/plugin-dtmf.xml docs/plugins/inspect/plugin-dtsdec.xml docs/plugins/inspect/plugin-dvbsuboverlay.xml docs/plugins/inspect/plugin-dvdspu.xml docs/plugins/inspect/plugin-faac.xml docs/plugins/inspect/plugin-faad.xml docs/plugins/inspect/plugin-gsm.xml docs/plugins/inspect/plugin-h264parse.xml docs/plugins/inspect/plugin-mms.xml docs/plugins/inspect/plugin-modplug.xml docs/plugins/inspect/plugin-mpeg2enc.xml docs/plugins/inspect/plugin-mpegdemux2.xml docs/plugins/inspect/plugin-mpegtsdemux.xml docs/plugins/inspect/plugin-mpegvideoparse.xml docs/plugins/inspect/plugin-mplex.xml docs/plugins/inspect/plugin-pcapparse.xml docs/plugins/inspect/plugin-rawparse.xml docs/plugins/inspect/plugin-rtpmux.xml docs/plugins/inspect/plugin-rtpvp8.xml docs/plugins/inspect/plugin-scaletempo.xml docs/plugins/inspect/plugin-schro.xml docs/plugins/inspect/plugin-sdp.xml docs/plugins/inspect/plugin-segmentclip.xml docs/plugins/inspect/plugin-shm.xml docs/plugins/inspect/plugin-videomaxrate.xml docs/plugins/inspect/plugin-videoparsersbad.xml docs/plugins/inspect/plugin-vp8.xml docs/plugins/inspect/plugin-y4mdec.xml ext/celt/gstceltdec.c ext/dts/gstdtsdec.c ext/modplug/gstmodplug.cc ext/opus/gstopusenc.c gst-libs/gst/video/gstbasevideocodec.c gst-libs/gst/video/gstbasevideocodec.h gst-libs/gst/video/gstbasevideodecoder.c gst-libs/gst/video/gstbasevideodecoder.h gst-libs/gst/video/gstbasevideoencoder.c gst-libs/gst/video/gstbasevideoencoder.h gst/adpcmdec/Makefile.am gst/audiovisualizers/gstbaseaudiovisualizer.c gst/h264parse/gsth264parse.c gst/mpegdemux/mpegtsparse.c gst/mpegtsdemux/mpegtsbase.c gst/mpegtsdemux/mpegtspacketizer.c gst/mpegtsdemux/mpegtsparse.c gst/mpegtsdemux/tsdemux.c gst/mpegtsdemux/tsdemux.h gst/mxf/mxfdemux.c gst/rawparse/gstaudioparse.c gst/videoparsers/gsth263parse.c gst/videoparsers/gsth264parse.c sys/d3dvideosink/d3dvideosink.c sys/decklink/gstdecklinksink.cpp sys/dvb/gstdvbsrc.c sys/shm/gstshmsrc.c sys/vdpau/h264/gstvdph264dec.c sys/vdpau/mpeg/gstvdpmpegdec.c tests/examples/opencv/gst_element_print_properties.c win32/common/config.h
Diffstat (limited to 'ext/opus')
-rw-r--r--ext/opus/gstopusenc.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c
index 9c10d1a4b..be95fb798 100644
--- a/ext/opus/gstopusenc.c
+++ b/ext/opus/gstopusenc.c
@@ -368,11 +368,9 @@ gst_opus_enc_setup_base_class (GstOpusEnc * enc, GstAudioEncoder * benc)
{
gst_audio_encoder_set_latency (benc,
gst_opus_enc_get_latency (enc), gst_opus_enc_get_latency (enc));
- gst_audio_encoder_set_frame_samples_min (benc,
- enc->frame_samples * enc->n_channels * 2);
- gst_audio_encoder_set_frame_samples_max (benc,
- enc->frame_samples * enc->n_channels * 2);
- gst_audio_encoder_set_frame_max (benc, 0);
+ gst_audio_encoder_set_frame_samples_min (benc, enc->frame_samples);
+ gst_audio_encoder_set_frame_samples_max (benc, enc->frame_samples);
+ gst_audio_encoder_set_frame_max (benc, 1);
}
static gint
@@ -789,6 +787,9 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf)
gsize bytes = enc->frame_samples * enc->n_channels * 2;
gint ret = GST_FLOW_OK;
GstMapInfo map;
+ GstMapInfo omap;
+ gint outsize;
+ GstBuffer *outbuf;
g_mutex_lock (enc->property_lock);
@@ -813,50 +814,46 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf)
goto done;
}
- while (size) {
- gint encoded_size;
- GstBuffer *outbuf;
- GstMapInfo omap;
-
- outbuf = gst_buffer_new_and_alloc (enc->max_payload_size * enc->n_channels);
- if (!outbuf)
- goto done;
-
- GST_DEBUG_OBJECT (enc, "encoding %d samples (%d bytes)",
- enc->frame_samples, (int) bytes);
-
- gst_buffer_map (outbuf, &omap, GST_MAP_WRITE);
- encoded_size =
- opus_multistream_encode (enc->state, (const gint16 *) data,
- enc->frame_samples, omap.data, enc->max_payload_size * enc->n_channels);
- gst_buffer_unmap (outbuf, &omap);
-
- if (encoded_size < 0) {
- GST_ERROR_OBJECT (enc, "Encoding failed: %d", encoded_size);
- ret = GST_FLOW_ERROR;
- goto done;
- } else if (encoded_size > enc->max_payload_size) {
- GST_WARNING_OBJECT (enc,
- "Encoded size %d is higher than max payload size (%d bytes)",
- encoded_size, enc->max_payload_size);
- ret = GST_FLOW_ERROR;
- goto done;
- }
+ g_assert (size == bytes);
+
+ outbuf = gst_buffer_new_and_alloc (enc->max_payload_size * enc->n_channels);
+ if (!outbuf)
+ goto done;
+
+ GST_DEBUG_OBJECT (enc, "encoding %d samples (%d bytes)",
+ enc->frame_samples, (int) bytes);
+
+ gst_buffer_map (outbuf, &omap, GST_MAP_WRITE);
- GST_DEBUG_OBJECT (enc, "Output packet is %u bytes", encoded_size);
- gst_buffer_set_size (outbuf, encoded_size);
+ GST_DEBUG_OBJECT (enc, "encoding %d samples (%d bytes)",
+ enc->frame_samples, (int) bytes);
- ret =
- gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (enc), outbuf,
- enc->frame_samples);
+ outsize =
+ opus_multistream_encode (enc->state, (const gint16 *) data,
+ enc->frame_samples, GST_BUFFER_DATA (outbuf),
+ enc->max_payload_size * enc->n_channels);
- if ((GST_FLOW_OK != ret) && (GST_FLOW_NOT_LINKED != ret))
- goto done;
+ gst_buffer_unmap (outbuf, &omap);
- data += bytes;
- size -= bytes;
+ if (outsize < 0) {
+ GST_ERROR_OBJECT (enc, "Encoding failed: %d", outsize);
+ ret = GST_FLOW_ERROR;
+ goto done;
+ } else if (outsize > enc->max_payload_size) {
+ GST_WARNING_OBJECT (enc,
+ "Encoded size %d is higher than max payload size (%d bytes)",
+ outsize, enc->max_payload_size);
+ ret = GST_FLOW_ERROR;
+ goto done;
}
+ GST_DEBUG_OBJECT (enc, "Output packet is %u bytes", outsize);
+ GST_BUFFER_SIZE (outbuf) = outsize;
+
+ ret =
+ gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (enc), outbuf,
+ enc->frame_samples);
+
done:
if (bdata)