sylware / nyanmp (public) (License: AGPLv3) (since 2020-02-12) (hash sha1)
intended to become a collection of media players for gnu/linux based on ffmpeg, alsa, vulkan, x11, wayland, etc.
List of commits:
Subject Hash Author Date (UTC)
move to new ffmpeg channel layout handling 938790d0c657278f405c4f57987d2274c5ada9b7 Sylvain BERTRAND 2022-03-20 22:18:01
npa: fine grained volume control 89279ea0c7dcaf7a718c9a57ecb6b08a0ccfbcb9 Sylvain BERTRAND 2022-02-15 23:24:36
npv: add fine grained volume control 06bc3b77b065f35f294659db520f66e7e8094c8c Sylvain BERTRAND 2022-02-15 18:47:34
npv: move to freetype SDF rendering 972a3027fec3b69a1e10405cc0da35b5194b6f46 Sylvain BERTRAND 2021-12-27 20:54:53
npv:osd:ascii only mode for the timer 3de3158fc3300f8a9c6f75fcca76b512331b8c2f Sylvain BERTRAND 2021-10-30 19:18:38
npv: default to dejavu instead of noto 708f3166a09fd7ba815ec47907cabfb1af4d26c5 Sylvain BERTRAND 2021-10-10 17:05:17
npv: live mode and ready the code for indicators.. if ever... 2d6ddb83edd6f08e99fbe01dc60a354b5e5a2afe Sylvain BERTRAND 2021-07-23 13:17:47
npv: don't block the muted state 0c29e9329ec5db6bed191b2b4caffff8166bd11f Sylvain BERTRAND 2021-07-21 21:34:37
npv: now we have enough perspective, make states internal 62f6b1bf62fc083762f036ddde1f29dd23baf814 Sylvain BERTRAND 2021-07-21 20:12:36
npv/npa: add gcc4 atomic support d9676b20984dcbfd8df4afbf85178c8ff4295e4f Sylvain BERTRAND 2021-06-18 15:04:01
npv: better reuse of ffmpeg references, stats 4bb1b9ab45609f8e5113cc7613ebc1d09499561b Sylvain BERTRAND 2021-05-20 18:24:32
npv: avoid stale frames fb20683b7cb91622b639b05e8b324d13edc72522 Sylvain BERTRAND 2021-05-16 20:51:34
npv: inverted resync logic and rate limiter 9e772be0d5e19dc4dcef05ee2b4ce47c42788f8e Sylvain BERTRAND 2021-05-16 18:06:23
npv:trying to work around nasty live streams 544ddd3381ad56363bb275ae59419e97e8c86895 Sylvain BERTRAND 2021-05-14 15:45:19
npv:spurious braces e8678920198c6795420c54a839b92e5d301b4183 Sylvain BERTRAND 2021-05-06 20:55:38
npv:pts debug tracing, ffmpeg dev tantrum 8c3bf9cf42fc3419b64c232f905c5c580d6a1942 Sylvain BERTRAND 2021-05-06 18:37:35
npa: forgot zero-ing before cmp ceff7a70798b604bdb876a92ba0c446e3ede8a5b Sylvain BERTRAND 2021-04-15 20:15:07
npv: namespace love cb385e293aeb094073963c46022f3c430b6bf9c1 Sylvain BERTRAND 2021-01-16 18:37:11
conservative handling of vulkan linear filtering 7736b342c3566ac3ffa7a83ff1c7985e5595265f Sylvain BERTRAND 2021-01-15 18:18:02
npv: spurious AND faulty image creation flag e7d0d4e9efa15781b323cd092989bc0b95331875 Sylvain BERTRAND 2021-01-15 02:01:16
Commit 938790d0c657278f405c4f57987d2274c5ada9b7 - move to new ffmpeg channel layout handling
Author: Sylvain BERTRAND
Author date (UTC): 2022-03-20 22:18
Committer name: Sylvain BERTRAND
Committer date (UTC): 2022-03-20 22:18
Parent(s): 89279ea0c7dcaf7a718c9a57ecb6b08a0ccfbcb9
Signing key:
Tree: d31c2447ea1eef49f4650b8a060eb5b46d7d5dc5
File Lines added Lines deleted
npa/npa.c 74 78
npv/audio/filt/local/code.frag.c 11 11
npv/audio/filt/local/state.frag.c 1 2
npv/audio/filt/namespace/main.c 0 4
npv/audio/filt/public.h 3 3
npv/audio/filt/public/code.frag.c 12 13
npv/audio/local/code.frag.c 32 30
npv/audio/namespace/ffmpeg.h 0 6
npv/audio/public.h 2 2
npv/audio/public/code.frag.c 8 15
npv/namespace/ffmpeg.h 0 6
File npa/npa.c changed (mode: 100644) (index 580ea57..59ac4e4)
172 172 #define av_frs_alloc av_frame_alloc #define av_frs_alloc av_frame_alloc
173 173 #define av_frs_set_silence av_samples_set_silence #define av_frs_set_silence av_samples_set_silence
174 174 #define av_frs_unref av_frame_unref #define av_frs_unref av_frame_unref
175 #define av_get_chan_layout_str av_get_channel_layout_string
176 #define av_get_default_chans_layout av_get_default_channel_layout
177 175 #define av_get_fr_fmt_name av_get_sample_fmt_name #define av_get_fr_fmt_name av_get_sample_fmt_name
178 176 #define av_get_fr_fmt_str av_get_sample_fmt_string #define av_get_fr_fmt_str av_get_sample_fmt_string
179 177 #define av_io_flush avio_flush #define av_io_flush avio_flush
 
188 186 #define av_frs AVFrame #define av_frs AVFrame
189 187 #define av_sd_pkt avcodec_send_packet #define av_sd_pkt avcodec_send_packet
190 188 #define av_st AVStream #define av_st AVStream
191 #define chans_layout channel_layout
192 #define chans_n channels
193 189 #define fmt format #define fmt format
194 190 #define fr_fmt sample_fmt #define fr_fmt sample_fmt
195 191 #define fr_rate sample_rate #define fr_rate sample_rate
 
... ... static av_filt_graph *filt_graph;
271 267 static av_filt_ctx *abufsrc_ctx; static av_filt_ctx *abufsrc_ctx;
272 268 static const av_filt *abufsrc_filt; static const av_filt *abufsrc_filt;
273 269 static struct { /* used to detected reconfiguration */ static struct { /* used to detected reconfiguration */
274 int chans_n;
275 uint64_t chans_layout;
270 AVChannelLayout chans_layout;
276 271 int rate; int rate;
277 272 enum av_fr_fmt fmt; enum av_fr_fmt fmt;
278 273 } abufsrc_key; } abufsrc_key;
 
... ... static void rd_thd_reset(int st_idx)
769 764 * XXX: if it is ever used significantly, a fine granularity wiring strategy * XXX: if it is ever used significantly, a fine granularity wiring strategy
770 765 * will be implemented instead of using the default wiring * will be implemented instead of using the default wiring
771 766 */ */
772 static uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
773 unsigned int pcm_chans_n, bool print_info)
767 static void pcm_chmaps2ff_chans_layout(AVChannelLayout *ff_chans_layout,
768 snd_pcm_t *pcm, unsigned int pcm_chans_n, bool print_info)
774 769 { {
775 770 int r; int r;
776 uint64_t ff_chans_layout;
771
777 772 snd_pcm_chmap_t *pcm_chmap; snd_pcm_chmap_t *pcm_chmap;
778 773 u8 chans_layout_str[STR_SZ]; /* should be overkill */ u8 chans_layout_str[STR_SZ]; /* should be overkill */
779 774
 
... ... static uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
786 781 pout("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented\n"); pout("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented\n");
787 782 free(pcm_chmap); free(pcm_chmap);
788 783 } }
789 ff_chans_layout = av_get_default_chans_layout((int)pcm_chans_n);
790 av_get_chan_layout_str(chans_layout_str, sizeof(chans_layout_str),
791 (int)pcm_chans_n, ff_chans_layout);
784 av_channel_layout_default(ff_chans_layout, (int)pcm_chans_n);
785 av_channel_layout_describe(ff_chans_layout, chans_layout_str,
786 sizeof(chans_layout_str));
792 787 if (print_info) if (print_info)
793 788 pout("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); pout("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n);
794 return ff_chans_layout;
795 789 } }
796 790 /* fatal if the wiring cannot be done */ /* fatal if the wiring cannot be done */
797 791 static void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt, static void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
 
