Allow to select sample rates.
Showing the changes to libavfilter (3 of 4 files). Show all
Unified · Split
| @@ -48,6 +48,7 @@ typedef struct { · 47 unmodified lines | |||
| 48 | const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1 | 48 | const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1 |
| 49 | const int *channel_counts; ///< list of allowed channel counts, terminated by -1 | 49 | const int *channel_counts; ///< list of allowed channel counts, terminated by -1 |
| 50 | int all_channel_counts; ///< if not 0, accept any channel count or layout | 50 | int all_channel_counts; ///< if not 0, accept any channel count or layout |
| 51 | int *sample_rates; ///< list of allowed sample rates, terminated by -1 | ||
| 51 | } AVABufferSinkParams; | 52 | } AVABufferSinkParams; |
| 52 | 53 | ||
| 53 | /** | 54 | /** |
| @@ -62,6 +62,7 @@ typedef struct { · 61 unmodified lines | |||
| 62 | enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE | 62 | enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE |
| 63 | int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1 | 63 | int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1 |
| 64 | int all_channel_counts; | 64 | int all_channel_counts; |
| 65 | int *sample_rates; ///< list of accepted sample rates, terminated by -1 | ||
| 65 | } BufferSinkContext; | 66 | } BufferSinkContext; |
| 66 | 67 | ||
| 67 | #define FIFO_INIT_SIZE 8 | 68 | #define FIFO_INIT_SIZE 8 |
| @@ -303,6 +304,11 @@ static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaq · 235 unmodified lines | |||
| 303 | if (!buf->sample_fmts) | 304 | if (!buf->sample_fmts) |
| 304 | return AVERROR(ENOMEM); | 305 | return AVERROR(ENOMEM); |
| 305 | } | 306 | } |
| 307 | if (params && params->sample_rates) { | ||
| 308 | buf->sample_rates = ff_copy_int_list(params->sample_rates); | ||
| 309 | if (!buf->sample_rates) | ||
| 310 | return AVERROR(ENOMEM); | ||
| 311 | } | ||
| 306 | if (params && (params->channel_layouts || params->channel_counts)) { | 312 | if (params && (params->channel_layouts || params->channel_counts)) { |
| 307 | if (params->all_channel_counts) { | 313 | if (params->all_channel_counts) { |
| 308 | av_log(ctx, AV_LOG_ERROR, | 314 | av_log(ctx, AV_LOG_ERROR, |
| @@ -324,6 +330,7 @@ static av_cold void asink_uninit(AVFilterContext *ctx) · 15 unmodified lines | |||
| 324 | BufferSinkContext *buf = ctx->priv; | 330 | BufferSinkContext *buf = ctx->priv; |
| 325 | 331 | ||
| 326 | av_freep(&buf->sample_fmts); | 332 | av_freep(&buf->sample_fmts); |
| 333 | av_freep(&buf->sample_rates); | ||
| 327 | av_freep(&buf->channel_layouts); | 334 | av_freep(&buf->channel_layouts); |
| 328 | common_uninit(ctx); | 335 | common_uninit(ctx); |
| 329 | } | 336 | } |
| @@ -348,6 +355,13 @@ static int asink_query_formats(AVFilterContext *ctx) · 18 unmodified lines | |||
| 348 | ff_set_common_channel_layouts(ctx, layouts); | 355 | ff_set_common_channel_layouts(ctx, layouts); |
| 349 | } | 356 | } |
| 350 | 357 | ||
| 358 | if (buf->sample_rates) { | ||
| 359 | formats = ff_make_format_list(buf->sample_rates); | ||
| 360 | if (!formats) | ||
| 361 | return AVERROR(ENOMEM); | ||
| 362 | ff_set_common_samplerates(ctx, formats); | ||
| 363 | } | ||
| 364 | |||
| 351 | return 0; | 365 | return 0; |
| 352 | } | 366 | } |
| 353 | 367 | ||
| @@ -29,7 +29,7 @@ · 28 unmodified lines | |||
| 29 | #include "libavutil/avutil.h" | 29 | #include "libavutil/avutil.h" |
| 30 | 30 | ||
| 31 | #define LIBAVFILTER_VERSION_MAJOR 3 | 31 | #define LIBAVFILTER_VERSION_MAJOR 3 |
| 32 | #define LIBAVFILTER_VERSION_MINOR 40 | 32 | #define LIBAVFILTER_VERSION_MINOR 41 |
| 33 | #define LIBAVFILTER_VERSION_MICRO 100 | 33 | #define LIBAVFILTER_VERSION_MICRO 100 |
| 34 | 34 | ||
| 35 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ | 35 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |