您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GST_AUDIO_DECODER函数代码示例

51自学网 2021-06-01 20:55:46
  C++
这篇教程C++ GST_AUDIO_DECODER函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GST_AUDIO_DECODER函数的典型用法代码示例。如果您正苦于以下问题:C++ GST_AUDIO_DECODER函数的具体用法?C++ GST_AUDIO_DECODER怎么用?C++ GST_AUDIO_DECODER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GST_AUDIO_DECODER函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gst_amc_audio_dec_init

static voidgst_amc_audio_dec_init (GstAmcAudioDec * self){  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (self), TRUE);  gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (self), TRUE);  g_mutex_init (&self->drain_lock);  g_cond_init (&self->drain_cond);}
开发者ID:iainlane,项目名称:gstreamer,代码行数:9,


示例2: gst_ffmpegauddec_init

static voidgst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec){  GstFFMpegAudDecClass *klass =      (GstFFMpegAudDecClass *) G_OBJECT_GET_CLASS (ffmpegdec);  /* some ffmpeg data */  ffmpegdec->context = avcodec_alloc_context3 (klass->in_plugin);  ffmpegdec->opened = FALSE;  gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (ffmpegdec), TRUE);  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (ffmpegdec), TRUE);}
开发者ID:cablelabs,项目名称:gst-libav,代码行数:13,


示例3: gst_ffmpegauddec_drain

static voidgst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec){  GstFFMpegAudDecClass *oclass;  oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));  if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {    gint have_data, len;    GST_LOG_OBJECT (ffmpegdec,        "codec has delay capabilities, calling until libav has drained everything");    do {      GstFlowReturn ret;      len = gst_ffmpegauddec_frame (ffmpegdec, NULL, 0, &have_data, &ret);    } while (len >= 0 && have_data == 1);    avcodec_flush_buffers (ffmpegdec->context);  }  if (ffmpegdec->outbuf)    gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec),        ffmpegdec->outbuf, 1);  ffmpegdec->outbuf = NULL;}
开发者ID:GStreamer,项目名称:gst-libav,代码行数:27,


示例4: gst_dtsdec_renegotiate

static gbooleangst_dtsdec_renegotiate (GstDtsDec * dts){  gint channels;  gboolean result = FALSE;  GstAudioChannelPosition from[6], to[6];  GstAudioInfo info;  channels = gst_dtsdec_channels (dts->using_channels, from);  if (!channels)    goto done;  GST_INFO_OBJECT (dts, "dtsdec renegotiate, channels=%d, rate=%d",      channels, dts->sample_rate);  memcpy (to, from, sizeof (GstAudioChannelPosition) * channels);  gst_audio_channel_positions_to_valid_order (to, channels);  gst_audio_get_channel_reorder_map (channels, from, to,      dts->channel_reorder_map);  gst_audio_info_init (&info);  gst_audio_info_set_format (&info,      SAMPLE_TYPE, dts->sample_rate, channels, (channels > 1 ? to : NULL));  if (!gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (dts), &info))    goto done;  result = TRUE;done:  return result;}
开发者ID:lubing521,项目名称:gst-embedded-builder,代码行数:34,


示例5: gst_mulawdec_init

static voidgst_mulawdec_init (GstMuLawDec * mulawdec){    gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (mulawdec), TRUE);    gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST            (mulawdec), TRUE);    GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (mulawdec));}
开发者ID:DylanZA,项目名称:gst-plugins-good,代码行数:8,


示例6: gst_droidadec_init

static voidgst_droidadec_init (GstDroidADec * dec){  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (dec), TRUE);  dec->codec = NULL;  dec->codec_type = NULL;  dec->downstream_flow_ret = GST_FLOW_OK;  dec->eos = FALSE;  dec->codec_data = NULL;  dec->channels = 0;  dec->rate = 0;  g_mutex_init (&dec->eos_lock);  g_cond_init (&dec->eos_cond);  dec->adapter = gst_adapter_new ();}
开发者ID:rss351,项目名称:gst-droid,代码行数:18,


示例7: gst_wavpack_dec_init

static voidgst_wavpack_dec_init (GstWavpackDec * dec){  dec->context = NULL;  dec->stream_reader = gst_wavpack_stream_reader_new ();  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_wavpack_dec_reset (dec);}
开发者ID:Lachann,项目名称:gst-plugins-good,代码行数:10,


示例8: gst_opus_dec_init

static voidgst_opus_dec_init (GstOpusDec * dec){  dec->use_inband_fec = FALSE;  dec->apply_gain = DEFAULT_APPLY_GAIN;  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_opus_dec_reset (dec);}
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:10,


