[FFmpeg-devel,1/4] swresample/swresample: Support unspecified sample rate when it is not needed

Submitted by Michael Niedermayer on May 30, 2019, 2:03 p.m.

Details

Message ID 20190530140400.6205-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer May 30, 2019, 2:03 p.m.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libswresample/swresample.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 1ac5ef9a30..f1decb600a 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -164,6 +164,11 @@  av_cold int swr_init(struct SwrContext *s){
         return AVERROR(EINVAL);
     }
 
+    if (s->in_sample_rate == 0 && s->out_sample_rate == 0)
+        s->in_sample_rate = 1;
+    if (s->in_sample_rate == 0 || s->out_sample_rate == 0)
+        s->in_sample_rate = s->out_sample_rate = s->in_sample_rate + s->out_sample_rate;
+
     if(s-> in_sample_rate <= 0){
         av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is invalid\n", s->in_sample_rate);
         return AVERROR(EINVAL);