Unified · Split
| @@ -58,7 +58,6 @@ enum MappingMode { · 57 unmodified lines | |||
| 58 | typedef struct ChannelMapContext { | 58 | typedef struct ChannelMapContext { |
| 59 | const AVClass *class; | 59 | const AVClass *class; |
| 60 | char *mapping_str; | 60 | char *mapping_str; |
| 61 | char *channel_layout_str; | ||
| 62 | AVChannelLayout output_layout; | 61 | AVChannelLayout output_layout; |
| 63 | struct ChannelMap map[MAX_CH]; | 62 | struct ChannelMap map[MAX_CH]; |
| 64 | int nch; | 63 | int nch; |
| @@ -72,7 +71,7 @@ static const AVOption channelmap_options[] = { · 7 unmodified lines | |||
| 72 | { "map", "A comma-separated list of input channel numbers in output order.", | 71 | { "map", "A comma-separated list of input channel numbers in output order.", |
| 73 | OFFSET(mapping_str), AV_OPT_TYPE_STRING, .flags = A|F }, | 72 | OFFSET(mapping_str), AV_OPT_TYPE_STRING, .flags = A|F }, |
| 74 | { "channel_layout", "Output channel layout.", | 73 | { "channel_layout", "Output channel layout.", |
| 75 | OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A|F }, | 74 | OFFSET(output_layout), AV_OPT_TYPE_CHLAYOUT, .flags = A|F }, |
| 76 | { NULL } | 75 | { NULL } |
| 77 | }; | 76 | }; |
| 78 | 77 | ||
| @@ -122,7 +121,6 @@ static av_cold int channelmap_init(AVFilterContext *ctx) · 43 unmodified lines | |||
| 122 | ChannelMapContext *s = ctx->priv; | 121 | ChannelMapContext *s = ctx->priv; |
| 123 | char *mapping, separator = '|'; | 122 | char *mapping, separator = '|'; |
| 124 | int map_entries = 0; | 123 | int map_entries = 0; |
| 125 | char buf[256]; | ||
| 126 | enum MappingMode mode; | 124 | enum MappingMode mode; |
| 127 | uint64_t out_ch_mask = 0; | 125 | uint64_t out_ch_mask = 0; |
| 128 | int i; | 126 | int i; |
| @@ -232,50 +230,25 @@ static av_cold int channelmap_init(AVFilterContext *ctx) · 103 unmodified lines | |||
| 232 | s->nch = map_entries; | 230 | s->nch = map_entries; |
| 233 | if (out_ch_mask) | 231 | if (out_ch_mask) |
| 234 | av_channel_layout_from_mask(&s->output_layout, out_ch_mask); | 232 | av_channel_layout_from_mask(&s->output_layout, out_ch_mask); |
| 235 | else | 233 | else if (map_entries) |
| 236 | av_channel_layout_default(&s->output_layout, map_entries); | 234 | av_channel_layout_default(&s->output_layout, map_entries); |
| 237 | 235 | ||
| 238 | if (s->channel_layout_str) { | 236 | if (mode == MAP_NONE) { |
| 239 | AVChannelLayout fmt = { 0 }; | 237 | int i; |
| 240 | int ret; | 238 | s->nch = s->output_layout.nb_channels; |
| 241 | if ((ret = av_channel_layout_from_string(&fmt, s->channel_layout_str)) < 0) { | 239 | for (i = 0; i < s->nch; i++) { |
| 242 | #if FF_API_OLD_CHANNEL_LAYOUT | 240 | s->map[i].in_channel_idx = i; |
| 243 | uint64_t mask; | 241 | s->map[i].out_channel_idx = i; |
| 244 | FF_DISABLE_DEPRECATION_WARNINGS | ||
| 245 | if ((mask = av_get_channel_layout(s->channel_layout_str)) == 0) { | ||
| 246 | #endif | ||
| 247 | av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n", | ||
| 248 | s->channel_layout_str); | ||
| 249 | return AVERROR(EINVAL); | ||
| 250 | #if FF_API_OLD_CHANNEL_LAYOUT | ||
| 251 | } | ||
| 252 | FF_ENABLE_DEPRECATION_WARNINGS | ||
| 253 | av_log(ctx, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n", | ||
| 254 | s->channel_layout_str); | ||
| 255 | av_channel_layout_from_mask(&fmt, mask); | ||
| 256 | #endif | ||
| 257 | } | ||
| 258 | if (mode == MAP_NONE) { | ||
| 259 | int i; | ||
| 260 | s->nch = fmt.nb_channels; | ||
| 261 | for (i = 0; i < s->nch; i++) { | ||
| 262 | s->map[i].in_channel_idx = i; | ||
| 263 | s->map[i].out_channel_idx = i; | ||
| 264 | } | ||
| 265 | } else if (out_ch_mask && av_channel_layout_compare(&s->output_layout, &fmt)) { | ||
| 266 | av_channel_layout_describe(&s->output_layout, buf, sizeof(buf)); | ||
| 267 | av_log(ctx, AV_LOG_ERROR, | ||
| 268 | "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n", | ||
| 269 | s->channel_layout_str, buf); | ||
| 270 | return AVERROR(EINVAL); | ||
| 271 | } else if (s->nch != fmt.nb_channels) { | ||
| 272 | av_log(ctx, AV_LOG_ERROR, | ||
| 273 | "Output channel layout %s does not match the number of channels mapped %d.\n", | ||
| 274 | s->channel_layout_str, s->nch); | ||
| 275 | return AVERROR(EINVAL); | ||
| 276 | } | 242 | } |
| 277 | s->output_layout = fmt; | 243 | } else if (s->nch != s->output_layout.nb_channels) { |
| 244 | char buf[256]; | ||
| 245 | av_channel_layout_describe(&s->output_layout, buf, sizeof(buf)); | ||
| 246 | av_log(ctx, AV_LOG_ERROR, | ||
| 247 | "Output channel layout %s does not match the number of channels mapped %d.\n", | ||
| 248 | buf, s->nch); | ||
| 249 | return AVERROR(EINVAL); | ||
| 278 | } | 250 | } |
| 251 | |||
| 279 | if (!s->output_layout.nb_channels) { | 252 | if (!s->output_layout.nb_channels) { |
| 280 | av_log(ctx, AV_LOG_ERROR, "Output channel layout is not set and " | 253 | av_log(ctx, AV_LOG_ERROR, "Output channel layout is not set and " |
| 281 | "cannot be guessed from the maps.\n"); | 254 | "cannot be guessed from the maps.\n"); |
| @@ -40,7 +40,6 @@ typedef struct ChannelSplitContext { · 39 unmodified lines | |||
| 40 | const AVClass *class; | 40 | const AVClass *class; |
| 41 | 41 | ||
| 42 | AVChannelLayout channel_layout; | 42 | AVChannelLayout channel_layout; |
| 43 | char *channel_layout_str; | ||
| 44 | char *channels_str; | 43 | char *channels_str; |
| 45 | 44 | ||
| 46 | int map[64]; | 45 | int map[64]; |
| @@ -50,7 +49,7 @@ typedef struct ChannelSplitContext { · 3 unmodified lines | |||
| 50 | #define A AV_OPT_FLAG_AUDIO_PARAM | 49 | #define A AV_OPT_FLAG_AUDIO_PARAM |
| 51 | #define F AV_OPT_FLAG_FILTERING_PARAM | 50 | #define F AV_OPT_FLAG_FILTERING_PARAM |
| 52 | static const AVOption channelsplit_options[] = { | 51 | static const AVOption channelsplit_options[] = { |
| 53 | { "channel_layout", "Input channel layout.", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, { .str = "stereo" }, .flags = A|F }, | 52 | { "channel_layout", "Input channel layout.", OFFSET(channel_layout), AV_OPT_TYPE_CHLAYOUT, { .str = "stereo" }, .flags = A|F }, |
| 54 | { "channels", "Channels to extract.", OFFSET(channels_str), AV_OPT_TYPE_STRING, { .str = "all" }, .flags = A|F }, | 53 | { "channels", "Channels to extract.", OFFSET(channels_str), AV_OPT_TYPE_STRING, { .str = "all" }, .flags = A|F }, |
| 55 | { NULL } | 54 | { NULL } |
| 56 | }; | 55 | }; |
| @@ -63,13 +62,6 @@ static av_cold int init(AVFilterContext *ctx) · 6 unmodified lines | |||
| 63 | AVChannelLayout channel_layout = { 0 }; | 62 | AVChannelLayout channel_layout = { 0 }; |
| 64 | int all = 0, ret = 0, i; | 63 | int all = 0, ret = 0, i; |
| 65 | 64 | ||
| 66 | if ((ret = av_channel_layout_from_string(&s->channel_layout, s->channel_layout_str)) < 0) { | ||
| 67 | av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n", | ||
| 68 | s->channel_layout_str); | ||
| 69 | ret = AVERROR(EINVAL); | ||
| 70 | goto fail; | ||
| 71 | } | ||
| 72 | |||
| 73 | if (!strcmp(s->channels_str, "all")) { | 65 | if (!strcmp(s->channels_str, "all")) { |
| 74 | if ((ret = av_channel_layout_copy(&channel_layout, &s->channel_layout)) < 0) | 66 | if ((ret = av_channel_layout_copy(&channel_layout, &s->channel_layout)) < 0) |
| 75 | goto fail; | 67 | goto fail; |
| @@ -100,9 +92,11 @@ static av_cold int init(AVFilterContext *ctx) · 24 unmodified lines | |||
| 100 | if (all) { | 92 | if (all) { |
| 101 | s->map[i] = i; | 93 | s->map[i] = i; |
| 102 | } else { | 94 | } else { |
| 95 | char buf[128]; | ||
| 96 | av_channel_layout_describe(&s->channel_layout, buf, sizeof(buf)); | ||
| 103 | if ((ret = av_channel_layout_index_from_channel(&s->channel_layout, channel)) < 0) { | 97 | if ((ret = av_channel_layout_index_from_channel(&s->channel_layout, channel)) < 0) { |
| 104 | av_log(ctx, AV_LOG_ERROR, "Channel name '%s' not present in channel layout '%s'.\n", | 98 | av_log(ctx, AV_LOG_ERROR, "Channel name '%s' not present in channel layout '%s'.\n", |
| 105 | pad.name, s->channel_layout_str); | 99 | pad.name, buf); |
| 106 | av_freep(&pad.name); | 100 | av_freep(&pad.name); |
| 107 | goto fail; | 101 | goto fail; |
| 108 | } | 102 | } |
| @@ -48,7 +48,6 @@ typedef struct JoinContext { · 47 unmodified lines | |||
| 48 | 48 | ||
| 49 | int inputs; | 49 | int inputs; |
| 50 | char *map; | 50 | char *map; |
| 51 | char *channel_layout_str; | ||
| 52 | AVChannelLayout ch_layout; | 51 | AVChannelLayout ch_layout; |
| 53 | 52 | ||
| 54 | int64_t eof_pts; | 53 | int64_t eof_pts; |
| @@ -73,7 +72,7 @@ typedef struct JoinContext { · 18 unmodified lines | |||
| 73 | static const AVOption join_options[] = { | 72 | static const AVOption join_options[] = { |
| 74 | { "inputs", "Number of input streams.", OFFSET(inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, A|F }, | 73 | { "inputs", "Number of input streams.", OFFSET(inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, A|F }, |
| 75 | { "channel_layout", "Channel layout of the " | 74 | { "channel_layout", "Channel layout of the " |
| 76 | "output stream.", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0, A|F }, | 75 | "output stream.", OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "stereo"}, 0, 0, A|F }, |
| 77 | { "map", "A comma-separated list of channels maps in the format " | 76 | { "map", "A comma-separated list of channels maps in the format " |
| 78 | "'input_stream.input_channel-output_channel.", | 77 | "'input_stream.input_channel-output_channel.", |
| 79 | OFFSET(map), AV_OPT_TYPE_STRING, .flags = A|F }, | 78 | OFFSET(map), AV_OPT_TYPE_STRING, .flags = A|F }, |
| @@ -157,26 +156,6 @@ static av_cold int join_init(AVFilterContext *ctx) · 77 unmodified lines | |||
| 157 | JoinContext *s = ctx->priv; | 156 | JoinContext *s = ctx->priv; |
| 158 | int ret, i; | 157 | int ret, i; |
| 159 | 158 | ||
| 160 | ret = av_channel_layout_from_string(&s->ch_layout, s->channel_layout_str); | ||
| 161 | if (ret < 0) { | ||
| 162 | #if FF_API_OLD_CHANNEL_LAYOUT | ||
| 163 | uint64_t mask; | ||
| 164 | FF_DISABLE_DEPRECATION_WARNINGS | ||
| 165 | mask = av_get_channel_layout(s->channel_layout_str); | ||
| 166 | if (!mask) { | ||
| 167 | #endif | ||
| 168 | av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n", | ||
| 169 | s->channel_layout_str); | ||
| 170 | return AVERROR(EINVAL); | ||
| 171 | #if FF_API_OLD_CHANNEL_LAYOUT | ||
| 172 | } | ||
| 173 | FF_ENABLE_DEPRECATION_WARNINGS | ||
| 174 | av_log(ctx, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n", | ||
| 175 | s->channel_layout_str); | ||
| 176 | av_channel_layout_from_mask(&s->ch_layout, mask); | ||
| 177 | #endif | ||
| 178 | } | ||
| 179 | |||
| 180 | s->channels = av_calloc(s->ch_layout.nb_channels, sizeof(*s->channels)); | 159 | s->channels = av_calloc(s->ch_layout.nb_channels, sizeof(*s->channels)); |
| 181 | s->buffers = av_calloc(s->ch_layout.nb_channels, sizeof(*s->buffers)); | 160 | s->buffers = av_calloc(s->ch_layout.nb_channels, sizeof(*s->buffers)); |
| 182 | s->input_frames = av_calloc(s->inputs, sizeof(*s->input_frames)); | 161 | s->input_frames = av_calloc(s->inputs, sizeof(*s->input_frames)); |
| @@ -61,8 +61,8 @@ static const int sc_map[16] = { · 60 unmodified lines | |||
| 61 | typedef struct AudioSurroundContext { | 61 | typedef struct AudioSurroundContext { |
| 62 | const AVClass *class; | 62 | const AVClass *class; |
| 63 | 63 | ||
| 64 | char *out_channel_layout_str; | 64 | AVChannelLayout out_ch_layout; |
| 65 | char *in_channel_layout_str; | 65 | AVChannelLayout in_ch_layout; |
| 66 | 66 | ||
| 67 | float level_in; | 67 | float level_in; |
| 68 | float level_out; | 68 | float level_out; |
| @@ -93,8 +93,6 @@ typedef struct AudioSurroundContext { · 24 unmodified lines | |||
| 93 | float lowcut; | 93 | float lowcut; |
| 94 | float highcut; | 94 | float highcut; |
| 95 | 95 | ||
| 96 | AVChannelLayout out_ch_layout; | ||
| 97 | AVChannelLayout in_ch_layout; | ||
| 98 | int nb_in_channels; | 96 | int nb_in_channels; |
| 99 | int nb_out_channels; | 97 | int nb_out_channels; |
| 100 | 98 | ||
| @@ -1107,20 +1105,8 @@ static av_cold int init(AVFilterContext *ctx) · 1006 unmodified lines | |||
| 1107 | { | 1105 | { |
| 1108 | AudioSurroundContext *s = ctx->priv; | 1106 | AudioSurroundContext *s = ctx->priv; |
| 1109 | int64_t in_channel_layout, out_channel_layout; | 1107 | int64_t in_channel_layout, out_channel_layout; |
| 1108 | char in_name[128], out_name[128]; | ||
| 1110 | float overlap; | 1109 | float overlap; |
| 1111 | int ret; | ||
| 1112 | |||
| 1113 | if ((ret = av_channel_layout_from_string(&s->out_ch_layout, s->out_channel_layout_str)) < 0) { | ||
| 1114 | av_log(ctx, AV_LOG_ERROR, "Error parsing output channel layout '%s'.\n", | ||
| 1115 | s->out_channel_layout_str); | ||
| 1116 | return ret; | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | if ((ret = av_channel_layout_from_string(&s->in_ch_layout, s->in_channel_layout_str)) < 0) { | ||
| 1120 | av_log(ctx, AV_LOG_ERROR, "Error parsing input channel layout '%s'.\n", | ||
| 1121 | s->in_channel_layout_str); | ||
| 1122 | return AVERROR(EINVAL); | ||
| 1123 | } | ||
| 1124 | 1110 | ||
| 1125 | if (s->lowcutf >= s->highcutf) { | 1111 | if (s->lowcutf >= s->highcutf) { |
| 1126 | av_log(ctx, AV_LOG_ERROR, "Low cut-off '%d' should be less than high cut-off '%d'.\n", | 1112 | av_log(ctx, AV_LOG_ERROR, "Low cut-off '%d' should be less than high cut-off '%d'.\n", |
| @@ -1181,8 +1167,10 @@ static av_cold int init(AVFilterContext *ctx) · 54 unmodified lines | |||
| 1181 | break; | 1167 | break; |
| 1182 | default: | 1168 | default: |
| 1183 | fail: | 1169 | fail: |
| 1170 | av_channel_layout_describe(&s->out_ch_layout, out_name, sizeof(out_name)); | ||
| 1171 | av_channel_layout_describe(&s->in_ch_layout, in_name, sizeof(in_name)); | ||
| 1184 | av_log(ctx, AV_LOG_ERROR, "Unsupported upmix: '%s' -> '%s'.\n", | 1172 | av_log(ctx, AV_LOG_ERROR, "Unsupported upmix: '%s' -> '%s'.\n", |
| 1185 | s->in_channel_layout_str, s->out_channel_layout_str); | 1173 | in_name, out_name); |
| 1186 | return AVERROR(EINVAL); | 1174 | return AVERROR(EINVAL); |
| 1187 | } | 1175 | } |
| 1188 | 1176 | ||
| @@ -1417,8 +1405,8 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar · 228 unmodified lines | |||
| 1417 | #define TFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM | 1405 | #define TFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM |
| 1418 | 1406 | ||
| 1419 | static const AVOption surround_options[] = { | 1407 | static const AVOption surround_options[] = { |
| 1420 | { "chl_out", "set output channel layout", OFFSET(out_channel_layout_str), AV_OPT_TYPE_STRING, {.str="5.1"}, 0, 0, FLAGS }, | 1408 | { "chl_out", "set output channel layout", OFFSET(out_ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str="5.1"}, 0, 0, FLAGS }, |
| 1421 | { "chl_in", "set input channel layout", OFFSET(in_channel_layout_str), AV_OPT_TYPE_STRING, {.str="stereo"},0, 0, FLAGS }, | 1409 | { "chl_in", "set input channel layout", OFFSET(in_ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str="stereo"},0, 0, FLAGS }, |
| 1422 | { "level_in", "set input level", OFFSET(level_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, TFLAGS }, | 1410 | { "level_in", "set input level", OFFSET(level_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, TFLAGS }, |
| 1423 | { "level_out", "set output level", OFFSET(level_out), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, TFLAGS }, | 1411 | { "level_out", "set output level", OFFSET(level_out), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 10, TFLAGS }, |
| 1424 | { "lfe", "output LFE", OFFSET(output_lfe), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, TFLAGS }, | 1412 | { "lfe", "output LFE", OFFSET(output_lfe), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, TFLAGS }, |
| @@ -36,23 +36,10 @@ typedef struct AFDelaySrcContext { · 35 unmodified lines | |||
| 36 | int nb_samples; | 36 | int nb_samples; |
| 37 | int nb_taps; | 37 | int nb_taps; |
| 38 | AVChannelLayout chlayout; | 38 | AVChannelLayout chlayout; |
| 39 | char *chlayout_str; | ||
| 40 | 39 | ||
| 41 | int64_t pts; | 40 | int64_t pts; |
| 42 | } AFDelaySrcContext; | 41 | } AFDelaySrcContext; |
| 43 | 42 | ||
| 44 | static av_cold int init(AVFilterContext *ctx) | ||
| 45 | { | ||
| 46 | AFDelaySrcContext *s = ctx->priv; | ||
| 47 | int ret; | ||
| 48 | |||
| 49 | ret = ff_parse_channel_layout(&s->chlayout, NULL, s->chlayout_str, ctx); | ||
| 50 | if (ret < 0) | ||
| 51 | return ret; | ||
| 52 | |||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | |||
| 56 | static float sincf(float x) | 43 | static float sincf(float x) |
| 57 | { | 44 | { |
| 58 | if (x == 0.f) | 45 | if (x == 0.f) |
| @@ -134,13 +121,6 @@ static const AVFilterPad afdelaysrc_outputs[] = { · 75 unmodified lines | |||
| 134 | }, | 121 | }, |
| 135 | }; | 122 | }; |
| 136 | 123 | ||
| 137 | static av_cold void uninit(AVFilterContext *ctx) | ||
| 138 | { | ||
| 139 | AFDelaySrcContext *s = ctx->priv; | ||
| 140 | |||
| 141 | av_channel_layout_uninit(&s->chlayout); | ||
| 142 | } | ||
| 143 | |||
| 144 | #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM | 124 | #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
| 145 | #define OFFSET(x) offsetof(AFDelaySrcContext, x) | 125 | #define OFFSET(x) offsetof(AFDelaySrcContext, x) |
| 146 | 126 | ||
| @@ -153,8 +133,8 @@ static const AVOption afdelaysrc_options[] = { · 6 unmodified lines | |||
| 153 | { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, AF }, | 133 | { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, AF }, |
| 154 | { "taps", "set number of taps for delay filter", OFFSET(nb_taps), AV_OPT_TYPE_INT, {.i64=0}, 0, 32768, AF }, | 134 | { "taps", "set number of taps for delay filter", OFFSET(nb_taps), AV_OPT_TYPE_INT, {.i64=0}, 0, 32768, AF }, |
| 155 | { "t", "set number of taps for delay filter", OFFSET(nb_taps), AV_OPT_TYPE_INT, {.i64=0}, 0, 32768, AF }, | 135 | { "t", "set number of taps for delay filter", OFFSET(nb_taps), AV_OPT_TYPE_INT, {.i64=0}, 0, 32768, AF }, |
| 156 | { "channel_layout", "set channel layout", OFFSET(chlayout_str),AV_OPT_TYPE_STRING,{.str="stereo"},0, 0, AF }, | 136 | { "channel_layout", "set channel layout", OFFSET(chlayout), AV_OPT_TYPE_CHLAYOUT,{.str="stereo"},0, 0, AF }, |
| 157 | { "c", "set channel layout", OFFSET(chlayout_str),AV_OPT_TYPE_STRING,{.str="stereo"},0, 0, AF }, | 137 | { "c", "set channel layout", OFFSET(chlayout), AV_OPT_TYPE_CHLAYOUT,{.str="stereo"},0, 0, AF }, |
| 158 | { NULL } | 138 | { NULL } |
| 159 | }; | 139 | }; |
| 160 | 140 | ||
| @@ -165,9 +145,7 @@ const AVFilter ff_asrc_afdelaysrc = { · 4 unmodified lines | |||
| 165 | .description = NULL_IF_CONFIG_SMALL("Generate a Fractional delay FIR coefficients."), | 145 | .description = NULL_IF_CONFIG_SMALL("Generate a Fractional delay FIR coefficients."), |
| 166 | .priv_size = sizeof(AFDelaySrcContext), | 146 | .priv_size = sizeof(AFDelaySrcContext), |
| 167 | .priv_class = &afdelaysrc_class, | 147 | .priv_class = &afdelaysrc_class, |
| 168 | .init = init, | ||
| 169 | .activate = activate, | 148 | .activate = activate, |
| 170 | .uninit = uninit, | ||
| 171 | .inputs = NULL, | 149 | .inputs = NULL, |
| 172 | FILTER_OUTPUTS(afdelaysrc_outputs), | 150 | FILTER_OUTPUTS(afdelaysrc_outputs), |
| 173 | FILTER_QUERY_FUNC(query_formats), | 151 | FILTER_QUERY_FUNC(query_formats), |
| @@ -38,9 +38,7 @@ · 37 unmodified lines | |||
| 38 | 38 | ||
| 39 | typedef struct ANullContext { | 39 | typedef struct ANullContext { |
| 40 | const AVClass *class; | 40 | const AVClass *class; |
| 41 | char *channel_layout_str; | ||
| 42 | AVChannelLayout ch_layout; | 41 | AVChannelLayout ch_layout; |
| 43 | char *sample_rate_str; | ||
| 44 | int sample_rate; | 42 | int sample_rate; |
| 45 | int64_t duration; | 43 | int64_t duration; |
| 46 | int nb_samples; ///< number of samples per requested frame | 44 | int nb_samples; ///< number of samples per requested frame |
| @@ -51,10 +49,10 @@ typedef struct ANullContext { · 4 unmodified lines | |||
| 51 | #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM | 49 | #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
| 52 | 50 | ||
| 53 | static const AVOption anullsrc_options[]= { | 51 | static const AVOption anullsrc_options[]= { |
| 54 | { "channel_layout", "set channel_layout", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0, FLAGS }, | 52 | { "channel_layout", "set channel_layout", OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "stereo"}, 0, 0, FLAGS }, |
| 55 | { "cl", "set channel_layout", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0, FLAGS }, | 53 | { "cl", "set channel_layout", OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = "stereo"}, 0, 0, FLAGS }, |
| 56 | { "sample_rate", "set sample rate", OFFSET(sample_rate_str) , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS }, | 54 | { "sample_rate", "set sample rate", OFFSET(sample_rate) , AV_OPT_TYPE_INT, {.i64 = 44100}, 0, 0, FLAGS }, |
| 57 | { "r", "set sample rate", OFFSET(sample_rate_str) , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0, FLAGS }, | 55 | { "r", "set sample rate", OFFSET(sample_rate) , AV_OPT_TYPE_INT, {.i64 = 44100}, 0, 0, FLAGS }, |
| 58 | { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, UINT16_MAX, FLAGS }, | 56 | { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, UINT16_MAX, FLAGS }, |
| 59 | { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, UINT16_MAX, FLAGS }, | 57 | { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, UINT16_MAX, FLAGS }, |
| 60 | { "duration", "set the audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS }, | 58 | { "duration", "set the audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS }, |
| @@ -64,22 +62,6 @@ static const AVOption anullsrc_options[]= { · 3 unmodified lines | |||
| 64 | 62 | ||
| 65 | AVFILTER_DEFINE_CLASS(anullsrc); | 63 | AVFILTER_DEFINE_CLASS(anullsrc); |
| 66 | 64 | ||
| 67 | static av_cold int init(AVFilterContext *ctx) | ||
| 68 | { | ||
| 69 | ANullContext *null = ctx->priv; | ||
| 70 | int ret; | ||
| 71 | |||
| 72 | if ((ret = ff_parse_sample_rate(&null->sample_rate, | ||
| 73 | null->sample_rate_str, ctx)) < 0) | ||
| 74 | return ret; | ||
| 75 | |||
| 76 | if ((ret = ff_parse_channel_layout(&null->ch_layout, NULL, | ||
| 77 | null->channel_layout_str, ctx)) < 0) | ||
| 78 | return ret; | ||
| 79 | |||
| 80 | return 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | static int query_formats(AVFilterContext *ctx) | 65 | static int query_formats(AVFilterContext *ctx) |
| 84 | { | 66 | { |
| 85 | ANullContext *null = ctx->priv; | 67 | ANullContext *null = ctx->priv; |
| @@ -129,12 +111,6 @@ static int activate(AVFilterContext *ctx) · 43 unmodified lines | |||
| 129 | return FFERROR_NOT_READY; | 111 | return FFERROR_NOT_READY; |
| 130 | } | 112 | } |
| 131 | 113 | ||
| 132 | static av_cold void uninit(AVFilterContext *ctx) | ||
| 133 | { | ||
| 134 | ANullContext *s = ctx->priv; | ||
| 135 | av_channel_layout_uninit(&s->ch_layout); | ||
| 136 | } | ||
| 137 | |||
| 138 | static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = { | 114 | static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = { |
| 139 | { | 115 | { |
| 140 | .name = "default", | 116 | .name = "default", |
| @@ -146,8 +122,6 @@ static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = { · 5 unmodified lines | |||
| 146 | const AVFilter ff_asrc_anullsrc = { | 122 | const AVFilter ff_asrc_anullsrc = { |
| 147 | .name = "anullsrc", | 123 | .name = "anullsrc", |
| 148 | .description = NULL_IF_CONFIG_SMALL("Null audio source, return empty audio frames."), | 124 | .description = NULL_IF_CONFIG_SMALL("Null audio source, return empty audio frames."), |
| 149 | .init = init, | ||
| 150 | .uninit = uninit, | ||
| 151 | .priv_size = sizeof(ANullContext), | 125 | .priv_size = sizeof(ANullContext), |
| 152 | .inputs = NULL, | 126 | .inputs = NULL, |
| 153 | FILTER_OUTPUTS(avfilter_asrc_anullsrc_outputs), | 127 | FILTER_OUTPUTS(avfilter_asrc_anullsrc_outputs), |