示例9: gst_sbc_dec_init

static voidgst_sbc_dec_init (GstSbcDec * dec){  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST      (dec), TRUE);  GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (dec));  dec->samples_per_frame = 0;  dec->frame_len = 0;}
开发者ID:0p1pp1,项目名称:gst-plugins-bad,代码行数:11,


示例10: gst_ffmpegauddec_init

static voidgst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec){  GstFFMpegAudDecClass *klass =      (GstFFMpegAudDecClass *) G_OBJECT_GET_CLASS (ffmpegdec);  /* some ffmpeg data */  ffmpegdec->context = avcodec_alloc_context3 (klass->in_plugin);  ffmpegdec->context->opaque = ffmpegdec;  ffmpegdec->opened = FALSE;  ffmpegdec->frame = av_frame_alloc ();  GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_DECODER_SINK_PAD (ffmpegdec));  gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST      (ffmpegdec), TRUE);  gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (ffmpegdec), TRUE);  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (ffmpegdec), TRUE);}
开发者ID:GStreamer,项目名称:gst-libav,代码行数:20,


示例11: gst_ffmpegauddec_get_buffer

/* called when ffmpeg wants us to allocate a buffer to write the decoded frame * into. We try to give it memory from our pool */static intgst_ffmpegauddec_get_buffer (AVCodecContext * context, AVFrame * frame){  GstFFMpegAudDec *ffmpegdec;  GstAudioInfo *info;  BufferInfo *buffer_info;  ffmpegdec = (GstFFMpegAudDec *) context->opaque;  if (G_UNLIKELY (!gst_ffmpegauddec_negotiate (ffmpegdec, FALSE)))    goto negotiate_failed;  /* Always use the default allocator for planar audio formats because   * we will have to copy and deinterleave later anyway */  if (av_sample_fmt_is_planar (ffmpegdec->context->sample_fmt))    goto fallback;  info = gst_audio_decoder_get_audio_info (GST_AUDIO_DECODER (ffmpegdec));  buffer_info = g_slice_new (BufferInfo);  buffer_info->buffer =      gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER (ffmpegdec),      frame->nb_samples * info->bpf);  gst_buffer_map (buffer_info->buffer, &buffer_info->map, GST_MAP_WRITE);  frame->opaque = buffer_info;  frame->data[0] = buffer_info->map.data;  frame->extended_data = frame->data;  frame->linesize[0] = buffer_info->map.size;  frame->type = FF_BUFFER_TYPE_USER;  return 0;  /* fallbacks */negotiate_failed:  {    GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");    goto fallback;  }fallback:  {    return avcodec_default_get_buffer (context, frame);  }}
开发者ID:cablelabs,项目名称:gst-libav,代码行数:43,


示例12: gst_speex_dec_init

static voidgst_speex_dec_init (GstSpeexDec * dec){  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST      (dec), TRUE);  GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (dec));  dec->enh = DEFAULT_ENH;  gst_speex_dec_reset (dec);}
开发者ID:pexip,项目名称:gst-plugins-good,代码行数:12,


示例13: gst_opus_dec_init

static voidgst_opus_dec_init (GstOpusDec * dec){  dec->use_inband_fec = FALSE;  dec->apply_gain = DEFAULT_APPLY_GAIN;  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST      (dec), TRUE);  GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (dec));  gst_opus_dec_reset (dec);}
开发者ID:GrokImageCompression,项目名称:gst-plugins-base,代码行数:13,


示例14: gst_wavpack_dec_init

static voidgst_wavpack_dec_init (GstWavpackDec * dec){  dec->context = NULL;  dec->stream_reader = gst_wavpack_stream_reader_new ();  gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);  gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST      (dec), TRUE);  GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (dec));  gst_wavpack_dec_reset (dec);}
开发者ID:DylanZA,项目名称:gst-plugins-good,代码行数:13,


示例15: gst_a52dec_update_streaminfo

static voidgst_a52dec_update_streaminfo (GstA52Dec * a52dec){  GstTagList *taglist;  taglist = gst_tag_list_new_empty ();  gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_BITRATE,      (guint) a52dec->bit_rate, NULL);  gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (a52dec), taglist,      GST_TAG_MERGE_REPLACE);  gst_tag_list_unref (taglist);}
开发者ID:lubing521,项目名称:gst-embedded-builder,代码行数:13,


示例16: gst_dtsdec_update_streaminfo

