Michael Witten (1 week ago):
> This series improves the following function:
>
> libavformat/protocols.c: avio_enum_protocols()
>
> There are only 2 commits:
>
> [1] Quash warning about const-correctness
> [2] Refactoring
>
> This series is a
Date: Wed, 11 Aug 2021 19:00:00 -
This commit is the result of squashing a series of very tiny
transformations; it refactors 'avio_enum_protocols()' into
2 functions:
* avio_enum_protocols_for_input()
* avio_enum_protocols_for_output()
Those functions are in turn mostly implemented by thi
Date: Wed, 11 Aug 2021 10:15:01 -
This quashes a compile-time warning.
* 'url_protocols' is an array of const pointers.
* The explicit conversion to '(void *)' is okay,
because the destination is an "opaque" blob of
private data.
---
libavformat/protocols.c | 4 ++--
1 file chang
changed, 28 insertions(+), 12 deletions(-)
Sincerely,
Michael Witten
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
| Michael Witten:
|
| > In the repo, there is only one function that enumerates protocols:
| >
| > fftools/cmdutils.c: show_protocols()
| >
| > This commit simply has that function make calls directly to the
| > desired functions, namely:
| >
| > * avio_
| Michael Witten:
|
| > -const char *avio_enum_protocols(void **opaque, int output)
| > +const char *avio_enum_protocols(void **const opaque, const int output)
|
| Andreas Rheinhardt:
|
| > This thing makes nothing more const-correct at all; C uses call be
| > value, so we on
| Michael Witten:
|
| > However, {2} is presented as a bunch of tiny little transformations
| > that are intended to aid comprehension; they can be squashed into
| > one commit as the maintainer sees fit (indeed, as shown below, the
| > squashed diff is already quite co
| Michael Witten:
|
| > -iterate:
| > +for(;;) {
| > if (*p) {
| > if ((output && (*p)->url_write) || (!output && (*p)->url_read)) {
| > *opaque = (void *)p;
| > @@ -105,7 +105,7 @@ iterate:
| >
The function 'avio_enum_protocols()' iterates through the list of
protocols, looking for a protocol that has a certain non-zero
pointer-to-function; the exact pointer-to-function to use depends
on the the argument passed through the parameter 'output'.
* Before this commit, the parameter 'output'
In the repo, there is only one function that enumerates protocols:
fftools/cmdutils.c: show_protocols()
This commit simply has that function make calls directly to the
desired functions, namely:
* avio_enum_protocols_for_input()
* avio_enum_protocols_for_output()
---
fftools/cmdutils.c
For the sake of completeness and scope correctness, the declaration
and initialization of 'p' has been moved into the 'for(;;)' statement.
---
libavformat/protocols.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index e3cd
The loop variables can now be moved into their respective
slots of the 'for(;;)' statement; this removes the need
for the 'done' label.
---
libavformat/protocols.c | 8 +---
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 2a
The indentation will be cleaned up in the next commit.
---
libavformat/protocols.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 032f07bf72..2aa302d08f 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocol
A 'goto done;' statement is used to jump to the desired code.
---
libavformat/protocols.c | 7 +--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 0deadbfbe7..032f07bf72 100644
--- a/libavformat/protocols.c
+++ b/libavformat
The 'if(!*p)' has been turned into 'if (*p)'; of course,
this has necessitated the swapping of the branches.
---
libavformat/protocols.c | 8
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 5828113428..0deadbfbe7 10064
---
libavformat/protocols.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 3f8433e317..5828113428 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -99,11 +99,12 @@ iterate:
if (!*p) {
Nothing but white space changed:
$ git diff --ignore-all-space "$THIS"^ "$THIS" && echo NOTHING
NOTHING
This is just setting up for the next commit.
---
libavformat/protocols.c | 8
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavformat/protocols.c b/libavformat/p
The assignment is not necessary until returning.
---
libavformat/protocols.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index bedaa9ef77..ec7c72b14f 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -96,
This is preparation for the next commit.
---
libavformat/protocols.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index 5e4bf5cbae..bedaa9ef77 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -101,8 +10
Now that the label has been moved past the initial assignment of 'p',
it is possible to consolidate both the declaration and initialization.
A typedef is used to simplify the declaration of 'p', and to help the
reader understand what the purpose of 'p' is.
---
libavformat/protocols.c | 6 ++
Upon iteration ('goto iterate;'), it is known that 'p' is non-zero,
so there is no point in doing the check; it is known that 'p' must
be incremented. Therefore, the 'iterate' label may be moved past
the ternary operator, provided that '++p;' is added just before
the 'goto', so as to perform the re
In C, it's generally not good to write a recursive algorithm,
because it is not possible to rely on the compiler to elide
a tail call; therefore, this commit converts a tail call into
an iterative loop by means of an explicit 'goto' statement.
---
libavformat/protocols.c | 3 ++-
1 file changed, 2
The main purpose of doing this is to allow for inserting a
a statement label; as I recall, a label cannot be placed
just before a declaration, even when that declaration has
an initializer (then again, I never tried, so maybe this
is not true...)
---
libavformat/protocols.c | 3 ++-
1 file change
This commit adds 'const' qualifiers to the parameters.
---
libavformat/avio.h | 2 +-
libavformat/protocols.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 0b35409787..3b92cf742a 100644
--- a/libavformat/avio.h
+++ b/liba
This quashes a compile-time warning.
* 'url_protocols' is an array of const pointers.
* The explicit conversion to '(void *)' is okay,
because the destination is an "opaque" blob of
private data.
---
libavformat/protocols.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
d
nice history:
$ git log --oneline --graph
Here is the overall change for the entire series:
fftools/cmdutils.c | 4 ++--
libavformat/avio.h | 24 +++-
libavformat/protocols.c | 36 +++++++++---
3 files changed, 50 insertions(+), 14 del
This quashes 2 warnings when the 'file' protocol is not enabled.
---
libavformat/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavformat/file.c b/libavformat/file.c
index 8303436be0..9c23f680cd 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -167,6 +1
!
Sincerely,
Michael Witten
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
28 matches
Mail list logo