Browse code

lavfi: consistently use int for sample_rate in AVFilterLink and AVFilterBufferRefAudioProps

Also consistent with AVCodecContext.sample_rate. Simplify/avoid
pointless type checks and conversions.

Breaks audio API/ABI.

Stefano Sabatini authored on 2011/08/22 02:17:24
Showing 5 changed files
... ...
@@ -125,9 +125,9 @@ static inline void log_input_change(void *ctx, AVFilterLink *link, AVFilterBuffe
125 125
                                  -1, ref->audio->channel_layout);
126 126
     av_log(ctx, AV_LOG_INFO,
127 127
            "Audio input format changed: "
128
-           "%s:%s:%"PRId64" -> %s:%s:%u, normalizing\n",
128
+           "%s:%s:%d -> %s:%s:%d, normalizing\n",
129 129
            av_get_sample_fmt_name(link->format),
130
-           old_layout_str, link->sample_rate,
130
+           old_layout_str, (int)link->sample_rate,
131 131
            av_get_sample_fmt_name(ref->format),
132 132
            new_layout_str, ref->audio->sample_rate);
133 133
 }
... ...
@@ -374,8 +374,8 @@ static void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
374 374
         av_get_channel_layout_string(buf, sizeof(buf), -1, link->channel_layout);
375 375
 
376 376
         av_dlog(ctx,
377
-                "link[%p r:%"PRId64" cl:%s fmt:%-16s %-16s->%-16s]%s",
378
-                link, link->sample_rate, buf,
377
+                "link[%p r:%d cl:%s fmt:%-16s %-16s->%-16s]%s",
378
+                link, (int)link->sample_rate, buf,
379 379
                 av_get_sample_fmt_name(link->format),
380 380
                 link->src ? link->src->filter->name : "",
381 381
                 link->dst ? link->dst->filter->name : "",
... ...
@@ -106,7 +106,7 @@ typedef struct AVFilterBuffer {
106 106
 typedef struct AVFilterBufferRefAudioProps {
107 107
     int64_t channel_layout;     ///< channel layout of audio buffer
108 108
     int nb_samples;             ///< number of audio samples per channel
109
-    uint32_t sample_rate;       ///< audio buffer sample rate
109
+    int sample_rate;            ///< audio buffer sample rate
110 110
     int planar;                 ///< audio buffer - planar or packed
111 111
 } AVFilterBufferRefAudioProps;
112 112
 
... ...
@@ -623,7 +623,11 @@ struct AVFilterLink {
623 623
     AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
624 624
     /* These parameters apply only to audio */
625 625
     int64_t channel_layout;     ///< channel layout of current buffer (see libavutil/audioconvert.h)
626
+#if LIBAVFILTER_VERSION_MAJOR < 3
626 627
     int64_t sample_rate;        ///< samples per second
628
+#else
629
+    int sample_rate;            ///< samples per second
630
+#endif
627 631
     int planar;                 ///< agreed upon packing mode of audio buffers. true if planar.
628 632
 
629 633
     int format;                 ///< agreed upon media format
... ...
@@ -266,11 +266,11 @@ int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx)
266 266
     return 0;
267 267
 }
268 268
 
269
-int ff_parse_sample_rate(unsigned *ret, const char *arg, void *log_ctx)
269
+int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
270 270
 {
271 271
     char *tail;
272 272
     double srate = av_strtod(arg, &tail);
273
-    if (*tail || srate < 1 || (int)srate != srate) {
273
+    if (*tail || srate < 1 || (int)srate != srate || srate > INT_MAX) {
274 274
         av_log(log_ctx, AV_LOG_ERROR, "Invalid sample rate '%s'\n", arg);
275 275
         return AVERROR(EINVAL);
276 276
     }
... ...
@@ -88,7 +88,7 @@ int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx)
88 88
  * @param log_ctx log context
89 89
  * @return 0 in case of success, a negative AVERROR code on error
90 90
  */
91
-int ff_parse_sample_rate(unsigned *ret, const char *arg, void *log_ctx);
91
+int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx);
92 92
 
93 93
 /**
94 94
  * Parse a sample format name or a corresponding integer representation.