static XDAS_Int32 codec_prepare_outbuf (GstDucatiVidDec * self, GstBuffer * buf) { XDAS_Int16 y_type, uv_type; guint8 *y_vaddr, *uv_vaddr; SSPtr y_paddr, uv_paddr; y_vaddr = GST_BUFFER_DATA (buf); uv_vaddr = y_vaddr + self->stride * self->padded_height; y_paddr = TilerMem_VirtToPhys (y_vaddr); uv_paddr = TilerMem_VirtToPhys (uv_vaddr); y_type = gst_ducati_get_mem_type (y_paddr); uv_type = gst_ducati_get_mem_type (uv_paddr); if ((y_type < 0) || (uv_type < 0)) { GST_DEBUG_OBJECT (self, "non TILER buffer, fallback to bufferpool"); return codec_prepare_outbuf (self, codec_bufferpool_get (self, buf)); } if (!self->outBufs->numBufs) { /* initialize output buffer type */ self->outBufs->numBufs = 2; self->outBufs->descs[0].memType = y_type; self->outBufs->descs[0].bufSize.tileMem.width = self->padded_width; self->outBufs->descs[0].bufSize.tileMem.height = self->padded_height; self->outBufs->descs[1].memType = uv_type; /* note that UV interleaved width is same a Y: */ self->outBufs->descs[1].bufSize.tileMem.width = self->padded_width; self->outBufs->descs[1].bufSize.tileMem.height = self->padded_height / 2; } else { /* verify output buffer type matches what we've already given * to the codec */ if ((self->outBufs->descs[0].memType != y_type) || (self->outBufs->descs[1].memType != uv_type)) { GST_DEBUG_OBJECT (self, "buffer mismatch, fallback to bufferpool"); return codec_prepare_outbuf (self, codec_bufferpool_get (self, buf)); } } self->outBufs->descs[0].buf = (XDAS_Int8 *) y_paddr; self->outBufs->descs[1].buf = (XDAS_Int8 *) uv_paddr; return (XDAS_Int32) buf; // XXX use lookup table }
/*! * @brief Function to Map Host processor to Remote processors * module * * This function can be called by the application to map their * address space to remote slave's address space. * * @param MpuAddr * * @sa SysLinkMemUtils_unmap */ Int SysLinkMemUtils_map (SyslinkMemUtils_MpuAddrToMap mpuAddrList [], UInt32 numOfBuffers, UInt32 * mappedAddr, ProcMgr_MapType memType, ProcMgr_ProcId procId) { ProcMgr_Handle procMgrHandle; UInt32 mappedSize; Int32 status = PROCMGR_SUCCESS; if (numOfBuffers > 1) { status = PROCMGR_E_INVALIDARG; Osal_printf ("SysLinkMemUtils_map numBufError [0x%x]\n", status); return status; } if (procId == PROC_APPM3) { procId = PROC_SYSM3; } if (memType == ProcMgr_MapType_Tiler) { /* TILER addresses are pre-mapped, so just return the TILER ssPtr */ *mappedAddr = TilerMem_VirtToPhys ((Void *)mpuAddrList [0].mpuAddr); return status; } /* Open a handle to the ProcMgr instance. */ status = ProcMgr_open (&procMgrHandle, procId); if (status < 0) { Osal_printf ("Error in ProcMgr_open [0x%x]\n", status); } else { /* FIX ME: Add Proc reserve call */ status = ProcMgr_map (procMgrHandle, (UInt32)mpuAddrList [0].mpuAddr, (UInt32)mpuAddrList [0].size, mappedAddr, &mappedSize, memType, procId); /* FIX ME: Add the table that keeps the C-D translations */ if (status < 0) { Osal_printf ("Error in ProcMgr_map [0x%x]\n", status); } else { status = ProcMgr_close (&procMgrHandle); } } return status; }
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 gboolean codec_create (GstDucatiVidDec * self) { gint err; const gchar *codec_name; codec_delete (self); if (G_UNLIKELY (!self->engine)) { GST_ERROR_OBJECT (self, "no engine"); return FALSE; } /* these need to be set before VIDDEC3_create */ self->params->maxWidth = self->width; self->params->maxHeight = self->height; codec_name = GST_DUCATIVIDDEC_GET_CLASS (self)->codec_name; /* create codec: */ GST_DEBUG_OBJECT (self, "creating codec: %s", codec_name); self->codec = VIDDEC3_create (self->engine, (String)codec_name, self->params); if (!self->codec) { return FALSE; } err = VIDDEC3_control (self->codec, XDM_SETPARAMS, self->dynParams, self->status); if (err) { GST_ERROR_OBJECT (self, "failed XDM_SETPARAMS"); return FALSE; } self->first_in_buffer = TRUE; self->first_out_buffer = TRUE; /* allocate input buffer and initialize inBufs: */ self->inBufs->numBufs = 1; self->input = gst_ducati_alloc_1d (self->width * self->height); self->inBufs->descs[0].buf = (XDAS_Int8 *) TilerMem_VirtToPhys (self->input); self->inBufs->descs[0].memType = XDM_MEMTYPE_RAW; return TRUE; }
{ /* TODO: for now, allocate in tiler paged mode (1d) container.. until DMM * is enabled on ducati, this would make the physical address the same as * the virtual address on ducati, which simplifies some things. Maybe * later use ducati heap instead.. */ MemAllocBlock block = { .pixelFormat = PIXEL_FMT_PAGE, .dim = { .len = sz + sizeof(MemHeader), } }; MemHeader *h = MemMgr_Alloc(&block, 1); h->size = sz; h->ducati_addr = TilerMem_VirtToPhys(H2P(h)); memset(H2P(h), 0, sz); return H2P(h); } /** * Free a block allocated by dce_alloc() */ void dce_free(void *ptr) { MemMgr_Free(P2H(ptr)); } /**