summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2002-04-14 13:16:54 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2002-04-14 13:16:54 +0000
commit093ae8c8c7129d438cee6f99a27f9309af74352c (patch)
tree4e0f67cc273f6f1fb6056c4d6e4af6f5e934a5cf
parentbe4188514856c9cce89c57a3bd8cba0bd9b7c455 (diff)
downloadgstreamer-plugins-base-093ae8c8c7129d438cee6f99a27f9309af74352c.tar.gz
vakor's fix to use bitrates
Original commit message from CVS: vakor's fix to use bitrates
-rw-r--r--ext/vorbis/vorbisenc.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c
index ce2a852d9..7f140ac64 100644
--- a/ext/vorbis/vorbisenc.c
+++ b/ext/vorbis/vorbisenc.c
@@ -268,35 +268,39 @@ gst_vorbisenc_chain (GstPad * pad, GstBuffer * buf)
while (vorbis_analysis_blockout (&vorbisenc->vd, &vorbisenc->vb) == 1) {
/* analysis */
- vorbis_analysis (&vorbisenc->vb, &vorbisenc->op);
+ vorbis_analysis (&vorbisenc->vb, NULL);
+ vorbis_bitrate_addblock(&vorbisenc->vb);
+
+ while(vorbis_bitrate_flushpacket(&vorbisenc->vd, &vorbisenc->op)) {
- /* weld the packet into the bitstream */
- ogg_stream_packetin (&vorbisenc->os, &vorbisenc->op);
+ /* weld the packet into the bitstream */
+ ogg_stream_packetin (&vorbisenc->os, &vorbisenc->op);
- /* write out pages (if any) */
- while (!vorbisenc->eos) {
- int result = ogg_stream_pageout (&vorbisenc->os, &vorbisenc->og);
- GstBuffer *outbuf;
+ /* write out pages (if any) */
+ while (!vorbisenc->eos) {
+ int result = ogg_stream_pageout (&vorbisenc->os, &vorbisenc->og);
+ GstBuffer *outbuf;
- if (result == 0)
- break;
+ if (result == 0)
+ break;
- outbuf = gst_buffer_new ();
- GST_BUFFER_DATA (outbuf) = g_malloc (vorbisenc->og.header_len + vorbisenc->og.body_len);
- GST_BUFFER_SIZE (outbuf) = vorbisenc->og.header_len + vorbisenc->og.body_len;
+ outbuf = gst_buffer_new ();
+ GST_BUFFER_DATA (outbuf) = g_malloc (vorbisenc->og.header_len + vorbisenc->og.body_len);
+ GST_BUFFER_SIZE (outbuf) = vorbisenc->og.header_len + vorbisenc->og.body_len;
- memcpy (GST_BUFFER_DATA (outbuf), vorbisenc->og.header, vorbisenc->og.header_len);
- memcpy (GST_BUFFER_DATA (outbuf) + vorbisenc->og.header_len, vorbisenc->og.body,
- vorbisenc->og.body_len);
+ memcpy (GST_BUFFER_DATA (outbuf), vorbisenc->og.header, vorbisenc->og.header_len);
+ memcpy (GST_BUFFER_DATA (outbuf) + vorbisenc->og.header_len, vorbisenc->og.body,
+ vorbisenc->og.body_len);
- GST_DEBUG (0, "vorbisenc: encoded buffer of %d bytes", GST_BUFFER_SIZE (outbuf));
+ GST_DEBUG (0, "vorbisenc: encoded buffer of %d bytes", GST_BUFFER_SIZE (outbuf));
- gst_pad_push (vorbisenc->srcpad, outbuf);
+ gst_pad_push (vorbisenc->srcpad, outbuf);
- /* this could be set above, but for illustrative purposes, I do
- it here (to show that vorbis does know where the stream ends) */
- if (ogg_page_eos (&vorbisenc->og)) {
- vorbisenc->eos = 1;
+ /* this could be set above, but for illustrative purposes, I do
+ it here (to show that vorbis does know where the stream ends) */
+ if (ogg_page_eos (&vorbisenc->og)) {
+ vorbisenc->eos = 1;
+ }
}
}
}