static voidgst_dtsdec_update_streaminfo (GstDtsDec * dts){  GstTagList *taglist;  if (dts->bit_rate > 3) {    taglist = gst_tag_list_new_empty ();    /* 1 => open bitrate, 2 => variable bitrate, 3 => lossless */    gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_BITRATE,        (guint) dts->bit_rate, NULL);    gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (dts), taglist,        GST_TAG_MERGE_REPLACE);  }}
开发者ID:lubing521,项目名称:gst-embedded-builder,代码行数:14,


示例17: gst_imx_audio_uniaudio_dec_init

void gst_imx_audio_uniaudio_dec_init(GstImxAudioUniaudioDec *imx_decoder){	GstAudioDecoder *base = GST_AUDIO_DECODER(imx_decoder);	gst_audio_decoder_set_drainable(base, TRUE);	gst_audio_decoder_set_plc_aware(base, FALSE);	imx_decoder->codec = NULL;	imx_decoder->handle = NULL;	imx_decoder->original_channel_positions = NULL;	imx_decoder->reordered_channel_positions = NULL;	imx_decoder->out_adapter = gst_adapter_new();	imx_decoder->skip_header_counter = 0;	imx_decoder->codec_data = NULL;}
开发者ID:Freescale,项目名称:gstreamer-imx,代码行数:14,


示例18: gst_amc_audio_dec_set_src_caps

static gbooleangst_amc_audio_dec_set_src_caps (GstAmcAudioDec * self, GstAmcFormat * format){  gint rate, channels;  guint32 channel_mask = 0;  GstAudioChannelPosition to[64];  GError *err = NULL;  if (!gst_amc_format_get_int (format, "sample-rate", &rate, &err) ||      !gst_amc_format_get_int (format, "channel-count", &channels, &err)) {    GST_ERROR_OBJECT (self, "Failed to get output format metadata: %s",        err->message);    g_clear_error (&err);    return FALSE;  }  if (rate == 0 || channels == 0) {    GST_ERROR_OBJECT (self, "Rate or channels not set");    return FALSE;  }  /* Not always present */  if (gst_amc_format_contains_key (format, "channel-mask", NULL))    gst_amc_format_get_int (format, "channel-mask", (gint *) & channel_mask,        NULL);  gst_amc_audio_channel_mask_to_positions (channel_mask, channels,      self->positions);  memcpy (to, self->positions, sizeof (to));  gst_audio_channel_positions_to_valid_order (to, channels);  self->needs_reorder =      (memcmp (self->positions, to,          sizeof (GstAudioChannelPosition) * channels) != 0);  if (self->needs_reorder)    gst_audio_get_channel_reorder_map (channels, self->positions, to,        self->reorder_map);  gst_audio_info_init (&self->info);  gst_audio_info_set_format (&self->info, GST_AUDIO_FORMAT_S16, rate, channels,      to);  if (!gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (self),          &self->info))    return FALSE;  self->input_caps_changed = FALSE;  return TRUE;}
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:49,


示例19: gst_droidadec_finalize

static voidgst_droidadec_finalize (GObject * object){  GstDroidADec *dec = GST_DROIDADEC (object);  GST_DEBUG_OBJECT (dec, "finalize");  gst_droidadec_stop (GST_AUDIO_DECODER (dec));  g_mutex_clear (&dec->eos_lock);  g_cond_clear (&dec->eos_cond);  gst_object_unref (dec->adapter);  dec->adapter = NULL;  G_OBJECT_CLASS (parent_class)->finalize (object);}
开发者ID:rss351,项目名称:gst-droid,代码行数:17,


示例20: vorbis_handle_identification_packet

static GstFlowReturnvorbis_handle_identification_packet (GstVorbisDec * vd){  GstAudioInfo info;  switch (vd->vi.channels) {    case 1:    case 2:    case 3:    case 4:    case 5:    case 6:    case 7:    case 8:    {      const GstAudioChannelPosition *pos;      pos = gst_vorbis_default_channel_positions[vd->vi.channels - 1];      gst_audio_info_set_format (&info, GST_VORBIS_AUDIO_FORMAT, vd->vi.rate,          vd->vi.channels, pos);      break;    }    default:{      GstAudioChannelPosition position[64];      gint i, max_pos = MAX (vd->vi.channels, 64);      GST_ELEMENT_WARNING (vd, STREAM, DECODE,          (NULL), ("Using NONE channel layout for more than 8 channels"));      for (i = 0; i < max_pos; i++)        position[i] = GST_AUDIO_CHANNEL_POSITION_NONE;      gst_audio_info_set_format (&info, GST_VORBIS_AUDIO_FORMAT, vd->vi.rate,          vd->vi.channels, position);      break;    }  }  gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (vd), &info);  vd->info = info;  /* select a copy_samples function, this way we can have specialized versions   * for mono/stereo and avoid the depth switch in tremor case */  vd->copy_samples = gst_vorbis_get_copy_sample_func (info.channels);  return GST_FLOW_OK;}
开发者ID:Lachann,项目名称:gst-plugins-base,代码行数:45,


