ioparam.ctx_index = ctx_index;
ioparam.mem_offset = mem_offset;
if (ioctl (fd, CODEC_CMD_INVOKE_API_AND_RELEASE_BUFFER, &ioparam) < 0) {
- CODEC_LOG (ERR, "failed to invoke codec APIs\n");
+ GST_ERROR ("failed to invoke codec APIs");
}
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
* - sets device memory offset into opaque.buffer_size
*/
*buffer = (gpointer)((uint32_t)device_mem + opaque.buffer_size);
- CODEC_LOG (DEBUG, "buffer: 0x%x\n", (int)buffer);
+ GST_DEBUG ("device_mem %p, offset_size 0x%x", device_mem, opaque.buffer_size);
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
- CODEC_LOG (DEBUG, "release device_mem start: %p, offset: 0x%x\n", start, offset);
+ GST_DEBUG ("release device_mem start: %p, offset: 0x%x", start, offset);
ret = ioctl (fd, CODEC_CMD_RELEASE_BUFFER, &offset);
if (ret < 0) {
- CODEC_LOG (ERR, "failed to release buffer\n");
+ GST_ERROR ("failed to release buffer\n");
}
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
opaque.buffer_index = marudec->context->index;
opaque.buffer_size = size;
- CODEC_LOG (DEBUG, "buffer_and_copy. ctx_id: %d\n", marudec->context->index);
- _codec_invoke_qemu (marudec->context->index, CODEC_PICTURE_COPY,
- 0, marudec->dev->fd);
+ GST_DEBUG ("buffer_and_copy. ctx_id: %d", marudec->context->index);
+ _codec_invoke_qemu (marudec->context->index, CODEC_PICTURE_COPY, 0, marudec->dev->fd);
ret = ioctl (marudec->dev->fd, CODEC_CMD_PUT_DATA_INTO_BUFFER, &opaque);
if (ret < 0) {
- CODEC_LOG (DEBUG, "failed to get available buffer\n");
+ GST_DEBUG ("failed to get available buffer");
} else if (ret == 1) {
// FIXME: we must aligned buffer offset.
info.start = g_malloc (size);
memcpy (info.start, device_mem + opaque.buffer_size, size);
release_device_mem(marudec->dev->fd, device_mem + opaque.buffer_size);
- CODEC_LOG (DEBUG, "we secured last buffer, so we will use heap buffer\n");
+ GST_DEBUG ("secured last buffer!! Use heap buffer");
} else {
// address of "device_mem" and "opaque" is aleady aligned.
info.start = (gpointer)(device_mem + opaque.buffer_size);
GST_BUFFER_FREE_FUNC (*buf) = codec_buffer_free;
- CODEC_LOG (DEBUG, "device memory start: 0x%p, offset 0x%x\n", info.start, info.offset);
+ GST_DEBUG ("device memory start: 0x%p, offset 0x%x", info.start, info.offset);
}
GST_BUFFER_DATA (*buf) = GST_BUFFER_MALLOCDATA (*buf) = info.start;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
if (ioctl(dev->fd, CODEC_CMD_GET_CONTEXT_INDEX, &ctx->index) < 0) {
- CODEC_LOG (ERR,
- "[%s] failed to get a context index\n", __func__);
+ GST_ERROR ("failed to get a context index");
return -1;
}
- CODEC_LOG (DEBUG, "get context index: %d\n", ctx->index);
+ GST_DEBUG ("get context index: %d", ctx->index);
/* buffer size is 0. It means that this function is required to
* use small size.
*/
if (secure_device_mem(dev->fd, ctx->index, 0, &buffer) < 0) {
- CODEC_LOG (ERR,
- "[%s] failed to get a memory block\n", __func__);
+ GST_ERROR ("failed to get a memory block");
return -1;
}
opaque.buffer_size = SMALLDATA;
if (ioctl (dev->fd, CODEC_CMD_PUT_DATA_INTO_BUFFER, &opaque) < 0) {
- CODEC_LOG (ERR,
- "[%s] failed to accquire a memory block\n", __func__);
+ GST_ERROR ("failed to accquire a memory block");
return -1;
}
codec_init_data_from (ctx, codec->media_type, device_mem + opaque.buffer_size);
if (opened < 0) {
- CODEC_LOG (ERR, "failed to open Context for %s\n", codec->name);
+ GST_ERROR ("failed to open Context for %s", codec->name);
} else {
ctx->codec = codec;
}
{
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
- CODEC_LOG (INFO, "close. context index: %d\n", ctx->index);
+ GST_INFO ("close context %d", ctx->index);
_codec_invoke_qemu (ctx->index, CODEC_DEINIT, 0, dev->fd);
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
{
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
- CODEC_LOG (DEBUG, "flush buffers. context index: %d\n", ctx->index);
+ GST_DEBUG ("flush buffers of context: %d", ctx->index);
_codec_invoke_qemu (ctx->index, CODEC_FLUSH_BUFFERS, 0, dev->fd);
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
ret = secure_device_mem(dev->fd, ctx->index, in_size, &buffer);
if (ret < 0) {
- CODEC_LOG (ERR,
- "decode_video. failed to get available memory to write inbuf\n");
+ GST_ERROR ("failed to get available memory to write inbuf");
return -1;
}
opaque.buffer_size = SMALLDATA;
if (ioctl (dev->fd, CODEC_CMD_PUT_DATA_INTO_BUFFER, &opaque) < 0) {
- CODEC_LOG (ERR,
- "[%s] failed to accquire a memory block\n", __func__);
+ GST_ERROR ("failed to accquire a memory block");
return -1;
}
int in_size, CodecDevice *dev)
{
int len = 0, ret = 0;
- int outbuf_size = 0;
gpointer buffer = NULL;
CodecBufferId opaque;
ret = secure_device_mem(dev->fd, ctx->index, in_size, &buffer);
if (ret < 0) {
- CODEC_LOG (ERR,
- "decode_audio. failed to get available memory to write inbuf\n");
+ GST_ERROR ("failed to get available memory to write inbuf");
return -1;
}
- CODEC_LOG (DEBUG, "decode_audio. in_buffer size %d\n", in_size);
+ GST_DEBUG ("decode_audio 1. in_buffer size %d", in_size);
codec_decode_audio_data_to (in_size, in_buf, buffer);
dev->mem_info.offset = GET_OFFSET(buffer);
return -1;
}
- CODEC_LOG (DEBUG, "after decode_audio. ctx_id: %d, buffer = 0x%x\n",
- ctx->index, device_mem + opaque.buffer_size);
+ GST_DEBUG ("decode_audio 2. ctx_id: %d, buffer = 0x%x",
+ ctx->index, device_mem + opaque.buffer_size);
- len = codec_decode_audio_data_from (have_data, samples,
+ len = codec_decode_audio_data_from (have_data, samples,
&ctx->audio, device_mem + opaque.buffer_size);
- CODEC_LOG (DEBUG, "decode_audio. ctx_id: %d len: %d\n", ctx->index, len);
+ GST_DEBUG ("decode_audio 3. ctx_id: %d len: %d", ctx->index, len);
release_device_mem(dev->fd, device_mem + opaque.buffer_size);
ret = secure_device_mem(dev->fd, ctx->index, in_size, &buffer);
if (ret < 0) {
- CODEC_LOG (ERR, "failed to small size of buffer.\n");
+ GST_ERROR ("failed to small size of buffer");
return -1;
}
if (ret < 0) {
return -1;
}
- CODEC_LOG (DEBUG, "encode_video. mem_offset = 0x%x\n", opaque.buffer_size);
+ GST_DEBUG ("encode_video. mem_offset = 0x%x", opaque.buffer_size);
len = codec_encode_video_data_from (out_buf, coded_frame, is_keyframe, device_mem + opaque.buffer_size);
dev->mem_info.offset = opaque.buffer_size;
opaque.buffer_index = ctx->index;
opaque.buffer_size = SMALLDATA;
- // FIXME: how can we know output data size ?
+
ret = ioctl (dev->fd, CODEC_CMD_PUT_DATA_INTO_BUFFER, &opaque);
if (ret < 0) {
return -1;
}
- CODEC_LOG (DEBUG, "encode_video. mem_offset = 0x%x\n", opaque.buffer_size);
+ GST_DEBUG ("encode_audio. mem_offset = 0x%x", opaque.buffer_size);
len = codec_encode_audio_data_from (out_buf, device_mem + opaque.buffer_size);
CODEC_LOG (DEBUG, "enter, %s\n", __func__);
- CODEC_LOG (DEBUG, "type: %d, name: %s\n", codec->codec_type, codec->name);
+ GST_INFO ("type: %d, name: %s", codec->codec_type, codec->name);
+
memcpy (buffer + size, &codec->codec_type, sizeof(codec->codec_type));
size += sizeof(codec->codec_type);
size = _codec_info_data (codec, buffer);
- CODEC_LOG (INFO, "context_id: %d, name: %s, media type: %s\n",
- ctx->index, codec->name, codec->media_type ? "AUDIO" : "VIDEO");
+ GST_INFO ("context_id: %d, name: %s, media type: %s",
+ ctx->index, codec->name, codec->media_type ? "audio" : "video");
memcpy (buffer + size, ctx, sizeof(CodecContext) - 12);
size += (sizeof(CodecContext) - 12);
{
int ret = 0, size = 0;
- CODEC_LOG (DEBUG, "after init. read data from device.\n");
-
memcpy (&ret, buffer, sizeof(ret));
size = sizeof(ret);
if (ret < 0) {
size += sizeof(ctx->audio.frame_size);
memcpy(&ctx->audio.bits_per_sample_fmt, buffer + size, sizeof(ctx->audio.bits_per_sample_fmt));
-#if 0
- // TODO: check!!
- memcpy (&ctx->audio, buffer + size, sizeof(ctx->audio));
-#endif
- } else {
- CODEC_LOG (DEBUG, "video type\n");
+ size += sizeof(ctx->audio.bits_per_sample_fmt);
}
}
+#if 1
+ memcpy(&ctx->codecdata_size, buffer + size, sizeof(ctx->codecdata_size));
+ size += sizeof(ctx->codecdata_size);
+
+ GST_DEBUG ("codec_init. extradata_size %d", ctx->codecdata_size);
+ if (ctx->codecdata_size > 0) {
+ ctx->codecdata = g_malloc(ctx->codecdata_size);
+ memcpy(ctx->codecdata, buffer + size, ctx->codecdata_size);
+ }
+#endif
+
return ret;
}
size += sizeof(*got_picture_ptr);
memcpy (video, buffer + size, sizeof(VideoData));
- CODEC_LOG (DEBUG, "decode_video. len: %d, have_data: %d\n", len, *got_picture_ptr);
+ GST_DEBUG ("decode_video. len: %d, have_data: %d", len, *got_picture_ptr);
return len;
}
memcpy (&len, buffer, sizeof(len));
size = sizeof(len);
- CODEC_LOG (DEBUG, "encode_video. outbuf size: %d\n", len);
+ GST_DEBUG ("encode_video. outbuf size: %d", len);
+
if (len > 0) {
memcpy (coded_frame, buffer + size, sizeof(int));
size += sizeof(int);
memcpy (out_buf, buffer + size, len);
}
- CODEC_LOG (DEBUG, "encode_audio. outbuf size: %d\n", len);
+ GST_DEBUG ("encode_audio. outbuf size: %d", len);
return len;
}