diff options
Diffstat (limited to 'audio/decode/ad_lavc.c')
-rw-r--r-- | audio/decode/ad_lavc.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index d701630fc6..fb429d567b 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -40,7 +40,6 @@ struct priv { AVCodecContext *avctx; AVFrame *avframe; - struct mp_audio frame; bool force_channel_map; uint32_t skip_samples, trim_samples; bool preroll_done; @@ -191,7 +190,7 @@ static bool send_packet(struct dec_audio *da, struct demux_packet *mpkt) return true; } -static bool receive_frame(struct dec_audio *da, struct mp_audio **out) +static bool receive_frame(struct dec_audio *da, struct mp_aframe **out) { struct priv *priv = da->priv; AVCodecContext *avctx = priv->avctx; @@ -217,25 +216,18 @@ static bool receive_frame(struct dec_audio *da, struct mp_audio **out) double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase); - struct mp_audio *mpframe = mp_audio_from_avframe(priv->avframe); + struct mp_aframe *mpframe = mp_aframe_from_avframe(priv->avframe); if (!mpframe) return true; - struct mp_chmap lavc_chmap = mpframe->channels; - if (lavc_chmap.num != avctx->channels) - mp_chmap_from_channels(&lavc_chmap, avctx->channels); - if (priv->force_channel_map) { - if (lavc_chmap.num == da->codec->channels.num) - lavc_chmap = da->codec->channels; - } - mp_audio_set_channels(mpframe, &lavc_chmap); + if (priv->force_channel_map) + mp_aframe_set_chmap(mpframe, &da->codec->channels); - mpframe->pts = out_pts; + if (out_pts == MP_NOPTS_VALUE) + out_pts = priv->next_pts; + mp_aframe_set_pts(mpframe, out_pts); - if (mpframe->pts == MP_NOPTS_VALUE) - mpframe->pts = priv->next_pts; - if (mpframe->pts != MP_NOPTS_VALUE) - priv->next_pts = mpframe->pts + mpframe->samples / (double)mpframe->rate; + priv->next_pts = mp_aframe_end_pts(mpframe); #if LIBAVCODEC_VERSION_MICRO >= 100 AVFrameSideData *sd = @@ -254,14 +246,14 @@ static bool receive_frame(struct dec_audio *da, struct mp_audio **out) priv->preroll_done = true; } - uint32_t skip = MPMIN(priv->skip_samples, mpframe->samples); + uint32_t skip = MPMIN(priv->skip_samples, mp_aframe_get_size(mpframe)); if (skip) { - mp_audio_skip_samples(mpframe, skip); + mp_aframe_skip_samples(mpframe, skip); priv->skip_samples -= skip; } - uint32_t trim = MPMIN(priv->trim_samples, mpframe->samples); + uint32_t trim = MPMIN(priv->trim_samples, mp_aframe_get_size(mpframe)); if (trim) { - mpframe->samples -= trim; + mp_aframe_set_size(mpframe, mp_aframe_get_size(mpframe) - trim); priv->trim_samples -= trim; } @@ -269,7 +261,6 @@ static bool receive_frame(struct dec_audio *da, struct mp_audio **out) av_frame_unref(priv->avframe); - MP_DBG(da, "Decoded %d samples\n", mpframe->samples); return true; } |