示例21: gst_opus_dec_negotiate

static voidgst_opus_dec_negotiate (GstOpusDec * dec, const GstAudioChannelPosition * pos){  GstCaps *caps = gst_pad_get_allowed_caps (GST_AUDIO_DECODER_SRC_PAD (dec));  GstStructure *s;  GstAudioInfo info;  if (caps) {    caps = gst_caps_truncate (caps);    caps = gst_caps_make_writable (caps);    s = gst_caps_get_structure (caps, 0);    gst_structure_fixate_field_nearest_int (s, "rate", 48000);    gst_structure_get_int (s, "rate", &dec->sample_rate);    gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels);    gst_structure_get_int (s, "channels", &dec->n_channels);    gst_caps_unref (caps);  } else {    dec->sample_rate = 48000;  }  GST_INFO_OBJECT (dec, "Negotiated %d channels, %d Hz", dec->n_channels,      dec->sample_rate);  /* pass valid order to audio info */  if (pos) {    memcpy (dec->opus_pos, pos, sizeof (pos[0]) * dec->n_channels);    gst_audio_channel_positions_to_valid_order (dec->opus_pos, dec->n_channels);  }  /* set up source format */  gst_audio_info_init (&info);  gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S16,      dec->sample_rate, dec->n_channels, pos ? dec->opus_pos : NULL);  gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (dec), &info);  /* but we still need the opus order for later reordering */  if (pos) {    memcpy (dec->opus_pos, pos, sizeof (pos[0]) * dec->n_channels);    gst_audio_channel_positions_to_valid_order (dec->opus_pos, dec->n_channels);  } else {    dec->opus_pos[0] = GST_AUDIO_CHANNEL_POSITION_INVALID;  }  dec->info = info;}
开发者ID:Lachann,项目名称:gst-plugins-bad,代码行数:45,


示例22: gst_speex_dec_parse_comments

static GstFlowReturngst_speex_dec_parse_comments (GstSpeexDec * dec, GstBuffer * buf){  GstTagList *list;  gchar *ver, *encoder = NULL;  list = gst_tag_list_from_vorbiscomment_buffer (buf, NULL, 0, &encoder);  if (!list) {    GST_WARNING_OBJECT (dec, "couldn't decode comments");    list = gst_tag_list_new ();  }  if (encoder) {    gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,        GST_TAG_ENCODER, encoder, NULL);  }  gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,      GST_TAG_AUDIO_CODEC, "Speex", NULL);  ver = g_strndup (dec->header->speex_version, SPEEX_HEADER_VERSION_LENGTH);  g_strstrip (ver);  if (ver != NULL && *ver != '/0') {    gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,        GST_TAG_ENCODER_VERSION, ver, NULL);  }  if (dec->header->bitrate > 0) {    gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,        GST_TAG_BITRATE, (guint) dec->header->bitrate, NULL);  }  GST_INFO_OBJECT (dec, "tags: %" GST_PTR_FORMAT, list);  gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (dec), list,      GST_TAG_MERGE_REPLACE);  gst_tag_list_free (list);  g_free (encoder);  g_free (ver);  return GST_FLOW_OK;}
开发者ID:freedesktop-unofficial-mirror,项目名称:gstreamer-sdk__gst-plugins-good,代码行数:45,


示例23: gst_wavpack_dec_negotiate

static voidgst_wavpack_dec_negotiate (GstWavpackDec * dec){  GstAudioInfo info;  GstAudioFormat fmt;  GstAudioChannelPosition pos[64] = { GST_AUDIO_CHANNEL_POSITION_INVALID, };  /* arrange for 1, 2 or 4-byte width == depth output */  dec->width = dec->depth;  switch (dec->depth) {    case 8:      fmt = GST_AUDIO_FORMAT_S8;      break;    case 16:      fmt = _GST_AUDIO_FORMAT_NE (S16);      break;    case 24:    case 32:      fmt = _GST_AUDIO_FORMAT_NE (S32);      dec->width = 32;      break;    default:      fmt = GST_AUDIO_FORMAT_UNKNOWN;      g_assert_not_reached ();      break;  }  g_assert (dec->channel_mask != 0);  if (!gst_wavpack_get_channel_positions (dec->channels,          dec->channel_mask, pos))    GST_WARNING_OBJECT (dec, "Failed to set channel layout");  gst_audio_info_init (&info);  gst_audio_info_set_format (&info, fmt, dec->sample_rate, dec->channels, pos);  gst_audio_channel_positions_to_valid_order (info.position, info.channels);  gst_audio_get_channel_reorder_map (info.channels,      info.position, pos, dec->channel_reorder_map);  /* should always succeed */  gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (dec), &info);}
开发者ID:DylanZA,项目名称:gst-plugins-good,代码行数:43,


