static gboolean
gst_maru_codec_element_init ()
{
- int fd = 0;
- int version = 0;
+ int fd = 0, version = 0;
int i, elem_cnt = 0;
uint32_t data_length = 0;
- void *buffer = NULL;
+ void *buffer = MAP_FAILED;
CodecElement *elem = NULL;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
fd = open (CODEC_DEV, O_RDWR);
if (fd < 0) {
- perror ("[gst-maru] failed to open codec device");
+ // perror ("[gst-maru] failed to open codec device");
+ GST_ERROR ("failed to open codec device");
return FALSE;
}
ioctl (fd, CODEC_CMD_GET_VERSION, &version);
if (version != CODEC_VER) {
- CODEC_LOG (INFO, "version conflict between device: %d, plugin: %d\n",
- version, CODEC_VER);
+ // CODEC_LOG (INFO, "version conflict between device: %d, plugin: %d\n", version, CODEC_VER);
+ GST_LOG ("version conflict between device: %d, plugin: %d", version, CODEC_VER);
close (fd);
return FALSE;
}
buffer = mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (!buffer) {
- perror ("[gst-maru] failure memory mapping.");
+ if (buffer == MAP_FAILED) {
+ // perror ("[gst-maru] failure memory mapping.");
+ GST_ERROR ("memory mapping failure");
close (fd);
return FALSE;
}
- CODEC_LOG (DEBUG, "request a device to get codec element.\n");
+ // CODEC_LOG (DEBUG, "request a device to get codec element.\n");
+ GST_DEBUG ("request a device to get codec element");
if (ioctl(fd, CODEC_CMD_GET_ELEMENT, &data_length) < 0) {
- perror ("[gst-maru] failed to get codec elements");
+ // perror ("[gst-maru] failed to get codec elements");
+ GST_ERROR ("failed to get codec elements");
munmap (buffer, 4096);
close (fd);
return FALSE;
}
- CODEC_LOG (DEBUG, "sizeof codec elements. %d\n", data_length);
+ // CODEC_LOG (DEBUG, "sizeof codec elements. %d\n", data_length);
+ GST_DEBUG ("total size of codec elements %d", data_length);
elem = g_malloc0 (data_length);
if (!elem) {
- CODEC_LOG (ERR, "Failed to allocate memory.\n");
+ // CODEC_LOG (ERR, "Failed to allocate memory.\n");
+ GST_ERROR ("failed to allocate memory for codec elements");
munmap (buffer, 4096);
close (fd);
return FALSE;
}
if (ioctl(fd, CODEC_CMD_GET_ELEMENT_DATA, elem) < 0) {
- CODEC_LOG (ERR, "failed to get codec elements\n");
+ // CODEC_LOG (ERR, "failed to get codec elements\n");
+ GST_ERROR ("failed to get codec elements");
munmap (buffer, 4096);
close (fd);
return FALSE;
"tizen-emul",
"Codecs for Tizen Emulator",
plugin_init,
- "0.2.2",
+ "0.2.7",
"LGPL",
"gst-plugins-emulator",
- "http://tizen.org"
+ "http://www.tizen.org"
)
int32_t channels, sample_rate;
int32_t block_align, depth;
int32_t sample_fmt, frame_size;
- int32_t bits_per_sample_fmt;
+ int32_t bits_per_sample_fmt, reserved;
int64_t channel_layout;
} AudioData;
CODEC_TYPE_ENCODE,
};
-enum SAMPLT_FORMAT {
+enum AUDIO_SAMPLE_FORMAT {
SAMPLE_FMT_NONE = -1,
SAMPLE_FMT_U8,
SAMPLE_FMT_S16,
SAMPLE_FMT_S32,
SAMPLE_FMT_FLT,
SAMPLE_FMT_DBL,
+
+ SAMPLE_FMT_U8P,
+ SAMPLE_FMT_S16P,
+ SAMPLE_FMT_S32P,
+ SAMPLE_FMT_FLTP,
+ SAMPLE_FMT_DBLP,
SAMPLE_FMT_NB
};
{
GstFlowReturn res = GST_FLOW_OK;
- CODEC_LOG (DEBUG, "flush queued\n");
+ GST_DEBUG_OBJECT (marudec, "flush queued");
while (marudec->queued) {
GstBuffer *buf = GST_BUFFER_CAST (marudec->queued->data);
oclass = (GstMaruDecClass *) (G_OBJECT_GET_CLASS (marudec));
#endif
- CODEC_LOG (DEBUG, "drain frame\n");
+ GST_DEBUG_OBJECT (marudec, "drain frame");
{
gint have_data, len, try = 0;
}
if (marudec->segment.rate < 0.0) {
- CODEC_LOG (DEBUG, "reverse playback\n");
+ GST_DEBUG_OBJECT (marudec, "reverse playback");
flush_queued (marudec);
}
}
marudec->dev = g_malloc0 (sizeof(CodecDevice));
if (!marudec->dev) {
- CODEC_LOG (ERR, "failed to allocate memory.\n");
+ GST_ERROR_OBJECT (marudec, "failed to allocate memory for CodecDevice");
}
}
return GST_FLOW_ERROR;
}
- CODEC_LOG (DEBUG, "outbuf size of decoded video: %d\n", pict_size);
+ GST_DEBUG_OBJECT (marudec, "outbuf size of decoded video %d", pict_size);
gst_pad_set_element_private(GST_PAD_PEER(marudec->srcpad), (gpointer)marudec);
const GstTSInfo *out_info;
decode = gst_marudec_do_qos (marudec, dec_info->timestamp, &mode_switch);
- CODEC_LOG (DEBUG, "decode: %d\n", decode);
- CODEC_LOG (DEBUG, "decode video: input buffer size: %d\n", size);
+ GST_DEBUG_OBJECT (marudec, "decode video: input buffer size %d", size);
len =
codec_decode_video (marudec->context, data, size,
dec_info->idx, in_offset, outbuf,
// if (len < 0) { // have_data <= 0) {
GST_DEBUG_OBJECT (marudec, "return flow %d, out %p, len %d",
*ret, *outbuf, len);
-
- CODEC_LOG (DEBUG,
- "return flow %d, out %p, len %d, have_data: %d\n",
- *ret, *outbuf, len, have_data);
-
return len;
}
new_aligned_buffer (FF_MAX_AUDIO_FRAME_SIZE,
GST_PAD_CAPS (marudec->srcpad));
- CODEC_LOG (DEBUG, "decode audio, input buffer size: %d\n", size);
+ GST_DEBUG_OBJECT (marudec, "decode audio, input buffer size %d", size);
len = codec_decode_audio (marudec->context,
(int16_t *) GST_BUFFER_DATA (*outbuf), &have_data,
return len;
}
- GST_BUFFER_SIZE (*outbuf) = have_data;
+ // GST_BUFFER_SIZE (*outbuf) = have_data;
+ GST_BUFFER_SIZE (*outbuf) = len;
if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
out_timestamp = dec_info->timestamp;
#if 0
ret = ioctl(maruenc->dev->fd, CODEC_CMD_RELEASE_BUFFER, &mem_offset);
if (ret < 0) {
- CODEC_LOG (ERR, "failed to release used buffer\n");
+ GST_ERROR_OBJECT (maruenc, "failed to release used buffer");
}
#endif
if (coded_frame) {
if (!is_keyframe) {
GST_DEBUG_OBJECT (maruenc, "this frame is not a keyframe");
+
+ /* GST_BUFFER_FLAG_DELTA_UNIT
+ * - this unit cannot be decoded independently.
+ */
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
- // GST_BUFFER_FLAG_DELTA_UNIT
- // - this unit cannot be decoded independently.
}
} else {
GST_WARNING_OBJECT (maruenc, "codec did not provide keyframe info");
int in_size, CodecDevice *dev)
{
int len = 0, ret = 0;
+ int outbuf_size = 0;
gpointer buffer = NULL;
CodecBufferId opaque;
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, "after decode_audio. ctx_id: %d, buffer = 0x%x\n",
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);
AudioData *audio, gpointer buffer)
{
int len = 0, size = 0;
+ int resample_size = 0;
memcpy (&len, buffer, sizeof(len));
size = sizeof(len);
memcpy (have_data, buffer + size, sizeof(*have_data));
size += sizeof(*have_data);
- CODEC_LOG (DEBUG, "decode_audio. len %d, have_data %d\n",
- len, (*have_data));
+ GST_DEBUG ("decode_audio. len %d, have_data %d", len, (*have_data));
if (*have_data) {
+ memcpy (&audio->sample_fmt, buffer + size, sizeof(audio->sample_fmt));
+ size += sizeof(audio->sample_fmt);
+
memcpy (&audio->sample_rate, buffer + size, sizeof(audio->sample_rate));
size += sizeof(audio->sample_rate);
memcpy (&audio->channel_layout, buffer + size, sizeof(audio->channel_layout));
size += sizeof(audio->channel_layout);
- CODEC_LOG (DEBUG, "decode_audio. sample_rate %d, channels %d, ch_layout %lld\n", audio->sample_rate, audio->channels, audio->channel_layout);
+ GST_DEBUG ("decode_audio. sample_fmt %d sample_rate %d, channels %d, ch_layout %lld",
+ audio->sample_fmt, audio->sample_rate, audio->channels, audio->channel_layout);
- memcpy (samples, buffer + size, (*have_data));
+ memcpy (&resample_size, buffer + size, sizeof(resample_size));
+ size += sizeof(resample_size);
+ memcpy (samples, buffer + size, resample_size);
}
- return len;
+// return len;
+ return resample_size;
}
void
switch (smp_fmt) {
case SAMPLE_FMT_U8:
+ case SAMPLE_FMT_U8P:
depth = 1;
break;
case SAMPLE_FMT_S16:
+ case SAMPLE_FMT_S16P:
depth = 2;
break;
case SAMPLE_FMT_S32:
case SAMPLE_FMT_FLT:
+ case SAMPLE_FMT_S32P:
+ case SAMPLE_FMT_FLTP:
depth = 4;
break;
case SAMPLE_FMT_DBL:
+ case SAMPLE_FMT_DBLP:
depth = 8;
break;
default:
switch (sample_fmt) {
case SAMPLE_FMT_S16:
+ case SAMPLE_FMT_S16P:
signedness = TRUE;
bpp = 16;
break;
case SAMPLE_FMT_S32:
+ case SAMPLE_FMT_S32P:
signedness = TRUE;
bpp = 32;
break;
case SAMPLE_FMT_FLT:
+ case SAMPLE_FMT_FLTP:
integer = FALSE;
bpp = 32;
break;
case SAMPLE_FMT_DBL:
+ case SAMPLE_FMT_DBLP:
integer = FALSE;
bpp = 64;
break;
break;
}
+ GST_DEBUG ("sample format: %d", sample_fmt);
+
if (bpp) {
if (integer) {
caps = gst_maru_audio_caps_new (ctx, name, "audio/x-raw-int",