diff options
Diffstat (limited to 'audio')
44 files changed, 2796 insertions, 1337 deletions
diff --git a/audio/aframe.c b/audio/aframe.c index 6781bb7b55..03e8ab8ae8 100644 --- a/audio/aframe.c +++ b/audio/aframe.c @@ -52,8 +52,7 @@ struct mp_aframe *mp_aframe_create(void) { struct mp_aframe *frame = talloc_zero(NULL, struct mp_aframe); frame->av_frame = av_frame_alloc(); - if (!frame->av_frame) - abort(); + MP_HANDLE_OOM(frame->av_frame); talloc_set_destructor(frame, free_frame); mp_aframe_reset(frame); return frame; @@ -466,6 +465,37 @@ void mp_aframe_skip_samples(struct mp_aframe *f, int samples) f->pts += samples / mp_aframe_get_effective_rate(f); } +// sanitize a floating point sample value +#define sanitizef(f) do { \ + if (!isnormal(f)) \ + (f) = 0; \ +} while (0) + +void mp_aframe_sanitize_float(struct mp_aframe *mpa) +{ + int format = af_fmt_from_planar(mp_aframe_get_format(mpa)); + if (format != AF_FORMAT_FLOAT && format != AF_FORMAT_DOUBLE) + return; + int num_planes = mp_aframe_get_planes(mpa); + uint8_t **planes = mp_aframe_get_data_rw(mpa); + if (!planes) + return; + for (int p = 0; p < num_planes; p++) { + void *ptr = planes[p]; + int total = mp_aframe_get_total_plane_samples(mpa); + switch (format) { + case AF_FORMAT_FLOAT: + for (int s = 0; s < total; s++) + sanitizef(((float *)ptr)[s]); + break; + case AF_FORMAT_DOUBLE: + for (int s = 0; s < total; s++) + sanitizef(((double *)ptr)[s]); + break; + } + } +} + // Return the timestamp of the sample just after the end of this frame. double mp_aframe_end_pts(struct mp_aframe *f) { @@ -570,7 +600,7 @@ bool mp_aframe_set_silence(struct mp_aframe *f, int offset, int samples) bool mp_aframe_reverse(struct mp_aframe *f) { int format = mp_aframe_get_format(f); - size_t bps = af_fmt_to_bytes(format); + int bps = af_fmt_to_bytes(format); if (!af_fmt_is_pcm(format) || bps > 16) return false; @@ -670,8 +700,7 @@ int mp_aframe_pool_allocate(struct mp_aframe_pool *pool, struct mp_aframe *frame if (planes > AV_NUM_DATA_POINTERS) { av_frame->extended_data = av_calloc(planes, sizeof(av_frame->extended_data[0])); - if (!av_frame->extended_data) - abort(); + MP_HANDLE_OOM(av_frame->extended_data); } else { av_frame->extended_data = av_frame->data; } diff --git a/audio/aframe.h b/audio/aframe.h index be456a3dd1..d19c7e8bcb 100644 --- a/audio/aframe.h +++ b/audio/aframe.h @@ -60,6 +60,7 @@ char *mp_aframe_format_str_buf(char *buf, size_t buf_size, struct mp_aframe *fmt #define mp_aframe_format_str(fmt) mp_aframe_format_str_buf((char[32]){0}, 32, (fmt)) void mp_aframe_skip_samples(struct mp_aframe *f, int samples); +void mp_aframe_sanitize_float(struct mp_aframe *f); double mp_aframe_end_pts(struct mp_aframe *f); double mp_aframe_duration(struct mp_aframe *f); void mp_aframe_clip_timestamps(struct mp_aframe *f, double start, double end); diff --git a/audio/chmap.c b/audio/chmap.c index cd8c767c47..a56d78dfe2 100644 --- a/audio/chmap.c +++ b/audio/chmap.c @@ -52,6 +52,11 @@ static const char *const speaker_names[MP_SPEAKER_ID_COUNT][2] = { [MP_SPEAKER_ID_SDL] = {"sdl", "surround direct left"}, [MP_SPEAKER_ID_SDR] = {"sdr", "surround direct right"}, [MP_SPEAKER_ID_LFE2] = {"lfe2", "low frequency 2"}, + [MP_SPEAKER_ID_TSL] = {"tsl", "top side left"}, + [MP_SPEAKER_ID_TSR] = {"tsr", "top side right"}, + [MP_SPEAKER_ID_BFC] = {"bfc", "bottom front center"}, + [MP_SPEAKER_ID_BFL] = {"bfl", "bottom front left"}, + [MP_SPEAKER_ID_BFR] = {"bfr", "bottom front right"}, [MP_SPEAKER_ID_NA] = {"na", "not available"}, }; @@ -83,7 +88,7 @@ static const char *const std_layout_names[][2] = { {"6.0(front)", "fl-fr-flc-frc-sl-sr"}, {"hexagonal", "fl-fr-fc-bl-br-bc"}, {"6.1", "fl-fr-fc-lfe-bc-sl-sr"}, - {"6.1(back)", "fl-fr-fc-lfe-bl-br-bc"}, // lavc calls this "6.1" too + {"6.1(back)", "fl-fr-fc-lfe-bl-br-bc"}, {"6.1(top)", "fl-fr-fc-lfe-bl-br-tc"}, // not in lavc {"6.1(front)", "fl-fr-lfe-flc-frc-sl-sr"}, {"7.0", "fl-fr-fc-bl-br-sl-sr"}, @@ -93,8 +98,13 @@ static const char *const std_layout_names[][2] = { {"7.1(alsa)", "fl-fr-bl-br-fc-lfe-sl-sr"}, // not in lavc {"7.1(wide)", "fl-fr-fc-lfe-bl-br-flc-frc"}, {"7.1(wide-side)", "fl-fr-fc-lfe-flc-frc-sl-sr"}, + {"7.1(top)", "fl-fr-fc-lfe-bl-br-tfl-tfr"}, {"7.1(rear)", "fl-fr-fc-lfe-bl-br-sdl-sdr"}, // not in lavc {"octagonal", "fl-fr-fc-bl-br-bc-sl-sr"}, + {"cube", "fl-fr-bl-br-tfl-tfr-tbl-tbr"}, + {"hexadecagonal", "fl-fr-fc-bl-br-bc-sl-sr-tfc-tfl-tfr-tbl-tbc-tbr-wl-wr"}, + {"downmix", "fl-fr"}, + {"22.2", "fl-fr-fc-lfe-bl-br-flc-frc-bc-sl-sr-tc-tfl-tfc-tfr-tbl-tbc-tbr-lfe2-tsl-tsr-bfc-bfl-bfr"}, {"auto", ""}, // not in lavc {0} }; @@ -229,8 +239,8 @@ void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels) } } -// Return the ffmpeg/libav channel layout as in <libavutil/channel_layout.h>. -// Speakers not representable by ffmpeg/libav are dropped. +// Return the ffmpeg channel layout as in <libavutil/channel_layout.h>. +// Speakers not representable by ffmpeg are dropped. // Warning: this ignores the order of the channels, and will return a channel // mask even if the order is different from libavcodec's. // Also, "unknown" channel maps are translated to non-sense channel @@ -253,7 +263,7 @@ uint64_t mp_chmap_to_lavc_unchecked(const struct mp_chmap *src) return mask; } -// Return the ffmpeg/libav channel layout as in <libavutil/channel_layout.h>. +// Return the ffmpeg channel layout as in <libavutil/channel_layout.h>. // Returns 0 if the channel order doesn't match lavc's or if it's invalid. uint64_t mp_chmap_to_lavc(const struct mp_chmap *src) { @@ -262,7 +272,7 @@ uint64_t mp_chmap_to_lavc(const struct mp_chmap *src) return mp_chmap_to_lavc_unchecked(src); } -// Set channel map from the ffmpeg/libav channel layout as in +// Set channel map from the ffmpeg channel layout as in // <libavutil/channel_layout.h>. // If the number of channels exceed MP_NUM_CHANNELS, set dst to empty. void mp_chmap_from_lavc(struct mp_chmap *dst, uint64_t src) diff --git a/audio/chmap.h b/audio/chmap.h index 6fbb60d025..58a3f71907 100644 --- a/audio/chmap.h +++ b/audio/chmap.h @@ -22,7 +22,7 @@ #include <stdbool.h> #include "misc/bstr.h" -#define MP_NUM_CHANNELS 16 +#define MP_NUM_CHANNELS 64 // Speaker a channel can be assigned to. // This corresponds to WAVEFORMATEXTENSIBLE channel mask bit indexes. @@ -55,6 +55,11 @@ enum mp_speaker_id { MP_SPEAKER_ID_SDL, // SURROUND_DIRECT_LEFT MP_SPEAKER_ID_SDR, // SURROUND_DIRECT_RIGHT MP_SPEAKER_ID_LFE2, // LOW_FREQUENCY_2 + MP_SPEAKER_ID_TSL, // TOP_SIDE_LEFT + MP_SPEAKER_ID_TSR, // TOP_SIDE_RIGHT, + MP_SPEAKER_ID_BFC, // BOTTOM_FRONT_CENTER + MP_SPEAKER_ID_BFL, // BOTTOM_FRONT_LEFT + MP_SPEAKER_ID_BFR, // BOTTOM_FRONT_RIGHT // Speaker IDs >= 64 are not representable in WAVEFORMATEXTENSIBLE or libav*. @@ -124,10 +129,12 @@ void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from, int mp_chmap_diffn(const struct mp_chmap *a, const struct mp_chmap *b); char *mp_chmap_to_str_buf(char *buf, size_t buf_size, const struct mp_chmap *src); -#define mp_chmap_to_str(m) mp_chmap_to_str_buf((char[64]){0}, 64, (m)) +#define mp_chmap_to_str_(m, sz) mp_chmap_to_str_buf((char[sz]){0}, sz, (m)) +#define mp_chmap_to_str(m) mp_chmap_to_str_(m, MP_NUM_CHANNELS * 4) char *mp_chmap_to_str_hr_buf(char *buf, size_t buf_size, const struct mp_chmap *src); -#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_buf((char[128]){0}, 128, (m)) +#define mp_chmap_to_str_hr_(m, sz) mp_chmap_to_str_hr_buf((char[sz]){0}, sz, (m)) +#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_(m, MP_NUM_CHANNELS * 4) bool mp_chmap_from_str(struct mp_chmap *dst, bstr src); diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 34c3a183eb..39cd74cd2a 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -17,7 +17,6 @@ #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <stdbool.h> #include <assert.h> @@ -44,8 +43,10 @@ #include "options/options.h" struct priv { + struct mp_codec_params *codec; AVCodecContext *avctx; AVFrame *avframe; + AVPacket *avpkt; struct mp_chmap force_channel_map; uint32_t skip_samples, trim_samples; bool preroll_done; @@ -59,7 +60,7 @@ struct priv { #define OPT_BASE_STRUCT struct ad_lavc_params struct ad_lavc_params { float ac3drc; - int downmix; + bool downmix; int threads; char **avopts; }; @@ -67,7 +68,7 @@ struct ad_lavc_params { const struct m_sub_options ad_lavc_conf = { .opts = (const m_option_t[]) { {"ac3drc", OPT_FLOAT(ac3drc), M_RANGE(0, 6)}, - {"downmix", OPT_FLAG(downmix)}, + {"downmix", OPT_BOOL(downmix)}, {"threads", OPT_INT(threads), M_RANGE(0, 16)}, {"o", OPT_KEYVALUELIST(avopts)}, {0} @@ -75,7 +76,6 @@ const struct m_sub_options ad_lavc_conf = { .size = sizeof(struct ad_lavc_params), .defaults = &(const struct ad_lavc_params){ .ac3drc = 0, - .downmix = 0, .threads = 1, }, }; @@ -104,6 +104,8 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec, lavc_context = avcodec_alloc_context3(lavc_codec); ctx->avctx = lavc_context; ctx->avframe = av_frame_alloc(); + ctx->avpkt = av_packet_alloc(); + MP_HANDLE_OOM(ctx->avctx && ctx->avframe && ctx->avpkt); lavc_context->codec_type = AVMEDIA_TYPE_AUDIO; lavc_context->codec_id = lavc_codec->id; lavc_context->pkt_timebase = ctx->codec_timebase; @@ -154,15 +156,16 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec, return true; } -static void destroy(struct mp_filter *da) +static void ad_lavc_destroy(struct mp_filter *da) { struct priv *ctx = da->priv; avcodec_free_context(&ctx->avctx); av_frame_free(&ctx->avframe); + mp_free_av_packet(&ctx->avpkt); } -static void reset(struct mp_filter *da) +static void ad_lavc_reset(struct mp_filter *da) { struct priv *ctx = da->priv; @@ -185,10 +188,9 @@ static int send_packet(struct mp_filter *da, struct demux_packet *mpkt) if (mpkt && priv->next_pts == MP_NOPTS_VALUE) priv->next_pts = mpkt->pts; - AVPacket pkt; - mp_set_av_packet(&pkt, mpkt, &priv->codec_timebase); + mp_set_av_packet(priv->avpkt, mpkt, &priv->codec_timebase); - int ret = avcodec_send_packet(avctx, mpkt ? &pkt : NULL); + int ret = avcodec_send_packet(avctx, mpkt ? priv->avpkt : NULL); if (ret < 0) MP_ERR(da, "Error decoding audio.\n"); return ret; @@ -217,6 +219,8 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out) if (!priv->avframe->buf[0]) return ret; + mp_codec_info_from_av(avctx, priv->codec); + double out_pts = mp_pts_from_av(priv->avframe->pts, &priv->codec_timebase); struct mp_aframe *mpframe = mp_aframe_from_avframe(priv->avframe); @@ -260,6 +264,9 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out) priv->trim_samples -= trim; } + // Strip possibly bogus float values like Infinity, NaN, denormalized + mp_aframe_sanitize_float(mpframe); + if (mp_aframe_get_size(mpframe) > 0) { *out = MAKE_FRAME(MP_FRAME_AUDIO, mpframe); } else { @@ -271,7 +278,7 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out) return ret; } -static void process(struct mp_filter *ad) +static void ad_lavc_process(struct mp_filter *ad) { struct priv *priv = ad->priv; @@ -281,9 +288,9 @@ static void process(struct mp_filter *ad) static const struct mp_filter_info ad_lavc_filter = { .name = "ad_lavc", .priv_size = sizeof(struct priv), - .process = process, - .reset = reset, - .destroy = destroy, + .process = ad_lavc_process, + .reset = ad_lavc_reset, + .destroy = ad_lavc_destroy, }; static struct mp_decoder *create(struct mp_filter *parent, @@ -300,12 +307,16 @@ static struct mp_decoder *create(struct mp_filter *parent, da->log = mp_log_new(da, parent->log, NULL); struct priv *priv = da->priv; + priv->codec = codec; priv->public.f = da; if (!init(da, codec, decoder)) { talloc_free(da); return NULL; } + + codec->codec_desc = priv->avctx->codec_descriptor->long_name; + return &priv->public; } diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 520803c4b0..3f83ab240e 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -37,10 +37,18 @@ #define OUTBUF_SIZE 65536 +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(60, 26, 100) +#define AV_PROFILE_UNKNOWN FF_PROFILE_UNKNOWN +#define AV_PROFILE_DTS_HD_HRA FF_PROFILE_DTS_HD_HRA +#define AV_PROFILE_DTS_HD_MA FF_PROFILE_DTS_HD_MA +#endif + struct spdifContext { struct mp_log *log; + struct mp_codec_params *codec; enum AVCodecID codec_id; AVFormatContext *lavf_ctx; + AVPacket *avpkt; int out_buffer_len; uint8_t out_buffer[OUTBUF_SIZE]; bool need_close; @@ -52,7 +60,11 @@ struct spdifContext { struct mp_decoder public; }; +#if LIBAVCODEC_VERSION_MAJOR < 61 static int write_packet(void *p, uint8_t *buf, int buf_size) +#else +static int write_packet(void *p, const uint8_t *buf, int buf_size) +#endif { struct spdifContext *ctx = p; @@ -68,7 +80,7 @@ static int write_packet(void *p, uint8_t *buf, int buf_size) } // (called on both filter destruction _and_ if lavf fails to init) -static void destroy(struct mp_filter *da) +static void ad_spdif_destroy(struct mp_filter *da) { struct spdifContext *spdif_ctx = da->priv; AVFormatContext *lavf_ctx = spdif_ctx->lavf_ctx; @@ -78,17 +90,18 @@ static void destroy(struct mp_filter *da) av_write_trailer(lavf_ctx); if (lavf_ctx->pb) av_freep(&lavf_ctx->pb->buffer); - av_freep(&lavf_ctx->pb); + avio_context_free(&lavf_ctx->pb); avformat_free_context(lavf_ctx); spdif_ctx->lavf_ctx = NULL; } + mp_free_av_packet(&spdif_ctx->avpkt); } static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, int *out_profile, int *out_rate) { struct spdifContext *spdif_ctx = da->priv; - int profile = FF_PROFILE_UNKNOWN; + int profile = AV_PROFILE_UNKNOWN; AVCodecContext *ctx = NULL; AVFrame *frame = NULL; @@ -105,15 +118,17 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, uint8_t *d = NULL; int s = 0; - av_parser_parse2(parser, ctx, &d, &s, pkt->data, pkt->size, 0, 0, 0); - *out_profile = profile = ctx->profile; - *out_rate = ctx->sample_rate; + if (av_parser_parse2(parser, ctx, &d, &s, pkt->data, pkt->size, 0, 0, 0) > 0) { + *out_profile = profile = ctx->profile; + *out_rate = ctx->sample_rate; + spdif_ctx->codec->codec_profile = avcodec_profile_name(spdif_ctx->codec_id, profile); + } avcodec_free_context(&ctx); av_parser_close(parser); } - if (profile != FF_PROFILE_UNKNOWN || spdif_ctx->codec_id != AV_CODEC_ID_DTS) + if (profile != AV_PROFILE_UNKNOWN || spdif_ctx->codec_id == AV_CODEC_ID_AC3) return; const AVCodec *codec = avcodec_find_decoder(spdif_ctx->codec_id); @@ -139,19 +154,28 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt, *out_profile = profile = ctx->profile; *out_rate = ctx->sample_rate; + struct mp_codec_params *c = spdif_ctx->codec; + c->codec_profile = av_get_profile_name(ctx->codec, ctx->profile); + if (!c->codec_profile) + c->codec_profile = avcodec_profile_name(ctx->codec_id, ctx->profile); + c->codec = ctx->codec_descriptor->name; + c->codec_desc = ctx->codec_descriptor->long_name; + done: av_frame_free(&frame); avcodec_free_context(&ctx); - if (profile == FF_PROFILE_UNKNOWN) + if (profile == AV_PROFILE_UNKNOWN) MP_WARN(da, "Failed to parse codec profile.\n"); } -static int init_filter(struct mp_filter *da, AVPacket *pkt) +static int init_filter(struct mp_filter *da) { struct spdifContext *spdif_ctx = da->priv; - int profile = FF_PROFILE_UNKNOWN; + AVPacket *pkt = spdif_ctx->avpkt; + + int profile = AV_PROFILE_UNKNOWN; int c_rate = 0; determine_codec_params(da, pkt, &profile, &c_rate); MP_VERBOSE(da, "In: profile=%d samplerate=%d\n", profile, c_rate); @@ -167,8 +191,7 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt) goto fail; void *buffer = av_mallocz(OUTBUF_SIZE); - if (!buffer) - abort(); + MP_HANDLE_OOM(buffer); lavf_ctx->pb = avio_alloc_context(buffer, OUTBUF_SIZE, 1, spdif_ctx, NULL, write_packet, NULL); if (!lavf_ctx->pb) { @@ -183,7 +206,8 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt) if (!stream) goto fail; - stream->codecpar->codec_id = spdif_ctx->codec_id; + stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + stream->codecpar->codec_id = spdif_ctx->codec_id; AVDictionary *format_opts = NULL; @@ -205,15 +229,15 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt) num_channels = 2; break; case AV_CODEC_ID_DTS: { - bool is_hd = profile == FF_PROFILE_DTS_HD_HRA || - profile == FF_PROFILE_DTS_HD_MA || - profile == FF_PROFILE_UNKNOWN; + bool is_hd = profile == AV_PROFILE_DTS_HD_HRA || + profile == AV_PROFILE_DTS_HD_MA || + profile == AV_PROFILE_UNKNOWN; // Apparently, DTS-HD over SPDIF is specified to be 7.1 (8 channels) // for DTS-HD MA, and stereo (2 channels) for DTS-HD HRA. The bit // streaming rate as well as the signaled channel count are defined // based on this value. - int dts_hd_spdif_channel_count = profile == FF_PROFILE_DTS_HD_HRA ? + int dts_hd_spdif_channel_count = profile == AV_PROFILE_DTS_HD_HRA ? 2 : 8; if (spdif_ctx->use_dts_hd && is_hd) { av_dict_set_int(&format_opts, "dtshd_rate", @@ -223,7 +247,7 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt) num_channels = dts_hd_spdif_channel_count; } else { sample_format = AF_FORMAT_S_DTS; - samplerate = 48000; + samplerate = c_rate > 44100 ? 48000 : 44100; num_channels = 2; } break; @@ -247,6 +271,8 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt) abort(); } + stream->codecpar->sample_rate = samplerate; + struct mp_chmap chmap; mp_chmap_from_channels(&chmap, num_channels); mp_aframe_set_chmap(spdif_ctx->fmt, &chmap); @@ -267,12 +293,12 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt) return 0; fail: - destroy(da); + ad_spdif_destroy(da); mp_filter_internal_mark_failed(da); return -1; } -static void process(struct mp_filter *da) +static void ad_spdif_process(struct mp_filter *da) { struct spdifContext *spdif_ctx = da->priv; @@ -295,15 +321,20 @@ static void process(struct mp_filter *da) struct mp_aframe *out = NULL; double pts = mpkt->pts; - AVPacket pkt; - mp_set_av_packet(&pkt, mpkt, NULL); - pkt.pts = pkt.dts = 0; + if (!spdif_ctx->avpkt) { + spdif_ctx->avpkt = av_packet_alloc(); + MP_HANDLE_OOM(spdif_ctx->avpkt); + } + mp_set_av_packet(spdif_ctx->avpkt, mpkt, NULL); + spdif_ctx->avpkt->pts = spdif_ctx->avpkt->dts = 0; if (!spdif_ctx->lavf_ctx) { - if (init_filter(da, &pkt) < 0) + if (init_filter(da) < 0) goto done; + assert(spdif_ctx->avpkt); } + spdif_ctx->out_buffer_len = 0; - int ret = av_write_frame(spdif_ctx->lavf_ctx, &pkt); + int ret = av_write_frame(spdif_ctx->lavf_ctx, spdif_ctx->avpkt); avio_flush(spdif_ctx->lavf_ctx->pb); if (ret < 0) { MP_ERR(da, "spdif mux error: '%s'\n", mp_strerror(AVUNERROR(ret))); @@ -392,8 +423,8 @@ struct mp_decoder_list *select_spdif_codec(const char *codec, const char *pref) static const struct mp_filter_info ad_spdif_filter = { .name = "ad_spdif", .priv_size = sizeof(struct spdifContext), - .process = process, - .destroy = destroy, + .process = ad_spdif_process, + .destroy = ad_spdif_destroy, }; static struct mp_decoder *create(struct mp_filter *parent, @@ -411,6 +442,7 @@ static struct mp_decoder *create(struct mp_filter *parent, struct spdifContext *spdif_ctx = da->priv; spdif_ctx->log = da->log; + spdif_ctx->codec = codec; spdif_ctx->pool = mp_aframe_pool_create(spdif_ctx); spdif_ctx->public.f = da; @@ -424,6 +456,11 @@ static struct mp_decoder *create(struct mp_filter *parent, talloc_free(da); return NULL; } + + const AVCodecDescriptor *desc = avcodec_descriptor_get(spdif_ctx->codec_id); + if (desc) + codec->codec_desc = desc->long_name; + return &spdif_ctx->public; } diff --git a/audio/filter/af_drop.c b/audio/filter/af_drop.c index 724c482720..499389dd2b 100644 --- a/audio/filter/af_drop.c +++ b/audio/filter/af_drop.c @@ -11,7 +11,7 @@ struct priv { struct mp_aframe *last; // for repeating }; -static void process(struct mp_filter *f) +static void af_drop_process(struct mp_filter *f) { struct priv *p = f->priv; @@ -52,7 +52,7 @@ static void process(struct mp_filter *f) mp_pin_in_write(f->ppins[1], frame); } -static bool command(struct mp_filter *f, struct mp_filter_command *cmd) +static bool af_drop_command(struct mp_filter *f, struct mp_filter_command *cmd) { struct priv *p = f->priv; @@ -65,7 +65,7 @@ static bool command(struct mp_filter *f, struct mp_filter_command *cmd) return false; } -static void reset(struct mp_filter *f) +static void af_drop_reset(struct mp_filter *f) { struct priv *p = f->priv; @@ -73,18 +73,18 @@ static void reset(struct mp_filter *f) p->diff = 0; } -static void destroy(struct mp_filter *f) +static void af_drop_destroy(struct mp_filter *f) { - reset(f); + af_drop_reset(f); } static const struct mp_filter_info af_drop_filter = { .name = "drop", .priv_size = sizeof(struct priv), - .process = process, - .command = command, - .reset = reset, - .destroy = destroy, + .process = af_drop_process, + .command = af_drop_command, + .reset = af_drop_reset, + .destroy = af_drop_destroy, }; static struct mp_filter *af_drop_create(struct mp_filter *parent, void *options) diff --git a/audio/filter/af_format.c b/audio/filter/af_format.c index 88ae99ed56..eddce6422f 100644 --- a/audio/filter/af_format.c +++ b/audio/filter/af_format.c @@ -30,7 +30,7 @@ struct f_opts { int out_srate; struct m_channels out_channels; - int fail; + bool fail; }; struct priv { @@ -38,7 +38,7 @@ struct priv { struct mp_pin *in_pin; }; -static void process(struct mp_filter *f) +static void af_format_process(struct mp_filter *f) { struct priv *p = f->priv; @@ -85,7 +85,7 @@ error: static const struct mp_filter_info af_format_filter = { .name = "format", .priv_size = sizeof(struct priv), - .process = process, + .process = af_format_process, }; static struct mp_filter *af_format_create(struct mp_filter *parent, @@ -135,7 +135,7 @@ const struct mp_user_filter_entry af_format = { {"out-srate", OPT_INT(out_srate), M_RANGE(1000, 8*48000)}, {"out-channels", OPT_CHANNELS(out_channels), .flags = M_OPT_CHANNELS_LIMITED}, - {"fail", OPT_FLAG(fail)}, + {"fail", OPT_BOOL(fail)}, {0} }, }, |