theoraenc: Use base class functions to allocate output buffers

This commit is contained in:
Sebastian Dröge 2012-07-23 09:45:11 +02:00
parent 8c55e1dd99
commit ca928f3916

View file

@ -619,23 +619,21 @@ static GstFlowReturn
theora_push_packet (GstTheoraEnc * enc, ogg_packet * packet) theora_push_packet (GstTheoraEnc * enc, ogg_packet * packet)
{ {
GstVideoEncoder *benc; GstVideoEncoder *benc;
GstBuffer *buf;
GstFlowReturn ret; GstFlowReturn ret;
GstVideoCodecFrame *frame; GstVideoCodecFrame *frame;
benc = GST_VIDEO_ENCODER (enc); benc = GST_VIDEO_ENCODER (enc);
buf = gst_buffer_new_allocate (NULL, packet->bytes, NULL); frame = gst_video_encoder_get_oldest_frame (benc);
if (!buf) { if (gst_video_encoder_alloc_output_frame (benc, frame,
packet->bytes) != GST_FLOW_OK) {
GST_WARNING_OBJECT (enc, "Could not allocate buffer"); GST_WARNING_OBJECT (enc, "Could not allocate buffer");
gst_video_codec_frame_unref (frame);
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
goto done; goto done;
} }
gst_buffer_fill (buf, 0, packet->packet, packet->bytes); gst_buffer_fill (frame->output_buffer, 0, packet->packet, packet->bytes);
frame = gst_video_encoder_get_oldest_frame (benc);
frame->output_buffer = buf;
/* the second most significant bit of the first data byte is cleared /* the second most significant bit of the first data byte is cleared
* for keyframes */ * for keyframes */
@ -838,7 +836,9 @@ theora_enc_buffer_from_header_packet (GstTheoraEnc * enc, ogg_packet * packet)
{ {
GstBuffer *outbuf; GstBuffer *outbuf;
outbuf = gst_buffer_new_allocate (NULL, packet->bytes, NULL); outbuf =
gst_video_encoder_alloc_output_buffer (GST_VIDEO_ENCODER (enc),
packet->bytes);
gst_buffer_fill (outbuf, 0, packet->packet, packet->bytes); gst_buffer_fill (outbuf, 0, packet->packet, packet->bytes);
GST_BUFFER_OFFSET (outbuf) = 0; GST_BUFFER_OFFSET (outbuf) = 0;
GST_BUFFER_OFFSET_END (outbuf) = 0; GST_BUFFER_OFFSET_END (outbuf) = 0;