gst_element_add_pad (GST_ELEMENT(emuldec), emuldec->sinkpad);
gst_element_add_pad (GST_ELEMENT(emuldec), emuldec->srcpad);
- // init
emuldec->context = g_malloc0 (sizeof(CodecContext));
- if (!emuldec->context) {
- CODEC_LOG (ERR, "failed to allocate memory.\n");
- }
-
emuldec->context->video.pix_fmt = PIX_FMT_NONE;
emuldec->context->audio.sample_fmt = SAMPLE_FMT_NONE;
- emuldec->dev = g_malloc0 (sizeof(CodecDevice));
- if (!emuldec->dev) {
- CODEC_LOG (ERR, "failed to allocate memory.\n");
- }
emuldec->opened = FALSE;
emuldec->format.video.par_n = -1;
emuldec->queued = NULL;
gst_segment_init (&emuldec->segment, GST_FORMAT_TIME);
+
+ emuldec->dev = g_malloc0 (sizeof(CodecDevice));
+ if (!emuldec->dev) {
+ CODEC_LOG (ERR, "failed to allocate memory.\n");
+ }
}
static void
pict_size = gst_emul_avpicture_size (emuldec->context->video.pix_fmt,
emuldec->context->video.width, emuldec->context->video.height);
+ if (pict_size < 0) {
+ GST_DEBUG_OBJECT (emuldec, "size of a picture is negative. "
+ "pixel format: %d, width: %d, height: %d",
+ emuldec->context->video.pix_fmt, emuldec->context->video.width,
+ emuldec->context->video.height);
+ return GST_FLOW_ERROR;
+ }
-//
- gst_pad_set_bufferalloc_function(GST_PAD_PEER(emuldec->srcpad), (GstPadBufferAllocFunction) emul_buffer_alloc);
-//
+ /* GstPadBufferAllocFunction is mostly overridden by elements that can
+ * provide a hardware buffer in order to avoid additional memcpy operations.
+ */
+ gst_pad_set_bufferalloc_function(GST_PAD_PEER(emuldec->srcpad),
+ (GstPadBufferAllocFunction) emul_buffer_alloc);
ret = gst_pad_alloc_buffer_and_set_caps (emuldec->srcpad,
GST_BUFFER_OFFSET_NONE, pict_size,
gst_buffer_unref (*outbuf);
*outbuf = new_aligned_buffer (pict_size, GST_PAD_CAPS (emuldec->srcpad));
}
-
gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (emuldec->srcpad));
emul_av_picture_copy (emuldec->context, GST_BUFFER_DATA (*outbuf),
CodecElement *codec = NULL;
if (!elem) {
- return FALSE;
+ return FALSE;
}
/* register element */
gst_element_add_pad (GST_ELEMENT (emulenc), emulenc->sinkpad);
gst_element_add_pad (GST_ELEMENT (emulenc), emulenc->srcpad);
- // init
emulenc->context = g_malloc0 (sizeof(CodecContext));
- if (!emulenc->context) {
- printf("failed to allocate memory.\n");
- }
emulenc->context->video.pix_fmt = PIX_FMT_NONE;
emulenc->context->audio.sample_fmt = SAMPLE_FMT_NONE;