int main(int argc, char **argv) { codec_register_all(); struct codec_packet pkt; struct codec_frame frame; // decoder test struct codec_para para; para.media_format = CODEC_MEDIA_FORMAT_H264; para.is_encoder = 0; para.media_type = CODEC_MEDIA_TYPE_VIDEO; para.width = 1280; para.height = 720; struct codec_context *codec = codec_create(¶); codec_destroy(codec); // video encoder test memset(¶, 0, sizeof(struct codec_para)); para.media_format = CODEC_MEDIA_FORMAT_H264; para.is_encoder = 1; para.media_type = CODEC_MEDIA_TYPE_VIDEO; para.width = 1280; para.height = 720; codec = codec_create(¶); pkt.data = (uint8_t *)malloc(1280 * 720 * 4); frame.key = 1; frame.data = (uint8_t *)malloc(1280 * 720 * 4); memset(frame.data, 256, 1000); codec_encode_frame(codec, &pkt, &frame); codec_destroy(codec); free(pkt.data); free(frame.data); // audio Encoder test memset(¶, 0, sizeof(struct codec_para)); para.media_format = CODEC_MEDIA_FORMAT_AAC; para.is_encoder = 1; para.media_type = CODEC_MEDIA_TYPE_AUDIO; para.samplerate = 44100; para.channels = 2; codec = codec_create(¶); pkt.data = (uint8_t *)malloc(1280 * 720 * 4); pkt.size = 1280 * 720 * 4; frame.key = 1; frame.data = (uint8_t *)malloc(1280 * 720 * 4); frame.size = 44100*2; frame.nb_samples = 44100; codec_encode_frame(codec, &pkt, &frame); codec_destroy(codec); free(pkt.data); free(frame.data); return 0; }
static void gst_ducati_viddec_get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec) { GstDucatiVidDec *self = GST_DUCATIVIDDEC (obj); switch (prop_id) { case PROP_VERSION: { int err; char *version = gst_ducati_alloc_1d (VERSION_LENGTH); /* in case something fails: */ snprintf (version, VERSION_LENGTH, "unsupported"); if (! self->engine) engine_open (self); if (! self->codec) codec_create (self); if (self->codec) { self->status->data.buf = (XDAS_Int8 *) TilerMem_VirtToPhys (version); self->status->data.bufSize = VERSION_LENGTH; err = VIDDEC3_control (self->codec, XDM_GETVERSION, self->dynParams, self->status); if (err) { GST_ERROR_OBJECT (self, "failed XDM_GETVERSION"); } self->status->data.buf = NULL; self->status->data.bufSize = 0; } g_value_set_string (value, version); MemMgr_Free (version); break; } default: { G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; } } }
static GstFlowReturn gst_ducati_viddec_chain (GstPad * pad, GstBuffer * buf) { GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad)); GstFlowReturn ret; Int32 err; GstBuffer *outbuf = NULL; if (G_UNLIKELY (!self->engine)) { GST_ERROR_OBJECT (self, "no engine"); return GST_FLOW_ERROR; } /* do this before creating codec to ensure reverse caps negotiation * happens first: */ ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad, 0, self->outsize, GST_PAD_CAPS (self->srcpad), &outbuf); if (ret != GST_FLOW_OK) { outbuf = codec_bufferpool_get (self, NULL); ret = GST_FLOW_OK; } if (G_UNLIKELY (!self->codec)) { if (!codec_create (self)) { GST_ERROR_OBJECT (self, "could not create codec"); return GST_FLOW_ERROR; } } GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); /* pass new output buffer as to the decoder to decode into: */ self->inArgs->inputID = codec_prepare_outbuf (self, outbuf); if (!self->inArgs->inputID) { GST_ERROR_OBJECT (self, "could not prepare output buffer"); return GST_FLOW_ERROR; } self->in_size = 0; buf = GST_DUCATIVIDDEC_GET_CLASS (self)->push_input (self, buf); if (self->in_size == 0) { GST_DEBUG_OBJECT (self, "no input, skipping process"); gst_buffer_unref (outbuf); return GST_FLOW_OK; } self->inArgs->numBytes = self->in_size; self->inBufs->descs[0].bufSize.bytes = self->in_size; if (buf) { // XXX GST_WARNING_OBJECT (self, "TODO.. can't push more than one.. need loop"); gst_buffer_unref (buf); buf = NULL; } err = codec_process (self, TRUE, FALSE); if (err) { GST_ERROR_OBJECT (self, "process returned error: %d %08x", err, self->outArgs->extendedError); return GST_FLOW_ERROR; } self->first_in_buffer = FALSE; if (self->outArgs->outBufsInUseFlag) { GST_WARNING_OBJECT (self, "TODO... outBufsInUseFlag"); // XXX } return GST_FLOW_OK; }