]> git.sesse.net Git - ffmpeg/blobdiff - libswresample/swresample.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libswresample / swresample.c
index 1efb563d8f113736094b67d0bf07cd5727162d65..84d0f4023237afa3c5824bdbd96531e886d16264 100644 (file)
@@ -70,6 +70,23 @@ static const AVClass av_class = {
     .parent_log_context_offset = OFFSET(log_ctx),
 };
 
+unsigned swresample_version(void)
+{
+    av_assert0(LIBSWRESAMPLE_VERSION_MICRO >= 100);
+    return LIBSWRESAMPLE_VERSION_INT;
+}
+
+const char *swresample_configuration(void)
+{
+    return FFMPEG_CONFIGURATION;
+}
+
+const char *swresample_license(void)
+{
+#define LICENSE_PREFIX "libswresample license: "
+    return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
+}
+
 int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map){
     if(!s || s->in_convert) // s needs to be allocated but not initialized
         return AVERROR(EINVAL);
@@ -105,6 +122,7 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
     av_opt_set_int(s, "tsf", AV_SAMPLE_FMT_S16, 0);
     av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> in_ch_layout), 0);
     av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->out_ch_layout), 0);
+    av_opt_set_int(s, "uch", 0, 0);
     return s;
 }
 
@@ -142,17 +160,17 @@ int swr_init(struct SwrContext *s){
     swri_audio_convert_free(&s->out_convert);
     swri_audio_convert_free(&s->full_convert);
 
-    s-> in.planar= s-> in_sample_fmt >= 0x100;
-    s->out.planar= s->out_sample_fmt >= 0x100;
-    s-> in_sample_fmt &= 0xFF;
-    s->out_sample_fmt &= 0xFF;
+    s-> in.planar= av_sample_fmt_is_planar(s-> in_sample_fmt);
+    s->out.planar= av_sample_fmt_is_planar(s->out_sample_fmt);
+    s-> in_sample_fmt= av_get_alt_sample_fmt(s-> in_sample_fmt, 0);
+    s->out_sample_fmt= av_get_alt_sample_fmt(s->out_sample_fmt, 0);
 
     if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
-        av_log(s, AV_LOG_ERROR, "Requested sample format %s is invalid\n", av_get_sample_fmt_name(s->in_sample_fmt));
+        av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
         return AVERROR(EINVAL);
     }
     if(s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
-        av_log(s, AV_LOG_ERROR, "Requested sample format %s is invalid\n", av_get_sample_fmt_name(s->out_sample_fmt));
+        av_log(s, AV_LOG_ERROR, "Requested output sample format %d is invalid\n", s->out_sample_fmt);
         return AVERROR(EINVAL);
     }
 
@@ -201,7 +219,12 @@ int swr_init(struct SwrContext *s){
     if(!s->out.ch_count)
         s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
 
-av_assert0(s-> in.ch_count);
+    if(!s-> in.ch_count){
+        av_assert0(!s->in_ch_layout);
+        av_log(s, AV_LOG_ERROR, "Input channel count and layout are unset\n");
+        return -1;
+    }
+
 av_assert0(s->used_ch_count);
 av_assert0(s->out.ch_count);
     s->resample_first= RSC*s->out.ch_count/s->in.ch_count - RSC < s->out_sample_rate/(float)s-> in_sample_rate - 1.0;