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] avfilter/avfiltergraph: remove unnecessary channel layout copy
@ 2022-08-05 23:17 James Almer
  2022-08-06 11:42 ` Nicolas George
  0 siblings, 1 reply; 3+ messages in thread
From: James Almer @ 2022-08-05 23:17 UTC (permalink / raw)
  To: ffmpeg-devel

It's not modified, so we can simply use a const pointer to it.
Also check the return value of the other copy in the function while at it.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavfilter/avfiltergraph.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index b7dbfc063b..53f468494d 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -729,12 +729,12 @@ static int reduce_formats_on_filter(AVFilterContext *filter)
     /* reduce channel layouts */
     for (i = 0; i < filter->nb_inputs; i++) {
         AVFilterLink *inlink = filter->inputs[i];
-        AVChannelLayout fmt = { 0 };
+        const AVChannelLayout *fmt;
 
         if (!inlink->outcfg.channel_layouts ||
             inlink->outcfg.channel_layouts->nb_channel_layouts != 1)
             continue;
-        av_channel_layout_copy(&fmt, &inlink->outcfg.channel_layouts->channel_layouts[0]);
+        fmt = &inlink->outcfg.channel_layouts->channel_layouts[0];
 
         for (j = 0; j < filter->nb_outputs; j++) {
             AVFilterLink *outlink = filter->outputs[j];
@@ -745,24 +745,25 @@ static int reduce_formats_on_filter(AVFilterContext *filter)
                 continue;
 
             if (fmts->all_layouts &&
-                (KNOWN(&fmt) || fmts->all_counts)) {
+                (KNOWN(fmt) || fmts->all_counts)) {
                 /* Turn the infinite list into a singleton */
                 fmts->all_layouts = fmts->all_counts  = 0;
-                if (ff_add_channel_layout(&outlink->incfg.channel_layouts, &fmt) < 0)
+                if (ff_add_channel_layout(&outlink->incfg.channel_layouts, fmt) < 0)
                     ret = 1;
                 break;
             }
 
             for (k = 0; k < outlink->incfg.channel_layouts->nb_channel_layouts; k++) {
-                if (!av_channel_layout_compare(&fmts->channel_layouts[k], &fmt)) {
-                    av_channel_layout_copy(&fmts->channel_layouts[0], &fmt);
+                if (!av_channel_layout_compare(&fmts->channel_layouts[k], fmt)) {
+                    ret = av_channel_layout_copy(&fmts->channel_layouts[0], fmt);
+                    if (ret < 0)
+                        return ret;
                     fmts->nb_channel_layouts = 1;
                     ret = 1;
                     break;
                 }
             }
         }
-        av_channel_layout_uninit(&fmt);
     }
 
     return ret;
-- 
2.37.1

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy
  2022-08-05 23:17 [FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy James Almer
@ 2022-08-06 11:42 ` Nicolas George
  2022-08-06 23:54   ` James Almer
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas George @ 2022-08-06 11:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 390 bytes --]

James Almer (12022-08-05):
> It's not modified, so we can simply use a const pointer to it.
> Also check the return value of the other copy in the function while at it.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavfilter/avfiltergraph.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)

Ok, thanks.

Regards,

-- 
  Nicolas George

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: 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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy
  2022-08-06 11:42 ` Nicolas George
@ 2022-08-06 23:54   ` James Almer
  0 siblings, 0 replies; 3+ messages in thread
From: James Almer @ 2022-08-06 23:54 UTC (permalink / raw)
  To: ffmpeg-devel

On 8/6/2022 8:42 AM, Nicolas George wrote:
> James Almer (12022-08-05):
>> It's not modified, so we can simply use a const pointer to it.
>> Also check the return value of the other copy in the function while at it.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavfilter/avfiltergraph.c | 15 ++++++++-------
>>   1 file changed, 8 insertions(+), 7 deletions(-)
> 
> Ok, thanks.
> 
> Regards,

Applied.
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2022-08-06 23:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 23:17 [FFmpeg-devel] [PATCH] avfilter/avfiltergraph: remove unnecessary channel layout copy James Almer
2022-08-06 11:42 ` Nicolas George
2022-08-06 23:54   ` James Almer

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