+/*
+ * gstvaapih264encoder.c - H.264 encoder
+ *
+ * Copyright (C) 2011 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
#include "gstvaapih264encoder.h"
SLICE_TYPE_I = 2
} H264_SLICE_TYPE;
-struct _GstH264EncodeBuffer {
- GstBuffer buffer;
- VABufferID *coded_id;
- GstH264EncoderPrivate *encoder;
-};
-
struct _GstH264EncoderPrivate {
GstH264Encoder *public;
guint32 format; /*NV12, I420,*/
*/
}
-
-static void
-gst_h264_encode_buffer_class_init (gpointer g_class, gpointer class_data)
-{
- GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS(g_class);
-
- h264_encode_buffer_parent_class = g_type_class_peek_parent(g_class);
- ENCODER_ASSERT(h264_encode_buffer_parent_class);
-
- mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
- gst_h264_encode_buffer_finalize;
-}
-
-
-static GType
-gst_h264_encode_buffer_get_type (void)
-{
- static GType s_h264_encode_buffer_type = 0;
- if (G_UNLIKELY (s_h264_encode_buffer_type == 0)) {
- static const GTypeInfo s_h264_encode_buffer_info = {
- sizeof(GstBufferClass),
- NULL,
- NULL,
- gst_h264_encode_buffer_class_init,
- NULL,
- NULL,
- sizeof(GstH264EncodeBuffer),
- 0,
- NULL,
- NULL
- };
- s_h264_encode_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
- "GstH264EncodeBuffer", &s_h264_encode_buffer_info, 0);
- }
- return s_h264_encode_buffer_type;
-}
-
-static void
-gst_h264_encode_buffer_finalize (GstH264EncodeBuffer *h264_buffer)
-{
- GstH264EncoderPrivate *h264_prv = NULL;
- VABufferID* coded_id = NULL;
- GstVaapiDisplay *display = NULL;
-
- gboolean is_locked = FALSE;
-
- h264_prv = h264_buffer->encoder;
- coded_id = h264_buffer->coded_id;
- display = ENCODER_DISPLAY(h264_prv->public);
-
- ENCODER_ASSERT(display);
- VADisplay va_dpy = gst_vaapi_display_get_display(display);
-
- ENCODER_ASSERT(h264_prv);
- ENCODER_ASSERT(coded_id && VA_INVALID_ID!= *coded_id);
-
- /*if (--(*h264_buffer->ref_coded_id) == 0) */
- {
- /*g_free(h264_buffer->ref_coded_id);*/
- ENCODER_ACQUIRE_DISPLAY_LOCK(display);
- vaUnmapBuffer(va_dpy, *coded_id);
- ENCODER_RELEASE_DISPLAY_LOCK(display);
- push_available_coded_buffer(h264_prv, coded_id);
- }
-
- if (GST_MINI_OBJECT_CLASS(h264_encode_buffer_parent_class)->finalize) {
- GST_MINI_OBJECT_CLASS(h264_encode_buffer_parent_class)->finalize(GST_MINI_OBJECT(h264_buffer));
- }
-}
-
-static GstH264EncodeBuffer *
-gst_h264_encode_buffer_new(GstH264EncoderPrivate *h264_prv,
- VABufferID *coded_id)
-{
- GstH264EncodeBuffer *buf = (GstH264EncodeBuffer*)gst_mini_object_new(GST_TYPE_H264_ENCODE_BUFFER);
- buf->coded_id = coded_id;
- buf->encoder = h264_prv;
- return buf;
-}
-
-
-static GstVaapiSurface *
-h264_get_video_surface(GstH264EncoderPrivate *h264_prv, GstVaapiVideoBuffer *video_buffer)
-{
- //ref_surface
- GstVaapiSurface *ret = gst_vaapi_video_buffer_get_surface(video_buffer);
-
- ENCODER_CHECK_STATUS(ret, NULL, "video buffer doesn't have a surface");
-#if 0
- g_queue_push_tail(h264_prv->video_buffer_caches,video_buffer);
- gst_buffer_ref(GST_BUFFER(video_buffer));
-#endif
- return ret;
-
- end:
- return NULL;
-}
-
-static void
-h264_release_video_surface(GstH264EncoderPrivate *h264_prv, VASurfaceID surface)
-{
-#if 0
- ENCODER_ASSERT(h264_prv->video_buffer_caches);
- g_queue_find_custom(h264_prv->video_buffer_caches,xx, compare_func);
- for (h264_prv->video_buffer_caches) {
- }
-#endif
-}
-
static VAProfile
h264_get_va_profile(guint32 profile)
{