示例24: gst_mpg123_audio_dec_push_decoded_bytes

static GstFlowReturngst_mpg123_audio_dec_push_decoded_bytes (GstMpg123AudioDec * mpg123_decoder,    unsigned char const *decoded_bytes, size_t const num_decoded_bytes){  GstBuffer *output_buffer;  GstFlowReturn alloc_error;  GstAudioDecoder *dec;  output_buffer = NULL;  dec = GST_AUDIO_DECODER (mpg123_decoder);  if ((num_decoded_bytes == 0) || (decoded_bytes == NULL)) {    /* This occurs in the first few frames, which do not carry data; once MPG123_AUDIO_DEC_NEW_FORMAT is received, the empty frames stop occurring */    GST_TRACE_OBJECT (mpg123_decoder,        "Nothing was decoded -> no output buffer to push");    return GST_FLOW_OK;  }  output_buffer = gst_buffer_new_allocate (NULL, num_decoded_bytes, NULL);  alloc_error = (output_buffer == NULL) ? GST_FLOW_ERROR : GST_FLOW_OK;  if (alloc_error != GST_FLOW_OK) {    /* This is necessary to advance playback in time, even when nothing was decoded. */    return gst_audio_decoder_finish_frame (dec, NULL, 1);  } else {    GstMapInfo info;    if (gst_buffer_map (output_buffer, &info, GST_MAP_WRITE)) {      if (info.size != num_decoded_bytes)        GST_ERROR_OBJECT (mpg123_decoder,            "Mapped memory region has size %u instead of expected size %u",            info.size, num_decoded_bytes);      else        memcpy (info.data, decoded_bytes, num_decoded_bytes);      gst_buffer_unmap (output_buffer, &info);    } else      GST_ERROR_OBJECT (mpg123_decoder, "Could not map buffer");    return gst_audio_decoder_finish_frame (dec, output_buffer, 1);  }}
开发者ID:ylatuya,项目名称:gst-plugins-bad,代码行数:42,


示例25: gst_mpg123_audio_dec_push_decoded_bytes

static GstFlowReturngst_mpg123_audio_dec_push_decoded_bytes (GstMpg123AudioDec * mpg123_decoder,    unsigned char const *decoded_bytes, size_t const num_decoded_bytes){  GstBuffer *output_buffer;  GstAudioDecoder *dec;  output_buffer = NULL;  dec = GST_AUDIO_DECODER (mpg123_decoder);  if ((num_decoded_bytes == 0) || (decoded_bytes == NULL)) {    /* This occurs in the first few frames, which do not carry data; once     * MPG123_AUDIO_DEC_NEW_FORMAT is received, the empty frames stop occurring */    GST_DEBUG_OBJECT (mpg123_decoder,        "cannot decode yet, need more data -> no output buffer to push");    return GST_FLOW_OK;  }  output_buffer = gst_buffer_new_allocate (NULL, num_decoded_bytes, NULL);  if (output_buffer == NULL) {    /* This is necessary to advance playback in time,     * even when nothing was decoded. */    return gst_audio_decoder_finish_frame (dec, NULL, 1);  } else {    GstMapInfo info;    if (gst_buffer_map (output_buffer, &info, GST_MAP_WRITE)) {      memcpy (info.data, decoded_bytes, num_decoded_bytes);      gst_buffer_unmap (output_buffer, &info);    } else {      GST_ERROR_OBJECT (mpg123_decoder, "gst_buffer_map() returned NULL");      gst_buffer_unref (output_buffer);      output_buffer = NULL;    }    return gst_audio_decoder_finish_frame (dec, output_buffer, 1);  }}
开发者ID:cbetz421,项目名称:gst-plugins-bad,代码行数:39,


示例26: gst_wavpack_dec_post_tags

static voidgst_wavpack_dec_post_tags (GstWavpackDec * dec){  GstTagList *list;  GstFormat format_time = GST_FORMAT_TIME, format_bytes = GST_FORMAT_BYTES;  gint64 duration, size;  /* try to estimate the average bitrate */  if (gst_pad_peer_query_duration (GST_AUDIO_DECODER_SINK_PAD (dec),          format_bytes, &size) &&      gst_pad_peer_query_duration (GST_AUDIO_DECODER_SINK_PAD (dec),          format_time, &duration) && size > 0 && duration > 0) {    guint64 bitrate;    list = gst_tag_list_new_empty ();    bitrate = gst_util_uint64_scale (size, 8 * GST_SECOND, duration);    gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_BITRATE,        (guint) bitrate, NULL);    gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (dec), list,        GST_TAG_MERGE_REPLACE);  }}
开发者ID:Lachann,项目名称:gst-plugins-good,代码行数:23,


