diff options
Diffstat (limited to 'audio/decode')
-rw-r--r-- | audio/decode/ad.h | 4 | ||||
-rw-r--r-- | audio/decode/ad_lavc.c | 33 | ||||
-rw-r--r-- | audio/decode/ad_spdif.c | 41 | ||||
-rw-r--r-- | audio/decode/dec_audio.c | 33 | ||||
-rw-r--r-- | audio/decode/dec_audio.h | 7 |
5 files changed, 59 insertions, 59 deletions
diff --git a/audio/decode/ad.h b/audio/decode/ad.h index 0af05e1827..a8384c277f 100644 --- a/audio/decode/ad.h +++ b/audio/decode/ad.h @@ -23,7 +23,7 @@ #include "demux/demux.h" #include "audio/format.h" -#include "audio/audio.h" +#include "audio/aframe.h" #include "dec_audio.h" struct mp_decoder_list; @@ -39,7 +39,7 @@ struct ad_functions { bool (*send_packet)(struct dec_audio *da, struct demux_packet *pkt); // Return whether decoding is still going on (false if EOF was reached). // Never returns false & *out set, but can return true with !*out. - bool (*receive_frame)(struct dec_audio *da, struct mp_audio **out); + bool (*receive_frame)(struct dec_audio *da, struct mp_aframe **out); }; enum ad_ctrl { 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; } diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 4b3e8149ec..0ca20e5485 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -40,8 +40,9 @@ struct spdifContext { uint8_t out_buffer[OUTBUF_SIZE]; bool need_close; bool use_dts_hd; - struct mp_audio fmt; - struct mp_audio_pool *pool; + struct mp_aframe *fmt; + int sstride; + struct mp_aframe_pool *pool; bool got_eof; struct demux_packet *queued_packet; }; @@ -84,7 +85,7 @@ static int init(struct dec_audio *da, const char *decoder) da->priv = spdif_ctx; spdif_ctx->log = da->log; spdif_ctx->use_dts_hd = da->opts->dtshd; - spdif_ctx->pool = mp_audio_pool_create(spdif_ctx); + spdif_ctx->pool = mp_aframe_pool_create(spdif_ctx); if (strcmp(decoder, "spdif_dts_hd") == 0) spdif_ctx->use_dts_hd = true; @@ -198,6 +199,9 @@ static int init_filter(struct dec_audio *da, AVPacket *pkt) AVDictionary *format_opts = NULL; + spdif_ctx->fmt = mp_aframe_create(); + talloc_steal(spdif_ctx, spdif_ctx->fmt); + int num_channels = 0; int sample_format = 0; int samplerate = 0; @@ -246,9 +250,14 @@ static int init_filter(struct dec_audio *da, AVPacket *pkt) default: abort(); } - mp_audio_set_num_channels(&spdif_ctx->fmt, num_channels); - mp_audio_set_format(&spdif_ctx->fmt, sample_format); - spdif_ctx->fmt.rate = samplerate; + + struct mp_chmap chmap; + mp_chmap_from_channels(&chmap, num_channels); + mp_aframe_set_chmap(spdif_ctx->fmt, &chmap); + mp_aframe_set_format(spdif_ctx->fmt, sample_format); + mp_aframe_set_rate(spdif_ctx->fmt, samplerate); + + spdif_ctx->sstride = mp_aframe_get_sstride(spdif_ctx->fmt); if (avformat_write_header(lavf_ctx, &format_opts) < 0) { MP_FATAL(da, "libavformat spdif initialization failed.\n"); @@ -279,7 +288,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 spdifContext *spdif_ctx = da->priv; @@ -308,13 +317,21 @@ static bool receive_frame(struct dec_audio *da, struct mp_audio **out) goto done; } - int samples = spdif_ctx->out_buffer_len / spdif_ctx->fmt.sstride; - *out = mp_audio_pool_get(spdif_ctx->pool, &spdif_ctx->fmt, samples); - if (!*out) + *out = mp_aframe_new_ref(spdif_ctx->fmt); + int samples = spdif_ctx->out_buffer_len / spdif_ctx->sstride; + if (mp_aframe_pool_allocate(spdif_ctx->pool, *out, samples) < 0) { + TA_FREEP(out); goto done; + } + + uint8_t **data = mp_aframe_get_data_rw(*out); + if (!data) { + TA_FREEP(out); + goto done; + } - memcpy((*out)->planes[0], spdif_ctx->out_buffer, spdif_ctx->out_buffer_len); - (*out)->pts = pts; + memcpy(data[0], spdif_ctx->out_buffer, spdif_ctx->out_buffer_len); + mp_aframe_set_pts(*out, pts); done: talloc_free(spdif_ctx->queued_packet); diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 1351cb8ecd..401e26fb7b 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -38,8 +38,6 @@ #include "dec_audio.h" #include "ad.h" #include "audio/format.h" -#include "audio/audio.h" -#include "audio/audio_buffer.h" #include "audio/filter/af.h" @@ -179,25 +177,24 @@ static void fix_audio_pts(struct dec_audio *da) if (!da->current_frame) return; - if (da->current_frame->pts != MP_NOPTS_VALUE) { - double newpts = da->current_frame->pts; - + double frame_pts = mp_aframe_get_pts(da->current_frame); + if (frame_pts != MP_NOPTS_VALUE) { if (da->pts != MP_NOPTS_VALUE) - MP_STATS(da, "value %f audio-pts-err", da->pts - newpts); + MP_STATS(da, "value %f audio-pts-err", da->pts - frame_pts); // Keep the interpolated timestamp if it doesn't deviate more // than 1 ms from the real one. (MKV rounded timestamps.) - if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - newpts) > 0.001) - da->pts = newpts; + if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - frame_pts) > 0.001) + da->pts = frame_pts; } if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps) da->pts = 0; - da->current_frame->pts = da->pts; + mp_aframe_set_pts(da->current_frame, da->pts); if (da->pts != MP_NOPTS_VALUE) - da->pts += da->current_frame->samples / (double)da->current_frame->rate; + da->pts += mp_aframe_duration(da->current_frame); } void audio_work(struct dec_audio *da) @@ -228,11 +225,6 @@ void audio_work(struct dec_audio *da) bool progress = da->ad_driver->receive_frame(da, &da->current_frame); - if (da->current_frame && !mp_audio_config_valid(da->current_frame)) { - talloc_free(da->current_frame); - da->current_frame = NULL; - } - da->current_state = da->current_frame ? DATA_OK : DATA_AGAIN; if (!progress) da->current_state = DATA_EOF; @@ -242,10 +234,11 @@ void audio_work(struct dec_audio *da) bool segment_end = da->current_state == DATA_EOF; if (da->current_frame) { - mp_audio_clip_timestamps(da->current_frame, da->start, da->end); - if (da->current_frame->pts != MP_NOPTS_VALUE && da->start != MP_NOPTS_VALUE) - segment_end = da->current_frame->pts >= da->end; - if (da->current_frame->samples == 0) { + mp_aframe_clip_timestamps(da->current_frame, da->start, da->end); + double frame_pts = mp_aframe_get_pts(da->current_frame); + if (frame_pts != MP_NOPTS_VALUE && da->start != MP_NOPTS_VALUE) + segment_end = frame_pts >= da->end; + if (mp_aframe_get_size(da->current_frame) == 0) { talloc_free(da->current_frame); da->current_frame = NULL; } @@ -280,7 +273,7 @@ void audio_work(struct dec_audio *da) // DATA_WAIT: waiting for demuxer; will receive a wakeup signal // DATA_EOF: end of file, no more frames to be expected // DATA_AGAIN: dropped frame or something similar -int audio_get_frame(struct dec_audio *da, struct mp_audio **out_frame) +int audio_get_frame(struct dec_audio *da, struct mp_aframe **out_frame) { *out_frame = NULL; if (da->current_frame) { diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h index 886b617b58..ea504328df 100644 --- a/audio/decode/dec_audio.h +++ b/audio/decode/dec_audio.h @@ -19,11 +19,10 @@ #define MPLAYER_DEC_AUDIO_H #include "audio/chmap.h" -#include "audio/audio.h" +#include "audio/aframe.h" #include "demux/demux.h" #include "demux/stheader.h" -struct mp_audio_buffer; struct mp_decoder_list; struct dec_audio { @@ -48,7 +47,7 @@ struct dec_audio { double start, end; struct demux_packet *packet; struct demux_packet *new_segment; - struct mp_audio *current_frame; + struct mp_aframe *current_frame; int current_state; }; @@ -57,7 +56,7 @@ int audio_init_best_codec(struct dec_audio *d_audio); void audio_uninit(struct dec_audio *d_audio); void audio_work(struct dec_audio *d_audio); -int audio_get_frame(struct dec_audio *d_audio, struct mp_audio **out_frame); +int audio_get_frame(struct dec_audio *d_audio, struct mp_aframe **out_frame); void audio_reset_decoding(struct dec_audio *d_audio); |