Ejemplo n.º 1
0
static void
propagate_eos_if_required (mp4dmuxflt_prc_t * ap_prc,
                           OMX_BUFFERHEADERTYPE * ap_out_hdr)
{
  assert (ap_prc);
  assert (ap_out_hdr);

  /* If EOS, propagate the flag to the next component */
  if (tiz_filter_prc_is_eos (ap_prc)
      && tiz_buffer_available (ap_prc->p_mp4_store_) == 0)
    {
      ap_out_hdr->nFlags |= OMX_BUFFERFLAG_EOS;
      tiz_filter_prc_update_eos_flag (ap_prc, false);
    }
}
Ejemplo n.º 2
0
static OMX_ERRORTYPE vorbisd_prc_buffers_ready (const void *ap_obj)
{
  vorbisd_prc_t *p_prc = (vorbisd_prc_t *)ap_obj;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  assert (NULL != p_prc);

  TIZ_TRACE (handleOf (p_prc), "eos [%s] ",
             tiz_filter_prc_is_eos (p_prc) ? "YES" : "NO");
  while (tiz_filter_prc_headers_available (p_prc) && OMX_ErrorNone == rc)
    {
      rc = transform_buffer (p_prc);
    }

  return rc;
}
Ejemplo n.º 3
0
static int
mp4_read_cback (void * ap_handle, void * ap_buffer, int64_t a_size,
                int64_t * ap_nin, int64_t a_maxChunkSize)
{
  mp4dmuxflt_prc_t * p_prc = ap_handle;
  int retval = -1;

  assert (gp_prc == ap_handle);
  assert (p_prc);
  assert (ap_buffer);
  assert (ap_nin);

  *ap_nin = 0;

  if (tiz_filter_prc_is_eos (p_prc)
      && tiz_buffer_available (p_prc->p_mp4_store_) == 0)
    {
      TIZ_DEBUG (handleOf (p_prc), "out of compressed data");
      return 1;
    }

  (void) store_data (p_prc);

  if (ap_buffer && a_size > 0)
    {
      if (tiz_buffer_available (p_prc->p_mp4_store_) >= a_size)
        {
          memcpy (ap_buffer, tiz_buffer_get (p_prc->p_mp4_store_), a_size);
          tiz_buffer_advance (p_prc->p_mp4_store_, a_size);
          *ap_nin = a_size;
          retval = 0;
        }
      else
        {
          TIZ_DEBUG (handleOf (p_prc), "out of compressed data");
          retval = 1;
        }
    }

  TIZ_DEBUG (handleOf (p_prc), "a_size [%lld] nin [%lld]", a_size, *ap_nin);

  return retval;
}
Ejemplo n.º 4
0
static int fishsound_decoded_callback (FishSound *ap_fsound, float *app_pcm[],
                                       long frames, void *ap_user_data)
{
  int rc = FISH_SOUND_CONTINUE;
  vorbisd_prc_t *p_prc = ap_user_data;
  OMX_BUFFERHEADERTYPE *p_out = NULL;

  (void)ap_fsound;
  assert (NULL != app_pcm);
  assert (NULL != ap_user_data);

  TIZ_TRACE (handleOf (p_prc), "frames [%d] ", frames);

  /* Possible return values are: */

  /* FISH_SOUND_CONTINUE Continue decoding */
  /* FISH_SOUND_STOP_OK Stop decoding immediately and return control to the
     fish_sound_decode() caller */
  /* FISH_SOUND_STOP_ERR Stop decoding immediately, purge buffered data, and
     return control to the fish_sound_decode() caller */

  if (!p_prc->started_)
    {
      p_prc->started_ = true;
      fish_sound_command (p_prc->p_fsnd_, FISH_SOUND_GET_INFO,
                          &(p_prc->fsinfo_), sizeof(FishSoundInfo));
      if (p_prc->fsinfo_.channels > 2 || p_prc->fsinfo_.format
                                         != FISH_SOUND_VORBIS)
        {
          TIZ_ERROR (handleOf (p_prc),
                     "Supported Vorbis "
                     "streams up tp 2 channels only.");
          rc = FISH_SOUND_STOP_ERR;
          goto end;
        }
      TIZ_NOTICE (handleOf (p_prc), "Channels [%d] sampling rate [%d]",
                  p_prc->fsinfo_.channels, p_prc->fsinfo_.samplerate);
    }

  p_out = tiz_filter_prc_get_header (p_prc, ARATELIA_VORBIS_DECODER_OUTPUT_PORT_INDEX);
  if (NULL == p_out)
    {
      TIZ_TRACE (handleOf (p_prc),
                 "No more output buffers "
                 "available at the moment");
      rc = FISH_SOUND_STOP_OK;
      goto end;
    }

  {
    /* write decoded PCM samples */
    size_t i = 0;
    size_t frame_len = sizeof(float) * p_prc->fsinfo_.channels;
    size_t frames_alloc = ((p_out->nAllocLen - p_out->nOffset) / frame_len);
    size_t frames_to_write = (frames > frames_alloc) ? frames_alloc : frames;
    size_t bytes_to_write = frames_to_write * frame_len;
    assert (NULL != p_out);

    for (i = 0; i < frames_to_write; ++i)
      {
        size_t frame_offset = i * frame_len;
        size_t float_offset = i * p_prc->fsinfo_.channels;
        float *out = (float *)(p_out->pBuffer + p_out->nOffset + frame_offset);
        write_frame_float_ilv (out, ((float *)app_pcm) + float_offset,
                               p_prc->fsinfo_.channels);
      }
    p_out->nFilledLen += bytes_to_write;
    p_out->nOffset += bytes_to_write;

    if (frames_to_write < frames)
      {
        /* Temporarily store the data until an omx buffer is
         * available */
        OMX_U32 nbytes_remaining = (frames - frames_to_write) * frame_len;
        TIZ_TRACE (handleOf (p_prc), "Need to store [%d] bytes",
                   nbytes_remaining);
        nbytes_remaining = store_data (
            p_prc, (OMX_U8 *)(app_pcm[frames_to_write * sizeof(float)]),
            nbytes_remaining);
      }

    if (tiz_filter_prc_is_eos (p_prc))
      {
        /* Propagate EOS flag to output */
        p_out->nFlags |= OMX_BUFFERFLAG_EOS;
        tiz_filter_prc_update_eos_flag (p_prc, false);
        TIZ_TRACE (handleOf (p_prc), "Propagating EOS flag to output");
      }
    /* TODO: Shouldn't ignore this rc */
    (void)tiz_filter_prc_release_header
      (p_prc, ARATELIA_VORBIS_DECODER_OUTPUT_PORT_INDEX);
    /* Let's process one input buffer at a time, for now */
    rc = FISH_SOUND_STOP_OK;
  }

end:

  return rc;
}