示例27: opus_dec_chain_parse_data

static GstFlowReturnopus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buffer){  GstFlowReturn res = GST_FLOW_OK;  gsize size;  guint8 *data;  GstBuffer *outbuf;  gint16 *out_data;  int n, err;  int samples;  unsigned int packet_size;  GstBuffer *buf;  GstMapInfo map, omap;  if (dec->state == NULL) {    /* If we did not get any headers, default to 2 channels */    if (dec->n_channels == 0) {      GST_INFO_OBJECT (dec, "No header, assuming single stream");      dec->n_channels = 2;      dec->sample_rate = 48000;      /* default stereo mapping */      dec->channel_mapping_family = 0;      dec->channel_mapping[0] = 0;      dec->channel_mapping[1] = 1;      dec->n_streams = 1;      dec->n_stereo_streams = 1;      gst_opus_dec_negotiate (dec, NULL);    }    GST_DEBUG_OBJECT (dec, "Creating decoder with %d channels, %d Hz",        dec->n_channels, dec->sample_rate);#ifndef GST_DISABLE_GST_DEBUG    gst_opus_common_log_channel_mapping_table (GST_ELEMENT (dec), opusdec_debug,        "Mapping table", dec->n_channels, dec->channel_mapping);#endif    GST_DEBUG_OBJECT (dec, "%d streams, %d stereo", dec->n_streams,        dec->n_stereo_streams);    dec->state =        opus_multistream_decoder_create (dec->sample_rate, dec->n_channels,        dec->n_streams, dec->n_stereo_streams, dec->channel_mapping, &err);    if (!dec->state || err != OPUS_OK)      goto creation_failed;  }  if (buffer) {    GST_DEBUG_OBJECT (dec, "Received buffer of size %" G_GSIZE_FORMAT,        gst_buffer_get_size (buffer));  } else {    GST_DEBUG_OBJECT (dec, "Received missing buffer");  }  /* if using in-band FEC, we introdude one extra frame's delay as we need     to potentially wait for next buffer to decode a missing buffer */  if (dec->use_inband_fec && !dec->primed) {    GST_DEBUG_OBJECT (dec, "First buffer received in FEC mode, early out");    gst_buffer_replace (&dec->last_buffer, buffer);    dec->primed = TRUE;    goto done;  }  /* That's the buffer we'll be sending to the opus decoder. */  buf = (dec->use_inband_fec      && gst_buffer_get_size (dec->last_buffer) >      0) ? dec->last_buffer : buffer;  if (buf && gst_buffer_get_size (buf) > 0) {    gst_buffer_map (buf, &map, GST_MAP_READ);    data = map.data;    size = map.size;    GST_DEBUG_OBJECT (dec, "Using buffer of size %" G_GSIZE_FORMAT, size);  } else {    /* concealment data, pass NULL as the bits parameters */    GST_DEBUG_OBJECT (dec, "Using NULL buffer");    data = NULL;    size = 0;  }  /* use maximum size (120 ms) as the number of returned samples is     not constant over the stream. */  samples = 120 * dec->sample_rate / 1000;  packet_size = samples * dec->n_channels * 2;  outbuf =      gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER (dec),      packet_size);  if (!outbuf) {    goto buffer_failed;  }  gst_buffer_map (outbuf, &omap, GST_MAP_WRITE);  out_data = (gint16 *) omap.data;  if (dec->use_inband_fec) {    if (dec->last_buffer) {      /* normal delayed decode */      GST_LOG_OBJECT (dec, "FEC enabled, decoding last delayed buffer");      n = opus_multistream_decode (dec->state, data, size, out_data, samples,          0);//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:101,


示例28: vorbis_dec_handle_frame

static GstFlowReturnvorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer){  ogg_packet *packet;  ogg_packet_wrapper packet_wrapper;  GstFlowReturn result = GST_FLOW_OK;  GstMapInfo map;  GstVorbisDec *vd = GST_VORBIS_DEC (dec);  /* no draining etc */  if (G_UNLIKELY (!buffer))    return GST_FLOW_OK;  GST_LOG_OBJECT (vd, "got buffer %p", buffer);  /* make ogg_packet out of the buffer */  gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map);  packet = gst_ogg_packet_from_wrapper (&packet_wrapper);  /* set some more stuff */  packet->granulepos = -1;  packet->packetno = 0;         /* we don't care */  /* EOS does not matter, it is used in vorbis to implement clipping the last   * block of samples based on the granulepos. We clip based on segments. */  packet->e_o_s = 0;  GST_LOG_OBJECT (vd, "decode buffer of size %ld", packet->bytes);  /* error out on empty header packets, but just skip empty data packets */  if (G_UNLIKELY (packet->bytes == 0)) {    if (vd->initialized)      goto empty_buffer;    else      goto empty_header;  }  /* switch depending on packet type */  if ((gst_ogg_packet_data (packet))[0] & 1) {    if (vd->initialized) {      GST_WARNING_OBJECT (vd, "Already initialized, so ignoring header packet");      goto done;    }    result = vorbis_handle_header_packet (vd, packet);    if (result != GST_FLOW_OK)      goto done;    /* consumer header packet/frame */    result = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (vd), NULL, 1);  } else {    GstClockTime timestamp, duration;    timestamp = GST_BUFFER_TIMESTAMP (buffer);    duration = GST_BUFFER_DURATION (buffer);    result = vorbis_handle_data_packet (vd, packet, timestamp, duration);  }done:  GST_LOG_OBJECT (vd, "unmap buffer %p", buffer);  gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map);  return result;empty_buffer:  {    /* don't error out here, just ignore the buffer, it's invalid for vorbis     * but not fatal. */    GST_WARNING_OBJECT (vd, "empty buffer received, ignoring");    result = GST_FLOW_OK;    goto done;  }/* ERRORS */empty_header:  {    GST_ELEMENT_ERROR (vd, STREAM, DECODE, (NULL), ("empty header received"));    result = GST_FLOW_ERROR;    goto done;  }}
开发者ID:Lachann,项目名称:gst-plugins-base,代码行数:77,


