Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] swresample fixes
@ 2023-01-04 16:59 Paul B Mahol
  2023-01-04 17:02 ` James Almer
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Paul B Mahol @ 2023-01-04 16:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 18 bytes --]

Patches attached.

[-- Attachment #2: 0003-avfilter-af_aresample-if-frame-parameters-change-upd.patch --]
[-- Type: text/x-patch, Size: 1017 bytes --]

From 3959bcb707f52339bac41acc9aec856cad3aced1 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 4 Jan 2023 17:55:10 +0100
Subject: [PATCH 3/3] avfilter/af_aresample: if frame parameters change update
 swr context

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/af_aresample.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index 7923377c8c..2744388f75 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -209,8 +209,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
     } else {
         outsamplesref->pts  = AV_NOPTS_VALUE;
     }
+again:
     ret = swr_convert_frame(aresample->swr, outsamplesref,
                             (void *)insamplesref);
+    if (ret & (AVERROR_INPUT_CHANGED | AVERROR_OUTPUT_CHANGED)) {
+        swr_close(aresample->swr);
+        goto again;
+    }
+
     if (ret < 0) {
         av_frame_free(&outsamplesref);
         av_frame_free(&insamplesref);
-- 
2.37.2


[-- Attachment #3: 0001-avfilter-af_aresample-switch-to-convert-frame-API.patch --]
[-- Type: text/x-patch, Size: 1380 bytes --]

From fe951a82dc6c75eced5b306a11ea5462a245c4c3 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 4 Jan 2023 17:13:16 +0100
Subject: [PATCH 1/3] avfilter/af_aresample: switch to convert frame API

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/af_aresample.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index 971c861d0e..7923377c8c 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -209,18 +209,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
     } else {
         outsamplesref->pts  = AV_NOPTS_VALUE;
     }
-    n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
-                                 (void *)insamplesref->extended_data, n_in);
-    if (n_out <= 0) {
+    ret = swr_convert_frame(aresample->swr, outsamplesref,
+                            (void *)insamplesref);
+    if (ret < 0) {
         av_frame_free(&outsamplesref);
         av_frame_free(&insamplesref);
-        return 0;
+        return ret;
     }
 
     aresample->more_data = outsamplesref->nb_samples == n_out; // Indicate that there is probably more data in our buffers
 
-    outsamplesref->nb_samples  = n_out;
-
     ret = ff_filter_frame(outlink, outsamplesref);
     av_frame_free(&insamplesref);
     return ret;
-- 
2.37.2


[-- Attachment #4: 0002-swresample-swresample_frame-fix-regression-in-detect.patch --]
[-- Type: text/x-patch, Size: 1919 bytes --]

From 0415ed37bee0c2b640920edad87ec927dda95fb5 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 4 Jan 2023 17:53:01 +0100
Subject: [PATCH 2/3] swresample/swresample_frame: fix regression in detecting
 changes

Do not overwrite return variable values, instead use different
one for checking results.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libswresample/swresample_frame.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libswresample/swresample_frame.c b/libswresample/swresample_frame.c
index 53ac487136..319ce045a1 100644
--- a/libswresample/swresample_frame.c
+++ b/libswresample/swresample_frame.c
@@ -84,7 +84,7 @@ static int config_changed(SwrContext *s,
                           const AVFrame *out, const AVFrame *in)
 {
     AVChannelLayout ch_layout = { 0 };
-    int ret = 0;
+    int ret = 0, iret;
 
     if (in) {
 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -96,8 +96,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
         } else
 #endif
-        if ((ret = av_channel_layout_copy(&ch_layout, &in->ch_layout)) < 0)
-            return ret;
+        if ((iret = av_channel_layout_copy(&ch_layout, &in->ch_layout)) < 0)
+            return iret;
         if (av_channel_layout_compare(&s->in_ch_layout, &ch_layout) ||
             s->in_sample_rate != in->sample_rate ||
             s->in_sample_fmt  != in->format) {
@@ -116,8 +116,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
         } else
 #endif
-        if ((ret = av_channel_layout_copy(&ch_layout, &out->ch_layout)) < 0)
-            return ret;
+        if ((iret = av_channel_layout_copy(&ch_layout, &out->ch_layout)) < 0)
+            return iret;
         if (av_channel_layout_compare(&s->out_ch_layout, &ch_layout) ||
             s->out_sample_rate != out->sample_rate ||
             s->out_sample_fmt  != out->format) {
-- 
2.37.2


[-- Attachment #5: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-01-05 20:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 16:59 [FFmpeg-devel] [PATCH] swresample fixes Paul B Mahol
2023-01-04 17:02 ` James Almer
2023-01-04 17:02 ` Andreas Rheinhardt
2023-01-04 17:18 ` Andreas Rheinhardt
2023-01-04 17:25   ` Paul B Mahol
2023-01-04 17:26 ` Andreas Rheinhardt
2023-01-04 17:35   ` Paul B Mahol
2023-01-04 17:37     ` Andreas Rheinhardt
2023-01-05 20:21 ` Michael Niedermayer
2023-01-05 20:34 ` Michael Niedermayer
2023-01-05 20:44   ` Paul B Mahol
2023-01-05 20:59     ` Michael Niedermayer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git