Add missing #includes for *INT64_MAX and *INT64_C
[ffmpeg.git] / libavfilter / af_asyncts.c
index a76415b..e662c84 100644 (file)
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
+
 #include "libavresample/avresample.h"
 #include "libavutil/attributes.h"
 #include "libavutil/audio_fifo.h"
 #include "libavresample/avresample.h"
 #include "libavutil/attributes.h"
 #include "libavutil/audio_fifo.h"
@@ -237,18 +239,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
         }
 
         if (s->first_frame && delta > 0) {
         }
 
         if (s->first_frame && delta > 0) {
+            int planar = av_sample_fmt_is_planar(buf_out->format);
+            int planes = planar ?  nb_channels : 1;
+            int block_size = av_get_bytes_per_sample(buf_out->format) *
+                             (planar ? 1 : nb_channels);
+
             int ch;
 
             av_samples_set_silence(buf_out->extended_data, 0, delta,
                                    nb_channels, buf->format);
 
             int ch;
 
             av_samples_set_silence(buf_out->extended_data, 0, delta,
                                    nb_channels, buf->format);
 
-            for (ch = 0; ch < nb_channels; ch++)
-                buf_out->extended_data[ch] += delta;
+            for (ch = 0; ch < planes; ch++)
+                buf_out->extended_data[ch] += delta * block_size;
 
             avresample_read(s->avr, buf_out->extended_data, out_size);
 
 
             avresample_read(s->avr, buf_out->extended_data, out_size);
 
-            for (ch = 0; ch < nb_channels; ch++)
-                buf_out->extended_data[ch] -= delta;
+            for (ch = 0; ch < planes; ch++)
+                buf_out->extended_data[ch] -= delta * block_size;
         } else {
             avresample_read(s->avr, buf_out->extended_data, out_size);
 
         } else {
             avresample_read(s->avr, buf_out->extended_data, out_size);
 
@@ -308,7 +315,7 @@ static const AVFilterPad avfilter_af_asyncts_outputs[] = {
     { NULL }
 };
 
     { NULL }
 };
 
-AVFilter avfilter_af_asyncts = {
+AVFilter ff_af_asyncts = {
     .name        = "asyncts",
     .description = NULL_IF_CONFIG_SMALL("Sync audio data to timestamps"),
 
     .name        = "asyncts",
     .description = NULL_IF_CONFIG_SMALL("Sync audio data to timestamps"),