示例29: vorbis_handle_data_packet

static GstFlowReturnvorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,    GstClockTime timestamp, GstClockTime duration){#ifdef USE_TREMOLO  vorbis_sample_t *pcm;#else  vorbis_sample_t **pcm;#endif  guint sample_count;  GstBuffer *out = NULL;  GstFlowReturn result;  GstMapInfo map;  gsize size;  if (G_UNLIKELY (!vd->initialized)) {    result = vorbis_dec_handle_header_caps (vd);    if (result != GST_FLOW_OK)      goto not_initialized;  }  /* normal data packet */  /* FIXME, we can skip decoding if the packet is outside of the   * segment, this is however not very trivial as we need a previous   * packet to decode the current one so we must be careful not to   * throw away too much. For now we decode everything and clip right   * before pushing data. */#ifdef USE_TREMOLO  if (G_UNLIKELY (vorbis_dsp_synthesis (&vd->vd, packet, 1)))    goto could_not_read;#else  if (G_UNLIKELY (vorbis_synthesis (&vd->vb, packet)))    goto could_not_read;  if (G_UNLIKELY (vorbis_synthesis_blockin (&vd->vd, &vd->vb) < 0))    goto not_accepted;#endif  /* assume all goes well here */  result = GST_FLOW_OK;  /* count samples ready for reading */#ifdef USE_TREMOLO  if ((sample_count = vorbis_dsp_pcmout (&vd->vd, NULL, 0)) == 0)#else  if ((sample_count = vorbis_synthesis_pcmout (&vd->vd, NULL)) == 0)    goto done;#endif  size = sample_count * vd->info.bpf;  GST_LOG_OBJECT (vd, "%d samples ready for reading, size %" G_GSIZE_FORMAT,      sample_count, size);  /* alloc buffer for it */  out = gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER (vd), size);  gst_buffer_map (out, &map, GST_MAP_WRITE);  /* get samples ready for reading now, should be sample_count */#ifdef USE_TREMOLO  if (G_UNLIKELY (vorbis_dsp_pcmout (&vd->vd, map.data, sample_count) !=          sample_count))#else  if (G_UNLIKELY (vorbis_synthesis_pcmout (&vd->vd, &pcm) != sample_count))#endif    goto wrong_samples;#ifdef USE_TREMOLO  if (vd->info.channels < 9)    gst_audio_reorder_channels (map.data, map.size, GST_VORBIS_AUDIO_FORMAT,        vd->info.channels, gst_vorbis_channel_positions[vd->info.channels - 1],        gst_vorbis_default_channel_positions[vd->info.channels - 1]);#else  /* copy samples in buffer */  vd->copy_samples ((vorbis_sample_t *) map.data, pcm,      sample_count, vd->info.channels);#endif  GST_LOG_OBJECT (vd, "have output size of %" G_GSIZE_FORMAT, size);  gst_buffer_unmap (out, &map);done:  /* whether or not data produced, consume one frame and advance time */  result = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (vd), out, 1);#ifdef USE_TREMOLO  vorbis_dsp_read (&vd->vd, sample_count);#else  vorbis_synthesis_read (&vd->vd, sample_count);#endif  return result;  /* ERRORS */not_initialized:  {    GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,        (NULL), ("no header sent yet"));    return GST_FLOW_NOT_NEGOTIATED;  }//.........这里部分代码省略.........
开发者ID:Lachann,项目名称:gst-plugins-base,代码行数:101,


示例30: gst_amc_audio_dec_set_format

static gbooleangst_amc_audio_dec_set_format (GstAudioDecoder * decoder, GstCaps * caps){  GstAmcAudioDec *self;  GstStructure *s;  GstAmcFormat *format;  const gchar *mime;  gboolean is_format_change = FALSE;  gboolean needs_disable = FALSE;  gchar *format_string;  gint rate, channels;  GError *err = NULL;  self = GST_AMC_AUDIO_DEC (decoder);  GST_DEBUG_OBJECT (self, "Setting new caps %" GST_PTR_FORMAT, caps);  /* Check if the caps change is a real format change or if only irrelevant   * parts of the caps have changed or nothing at all.   */  is_format_change |= (!self->input_caps      || !gst_caps_is_equal (self->input_caps, caps));  needs_disable = self->started;  /* If the component is not started and a real format change happens   * we have to restart the component. If no real format change   * happened we can just exit here.   */  if (needs_disable && !is_format_change) {    /* Framerate or something minor changed */    self->input_caps_changed = TRUE;    GST_DEBUG_OBJECT (self,        "Already running and caps did not change the format");    return TRUE;  }  if (needs_disable && is_format_change) {    gst_amc_audio_dec_drain (self);    GST_AUDIO_DECODER_STREAM_UNLOCK (self);    gst_amc_audio_dec_stop (GST_AUDIO_DECODER (self));    GST_AUDIO_DECODER_STREAM_LOCK (self);    gst_amc_audio_dec_close (GST_AUDIO_DECODER (self));    if (!gst_amc_audio_dec_open (GST_AUDIO_DECODER (self))) {      GST_ERROR_OBJECT (self, "Failed to open codec again");      return FALSE;    }    if (!gst_amc_audio_dec_start (GST_AUDIO_DECODER (self))) {      GST_ERROR_OBJECT (self, "Failed to start codec again");    }  }  /* srcpad task is not running at this point */  mime = caps_to_mime (caps);  if (!mime) {    GST_ERROR_OBJECT (self, "Failed to convert caps to mime");    return FALSE;  }  s = gst_caps_get_structure (caps, 0);  if (!gst_structure_get_int (s, "rate", &rate) ||      !gst_structure_get_int (s, "channels", &channels)) {    GST_ERROR_OBJECT (self, "Failed to get rate/channels");    return FALSE;  }  format = gst_amc_format_new_audio (mime, rate, channels, &err);  if (!format) {    GST_ELEMENT_ERROR_FROM_ERROR (self, err);    return FALSE;  }  /* FIXME: These buffers needs to be valid until the codec is stopped again */  g_list_foreach (self->codec_datas, (GFunc) gst_buffer_unref, NULL);  g_list_free (self->codec_datas);  self->codec_datas = NULL;  if (gst_structure_has_field (s, "codec_data")) {    const GValue *h = gst_structure_get_value (s, "codec_data");    GstBuffer *codec_data = gst_value_get_buffer (h);    GstMapInfo minfo;    guint8 *data;    gst_buffer_map (codec_data, &minfo, GST_MAP_READ);    data = g_memdup (minfo.data, minfo.size);    self->codec_datas = g_list_prepend (self->codec_datas, data);    gst_amc_format_set_buffer (format, "csd-0", data, minfo.size, &err);    if (err)      GST_ELEMENT_WARNING_FROM_ERROR (self, err);    gst_buffer_unmap (codec_data, &minfo);  } else if (gst_structure_has_field (s, "streamheader")) {    const GValue *sh = gst_structure_get_value (s, "streamheader");    gint nsheaders = gst_value_array_get_size (sh);    GstBuffer *buf;    const GValue *h;    gint i, j;    gchar *fname;    GstMapInfo minfo;    guint8 *data;//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:101,



注:本文中的GST_AUDIO_DECODER函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GST_AUDIO_INFO_CHANNELS函数代码示例
C++ GST_APP_SRC函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。