Opened 3 years ago
Last modified 22 months ago
#10520 new defect
Fails to build with pocketsphinx 5
| Reported by: | Samuel Thibault | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avfilter |
| Version: | unspecified | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
How to reproduce:
After having installed pocketsphinx version 5.0.2 (from https://github.com/cmusphinx/pocketsphinx/), ffmpeg fails to build:
src/libavfilter/af_asr.c:42:5: error: unknown type name 'cmd_ln_t'
42 | cmd_ln_t *config;
| ^~~~~~~~
src/libavfilter/af_asr.c: In function 'asr_init':
src/libavfilter/af_asr.c:110:17: error: implicit declaration of function 'cmd_ln_parse_r' [-Werror=implicit-function-declaration]
110 | s->config = cmd_ln_parse_r(NULL, ps_args(), 14, (char **)argv, 0);
| ^~~~~~~~~~~~~~
src/libavfilter/af_asr.c:110:15: warning: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
110 | s->config = cmd_ln_parse_r(NULL, ps_args(), 14, (char **)argv, 0);
| ^
src/libavfilter/af_asr.c:115:29: warning: passing argument 1 of 'ps_default_search_args' from incompatible pointer type [-Wincompatible-pointer-types]
115 | ps_default_search_args(s->config);
| ~^~~~~~~~
| |
| int *
In file included from src/libavfilter/af_asr.c:21:
/usr/include/pocketsphinx.h:465:42: note: expected 'ps_config_t *' {aka 'struct cmd_ln_s *'} but argument is of type 'int *'
465 | void ps_default_search_args(ps_config_t *config);
| ~~~~~~~~~~~~~^~~~~~
src/libavfilter/af_asr.c:116:22: warning: passing argument 1 of 'ps_init' from incompatible pointer type [-Wincompatible-pointer-types]
116 | s->ps = ps_init(s->config);
| ~^~~~~~~~
| |
| int *
/usr/include/pocketsphinx.h:498:36: note: expected 'ps_config_t *' {aka 'struct cmd_ln_s *'} but argument is of type 'int *'
498 | ps_decoder_t *ps_init(ps_config_t *config);
| ~~~~~~~~~~~~~^~~~~~
src/libavfilter/af_asr.c: In function 'asr_uninit':
src/libavfilter/af_asr.c:148:5: error: implicit declaration of function 'cmd_ln_free_r' [-Werror=implicit-function-declaration]
148 | cmd_ln_free_r(s->config);
| ^~~~~~~~~~~~~
This is apparently an intentional API break of pocketsphinx: from pocketsphinx.h:
* @section faq_sec Frequently Asked Questions * * @subsection faq_api My code no longer compiles! Why? * * Some APIs were intentionally broken by the 5.0.0 release. The most * likely culprit here is the configuration API, where the old * "options" which started with a `-` are now "parameters" which do * not, and instead of a `cmd_ln_t` it is now a `ps_config_t`. There * is no backward compatibility, you have to change your code * manually. This is straightforward for the most part. For example, * instead of writing: * * cmdln = cmd_ln_init(NULL, "-samprate", "16000", NULL); * cmd_ln_set_int32_r(NULL, "-maxwpf", 40); * * You should write: * * config = ps_config_init(NULL); * ps_config_set_int(config, "samprate", 16000); * ps_config_set_int(config, "maxwpf", 40);
So this needs to be done in ffmpeg.
Change History (2)
comment:1 by , 3 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 22 months ago
Note:
See TracTickets
for help on using tickets.



Here is a simple diff, but should be tested more
diff --git a/libavfilter/af_asr.c b/libavfilter/af_asr.c index 8e8eeb19a7..bba793cfb5 100644 --- a/libavfilter/af_asr.c +++ b/libavfilter/af_asr.c @@ -41,7 +41,7 @@ typedef struct ASRContext { char *logfn; ps_decoder_t *ps; - cmd_ln_t *config; + ps_config_t *config; int utt_started; } ASRContext; @@ -100,16 +100,16 @@ static av_cold int asr_init(AVFilterContext *ctx) ASRContext *s = ctx->priv; const float frate = s->rate; char *rate = av_asprintf("%f", frate); - const char *argv[] = { "-logfn", s->logfn, - "-hmm", s->hmm, - "-lm", s->lm, - "-lmctl", s->lmctl, - "-lmname", s->lmname, - "-dict", s->dict, - "-samprate", rate, - NULL }; - - s->config = cmd_ln_parse_r(NULL, ps_args(), 14, (char **)argv, 0); + + s->config = ps_config_init(NULL); + ps_config_set_str(s->config, "logfn", s->logfn); + ps_config_set_str(s->config, "hmm", s->hmm); + ps_config_set_str(s->config, "lm", s->lm); + ps_config_set_str(s->config, "lmctl", s->lmctl); + ps_config_set_str(s->config, "lmname", s->lmname); + ps_config_set_str(s->config, "dict", s->dict); + ps_config_set_str(s->config, "samprate", rate); + av_free(rate); if (!s->config) return AVERROR(ENOMEM); @@ -160,7 +160,7 @@ static av_cold void asr_uninit(AVFilterContext *ctx) ps_free(s->ps); s->ps = NULL; - cmd_ln_free_r(s->config); + ps_config_free(s->config); s->config = NULL; }