... ... static void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
836 830 pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str); pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str);
837 831 } }
838 832 } }
839 static void pcm2ff(snd_pcm_t *pcm, enum av_fr_fmt *ff_fmt,
840 int *ff_rate, int *ff_chans_n, uint64_t *ff_chans_layout,
841 bool print_info)
833 static void pcm2ff(snd_pcm_t *pcm, enum av_fr_fmt *ff_fmt, int *ff_rate,
834 AVChannelLayout *ff_chans_layout, bool print_info)
842 835 { {
843 836 int r; int r;
844 837 snd_pcm_hw_params_t *hw_params; snd_pcm_hw_params_t *hw_params;
 
... ... static void pcm2ff(snd_pcm_t *pcm, enum av_fr_fmt *ff_fmt,
870 863 r = snd_pcm_hw_params_get_chans(hw_params, &pcm_chans_n); r = snd_pcm_hw_params_get_chans(hw_params, &pcm_chans_n);
871 864 if (r < 0) if (r < 0)
872 865 fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n"); fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n");
873 *ff_chans_n = (int)pcm_chans_n;
874 866 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
875 *ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n,
867 pcm_chmaps2ff_chans_layout(ff_chans_layout, pcm, pcm_chans_n,
876 868 print_info); print_info);
877 869 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
878 870 snd_pcm_hw_params_free(hw_params); snd_pcm_hw_params_free(hw_params);
879 871 } }
880 872 /* XXX: we don't program the tb of the filter since it should not be used */ /* XXX: we don't program the tb of the filter since it should not be used */
881 static void abufsrc_cfg(enum av_fr_fmt fmt, int rate, int chans_n,
882 uint64_t chans_layout, bool print_info)
873 static void abufsrc_cfg(enum av_fr_fmt fmt, int rate,
874 AVChannelLayout *chans_layout, bool print_info)
883 875 { {
884 876 int r; int r;
885 877 u8 chans_layout_str[STR_SZ]; /* should be overkill */ u8 chans_layout_str[STR_SZ]; /* should be overkill */
 
... ... static void abufsrc_cfg(enum av_fr_fmt fmt, int rate, int chans_n,
899 891 AV_OPT_SEARCH_CHILDREN); AV_OPT_SEARCH_CHILDREN);
900 892 if (r < 0) if (r < 0)
901 893 fatal("audio buffer source context:unable to set the decoder rate option\n"); fatal("audio buffer source context:unable to set the decoder rate option\n");
902 av_get_chan_layout_str(chans_layout_str, sizeof(chans_layout_str),
903 chans_n, chans_layout);
894 av_channel_layout_describe(chans_layout, chans_layout_str,
895 sizeof(chans_layout_str));
904 896 if (print_info) if (print_info)
905 pout("audio buffer source context:using channels layout \"%s\" (%d pcm channels)\n", chans_layout_str, chans_n);
897 pout("audio buffer source context:using channels layout \"%s\"\n", chans_layout_str);
906 898 r = av_opt_set(abufsrc_ctx, "channel_layout", chans_layout_str, r = av_opt_set(abufsrc_ctx, "channel_layout", chans_layout_str,
907 899 AV_OPT_SEARCH_CHILDREN); AV_OPT_SEARCH_CHILDREN);
908 900 if (r < 0) if (r < 0)
 
... ... static void vol_cfg(bool muted, double vol)
936 928 if (r < 0) if (r < 0)
937 929 fatal("volume buffer context:unable to initialize\n"); fatal("volume buffer context:unable to initialize\n");
938 930 } }
939 static void afmt_cfg(enum av_fr_fmt fmt, int rate, int chans_n,
940 uint64_t chans_layout, bool print_info)
931 static void afmt_cfg(enum av_fr_fmt fmt, int rate,
932 AVChannelLayout *chans_layout, bool print_info)
941 933 { {
942 934 int r; int r;
943 935 u8 rate_str[sizeof("dddddd")]; u8 rate_str[sizeof("dddddd")];
 
... ... static void afmt_cfg(enum av_fr_fmt fmt, int rate, int chans_n,
958 950 AV_OPT_SEARCH_CHILDREN); AV_OPT_SEARCH_CHILDREN);
959 951 if (r < 0) if (r < 0)
960 952 fatal("audio format context:could not set the pcm rate\n"); fatal("audio format context:could not set the pcm rate\n");
961 av_get_chan_layout_str(chans_layout_str, sizeof(chans_layout_str),
962 chans_n, chans_layout);
953 av_channel_layout_describe(chans_layout, chans_layout_str,
954 sizeof(chans_layout_str));
963 955 r = av_opt_set(afmt_ctx, "channel_layouts", chans_layout_str, r = av_opt_set(afmt_ctx, "channel_layouts", chans_layout_str,
964 956 AV_OPT_SEARCH_CHILDREN); AV_OPT_SEARCH_CHILDREN);
965 957 if (r < 0) if (r < 0)
 
... ... static void dec_ctx_cfg(AVCodecParameters *params)
1007 999 fatal("ffmpeg:unable to open the decoder context\n"); fatal("ffmpeg:unable to open the decoder context\n");
1008 1000 } }
1009 1001 static void filt_graph_cfg( static void filt_graph_cfg(
1010 enum av_fr_fmt src_fmt, int src_rate, int src_chans_n,
1011 uint64_t src_chans_layout,
1002 enum av_fr_fmt src_fmt, int src_rate,
1003 AVChannelLayout *src_chans_layout,
1012 1004 bool muted, double vol, bool muted, double vol,
1013 enum av_fr_fmt dst_fmt, int dst_rate, int dst_chans_n,
1014 uint64_t dst_chans_layout, bool print_info)
1005 enum av_fr_fmt dst_fmt, int dst_rate,
1006 AVChannelLayout *dst_chans_layout, bool print_info)
1015 1007 { {
1016 1008 int r; int r;
1017 1009 char *dump_str; char *dump_str;
 
... ... static void filt_graph_cfg(
1021 1013 filt_graph = av_filt_graph_alloc(); filt_graph = av_filt_graph_alloc();
1022 1014 if (filt_graph == 0) if (filt_graph == 0)
1023 1015 fatal("unable to create filter graph\n"); fatal("unable to create filter graph\n");
1024 abufsrc_cfg(src_fmt, src_rate, src_chans_n, src_chans_layout,
1025 print_info);
1016 abufsrc_cfg(src_fmt, src_rate, src_chans_layout, print_info);
1026 1017 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
1027 abufsrc_key.chans_n = src_chans_n;
1028 abufsrc_key.chans_layout = src_chans_layout;
1018 r = av_channel_layout_copy(&abufsrc_key.chans_layout, src_chans_layout);
1019 if (r < 0)
1020 fatal("unable to copy the source channel layout in the key\n");
1029 1021 abufsrc_key.rate = src_rate; abufsrc_key.rate = src_rate;
1030 1022 abufsrc_key.fmt = src_fmt; abufsrc_key.fmt = src_fmt;
1031 1023 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
1032 1024 vol_cfg(muted, vol); vol_cfg(muted, vol);
1033 afmt_cfg(dst_fmt, dst_rate, dst_chans_n, dst_chans_layout, print_info);
1025 afmt_cfg(dst_fmt, dst_rate, dst_chans_layout, print_info);
1034 1026 abufsink_cfg(); abufsink_cfg();
1035 1027 r = av_filt_link(abufsrc_ctx, 0, vol_ctx, 0); r = av_filt_link(abufsrc_ctx, 0, vol_ctx, 0);
1036 1028 if (r < 0) if (r < 0)
 
... ... static void filt_flush(void)
1063 1055 enum av_fr_fmt dst_fmt; enum av_fr_fmt dst_fmt;
1064 1056 int dst_rate; int dst_rate;
1065 1057 int dst_chans_n; int dst_chans_n;
1066 uint64_t src_chans_layout;
1067 uint64_t dst_chans_layout;
1058 AVChannelLayout src_chans_layout;
1059 AVChannelLayout dst_chans_layout;
1060 int r;
1061
1062 memset(&src_chans_layout, 0, sizeof(src_chans_layout));
1063 memset(&dst_chans_layout, 0, sizeof(dst_chans_layout));
1068 1064
1069 1065 av_frs_unref(filt_frs.av); av_frs_unref(filt_frs.av);
1070 1066 filt_frs.pcm_written_ufrs_n = 0; filt_frs.pcm_written_ufrs_n = 0;
1071 1067
1072 pcm2ff(pcm_g, &dst_fmt, &dst_rate, &dst_chans_n, &dst_chans_layout,
1068 pcm2ff(pcm_g, &dst_fmt, &dst_rate, &dst_chans_layout,
1073 1069 DONT_PRINT_INFO); DONT_PRINT_INFO);
1074 1070 /* the audio dec ctx may not have a valid chans layout */ /* the audio dec ctx may not have a valid chans layout */
1075 if (dec_ctx->chans_layout == 0) {
1076 src_chans_layout = av_get_default_chans_layout(dec_ctx->chans_n);
1077 } else
1078 src_chans_layout = dec_ctx->chans_layout;
1071 r = av_channel_layout_check(&dec_ctx->ch_layout);
1072 if (r == 0) /* XXX: we expect at least chans_n to be valid */
1073 av_channel_layout_default(&src_chans_layout,
1074 dec_ctx->ch_layout.nb_channels);
1075 else
1076 av_channel_layout_copy(&src_chans_layout, &dec_ctx->ch_layout);
1079 1077 filt_graph_cfg( filt_graph_cfg(
1080 dec_ctx->fr_fmt, dec_ctx->fr_rate,
1081 dec_ctx->chans_n, src_chans_layout,
1078 dec_ctx->fr_fmt, dec_ctx->fr_rate, &src_chans_layout,
1082 1079 filt_frs.muted, filt_frs.vol, filt_frs.muted, filt_frs.vol,
1083 dst_fmt, dst_rate, dst_chans_n, dst_chans_layout,
1080 dst_fmt, dst_rate, &dst_chans_layout,
1084 1081 DONT_PRINT_INFO); DONT_PRINT_INFO);
1082 av_channel_layout_uninit(&src_chans_layout);
1083 av_channel_layout_uninit(&dst_chans_layout);
1085 1084 } }
1086 1085 #undef DONT_PRINT_INFO #undef DONT_PRINT_INFO
1087 1086 static void stdin_tty_init_once(void) static void stdin_tty_init_once(void)
 
... ... static void dec_frs_get(void) { loop
1505 1504 }} }}
1506 1505 static bool is_recfg_required(av_frs *frs) static bool is_recfg_required(av_frs *frs)
1507 1506 { {
1508 if ( frs->chans_n != abufsrc_key.chans_n
1509 || frs->chans_layout != abufsrc_key.chans_layout
1507 if (av_channel_layout_compare(&frs->ch_layout,
1508 &abufsrc_key.chans_layout) != 0
1510 1509 || frs->fr_rate != abufsrc_key.rate || frs->fr_rate != abufsrc_key.rate
1511 1510 || frs->fmt != abufsrc_key.fmt) || frs->fmt != abufsrc_key.fmt)
1512 1511 return true; return true;
 
... ... static bool is_recfg_required(av_frs *frs)
1515 1514 #define AGAIN 0 #define AGAIN 0
1516 1515 #define PUSHED 1 #define PUSHED 1
1517 1516 #define FILT_RECFG_REQUIRED 2 #define FILT_RECFG_REQUIRED 2
1518 static u8 filt_graph_push_dec_frs(int *new_chans_n, uint64_t *new_chans_layout,
1517 static u8 filt_graph_push_dec_frs(AVChannelLayout *new_chans_layout,
1519 1518 int *new_fr_rate, enum av_fr_fmt *new_fmt) int *new_fr_rate, enum av_fr_fmt *new_fmt)
1520 1519 { {
1521 1520 int r; int r;
1522 1521
1523 1522 if (dec_frs.pushed_in_filt_graph) if (dec_frs.pushed_in_filt_graph)
1524 1523 dec_frs_get(); dec_frs_get();
1525 if (dec_frs.av->chans_layout == 0) /* choose one for the filt */
1526 dec_frs.av->chans_layout = av_get_default_chans_layout(
1527 dec_frs.av->chans_n);
1528 1524 if (is_recfg_required(dec_frs.av)) { if (is_recfg_required(dec_frs.av)) {
1529 *new_chans_n = dec_frs.av->chans_n;
1530 *new_chans_layout = dec_frs.av->chans_layout;
1525 r = av_channel_layout_copy(new_chans_layout,
1526 &dec_frs.av->ch_layout);
1527 if (r < 0)
1528 fatal("ffmpeg:unable to copy the decoder channel layout as the new channel layout\n");
1531 1529 *new_fr_rate = dec_frs.av->fr_rate; *new_fr_rate = dec_frs.av->fr_rate;
1532 1530 *new_fmt = dec_frs.av->fmt; *new_fmt = dec_frs.av->fmt;
1533 1531 return FILT_RECFG_REQUIRED; return FILT_RECFG_REQUIRED;
 
... ... static void dec_frs_filter(void)
1566 1564 { {
1567 1565 loop { loop {
1568 1566 u8 r; u8 r;
1569 int new_chans_n;
1570 uint64_t new_chans_layout;
1567 AVChannelLayout new_chans_layout;
1571 1568 int new_fr_rate; int new_fr_rate;
1572 1569 enum av_fr_fmt new_fmt; enum av_fr_fmt new_fmt;
1573 int dst_chans_n;
1574 uint64_t dst_chans_layout;
1570 AVChannelLayout dst_chans_layout;
1575 1571 int dst_rate; int dst_rate;
1576 1572 enum av_fr_fmt dst_fmt; enum av_fr_fmt dst_fmt;
1577 1573
1578 r = filt_graph_push_dec_frs(&new_chans_n, &new_chans_layout,
1579 &new_fr_rate, &new_fmt);
1574 memset(&new_chans_layout, 0, sizeof(new_chans_layout));
1575 memset(&dst_chans_layout, 0, sizeof(dst_chans_layout));
1576
1577 r = filt_graph_push_dec_frs(&new_chans_layout, &new_fr_rate,
1578 &new_fmt);
1580 1579 if (r != FILT_RECFG_REQUIRED) { if (r != FILT_RECFG_REQUIRED) {
1581 1580 /* PUSHED | AGAIN */ /* PUSHED | AGAIN */
1581 av_channel_layout_uninit(&new_chans_layout);
1582 1582 break; break;
1583 1583 } }
1584 1584 /* FILT_RECFG_REQUIRED */ /* FILT_RECFG_REQUIRED */
1585 pcm2ff(pcm_g, &dst_fmt, &dst_rate, &dst_chans_n,
1586 &dst_chans_layout, PRINT_INFO);
1585 pcm2ff(pcm_g, &dst_fmt, &dst_rate, &dst_chans_layout,
1586 PRINT_INFO);
1587 1587 filt_graph_cfg( filt_graph_cfg(
1588 new_fmt, new_fr_rate, new_chans_n, new_chans_layout,
1588 new_fmt, new_fr_rate, &new_chans_layout,
1589 1589 filt_frs.muted, filt_frs.vol, filt_frs.muted, filt_frs.vol,
1590 dst_fmt, dst_rate, dst_chans_n, dst_chans_layout,
1591 PRINT_INFO);
1590 dst_fmt, dst_rate, &dst_chans_layout, PRINT_INFO);
1591 av_channel_layout_uninit(&new_chans_layout);
1592 av_channel_layout_uninit(&dst_chans_layout);
1592 1593 } }
1593 1594 filt_frs_get(); filt_frs_get();
1594 1595 } }
 
... ... static void chans_buf_init(u8 **chans_buf, int start_fr_idx)
1609 1610 if (is_planar_fmt == NO) { /* or is pcm interleaved */ if (is_planar_fmt == NO) { /* or is pcm interleaved */
1610 1611 int fr_bytes_n; int fr_bytes_n;
1611 1612
1612 fr_bytes_n = sample_bytes_n * filt_frs.av->chans_n;
1613 fr_bytes_n = sample_bytes_n
1614 * filt_frs.av->ch_layout.nb_channels;
1613 1615 chans_buf[0] = (u8*)filt_frs.av->data[0] + start_fr_idx chans_buf[0] = (u8*)filt_frs.av->data[0] + start_fr_idx
1614 1616 * fr_bytes_n; * fr_bytes_n;
1615 1617 } else { /* ff planar or pcm noninterleaved */ } else { /* ff planar or pcm noninterleaved */
 
... ... static void chans_buf_init(u8 **chans_buf, int start_fr_idx)
1617 1619
1618 1620 p = 0; p = 0;
1619 1621 loop { loop {
1620 if (p == filt_frs.av->chans_n)
1622 if (p == filt_frs.av->ch_layout.nb_channels)
1621 1623 break; break;
1622 1624 chans_buf[p] = (u8*)filt_frs.av->data[p] chans_buf[p] = (u8*)filt_frs.av->data[p]
1623 1625 + start_fr_idx * sample_bytes_n; + start_fr_idx * sample_bytes_n;
 
... ... static void chans_buf_inc(u8 **chans_buf, int frs_inc)
1638 1640 if (is_planar_fmt == NO) { /* or is pcm interleaved */ if (is_planar_fmt == NO) { /* or is pcm interleaved */
1639 1641 int fr_bytes_n; int fr_bytes_n;
1640 1642
1641 fr_bytes_n = sample_bytes_n * filt_frs.av->chans_n;
1643 fr_bytes_n = sample_bytes_n
1644 * filt_frs.av->ch_layout.nb_channels;
1642 1645 chans_buf[0] += frs_inc * fr_bytes_n; chans_buf[0] += frs_inc * fr_bytes_n;
1643 1646 } else { /* ff planar or pcm noninterleaved */ } else { /* ff planar or pcm noninterleaved */
1644 1647 u8 p; u8 p;
1645 1648
1646 1649 p = 0; p = 0;
1647 1650 loop { loop {
1648 if (p == filt_frs.av->chans_n)
1651 if (p == filt_frs.av->ch_layout.nb_channels)
1649 1652 break; break;
1650 1653 chans_buf[p] += frs_inc * sample_bytes_n; chans_buf[p] += frs_inc * sample_bytes_n;
1651 1654 ++p; ++p;
 
... ... static void filt_graph_init_once(void)
2068 2071 filt_graph = 0; filt_graph = 0;
2069 2072 abufsrc_ctx = 0; abufsrc_ctx = 0;
2070 2073 abufsrc_filt = 0; abufsrc_filt = 0;
2074 memset(&abufsrc_key, 0, sizeof(abufsrc_key));
2071 2075 vol_ctx = 0; vol_ctx = 0;
2072 2076 vol_filt = 0; vol_filt = 0;
2073 2077 afmt_ctx = 0; afmt_ctx = 0;
 
... ... static void prepare(int st_idx, double initial_vol,
2573 2577 enum av_fr_fmt override_initial_ff_audio_fr_fmt) enum av_fr_fmt override_initial_ff_audio_fr_fmt)
2574 2578 { {
2575 2579 enum av_fr_fmt dst_fmt; enum av_fr_fmt dst_fmt;
2576 int dst_rate;
2577 int dst_chans_n;
2578 uint64_t src_chans_layout;
2579 uint64_t dst_chans_layout;
2580 2580 int initial_ff_chans_n; int initial_ff_chans_n;
2581 2581 int initial_ff_rate; int initial_ff_rate;
2582 2582 enum av_fr_fmt initial_ff_audio_fr_fmt; enum av_fr_fmt initial_ff_audio_fr_fmt;
 
... ... static void prepare(int st_idx, double initial_vol,
2593 2593 fmt_ctx_unlock(); fmt_ctx_unlock();
2594 2594
2595 2595 if (override_initial_ff_chans_n == CHANS_N_NOT_OVERRIDDEN) if (override_initial_ff_chans_n == CHANS_N_NOT_OVERRIDDEN)
2596 initial_ff_chans_n = dec_ctx->chans_n;
2596 initial_ff_chans_n = dec_ctx->ch_layout.nb_channels;
2597 2597 else else
2598 2598 initial_ff_chans_n = override_initial_ff_chans_n; initial_ff_chans_n = override_initial_ff_chans_n;
2599 2599 if (override_initial_ff_rate == RATE_NOT_OVERRIDDEN) if (override_initial_ff_rate == RATE_NOT_OVERRIDDEN)
 
... ... int main(int argc, u8 **args)
2909 2909 #undef av_frs_alloc #undef av_frs_alloc
2910 2910 #undef av_frs_set_silence #undef av_frs_set_silence
2911 2911 #undef av_frs_unref #undef av_frs_unref
2912 #undef av_get_chan_layout_str
2913 #undef av_get_default_chans_layout
2914 2912 #undef av_get_fr_fmt_name #undef av_get_fr_fmt_name
2915 2913 #undef av_get_fr_fmt_str #undef av_get_fr_fmt_str
2916 2914 #undef av_io_flush #undef av_io_flush
 
... ... int main(int argc, u8 **args)
2925 2923 #undef av_frs #undef av_frs
2926 2924 #undef av_sd_pkt #undef av_sd_pkt
2927 2925 #undef av_st #undef av_st
2928 #undef chan_layout
2929 #undef chans_n
2930 2926 #undef format #undef format
2931 2927 #undef fr_fmt #undef fr_fmt
2932 2928 #undef fr_rate #undef fr_rate
File npv/audio/filt/local/code.frag.c changed (mode: 100644) (index 7ce8f1f..06f1667)
... ... STATIC void pout(u8 *fmt, ...)
27 27 } }
28 28 STATIC bool is_recfg_required(avutil_audio_set_ref_t *src_set) STATIC bool is_recfg_required(avutil_audio_set_ref_t *src_set)
29 29 { {
30 if ( src_set->chans_n != abufsrc_l.key.chans_n
31 || src_set->chans_layout != abufsrc_l.key.chans_layout
30
31 if (av_channel_layout_compare(&src_set->ch_layout,
32 &abufsrc_l.key.chans_layout) != 0
32 33 || src_set->rate != abufsrc_l.key.rate || src_set->rate != abufsrc_l.key.rate
33 34 || src_set->fmt != abufsrc_l.key.fmt) || src_set->fmt != abufsrc_l.key.fmt)
34 35 return true; return true;
35 36 return false; return false;
36 37 } }
37 STATIC void abufsrc_cfg(avutil_rational_t tb, int chans_n,
38 uint64_t chans_layout, int rate, enum avutil_audio_fr_fmt_t fmt,
39 bool print_info)
38 STATIC void abufsrc_cfg(avutil_rational_t tb, AVChannelLayout *chans_layout,
39 int rate, enum avutil_audio_fr_fmt_t fmt, bool print_info)
40 40 { {
41 41 int r; int r;
42 42 u8 chans_layout_str[STR_SZ]; /* should be overkill */ u8 chans_layout_str[STR_SZ]; /* should be overkill */
 
... ... STATIC void abufsrc_cfg(avutil_rational_t tb, int chans_n,
57 57 rate, AVUTIL_OPT_SEARCH_CHILDREN); rate, AVUTIL_OPT_SEARCH_CHILDREN);
58 58 if (r < 0) if (r < 0)
59 59 fatal("audio buffer source context:unable to set the decoder rate option\n"); fatal("audio buffer source context:unable to set the decoder rate option\n");
60 avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str),
61 chans_n, chans_layout);
60 av_channel_layout_describe(chans_layout, chans_layout_str,
61 sizeof(chans_layout_str));
62 62 if (print_info) if (print_info)
63 pout("audio buffer source context:using channels layout \"%s\" (%d pcm channels)\n", chans_layout_str, chans_n);
63 pout("audio buffer source context:using channels layout \"%s\"\n", chans_layout_str);
64 64 r = avutil_opt_set(abufsrc_l.ctx, "channel_layout", chans_layout_str, r = avutil_opt_set(abufsrc_l.ctx, "channel_layout", chans_layout_str,
65 65 AVUTIL_OPT_SEARCH_CHILDREN); AVUTIL_OPT_SEARCH_CHILDREN);
66 66 if (r < 0) if (r < 0)
 
... ... STATIC void vol_cfg(bool muted, double vol_cfg)
99 99 if (r < 0) if (r < 0)
100 100 fatal("volume buffer context:unable to initialize\n"); fatal("volume buffer context:unable to initialize\n");
101 101 } }
102 STATIC void afmt_cfg(int chans_n, uint64_t chans_layout, int rate,
102 STATIC void afmt_cfg(AVChannelLayout *chans_layout, int rate,
103 103 enum avutil_audio_fr_fmt_t fmt, bool print_info) enum avutil_audio_fr_fmt_t fmt, bool print_info)
104 104 { {
105 105 int r; int r;
 
... ... STATIC void afmt_cfg(int chans_n, uint64_t chans_layout, int rate,
121 121 AVUTIL_OPT_SEARCH_CHILDREN); AVUTIL_OPT_SEARCH_CHILDREN);
122 122 if (r < 0) if (r < 0)
123 123 fatal("audio format context:could not set the pcm rate\n"); fatal("audio format context:could not set the pcm rate\n");
124 avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str),
125 chans_n, chans_layout);
124 av_channel_layout_describe(chans_layout, chans_layout_str,
125 sizeof(chans_layout_str));
126 126 r = avutil_opt_set(afmt_ctx_l, "channel_layouts", chans_layout_str, r = avutil_opt_set(afmt_ctx_l, "channel_layouts", chans_layout_str,
127 127 AVUTIL_OPT_SEARCH_CHILDREN); AVUTIL_OPT_SEARCH_CHILDREN);
128 128 if (r < 0) if (r < 0)
File npv/audio/filt/local/state.frag.c changed (mode: 100644) (index 5e2e6d9..0c5fd58)
... ... STATIC struct {
4 4 avfilter_filt_ctx_t *ctx; avfilter_filt_ctx_t *ctx;
5 5 /* key to detect required recfg */ /* key to detect required recfg */
6 6 struct { struct {
7 AVChannelLayout chans_layout;
7 8 int rate; int rate;
8 int chans_n;
9 uint64_t chans_layout;
10 9 enum avutil_audio_fr_fmt_t fmt; enum avutil_audio_fr_fmt_t fmt;
11 10 } key; } key;
12 11 } abufsrc_l; } abufsrc_l;
File npv/audio/filt/namespace/main.c changed (mode: 100644) (index 476c07a..2bd440e)
19 19 #define warning npv_audio_filt_warning #define warning npv_audio_filt_warning
20 20 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
21 21 /* some member names */ /* some member names */
22 #define chans_layout channel_layout
23 #define chans_n channels
24 22 #define fmt format #define fmt format
25 23 #define rate sample_rate #define rate sample_rate
26 24 /*============================================================================*/ /*============================================================================*/
 
44 42 #undef vol_l #undef vol_l
45 43 #undef warning #undef warning
46 44 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
47 #undef chans_layout
48 #undef chans_n
49 45 #undef rate #undef rate
50 46 #undef fmt #undef fmt
51 47 #endif #endif
File npv/audio/filt/public.h changed (mode: 100644) (index be7b588..12088ce)
21 21 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
22 22 STATIC void init_once(double initial_vol); STATIC void init_once(double initial_vol);
23 23 STATIC void cfg(avutil_rational_t tb, STATIC void cfg(avutil_rational_t tb,
24 int src_chans_n, uint64_t src_chans_layout, int src_rate,
24 AVChannelLayout *src_chans_layout, int src_rate,
25 25 enum avutil_audio_fr_fmt_t src_fmt, enum avutil_audio_fr_fmt_t src_fmt,
26 26 bool muted, double vol, bool muted, double vol,
27 int dst_chans_n, uint64_t dst_chans_layout, int dst_rate,
27 AVChannelLayout *dst_chans_layout, int dst_rate,
28 28 enum avutil_audio_fr_fmt_t dst_fmt, enum avutil_audio_fr_fmt_t dst_fmt,
29 29 bool print_info); bool print_info);
30 STATIC u8 filt_push_dec_set(int *new_chans_n, uint64_t *new_chans_layout,
30 STATIC u8 filt_push_dec_set(AVChannelLayout *new_chans_layout,
31 31 int *new_rate, enum avutil_audio_fr_fmt_t *new_fmt); int *new_rate, enum avutil_audio_fr_fmt_t *new_fmt);
32 32 STATIC u8 filt_set_get(void); STATIC u8 filt_set_get(void);
33 33 STATIC void filt_flush(void); STATIC void filt_flush(void);
File npv/audio/filt/public/code.frag.c changed (mode: 100644) (index 693218f..0312667)
3 3 #define NO_DEC_SET 2 #define NO_DEC_SET 2
4 4 #define FILT_SWITCHED_TO_DRAINING 3 #define FILT_SWITCHED_TO_DRAINING 3
5 5 #define FILT_RECFG_REQUIRED 4 #define FILT_RECFG_REQUIRED 4
6 STATIC u8 filt_push_dec_set(int *new_chans_n, uint64_t *new_chans_layout,
6 STATIC u8 filt_push_dec_set(AVChannelLayout *new_chans_layout,
7 7 int *new_rate, enum avutil_audio_fr_fmt_t *new_fmt) int *new_rate, enum avutil_audio_fr_fmt_t *new_fmt)
8 8 { {
9 9 u8 r8; u8 r8;
 
... ... STATIC u8 filt_push_dec_set(int *new_chans_n, uint64_t *new_chans_layout,
29 29 * XXX: this is were dynamic audio recfg is triggered and we get out of * XXX: this is were dynamic audio recfg is triggered and we get out of
30 30 * the critical section asap * the critical section asap
31 31 */ */
32 if (a[0]->chans_layout == 0) /* choose one for the filter */
33 a[0]->chans_layout = avutil_get_default_chans_layout(
34 a[0]->chans_n);
35 32 if (is_recfg_required(a[0])) { if (is_recfg_required(a[0])) {
36 33 /* because we are in a critical section */ /* because we are in a critical section */
37 *new_chans_n = a[0]->chans_n;
38 *new_chans_layout = a[0]->chans_layout;
34 ri = av_channel_layout_copy(new_chans_layout, &a[0]->ch_layout);
35 if (ri < 0)
36 fatal("ffmpeg:unable to copy the channel layout of the set of frames as a new channel layout\n");
39 37 *new_rate = a[0]->rate; *new_rate = a[0]->rate;
40 38 *new_fmt = a[0]->fmt; *new_fmt = a[0]->fmt;
41 39 r8 = FILT_RECFG_REQUIRED; r8 = FILT_RECFG_REQUIRED;
 
... ... STATIC void init_once(double initial_vol)
106 104 init_once_public(initial_vol); init_once_public(initial_vol);
107 105 } }
108 106 STATIC void cfg(avutil_rational_t tb, STATIC void cfg(avutil_rational_t tb,
109 int src_chans_n, uint64_t src_chans_layout, int src_rate,
107 AVChannelLayout *src_chans_layout, int src_rate,
110 108 enum avutil_audio_fr_fmt_t src_fmt, enum avutil_audio_fr_fmt_t src_fmt,
111 109 bool muted, double vol, bool muted, double vol,
112 int dst_chans_n, uint64_t dst_chans_layout, int dst_rate,
110 AVChannelLayout *dst_chans_layout, int dst_rate,
113 111 enum avutil_audio_fr_fmt_t dst_fmt, enum avutil_audio_fr_fmt_t dst_fmt,
114 112 bool print_info) bool print_info)
115 113 { {
 
... ... STATIC void cfg(avutil_rational_t tb,
121 119 graph_l = avfilter_graph_alloc(); graph_l = avfilter_graph_alloc();
122 120 if (graph_l == 0) if (graph_l == 0)
123 121 fatal("unable to create filter graph\n"); fatal("unable to create filter graph\n");
124 abufsrc_cfg(tb, src_chans_n, src_chans_layout, src_rate, src_fmt,
125 print_info);
122 abufsrc_cfg(tb, src_chans_layout, src_rate, src_fmt, print_info);
126 123 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
127 abufsrc_l.key.chans_n = src_chans_n;
128 abufsrc_l.key.chans_layout = src_chans_layout;
124 r = av_channel_layout_copy(&abufsrc_l.key.chans_layout,
125 src_chans_layout);
126 if (r < 0)
127 fatal("unable to copy the source channel layout to the key\n");
129 128 abufsrc_l.key.rate = src_rate; abufsrc_l.key.rate = src_rate;
130 129 abufsrc_l.key.fmt = src_fmt; abufsrc_l.key.fmt = src_fmt;
131 130 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
132 131 vol_cfg(muted, vol); vol_cfg(muted, vol);
133 afmt_cfg(dst_chans_n, dst_chans_layout, dst_rate, dst_fmt, print_info);
132 afmt_cfg(dst_chans_layout, dst_rate, dst_fmt, print_info);
134 133 abufsink_cfg(); abufsink_cfg();
135 134 r = avfilter_link(abufsrc_l.ctx, 0, vol_ctx_l, 0); r = avfilter_link(abufsrc_l.ctx, 0, vol_ctx_l, 0);
136 135 if (r < 0) if (r < 0)
File npv/audio/local/code.frag.c changed (mode: 100644) (index e10e8bd..7b27b7b)
... ... STATIC u8 *kernel_ts_types_str_l[] = {
38 38 * XXX: if it is ever used significantly, a fine granularity wiring strategy * XXX: if it is ever used significantly, a fine granularity wiring strategy
39 39 * will be implemented instead of using the default wiring * will be implemented instead of using the default wiring
40 40 */ */
41 STATIC uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
42 unsigned int pcm_chans_n, bool print_info)
41 STATIC void pcm_chmaps2ff_chans_layout(AVChannelLayout *ff_chans_layout,
42 snd_pcm_t *pcm, unsigned int pcm_chans_n, bool print_info)
43 43 { {
44 44 int r; int r;
45 uint64_t ff_chans_layout;
46 45 snd_pcm_chmap_t *pcm_chmap; snd_pcm_chmap_t *pcm_chmap;
47 46 u8 chans_layout_str[STR_SZ]; /* should be overkill */ u8 chans_layout_str[STR_SZ]; /* should be overkill */
48 47
 
... ... STATIC uint64_t pcm_chmaps2ff_chans_layout(snd_pcm_t *pcm,
55 54 pout("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented, using default ffmpeg layout\n"); pout("alsa:your pcm device support channel maps, but fine granularity wiring strategy is not implemented, using default ffmpeg layout\n");
56 55 free(pcm_chmap); free(pcm_chmap);
57 56 } }
58 ff_chans_layout = avutil_get_default_chans_layout((int)pcm_chans_n);
59 avutil_get_chans_layout_str(chans_layout_str, sizeof(chans_layout_str),
60 (int)pcm_chans_n, ff_chans_layout);
57 /* XXX: will need to get back at it if a wiring strategy is required */
58 av_channel_layout_default(ff_chans_layout, (int)pcm_chans_n);
59 av_channel_layout_describe(ff_chans_layout, chans_layout_str,
60 sizeof(chans_layout_str));
61 61 if (print_info) if (print_info)
62 62 pout("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n); pout("alsa channel map wired to ffmpeg channel layout:\"%s\" (%u pcm channels)\n", chans_layout_str, pcm_chans_n);
63 return ff_chans_layout;
64 63 } }
65 64 STATIC bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt, STATIC bool ff_fmt2pcm_layout_best_effort(enum avutil_audio_fr_fmt_t ff_fmt,
66 65 snd_pcm_fmt_t *alsa_fmt, snd_pcm_access_t *alsa_access) snd_pcm_fmt_t *alsa_fmt, snd_pcm_access_t *alsa_access)
 
... ... STATIC void pcm_hw_buf_sz_cfg(snd_pcm_t *pcm,
365 364 * we try to use a sensible restrict order regarding audio props * we try to use a sensible restrict order regarding audio props
366 365 */ */
367 366 STATIC void pcm_cfg_hw_core_best_effort(snd_pcm_t *pcm, STATIC void pcm_cfg_hw_core_best_effort(snd_pcm_t *pcm,
368 snd_pcm_hw_params_t *pcm_hw_params, int chans_n, uint64_t chans_layout,
367 snd_pcm_hw_params_t *pcm_hw_params, int chans_n,
369 368 int rate, enum avutil_audio_fr_fmt_t ff_fmt) int rate, enum avutil_audio_fr_fmt_t ff_fmt)
370 369 { {
371 370 int r; int r;
 
... ... STATIC void pcm_cfg_hw_core_best_effort(snd_pcm_t *pcm,
378 377 if (r < 0) if (r < 0)
379 378 fatal("alsa:unable to populate the hardware parameters context\n"); fatal("alsa:unable to populate the hardware parameters context\n");
380 379 pcm_hw_chans_n_decide(pcm, pcm_hw_params, chans_n); pcm_hw_chans_n_decide(pcm, pcm_hw_params, chans_n);
381 /* XXX: we ignore chans_layout (remapping done in bridge filt) */
382 380 pcm_hw_rate_decide(pcm, pcm_hw_params, rate); pcm_hw_rate_decide(pcm, pcm_hw_params, rate);
383 381 /* try our best with the fmt */ /* try our best with the fmt */
384 382 best_effort_wiring_success = ff_fmt2pcm_layout_best_effort( best_effort_wiring_success = ff_fmt2pcm_layout_best_effort(
 
... ... STATIC void chans_buf_init(u8 **chans_buf, int start_fr_idx)
469 467 if (is_planar_fmt == NO) { /* or is pcm interleaved */ if (is_planar_fmt == NO) { /* or is pcm interleaved */
470 468 int fr_bytes_n; int fr_bytes_n;
471 469
472 fr_bytes_n = sample_bytes_n * npv_audio_filt_p.set->chans_n;
470 fr_bytes_n = sample_bytes_n
471 * npv_audio_filt_p.set->ch_layout.nb_channels;
473 472 chans_buf[0] = (u8*)npv_audio_filt_p.set->data[0] + start_fr_idx chans_buf[0] = (u8*)npv_audio_filt_p.set->data[0] + start_fr_idx
474 473 * fr_bytes_n; * fr_bytes_n;
475 474 } else { /* ff planar or pcm noninterleaved */ } else { /* ff planar or pcm noninterleaved */
 
... ... STATIC void chans_buf_init(u8 **chans_buf, int start_fr_idx)
477 476
478 477 p = 0; p = 0;
479 478 loop { loop {
480 if (p == npv_audio_filt_p.set->chans_n)
479 if (p == npv_audio_filt_p.set->ch_layout.nb_channels)
481 480 break; break;
482 481 chans_buf[p] = (u8*)npv_audio_filt_p.set->data[p] chans_buf[p] = (u8*)npv_audio_filt_p.set->data[p]
483 482 + start_fr_idx * sample_bytes_n; + start_fr_idx * sample_bytes_n;
 
... ... STATIC void chans_buf_inc(u8 **chans_buf, int inc)
498 497 if (is_planar_fmt == NO) { /* or is pcm interleaved */ if (is_planar_fmt == NO) { /* or is pcm interleaved */
499 498 int fr_bytes_n; int fr_bytes_n;
500 499
501 fr_bytes_n = sample_bytes_n * npv_audio_filt_p.set->chans_n;
500 fr_bytes_n = sample_bytes_n
501 * npv_audio_filt_p.set->ch_layout.nb_channels;
502 502 chans_buf[0] = (u8*)chans_buf[0] + inc * fr_bytes_n; chans_buf[0] = (u8*)chans_buf[0] + inc * fr_bytes_n;
503 503 } else { /* ff planar or pcm noninterleaved */ } else { /* ff planar or pcm noninterleaved */
504 504 int p; int p;
505 505
506 506 p = 0; p = 0;
507 507 loop { loop {
508 if (p == npv_audio_filt_p.set->chans_n)
508 if (p == npv_audio_filt_p.set->ch_layout.nb_channels)
509 509 break; break;
510 510 chans_buf[p] = (u8*)chans_buf[p] + inc * sample_bytes_n; chans_buf[p] = (u8*)chans_buf[p] + inc * sample_bytes_n;
511 511 ++p; ++p;
 
... ... STATIC void pcm_layout2ff_fmt_strict(snd_pcm_fmt_t alsa_fmt,
613 613 pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str); pout("alsa pcm layout \"%s\"/\"%s\" wired strictly to ffmpeg format \"%sbits\"\n", snd_pcm_fmt_desc(alsa_fmt), snd_pcm_access_name(alsa_access), ff_fmt_str);
614 614 } }
615 615 } }
616 STATIC void pcm2ff_strict(snd_pcm_t *pcm, int *ff_chans_n,
617 uint64_t *ff_chans_layout, int *ff_rate,
618 enum avutil_audio_fr_fmt_t *ff_fmt, bool print_info)
616 STATIC void pcm2ff_strict(snd_pcm_t *pcm, AVChannelLayout *ff_chans_layout,
617 int *ff_rate, enum avutil_audio_fr_fmt_t *ff_fmt, bool print_info)
619 618 { {
620 619 int r; int r;
621 620 snd_pcm_hw_params_t *hw_params; snd_pcm_hw_params_t *hw_params;
 
... ... STATIC void pcm2ff_strict(snd_pcm_t *pcm, int *ff_chans_n,
647 646 r = snd_pcm_hw_params_get_chans_n(hw_params, &pcm_chans_n); r = snd_pcm_hw_params_get_chans_n(hw_params, &pcm_chans_n);
648 647 if (r < 0) if (r < 0)
649 648 fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n"); fatal("alsa:unable to get the pcm count of channels for ffmpeg filter wiring\n");
650 *ff_chans_n = (int)pcm_chans_n;
651 649 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
652 *ff_chans_layout = pcm_chmaps2ff_chans_layout(pcm, pcm_chans_n,
650 pcm_chmaps2ff_chans_layout(ff_chans_layout, pcm, pcm_chans_n,
653 651 print_info); print_info);
654 652 /*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
655 653 snd_pcm_hw_params_free(hw_params); snd_pcm_hw_params_free(hw_params);
 
... ... STATIC u8 dec_set_filter(void)
666 664 u8 r; u8 r;
667 665
668 666 loop { loop {
669 int new_chans_n;
670 uint64_t new_chans_layout;
667 AVChannelLayout new_chans_layout;
671 668 int new_rate; int new_rate;
672 669 enum avutil_audio_fr_fmt_t new_fmt; enum avutil_audio_fr_fmt_t new_fmt;
673 int dst_chans_n;
674 uint64_t dst_chans_layout;
670 AVChannelLayout dst_chans_layout;
675 671 int dst_rate; int dst_rate;
676 672 enum avutil_audio_fr_fmt_t dst_fmt; enum avutil_audio_fr_fmt_t dst_fmt;
677 673
678 r = filt_push_dec_set(&new_chans_n, &new_chans_layout,
679 &new_rate, &new_fmt);
680 if (r == NO_DEC_SET) /* pipeline not fast enough */
674 memset(&new_chans_layout, 0, sizeof(new_chans_layout));
675 memset(&dst_chans_layout, 0, sizeof(dst_chans_layout));
676
677 r = filt_push_dec_set(&new_chans_layout, &new_rate, &new_fmt);
678 if (r == NO_DEC_SET) {/* pipeline not fast enough */
679 av_channel_layout_uninit(&new_chans_layout);
681 680 return NO_DEC_SET; return NO_DEC_SET;
681 }
682 682 else if (r != FILT_RECFG_REQUIRED) { else if (r != FILT_RECFG_REQUIRED) {
683 683 /* FILT_SWITCHED_TO_DRAINING | PUSHED_ONE_SET | AGAIN */ /* FILT_SWITCHED_TO_DRAINING | PUSHED_ONE_SET | AGAIN */
684 av_channel_layout_uninit(&new_chans_layout);
684 685 break; break;
685 686 } }
686 687 /* FILT_RECFG_REQUIRED */ /* FILT_RECFG_REQUIRED */
687 pcm2ff_strict(npv_audio_pcm_p, &dst_chans_n, &dst_chans_layout,
688 &dst_rate, &dst_fmt, PRINT_INFO);
688 pcm2ff_strict(npv_audio_pcm_p, &dst_chans_layout, &dst_rate,
689 &dst_fmt, PRINT_INFO);
689 690 filt_cfg(st_p.tb, filt_cfg(st_p.tb,
690 new_chans_n, new_chans_layout, new_rate, new_fmt,
691 &new_chans_layout, new_rate, new_fmt,
691 692 filt_p.muted, filt_p.vol, filt_p.muted, filt_p.vol,
692 dst_chans_n, dst_chans_layout, dst_rate, dst_fmt,
693 PRINT_INFO);
693 &dst_chans_layout, dst_rate, dst_fmt, PRINT_INFO);
694 av_channel_layout_uninit(&new_chans_layout);
695 av_channel_layout_uninit(&dst_chans_layout);
694 696 } }
695 697 r = npv_audio_filt_set_get(); r = npv_audio_filt_set_get();
696 698 if (r == EOF_FILT) { if (r == EOF_FILT) {
File npv/audio/namespace/ffmpeg.h changed (mode: 100644) (index 13c90dc..435d845)
2 2 #define avcodec_receive_audio_set avcodec_receive_frame #define avcodec_receive_audio_set avcodec_receive_frame
3 3 #define avfilter_bufsink_get_audio_set av_buffersink_get_frame #define avfilter_bufsink_get_audio_set av_buffersink_get_frame
4 4 #define avfilter_bufsink_get_audio_fmt av_buffersink_get_format #define avfilter_bufsink_get_audio_fmt av_buffersink_get_format
5 #define avfilter_bufsink_get_chans_layout av_buffersink_get_channel_layout
6 5 #define avfilter_bufsrc_add_audio_set_flags av_buffersrc_add_frame_flags #define avfilter_bufsrc_add_audio_set_flags av_buffersrc_add_frame_flags
7 6 #define avutil_audio_fr_fmt_is_planar av_sample_fmt_is_planar #define avutil_audio_fr_fmt_is_planar av_sample_fmt_is_planar
8 7 #define avutil_audio_set_ref_alloc av_frame_alloc #define avutil_audio_set_ref_alloc av_frame_alloc
 
13 12 #define avutil_get_bytes_per_sample av_get_bytes_per_sample #define avutil_get_bytes_per_sample av_get_bytes_per_sample
14 13 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
15 14 /* some struct members, may conflict with the video ones */ /* some struct members, may conflict with the video ones */
16 #define chans_n channels
17 15 #define fr_rate sample_rate #define fr_rate sample_rate
18 16 #define fr_fmt sample_fmt #define fr_fmt sample_fmt
19 17 #define frs_n nb_samples #define frs_n nb_samples
20 #define chans_layout channel_layout
21 18 /*============================================================================*/ /*============================================================================*/
22 19 #else #else
23 20 #undef avcodec_receive_audio_set #undef avcodec_receive_audio_set
24 21 #undef avfilter_bufsink_get_audio_set #undef avfilter_bufsink_get_audio_set
25 22 #undef avfilter_bufsink_get_audio_fmt #undef avfilter_bufsink_get_audio_fmt
26 #undef avfilter_bufsink_get_chans_layout
27 23 #undef avfilter_bufsrc_add_audio_fr_flags #undef avfilter_bufsrc_add_audio_fr_flags
28 24 #undef avutil_audio_fr_fmt_is_planar #undef avutil_audio_fr_fmt_is_planar
29 25 #undef avutil_audio_set_ref_alloc #undef avutil_audio_set_ref_alloc
 
33 29 #undef avutil_get_audio_fr_fmt_str #undef avutil_get_audio_fr_fmt_str
34 30 #undef avutil_get_bytes_per_sample #undef avutil_get_bytes_per_sample
35 31 /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
36 #undef chans_n
37 32 #undef fr_rate #undef fr_rate
38 33 #undef fr_fmt #undef fr_fmt
39 34 #undef frs_n #undef frs_n
40 #undef chans_layout
41 35 #endif #endif
File npv/audio/public.h changed (mode: 100644) (index 01a0351..79a7117)
... ... STATIC u8 dec_set_try_receive(void);
32 32 STATIC void dec_sets_receive_avail(void); STATIC void dec_sets_receive_avail(void);
33 33 STATIC void draining_state_evt(void); STATIC void draining_state_evt(void);
34 34 STATIC void evt_pcm_write(void); STATIC void evt_pcm_write(void);
35 STATIC void pcm_cfg_hw_best_effort(snd_pcm_t *pcm, int chans_n,
36 uint64_t ff_chans_layout, int rate, enum avutil_audio_fr_fmt_t ff_fmt);
35 STATIC void pcm_cfg_hw_best_effort(snd_pcm_t *pcm, int chans_n, int rate,
36 enum avutil_audio_fr_fmt_t ff_fmt);
37 37 STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info); STATIC void pcm_silence_bufs_cfg(snd_pcm_t *pcm, bool print_info);
38 38 STATIC void pcm_cfg_sw(snd_pcm_t *pcm); STATIC void pcm_cfg_sw(snd_pcm_t *pcm);
39 39 STATIC void init_once(u8 *pcm_str); STATIC void init_once(u8 *pcm_str);
File npv/audio/public/code.frag.c changed (mode: 100644) (index e11ee55..8d25d49)
... ... STATIC void dec_sets_unlock(void)
253 253 if (r != 0) if (r != 0)
254 254 fatal("%d:unable to unlock the array of decoder sets\n", r); fatal("%d:unable to unlock the array of decoder sets\n", r);
255 255 } }
256 STATIC void pcm_cfg_hw_best_effort(snd_pcm_t *pcm, int chans_n,
257 uint64_t ff_chans_layout, int rate, enum avutil_audio_fr_fmt_t ff_fmt)
256 STATIC void pcm_cfg_hw_best_effort(snd_pcm_t *pcm, int chans_n, int rate,
257 enum avutil_audio_fr_fmt_t ff_fmt)
258 258 { {
259 259 int r; int r;
260 260 s8 i; s8 i;
 
... ... STATIC void pcm_cfg_hw_best_effort(snd_pcm_t *pcm, int chans_n,
265 265 r = snd_pcm_hw_params_malloc(&hw_params); r = snd_pcm_hw_params_malloc(&hw_params);
266 266 if (r < 0) if (r < 0)
267 267 fatal("alsa:unable to allocate hardware parameters context\n"); fatal("alsa:unable to allocate hardware parameters context\n");
268 pcm_cfg_hw_core_best_effort(pcm, hw_params, chans_n, ff_chans_layout,
269 rate, ff_fmt);
268 pcm_cfg_hw_core_best_effort(pcm, hw_params, chans_n, rate, ff_fmt);
270 269 r = snd_pcm_hw_params(pcm, hw_params); r = snd_pcm_hw_params(pcm, hw_params);
271 270 if (r != 0) if (r != 0)
272 271 fatal("alsa:unable to install the hardware parameters\n"); fatal("alsa:unable to install the hardware parameters\n");
 
... ... STATIC void npv_audio_prepare(int override_initial_ff_chans_n,
364 363 int override_initial_ff_rate, int override_initial_ff_rate,
365 364 enum avutil_audio_fr_fmt_t override_initial_ff_fmt) enum avutil_audio_fr_fmt_t override_initial_ff_fmt)
366 365 { {
367 int dst_chans_n;
368 uint64_t dst_chans_layout;
369 366 int dst_rate; int dst_rate;
370 367 enum avutil_audio_fr_fmt_t dst_fmt; enum avutil_audio_fr_fmt_t dst_fmt;
371 368 int initial_ff_chans_n; int initial_ff_chans_n;
372 uint64_t src_chans_layout;
373 369 int initial_ff_rate; int initial_ff_rate;
374 370 enum avutil_audio_fr_fmt_t initial_ff_fmt; enum avutil_audio_fr_fmt_t initial_ff_fmt;
371 int r;
372
375 373 /* /*
376 374 * do our best to match the pcm cfg to audio ff dec output OR the user * do our best to match the pcm cfg to audio ff dec output OR the user
377 375 * overrides, BUT we don't expect to match it "exactly": a ff filt * overrides, BUT we don't expect to match it "exactly": a ff filt
378 376 * will bridge the difference * will bridge the difference
379 377 */ */
380 378 if (override_initial_ff_chans_n == CHANS_N_NOT_OVERRIDDEN) if (override_initial_ff_chans_n == CHANS_N_NOT_OVERRIDDEN)
381 initial_ff_chans_n = dec_ctx_p->chans_n;
379 /* we presume the dec_ctx has at least a valid chans_n */
380 initial_ff_chans_n = dec_ctx_p->ch_layout.nb_channels;
382 381 else else
383 382 initial_ff_chans_n = override_initial_ff_chans_n; initial_ff_chans_n = override_initial_ff_chans_n;
384 /* the audio dec ctx may not have a valid chans layout */
385 if (dec_ctx_p->chans_layout == 0) {
386 src_chans_layout = avutil_get_default_chans_layout(
387 dec_ctx_p->chans_n);
388 } else
389 src_chans_layout = dec_ctx_p->chans_layout;
390 383 if (override_initial_ff_rate == RATE_NOT_OVERRIDDEN) if (override_initial_ff_rate == RATE_NOT_OVERRIDDEN)
391 384 initial_ff_rate = dec_ctx_p->fr_rate; initial_ff_rate = dec_ctx_p->fr_rate;
392 385 else else
 
... ... STATIC void npv_audio_prepare(int override_initial_ff_chans_n,
396 389 else else
397 390 initial_ff_fmt = override_initial_ff_fmt; initial_ff_fmt = override_initial_ff_fmt;
398 391 npv_audio_pcm_cfg_hw_best_effort(pcm_p, initial_ff_chans_n, npv_audio_pcm_cfg_hw_best_effort(pcm_p, initial_ff_chans_n,
399 src_chans_layout, initial_ff_rate, initial_ff_fmt);
392 initial_ff_rate, initial_ff_fmt);
400 393 npv_audio_pcm_silence_bufs_cfg(pcm_p, PRINT_INFO); npv_audio_pcm_silence_bufs_cfg(pcm_p, PRINT_INFO);
401 394 npv_audio_pcm_cfg_sw(pcm_p); npv_audio_pcm_cfg_sw(pcm_p);
402 395 pout("ALSA PCM DUMP START-------------------------------------------------------------\n"); pout("ALSA PCM DUMP START-------------------------------------------------------------\n");
File npv/namespace/ffmpeg.h changed (mode: 100644) (index c3446ea..9b9dde9)
56 56 #define avutil_cpus_n av_cpu_count #define avutil_cpus_n av_cpu_count
57 57 #define avutil_free av_free #define avutil_free av_free
58 58 #define avutil_get_audio_fr_fmt_name av_get_sample_fmt_name #define avutil_get_audio_fr_fmt_name av_get_sample_fmt_name
59 #define avutil_get_chans_layout_chans_n av_get_channel_layout_nb_channels
60 #define avutil_get_chans_layout_str av_get_channel_layout_string
61 #define avutil_get_default_chans_layout av_get_default_channel_layout
62 59 #define avutil_get_pix_fmt_name av_get_pix_fmt_name #define avutil_get_pix_fmt_name av_get_pix_fmt_name
63 60 #define avutil_get_pix_fmt_str av_get_pix_fmt_string #define avutil_get_pix_fmt_str av_get_pix_fmt_string
64 61 #define avutil_log_default_callback av_log_default_callback #define avutil_log_default_callback av_log_default_callback
 
136 133 #undef avutil_cpus_n #undef avutil_cpus_n
137 134 #undef avutil_free #undef avutil_free
138 135 #undef avutil_get_audio_fr_fmt_name #undef avutil_get_audio_fr_fmt_name
139 #undef avutil_get_chans_layout_chans_n
140 #undef avutil_get_chans_layout_str
141 #undef avutil_get_default_chans_layout
142 136 #undef avutil_get_pix_fmt_name #undef avutil_get_pix_fmt_name
143 137 #undef avutil_get_pix_fmt_str #undef avutil_get_pix_fmt_str
144 138 #undef avutil_log_default_callback #undef avutil_log_default_callback
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/nyanmp

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/nyanmp

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/nyanmp

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main