Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-06 Thread Chad Fraleigh


On 2/5/2022 6:09 PM, lance.lmw...@gmail.com wrote:
> On Sat, Feb 05, 2022 at 01:26:18PM -0800, Chad Fraleigh wrote:
>> Since any [valid] value over 255 is impossible in the IPv4 protocol (the TTL 
>> field is only 8-bits), it should always be capped at 255 (for consistency) 
>> or return an invalid value error (the one I would suggest).
>>
> 
> zhilizhao have submit a patch to limit the range of ttl from option. Do you 
> want
> to return an invalid error here still?

If it can never be called with an invalid value, not even programmatically if 
someone links against the ffmpeg libs, then checking it is unneeded. But also 
checking it to limit the unsigned char value would be redundant, so only the 
value cast would be needed, i.e.:

   ttl = (unsigned char) mcastTTL;


If however, it could be called without being first limited, then returning an 
error would be best to avoid silently having unexpected results. Also, checking 
that it isn't negative should be done in that case. Not counting pending 
patches, I only see udp_open() calls it, so if it's already bound in there, no 
extra checks are needed.

Of course, these are only suggestions, since I'm a nobody. =)


>> Despite VLC's reversed comment, using an int seems to be the exception to 
>> the rule (i.e. only linux and windows seem to use it [as-documented]), 
>> perhaps doing the unsigned char first and using the int as the fallback 
>> would be better? It's not really just a BSD thing, unless you also count 
>> LWIP and Solaris as BSD. Unless VLC's code history shows them doing it this 
>> way at one time and swapping it (but forgetting the comment) to fix a known 
>> bug?
>>
> 
> I have blamed vlc code and sure the code doing it this way at one 
> time(104938796a3). 
> For the mismatch of code and comments, I prefer to code always as code were 
> build 
> and used by all kinds of system which vlc is supported already. 
> 
> As for use BSD, I prefer to count LWIP and Solaris into BSD category which 
> using
> rule of byte. If you still prefer to add them into comments, I'm OK also. 
> 
>>
>> On 2/4/2022 9:28 PM, lance.lmw...@gmail.com wrote:
>>> From: Limin Wang 
>>>
>>> Suggested by zhilizhao, vlc project has solved the compatibility by
>>> the same way, so I borrowed the comments from vlc project.
>>>
>>> Fix #ticket9449
>>>
>>> Signed-off-by: Limin Wang 
>>> ---
>>>  libavformat/udp.c | 15 +--
>>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavformat/udp.c b/libavformat/udp.c
>>> index 3dc79eb..34488d6 100644
>>> --- a/libavformat/udp.c
>>> +++ b/libavformat/udp.c
>>> @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int 
>>> mcastTTL,
>>>  {
>>>  int protocol, cmd;
>>>  
>>> +/* There is some confusion in the world whether IP_MULTICAST_TTL
>>> + * takes a byte or an int as an argument.
>>> + * BSD seems to indicate byte so we are going with that and use
>>> + * int as a fallback to be safe */
>>>  switch (addr->sa_family) {
>>>  #ifdef IP_MULTICAST_TTL
>>>  case AF_INET:
>>> @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int 
>>> mcastTTL,
>>>  }
>>>  
>>>  if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 
>>> 0) {
>>> -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
>>> -return ff_neterrno();
>>> +/* BSD compatibility */
>>> +unsigned char ttl;
>>> +
>>> +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt");
>>> +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
>>> +if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
>>> +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
>>> +return ff_neterrno();
>>> +}
>>>  }
>>>  
>>>  return 0;
>> ___
>> 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".
> 
___
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".


Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility

2022-02-05 Thread Chad Fraleigh
Since any [valid] value over 255 is impossible in the IPv4 protocol (the TTL 
field is only 8-bits), it should always be capped at 255 (for consistency) or 
return an invalid value error (the one I would suggest).

Despite VLC's reversed comment, using an int seems to be the exception to the 
rule (i.e. only linux and windows seem to use it [as-documented]), perhaps 
doing the unsigned char first and using the int as the fallback would be 
better? It's not really just a BSD thing, unless you also count LWIP and 
Solaris as BSD. Unless VLC's code history shows them doing it this way at one 
time and swapping it (but forgetting the comment) to fix a known bug?


On 2/4/2022 9:28 PM, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Suggested by zhilizhao, vlc project has solved the compatibility by
> the same way, so I borrowed the comments from vlc project.
> 
> Fix #ticket9449
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/udp.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 3dc79eb..34488d6 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int 
> mcastTTL,
>  {
>  int protocol, cmd;
>  
> +/* There is some confusion in the world whether IP_MULTICAST_TTL
> + * takes a byte or an int as an argument.
> + * BSD seems to indicate byte so we are going with that and use
> + * int as a fallback to be safe */
>  switch (addr->sa_family) {
>  #ifdef IP_MULTICAST_TTL
>  case AF_INET:
> @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int 
> mcastTTL,
>  }
>  
>  if (setsockopt(sockfd, protocol, cmd, , sizeof(mcastTTL)) < 0) {
> -ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> -return ff_neterrno();
> +/* BSD compatibility */
> +unsigned char ttl;
> +
> +ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt");
> +ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL);
> +if (setsockopt(sockfd, protocol, cmd, , sizeof(ttl)) < 0) {
> +ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt");
> +return ff_neterrno();
> +}
>  }
>  
>  return 0;
___
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".


Re: [FFmpeg-devel] [PATCH] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-26 Thread Chad Fraleigh

On 1/26/2022 12:50 PM, Marton Balint wrote:
> 
> 
> On Wed, 26 Jan 2022, Brad Smith wrote:
> 
>> On Wed, Jan 12, 2022 at 12:13:14AM -0500, Brad Smith wrote:
>>> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
>>> type should be an unsigned char on anything but Linux.
>>
>> Based on feedback so far. Here is a much simpler approach to this issue..
> 
> Win32 needs DWORD unfortunately. I missed it earlier, sorry.
> 
> https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options

It gets worse from there. Since I can't look at the real Win32 source to see if 
it handles it both way, I had to go with Wine and ReactOS..

In Wine, the tests seem to use just an 'int' (which is probably always the same 
as 'DWORD'). But then, it proceeds to check it using a 1, 2, 3, and 4 byte 
optlen. In the implementation, it appears to just pass the values as-is to the 
underlying OS, rather than explicitly translate it to the appropriate type.

For ReactOS, it blindly treats it as an unsigned char (regardless of optlen, as 
long as it at least 1) when setting/getting the value. But then in a debug line 
just below that, it treats optval as an 'int *'.

Maybe some tests need to be done on Win32 to see if it works with either size 
(i.e. set as uchar, get as DWORD, then in reverse and make sure the 
input/output match in all cases).

I didn't check to see what msys/mingw* does, if anything.

> 
> Regards,
> Marton
> 
>>
>>
>> diff --git a/libavformat/udp.c b/libavformat/udp.c
>> index 83c042d079..da1b98890b 100644
>> --- a/libavformat/udp.c
>> +++ b/libavformat/udp.c
>> @@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int 
>> mcastTTL,
>> {
>> #ifdef IP_MULTICAST_TTL
>>     if (addr->sa_family == AF_INET) {
>> -    if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
>> sizeof(mcastTTL)) < 0) {
>> +    unsigned char ttl = mcastTTL;  /* ignore the outdated Linux 
>> documentation */
>> +
>> +    if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
>> sizeof(ttl)) < 0) {
>>     ff_log_net_error(logctx, AV_LOG_ERROR, 
>> "setsockopt(IP_MULTICAST_TTL)");
>>     return ff_neterrno();
>>     }
>> ___
>> 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".
>>
> ___
> 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".
___
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".


Re: [FFmpeg-devel] [PATCH] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

2022-01-25 Thread Chad Fraleigh
Since apparently linux will auto-detect (as mentioned by Marton Balint), based 
on the optlen parameter, just using unsigned char in all cases seems to be the 
cleanest. However, I would advise including a comment in the code to that 
effect which says to ignore the [outdated] linux documentation (so someone 
doesn't needlessly "correct" it in the future).

I looked at the kernel source and it does work both ways:

static int do_ip_setsockopt(struct sock *sk, int level, int optname,
sockptr_t optval, unsigned int optlen)
{
 ...
switch (optname) {
 ...
case IP_MULTICAST_TTL:
 ...
if (optlen >= sizeof(int)) {
if (copy_from_sockptr(, optval, sizeof(val)))
return -EFAULT;
} else if (optlen >= sizeof(char)) {
unsigned char ucval;

if (copy_from_sockptr(, optval, sizeof(ucval)))
return -EFAULT;
val = (int) ucval;
}
}
...
}

This check has been in the kernel since at least 2.6.12-rc2 (from Apr 2005). It 
should work fine, unless newer ffmpeg builds support is needed on older 
systems. So the only question is how old are the kernels in IoT and android 
devices which might use the current ffmpeg?


On 1/24/2022 11:25 PM, lance.lmw...@gmail.com wrote:
> On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote:
>> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
>> type should be an unsigned char on anything but Linux.
>>
>>
>> diff --git a/libavformat/udp.c b/libavformat/udp.c
>> index 180d96a988..29aa865fff 100644
>> --- a/libavformat/udp.c
>> +++ b/libavformat/udp.c
>> @@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int 
>> mcastTTL,
>>  {
>>  #ifdef IP_MULTICAST_TTL
>>  if (addr->sa_family == AF_INET) {
>> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
>> sizeof(mcastTTL)) < 0) {
>> +#ifdef __linux__
>> +int ttl = mcastTTL;
>> +#else
>> +unsigned char ttl = mcastTTL;
>> +#endif
> 
> 
> I don't have BSD system for test, but I prefer to use socklen_t, please try 
> with my proposal patch:
> 
> ---
>  libavformat/udp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 83c042d079..b9baa0a803 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
>  {
>  #ifdef IP_MULTICAST_TTL
>  if (addr->sa_family == AF_INET) {
> -if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> sizeof(mcastTTL)) < 0) {
> +socklen_t ttl = mcastTTL;
> +
> +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
> sizeof(ttl)) < 0) {
>  ff_log_net_error(logctx, AV_LOG_ERROR, 
> "setsockopt(IP_MULTICAST_TTL)");
>  return ff_neterrno();
> 
> 
>> +
>> +if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, , 
>> sizeof(ttl)) < 0) {
>>  ff_log_net_error(NULL, AV_LOG_ERROR, 
>> "setsockopt(IP_MULTICAST_TTL)");
>>  return ff_neterrno();
>>  }
>> ___
>> 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".
> 
___
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".


[FFmpeg-devel] [PATCH 6/6] libavutil/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavutil/hwcontext_qsv.c| 2 +-
 libavutil/hwcontext_vulkan.c | 6 +++---
 libavutil/opt.c  | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index c18747f7eb..23023c005d 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1451,7 +1451,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, 
const char *device,
 enum AVHWDeviceType child_device_type;
 AVHWDeviceContext *child_device;
 AVDictionary *child_device_opts;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 mfxIMPL impl;
 int ret;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2c3216857a..259fa12cba 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -545,7 +545,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int 
dev, AVDictionary *opts,
 int optional_exts_num;
 uint32_t sup_ext_count;
 char *user_exts_str = NULL;
-AVDictionaryEntry *user_exts;
+const AVDictionaryEntry *user_exts;
 VkExtensionProperties *sup_ext;
 const VulkanOptExtension *optional_exts;
 
@@ -671,7 +671,7 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)
 VulkanDevicePriv *p = ctx->internal->priv;
 VulkanFunctions *vk = >vkfn;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
-AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
+const AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
 const int debug_mode = debug_opt && strtol(debug_opt->value, NULL, 10);
 VkApplicationInfo application_info = {
 .sType  = VK_STRUCTURE_TYPE_APPLICATION_INFO,
@@ -1246,7 +1246,7 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 {
 int err = 0;
 VkResult ret;
-AVDictionaryEntry *opt_d;
+const AVDictionaryEntry *opt_d;
 VulkanDevicePriv *p = ctx->internal->priv;
 VulkanFunctions *vk = >vkfn;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
diff --git a/libavutil/opt.c b/libavutil/opt.c
index c7001dbcd3..51b9157c2e 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1633,7 +1633,7 @@ void av_opt_free(void *obj)
 
 int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 AVDictionary*tmp = NULL;
 int ret;
 
@@ -2005,8 +2005,8 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o)
 case AV_OPT_TYPE_DICT: {
 AVDictionary *dict1 = NULL;
 AVDictionary *dict2 = *(AVDictionary **)dst;
-AVDictionaryEntry *en1 = NULL;
-AVDictionaryEntry *en2 = NULL;
+const AVDictionaryEntry *en1 = NULL;
+const AVDictionaryEntry *en2 = NULL;
 ret = av_dict_parse_string(, o->default_val.str, "=", ":", 0);
 if (ret < 0) {
 av_dict_free();
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 5/6] libavformat/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavformat/aiffenc.c   |  2 +-
 libavformat/apetag.c|  2 +-
 libavformat/asfenc.c|  8 +++
 libavformat/au.c|  2 +-
 libavformat/avidec.c|  2 +-
 libavformat/avienc.c|  2 +-
 libavformat/avio.c  |  4 ++--
 libavformat/cafenc.c|  2 +-
 libavformat/dashenc.c   |  6 ++---
 libavformat/dvenc.c |  2 +-
 libavformat/ffmetaenc.c |  2 +-
 libavformat/fifo.c  |  2 +-
 libavformat/flacdec.c   |  2 +-
 libavformat/flacenc.c   |  4 ++--
 libavformat/flvdec.c|  2 +-
 libavformat/flvenc.c|  2 +-
 libavformat/gxfenc.c|  2 +-
 libavformat/hls.c   |  4 ++--
 libavformat/http.c  |  8 +++
 libavformat/id3v2.c |  6 ++---
 libavformat/id3v2enc.c  |  8 +++
 libavformat/matroskadec.c   |  2 +-
 libavformat/metadata.c  |  2 +-
 libavformat/mov.c   |  6 ++---
 libavformat/movenc.c| 44 ++---
 libavformat/mp3enc.c|  6 ++---
 libavformat/mpegtsenc.c |  6 ++---
 libavformat/mux.c   |  2 +-
 libavformat/mxfenc.c| 14 ++--
 libavformat/nutenc.c|  6 ++---
 libavformat/riffenc.c   |  2 +-
 libavformat/rmenc.c |  2 +-
 libavformat/sapenc.c|  2 +-
 libavformat/sdp.c   |  2 +-
 libavformat/segment.c   |  4 ++--
 libavformat/smjpegenc.c |  2 +-
 libavformat/soxenc.c|  2 +-
 libavformat/ttmlenc.c   |  2 +-
 libavformat/utils.c |  4 ++--
 libavformat/vorbiscomment.c |  6 ++---
 libavformat/wavenc.c|  4 ++--
 libavformat/webmdashenc.c   | 28 +++
 libavformat/wtvenc.c|  4 ++--
 43 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 24bc17400e..1f8e0dd670 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -82,7 +82,7 @@ static int put_id3v2_tags(AVFormatContext *s, 
AIFFOutputContext *aiff)
 
 static void put_meta(AVFormatContext *s, const char *key, uint32_t id)
 {
-AVDictionaryEntry *tag;
+const AVDictionaryEntry *tag;
 AVIOContext *pb = s->pb;
 
 if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 6f82fbe202..d94356f5a0 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -174,7 +174,7 @@ static int string_is_ascii(const uint8_t *str)
 
 int ff_ape_write_tag(AVFormatContext *s)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 int size, ret, count = 0;
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf;
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 041019b186..a60e5ac83d 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -327,7 +327,7 @@ static void asf_write_markers(AVFormatContext *s, 
AVIOContext *dyn_buf)
 
 for (unsigned i = 0; i < s->nb_chapters; i++) {
 AVChapter *c = s->chapters[i];
-AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
+const AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 
0);
 int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
 uint64_t offset;
 int32_t send_time = get_send_time(asf, pres_time, );
@@ -357,7 +357,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb, *dyn_buf;
-AVDictionaryEntry *tags[5];
+const AVDictionaryEntry *tags[5];
 int header_size, extra_size, extra_size2, wav_extra_size;
 int has_title, has_aspect_ratio = 0;
 int metadata_count;
@@ -388,7 +388,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 for (unsigned n = 0; n < s->nb_streams; n++) {
 AVStream *const st = s->streams[n];
 AVCodecParameters *const par = st->codecpar;
-AVDictionaryEntry *entry;
+const AVDictionaryEntry *entry;
 
 avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
 
@@ -566,7 +566,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 end_header(pb, hpos);
 }
 if (metadata_count) {
-AVDictionaryEntry *tag = NULL;
+const AVDictionaryEntry *tag = NULL;
 hpos = put_header(pb, _asf_extended_content_header);
 avio_wl16(pb, metadata_count);
 while ((tag = av_dict_get(s->metadata, "", tag, 
AV_DICT_IGNORE_SUFFIX))) {
diff --git a/libavformat/au.c b/libavformat/au.c
index 9bd408f65c..a408e55e36 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -258,7 +258,7 @@ static int au_get_annotations(AVFormatContext *s, AVBPrint 
*annotations)
 };
 int cnt = 0;
 AVDictionary *m = s-&g

[FFmpeg-devel] [PATCH 4/6] libavfilter/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavfilter/avfilter.c  | 2 +-
 libavfilter/f_bench.c   | 2 +-
 libavfilter/f_drawgraph.c   | 2 +-
 libavfilter/f_metadata.c| 2 +-
 libavfilter/f_select.c  | 4 ++--
 libavfilter/vf_cover_rect.c | 2 +-
 libavfilter/vf_drawtext.c   | 2 +-
 libavfilter/vf_scale.c  | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 7362bcdab5..9277aeea38 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -938,7 +938,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 int avfilter_init_str(AVFilterContext *filter, const char *args)
 {
 AVDictionary *options = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 int ret = 0;
 
 if (args && *args) {
diff --git a/libavfilter/f_bench.c b/libavfilter/f_bench.c
index f7098adaf4..16ca17723b 100644
--- a/libavfilter/f_bench.c
+++ b/libavfilter/f_bench.c
@@ -69,7 +69,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 if (s->action == ACTION_START) {
 av_dict_set_int(>metadata, START_TIME_KEY, t, 0);
 } else if (s->action == ACTION_STOP) {
-AVDictionaryEntry *e = av_dict_get(in->metadata, START_TIME_KEY, NULL, 
0);
+const AVDictionaryEntry *e = av_dict_get(in->metadata, START_TIME_KEY, 
NULL, 0);
 if (e) {
 const int64_t start = strtoll(e->value, NULL, 0);
 const int64_t diff = t - start;
diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c
index b6fcb3b75e..d34dc52a6b 100644
--- a/libavfilter/f_drawgraph.c
+++ b/libavfilter/f_drawgraph.c
@@ -163,7 +163,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 DrawGraphContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 AVDictionary *metadata;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 AVFrame *out = s->out;
 AVFrame *clone = NULL;
 int64_t in_pts, out_pts;
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index cecfe62a9c..ee87a2b37f 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -306,7 +306,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 AVFilterLink *outlink = ctx->outputs[0];
 MetadataContext *s = ctx->priv;
 AVDictionary **metadata = >metadata;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 e = av_dict_get(*metadata, !s->key ? "" : s->key, NULL,
 !s->key ? AV_DICT_IGNORE_SUFFIX: 0);
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 47e7d1fef8..fe7e294bf1 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -304,8 +304,8 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame 
*frame)
 static double get_concatdec_select(AVFrame *frame, int64_t pts)
 {
 AVDictionary *metadata = frame->metadata;
-AVDictionaryEntry *start_time_entry = av_dict_get(metadata, 
"lavf.concatdec.start_time", NULL, 0);
-AVDictionaryEntry *duration_entry = av_dict_get(metadata, 
"lavf.concatdec.duration", NULL, 0);
+const AVDictionaryEntry *start_time_entry = av_dict_get(metadata, 
"lavf.concatdec.start_time", NULL, 0);
+const AVDictionaryEntry *duration_entry = av_dict_get(metadata, 
"lavf.concatdec.duration", NULL, 0);
 if (start_time_entry) {
 int64_t start_time = strtoll(start_time_entry->value, NULL, 10);
 if (pts >= start_time) {
diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
index 01c9f2abbb..f094b2b593 100644
--- a/libavfilter/vf_cover_rect.c
+++ b/libavfilter/vf_cover_rect.c
@@ -124,7 +124,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
 CoverContext *cover = ctx->priv;
-AVDictionaryEntry *ex, *ey, *ew, *eh;
+const AVDictionaryEntry *ex, *ey, *ew, *eh;
 int x = -1, y = -1, w = -1, h = -1;
 char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL;
 
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 2a88692cbd..14e6430368 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1032,7 +1032,7 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint 
*bp,
  char *fct, unsigned argc, char **argv, int tag)
 {
 DrawTextContext *s = ctx->priv;
-AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
+const AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
 
 if (e && e->value)
 av_bprintf(bp, "%s", e->value);
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 44f85cb019..73bb3c0738 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilte

[FFmpeg-devel] [PATCH 3/6] libavcodec/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavcodec/libaomenc.c | 2 +-
 libavcodec/libvpxenc.c | 4 ++--
 libavcodec/libx264.c   | 2 +-
 libavcodec/libx265.c   | 2 +-
 libavcodec/mjpegdec.c  | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 800fda0591..85e8fc0f0b 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -882,7 +882,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int ret = aom_codec_set_option(>encoder, en->key, en->value);
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 10e5a22fa9..ea92eb6221 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -910,7 +910,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
 vpx_svc_extra_cfg_t svc_params;
 #endif
-AVDictionaryEntry* en = NULL;
+const AVDictionaryEntry* en = NULL;
 
 ctx->discard_hdr10_plus = 1;
 av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
@@ -1671,7 +1671,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 if (frame->pict_type == AV_PICTURE_TYPE_I)
 flags |= VPX_EFLAG_FORCE_KF;
 if (frame->metadata) {
-AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", 
NULL, 0);
+const AVDictionaryEntry* en = av_dict_get(frame->metadata, 
"vp8-flags", NULL, 0);
 if (en) {
 flags |= strtoul(en->value, NULL, 10);
 }
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 507fee39f2..0251842bd4 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -931,7 +931,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
 #endif
 
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 while (en = av_dict_get(x4->x264_params, "", en, 
AV_DICT_IGNORE_SUFFIX)) {
if ((ret = x264_param_parse(>params, en->key, en->value)) < 0) {
av_log(avctx, AV_LOG_WARNING,
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 7dd70a3450..ec50b8a77f 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -363,7 +363,7 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 }
 
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 while ((en = av_dict_get(ctx->x265_opts, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int parse_ret = ctx->api->param_parse(ctx->params, en->key, 
en->value);
 
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7f89641660..b22895cfe6 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2407,7 +2407,7 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame 
*frame)
 int i, index;
 int ret = 0;
 int is16bit;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 
 s->force_pal8 = 0;
 
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/6] fftools/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 fftools/cmdutils.c  | 2 +-
 fftools/ffmpeg.c| 6 +++---
 fftools/ffmpeg_filter.c | 6 +++---
 fftools/ffmpeg_opt.c| 8 
 fftools/ffplay.c| 8 
 fftools/ffprobe.c   | 8 
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 2c8e98982f..d351ceb7fa 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -2106,7 +2106,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum 
AVCodecID codec_id,
 AVFormatContext *s, AVStream *st, const 
AVCodec *codec)
 {
 AVDictionary*ret = NULL;
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 intflags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
   : AV_OPT_FLAG_DECODING_PARAM;
 char  prefix = 0;
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 9d4f9d7a2b..d46d154af1 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -677,7 +677,7 @@ static void ffmpeg_cleanup(int ret)
 
 void remove_avoptions(AVDictionary **a, AVDictionary *b)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 
 while ((t = av_dict_get(b, "", t, AV_DICT_IGNORE_SUFFIX))) {
 av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE);
@@ -686,7 +686,7 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b)
 
 void assert_avoptions(AVDictionary *m)
 {
-AVDictionaryEntry *t;
+const AVDictionaryEntry *t;
 if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
 exit_program(1);
@@ -3228,7 +3228,7 @@ static int init_output_stream_streamcopy(OutputStream 
*ost)
 
 static void set_encoder_id(OutputFile *of, OutputStream *ost)
 {
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 uint8_t *encoder_string;
 int encoder_string_len;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b798459946..c70903295f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -86,7 +86,7 @@ static enum AVPixelFormat choose_pixel_fmt(AVStream *st, 
AVCodecContext *enc_ctx
 static char *choose_pix_fmts(OutputFilter *ofilter)
 {
 OutputStream *ost = ofilter->ost;
-AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", 
NULL, 0);
+const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, 
"strict", NULL, 0);
 if (strict_dict)
 // used by choose_pixel_fmt() and below
 av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
@@ -437,7 +437,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
OutputFilter *ofilter,
 if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
 char args[255];
 AVFilterContext *filter;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 
 snprintf(args, sizeof(args), "%d:%d",
  ofilter->width, ofilter->height);
@@ -994,7 +994,7 @@ int configure_filtergraph(FilterGraph *fg)
 if (simple) {
 OutputStream *ost = fg->outputs[0]->ost;
 char args[512];
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 
 if (filter_nbthreads) {
 ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 7aff43d917..d034ff2a5b 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -249,7 +249,7 @@ static int show_hwaccels(void *optctx, const char *opt, 
const char *arg)
 /* return a copy of the input with the stream specifiers removed from the keys 
*/
 static AVDictionary *strip_specifiers(AVDictionary *dict)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 AVDictionary*ret = NULL;
 
 while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) {
@@ -1073,7 +1073,7 @@ static void dump_attachment(AVStream *st, const char 
*filename)
 {
 int ret;
 AVIOContext *out = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 if (!st->codecpar->extradata_size) {
 av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream 
#%d:%d.\n",
@@ -1109,7 +1109,7 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 int err, i, ret;
 int64_t timestamp;
 AVDictionary *unused_opts = NULL;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 char *   video_codec_name = NULL;
 char *   audio_codec_name = NULL;
 char *subtitle_codec_name = NULL;
@@ -2212,7 +2212,7 @@ static int open_output_file(OptionsC

[FFmpeg-devel] [PATCH 6/6] libavutil/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavutil/hwcontext_qsv.c| 2 +-
 libavutil/hwcontext_vulkan.c | 6 +++---
 libavutil/opt.c  | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index c18747f7eb..23023c005d 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1451,7 +1451,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, 
const char *device,
 enum AVHWDeviceType child_device_type;
 AVHWDeviceContext *child_device;
 AVDictionary *child_device_opts;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 mfxIMPL impl;
 int ret;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2c3216857a..259fa12cba 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -545,7 +545,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int 
dev, AVDictionary *opts,
 int optional_exts_num;
 uint32_t sup_ext_count;
 char *user_exts_str = NULL;
-AVDictionaryEntry *user_exts;
+const AVDictionaryEntry *user_exts;
 VkExtensionProperties *sup_ext;
 const VulkanOptExtension *optional_exts;
 
@@ -671,7 +671,7 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)
 VulkanDevicePriv *p = ctx->internal->priv;
 VulkanFunctions *vk = >vkfn;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
-AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
+const AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
 const int debug_mode = debug_opt && strtol(debug_opt->value, NULL, 10);
 VkApplicationInfo application_info = {
 .sType  = VK_STRUCTURE_TYPE_APPLICATION_INFO,
@@ -1246,7 +1246,7 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 {
 int err = 0;
 VkResult ret;
-AVDictionaryEntry *opt_d;
+const AVDictionaryEntry *opt_d;
 VulkanDevicePriv *p = ctx->internal->priv;
 VulkanFunctions *vk = >vkfn;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
diff --git a/libavutil/opt.c b/libavutil/opt.c
index c7001dbcd3..51b9157c2e 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1633,7 +1633,7 @@ void av_opt_free(void *obj)
 
 int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 AVDictionary*tmp = NULL;
 int ret;
 
@@ -2005,8 +2005,8 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o)
 case AV_OPT_TYPE_DICT: {
 AVDictionary *dict1 = NULL;
 AVDictionary *dict2 = *(AVDictionary **)dst;
-AVDictionaryEntry *en1 = NULL;
-AVDictionaryEntry *en2 = NULL;
+const AVDictionaryEntry *en1 = NULL;
+const AVDictionaryEntry *en2 = NULL;
 ret = av_dict_parse_string(, o->default_val.str, "=", ":", 0);
 if (ret < 0) {
 av_dict_free();
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 5/6] libavformat/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavformat/aiffenc.c   |  2 +-
 libavformat/apetag.c|  2 +-
 libavformat/asfenc.c|  8 +++
 libavformat/au.c|  2 +-
 libavformat/avidec.c|  2 +-
 libavformat/avienc.c|  2 +-
 libavformat/avio.c  |  4 ++--
 libavformat/cafenc.c|  2 +-
 libavformat/dashenc.c   |  6 ++---
 libavformat/dvenc.c |  2 +-
 libavformat/ffmetaenc.c |  2 +-
 libavformat/fifo.c  |  2 +-
 libavformat/flacdec.c   |  2 +-
 libavformat/flacenc.c   |  4 ++--
 libavformat/flvdec.c|  2 +-
 libavformat/flvenc.c|  2 +-
 libavformat/gxfenc.c|  2 +-
 libavformat/hls.c   |  4 ++--
 libavformat/http.c  |  8 +++
 libavformat/id3v2.c |  6 ++---
 libavformat/id3v2enc.c  |  8 +++
 libavformat/matroskadec.c   |  2 +-
 libavformat/metadata.c  |  2 +-
 libavformat/mov.c   |  6 ++---
 libavformat/movenc.c| 44 ++---
 libavformat/mp3enc.c|  6 ++---
 libavformat/mpegtsenc.c |  6 ++---
 libavformat/mux.c   |  2 +-
 libavformat/mxfenc.c| 14 ++--
 libavformat/nutenc.c|  6 ++---
 libavformat/riffenc.c   |  2 +-
 libavformat/rmenc.c |  2 +-
 libavformat/sapenc.c|  2 +-
 libavformat/sdp.c   |  2 +-
 libavformat/segment.c   |  4 ++--
 libavformat/smjpegenc.c |  2 +-
 libavformat/soxenc.c|  2 +-
 libavformat/ttmlenc.c   |  2 +-
 libavformat/utils.c |  4 ++--
 libavformat/vorbiscomment.c |  6 ++---
 libavformat/wavenc.c|  4 ++--
 libavformat/webmdashenc.c   | 28 +++
 libavformat/wtvenc.c|  4 ++--
 43 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 24bc17400e..1f8e0dd670 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -82,7 +82,7 @@ static int put_id3v2_tags(AVFormatContext *s, 
AIFFOutputContext *aiff)
 
 static void put_meta(AVFormatContext *s, const char *key, uint32_t id)
 {
-AVDictionaryEntry *tag;
+const AVDictionaryEntry *tag;
 AVIOContext *pb = s->pb;
 
 if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 6f82fbe202..d94356f5a0 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -174,7 +174,7 @@ static int string_is_ascii(const uint8_t *str)
 
 int ff_ape_write_tag(AVFormatContext *s)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 int size, ret, count = 0;
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf;
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index a0510df7dc..8632877117 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -355,7 +355,7 @@ static int asf_write_markers(AVFormatContext *s)
 
 for (unsigned i = 0; i < s->nb_chapters; i++) {
 AVChapter *c = s->chapters[i];
-AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
+const AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 
0);
 int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
 uint64_t offset;
 int32_t send_time = get_send_time(asf, pres_time, );
@@ -389,7 +389,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
-AVDictionaryEntry *tags[5];
+const AVDictionaryEntry *tags[5];
 int header_size, extra_size, extra_size2, wav_extra_size;
 int has_title, has_aspect_ratio = 0;
 int metadata_count;
@@ -420,7 +420,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 for (unsigned n = 0; n < s->nb_streams; n++) {
 AVStream *const st = s->streams[n];
 AVCodecParameters *const par = st->codecpar;
-AVDictionaryEntry *entry;
+const AVDictionaryEntry *entry;
 
 avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
 
@@ -599,7 +599,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 end_header(pb, hpos);
 }
 if (metadata_count) {
-AVDictionaryEntry *tag = NULL;
+const AVDictionaryEntry *tag = NULL;
 hpos = put_header(pb, _asf_extended_content_header);
 avio_wl16(pb, metadata_count);
 while ((tag = av_dict_get(s->metadata, "", tag, 
AV_DICT_IGNORE_SUFFIX))) {
diff --git a/libavformat/au.c b/libavformat/au.c
index 9bd408f65c..a408e55e36 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -258,7 +258,7 @@ static int au_get_annotations(AVFormatContext *s, AVBPrint 
*annotations)
 };
 int cnt = 0;
 AVDictionary *m = s->metadata;
-AVDiction

[FFmpeg-devel] [PATCH 4/6] libavfilter/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavfilter/avfilter.c  | 2 +-
 libavfilter/f_bench.c   | 2 +-
 libavfilter/f_drawgraph.c   | 2 +-
 libavfilter/f_metadata.c| 2 +-
 libavfilter/f_select.c  | 4 ++--
 libavfilter/vf_cover_rect.c | 2 +-
 libavfilter/vf_drawtext.c   | 2 +-
 libavfilter/vf_scale.c  | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index f325918021..c0573d53c9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -939,7 +939,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 int avfilter_init_str(AVFilterContext *filter, const char *args)
 {
 AVDictionary *options = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 int ret = 0;
 
 if (args && *args) {
diff --git a/libavfilter/f_bench.c b/libavfilter/f_bench.c
index f7098adaf4..16ca17723b 100644
--- a/libavfilter/f_bench.c
+++ b/libavfilter/f_bench.c
@@ -69,7 +69,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 if (s->action == ACTION_START) {
 av_dict_set_int(>metadata, START_TIME_KEY, t, 0);
 } else if (s->action == ACTION_STOP) {
-AVDictionaryEntry *e = av_dict_get(in->metadata, START_TIME_KEY, NULL, 
0);
+const AVDictionaryEntry *e = av_dict_get(in->metadata, START_TIME_KEY, 
NULL, 0);
 if (e) {
 const int64_t start = strtoll(e->value, NULL, 0);
 const int64_t diff = t - start;
diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c
index 9996eb3b0e..7cc1efb3d7 100644
--- a/libavfilter/f_drawgraph.c
+++ b/libavfilter/f_drawgraph.c
@@ -163,7 +163,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 DrawGraphContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 AVDictionary *metadata;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 AVFrame *out = s->out;
 AVFrame *clone = NULL;
 int64_t in_pts, out_pts;
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index cecfe62a9c..ee87a2b37f 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -306,7 +306,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 AVFilterLink *outlink = ctx->outputs[0];
 MetadataContext *s = ctx->priv;
 AVDictionary **metadata = >metadata;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 e = av_dict_get(*metadata, !s->key ? "" : s->key, NULL,
 !s->key ? AV_DICT_IGNORE_SUFFIX: 0);
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 187e98a1a7..ab26676e57 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -304,8 +304,8 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame 
*frame)
 static double get_concatdec_select(AVFrame *frame, int64_t pts)
 {
 AVDictionary *metadata = frame->metadata;
-AVDictionaryEntry *start_time_entry = av_dict_get(metadata, 
"lavf.concatdec.start_time", NULL, 0);
-AVDictionaryEntry *duration_entry = av_dict_get(metadata, 
"lavf.concatdec.duration", NULL, 0);
+const AVDictionaryEntry *start_time_entry = av_dict_get(metadata, 
"lavf.concatdec.start_time", NULL, 0);
+const AVDictionaryEntry *duration_entry = av_dict_get(metadata, 
"lavf.concatdec.duration", NULL, 0);
 if (start_time_entry) {
 int64_t start_time = strtoll(start_time_entry->value, NULL, 10);
 if (pts >= start_time) {
diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
index 0a8c10e06d..d3a9755234 100644
--- a/libavfilter/vf_cover_rect.c
+++ b/libavfilter/vf_cover_rect.c
@@ -135,7 +135,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
 CoverContext *cover = ctx->priv;
-AVDictionaryEntry *ex, *ey, *ew, *eh;
+const AVDictionaryEntry *ex, *ey, *ew, *eh;
 int x = -1, y = -1, w = -1, h = -1;
 char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL;
 
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index b1ea58f30a..197163f426 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1032,7 +1032,7 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint 
*bp,
  char *fct, unsigned argc, char **argv, int tag)
 {
 DrawTextContext *s = ctx->priv;
-AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
+const AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
 
 if (e && e->value)
 av_bprintf(bp, "%s", e->value);
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index a1902a13cf..698fbc4768 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilte

[FFmpeg-devel] [PATCH 3/6] libavcodec/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 libavcodec/libaomenc.c | 2 +-
 libavcodec/libvpxenc.c | 4 ++--
 libavcodec/libx264.c   | 2 +-
 libavcodec/libx265.c   | 2 +-
 libavcodec/mjpegdec.c  | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 800fda0591..85e8fc0f0b 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -882,7 +882,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int ret = aom_codec_set_option(>encoder, en->key, en->value);
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 10e5a22fa9..ea92eb6221 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -910,7 +910,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
 vpx_svc_extra_cfg_t svc_params;
 #endif
-AVDictionaryEntry* en = NULL;
+const AVDictionaryEntry* en = NULL;
 
 ctx->discard_hdr10_plus = 1;
 av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
@@ -1671,7 +1671,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 if (frame->pict_type == AV_PICTURE_TYPE_I)
 flags |= VPX_EFLAG_FORCE_KF;
 if (frame->metadata) {
-AVDictionaryEntry* en = av_dict_get(frame->metadata, "vp8-flags", 
NULL, 0);
+const AVDictionaryEntry* en = av_dict_get(frame->metadata, 
"vp8-flags", NULL, 0);
 if (en) {
 flags |= strtoul(en->value, NULL, 10);
 }
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 0f886713e3..e255432604 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -901,7 +901,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
 #endif
 
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 while (en = av_dict_get(x4->x264_params, "", en, 
AV_DICT_IGNORE_SUFFIX)) {
if ((ret = x264_param_parse(>params, en->key, en->value)) < 0) {
av_log(avctx, AV_LOG_WARNING,
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 7dd70a3450..ec50b8a77f 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -363,7 +363,7 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 }
 
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 while ((en = av_dict_get(ctx->x265_opts, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int parse_ret = ctx->api->param_parse(ctx->params, en->key, 
en->value);
 
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7f89641660..b22895cfe6 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2407,7 +2407,7 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame 
*frame)
 int i, index;
 int ret = 0;
 int is16bit;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 
 s->force_pal8 = 0;
 
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/6] fftools/: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 fftools/cmdutils.c  | 2 +-
 fftools/ffmpeg.c| 6 +++---
 fftools/ffmpeg_filter.c | 6 +++---
 fftools/ffmpeg_opt.c| 8 
 fftools/ffplay.c| 8 
 fftools/ffprobe.c   | 8 
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 2c8e98982f..d351ceb7fa 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -2106,7 +2106,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum 
AVCodecID codec_id,
 AVFormatContext *s, AVStream *st, const 
AVCodec *codec)
 {
 AVDictionary*ret = NULL;
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 intflags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
   : AV_OPT_FLAG_DECODING_PARAM;
 char  prefix = 0;
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 98c2421938..edbf3ac52a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -677,7 +677,7 @@ static void ffmpeg_cleanup(int ret)
 
 void remove_avoptions(AVDictionary **a, AVDictionary *b)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 
 while ((t = av_dict_get(b, "", t, AV_DICT_IGNORE_SUFFIX))) {
 av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE);
@@ -686,7 +686,7 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b)
 
 void assert_avoptions(AVDictionary *m)
 {
-AVDictionaryEntry *t;
+const AVDictionaryEntry *t;
 if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
 exit_program(1);
@@ -3243,7 +3243,7 @@ static int init_output_stream_streamcopy(OutputStream 
*ost)
 
 static void set_encoder_id(OutputFile *of, OutputStream *ost)
 {
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 uint8_t *encoder_string;
 int encoder_string_len;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b798459946..c70903295f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -86,7 +86,7 @@ static enum AVPixelFormat choose_pixel_fmt(AVStream *st, 
AVCodecContext *enc_ctx
 static char *choose_pix_fmts(OutputFilter *ofilter)
 {
 OutputStream *ost = ofilter->ost;
-AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", 
NULL, 0);
+const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, 
"strict", NULL, 0);
 if (strict_dict)
 // used by choose_pixel_fmt() and below
 av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
@@ -437,7 +437,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
OutputFilter *ofilter,
 if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
 char args[255];
 AVFilterContext *filter;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 
 snprintf(args, sizeof(args), "%d:%d",
  ofilter->width, ofilter->height);
@@ -994,7 +994,7 @@ int configure_filtergraph(FilterGraph *fg)
 if (simple) {
 OutputStream *ost = fg->outputs[0]->ost;
 char args[512];
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 
 if (filter_nbthreads) {
 ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1d6d29cfc9..147048e914 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -249,7 +249,7 @@ static int show_hwaccels(void *optctx, const char *opt, 
const char *arg)
 /* return a copy of the input with the stream specifiers removed from the keys 
*/
 static AVDictionary *strip_specifiers(AVDictionary *dict)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 AVDictionary*ret = NULL;
 
 while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) {
@@ -1069,7 +1069,7 @@ static void dump_attachment(AVStream *st, const char 
*filename)
 {
 int ret;
 AVIOContext *out = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 
 if (!st->codecpar->extradata_size) {
 av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream 
#%d:%d.\n",
@@ -1105,7 +1105,7 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 int err, i, ret;
 int64_t timestamp;
 AVDictionary *unused_opts = NULL;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 char *   video_codec_name = NULL;
 char *   audio_codec_name = NULL;
 char *subtitle_codec_name = NULL;
@@ -2204,7 +2204,7 @@ static int open_output_file(OptionsC

[FFmpeg-devel] [PATCH 1/6] doc/examples/metadata.c: constify values from av_dict_get().

2021-10-18 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are internal to 
AVDictionary.

Signed-off-by: Chad Fraleigh 
---
 doc/examples/metadata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/examples/metadata.c b/doc/examples/metadata.c
index b6cfa6bd36..7c44009a24 100644
--- a/doc/examples/metadata.c
+++ b/doc/examples/metadata.c
@@ -34,7 +34,7 @@
 int main (int argc, char **argv)
 {
 AVFormatContext *fmt_ctx = NULL;
-AVDictionaryEntry *tag = NULL;
+const AVDictionaryEntry *tag = NULL;
 int ret;
 
 if (argc != 2) {
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 6/6] libavutil/: constify values from av_dict_get().

2021-10-01 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are 
internal to AVDictionary.


Signed-off-by: Chad Fraleigh 
---
 libavutil/hwcontext_qsv.c| 2 +-
 libavutil/hwcontext_vulkan.c | 6 +++---
 libavutil/opt.c  | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index c18747f7eb..23023c005d 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1451,7 +1451,7 @@ static int qsv_device_create(AVHWDeviceContext 
*ctx, const char *device,

 enum AVHWDeviceType child_device_type;
 AVHWDeviceContext *child_device;
 AVDictionary *child_device_opts;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
  mfxIMPL impl;
 int ret;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2c3216857a..259fa12cba 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -545,7 +545,7 @@ static int check_extensions(AVHWDeviceContext *ctx, 
int dev, AVDictionary *opts,

 int optional_exts_num;
 uint32_t sup_ext_count;
 char *user_exts_str = NULL;
-AVDictionaryEntry *user_exts;
+const AVDictionaryEntry *user_exts;
 VkExtensionProperties *sup_ext;
 const VulkanOptExtension *optional_exts;
 @@ -671,7 +671,7 @@ static int create_instance(AVHWDeviceContext *ctx, 
AVDictionary *opts)

 VulkanDevicePriv *p = ctx->internal->priv;
 VulkanFunctions *vk = >vkfn;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
-AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0);
+const AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", 
NULL, 0);
 const int debug_mode = debug_opt && strtol(debug_opt->value, NULL, 
10);

 VkApplicationInfo application_info = {
 .sType  = VK_STRUCTURE_TYPE_APPLICATION_INFO,
@@ -1246,7 +1246,7 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,

 {
 int err = 0;
 VkResult ret;
-AVDictionaryEntry *opt_d;
+const AVDictionaryEntry *opt_d;
 VulkanDevicePriv *p = ctx->internal->priv;
 VulkanFunctions *vk = >vkfn;
 AVVulkanDeviceContext *hwctx = ctx->hwctx;
diff --git a/libavutil/opt.c b/libavutil/opt.c
index c7001dbcd3..51b9157c2e 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1633,7 +1633,7 @@ void av_opt_free(void *obj)
  int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 AVDictionary*tmp = NULL;
 int ret;
 @@ -2005,8 +2005,8 @@ int av_opt_is_set_to_default(void *obj, const 
AVOption *o)

 case AV_OPT_TYPE_DICT: {
 AVDictionary *dict1 = NULL;
 AVDictionary *dict2 = *(AVDictionary **)dst;
-AVDictionaryEntry *en1 = NULL;
-AVDictionaryEntry *en2 = NULL;
+const AVDictionaryEntry *en1 = NULL;
+const AVDictionaryEntry *en2 = NULL;
 ret = av_dict_parse_string(, o->default_val.str, "=", 
":", 0);

 if (ret < 0) {
 av_dict_free();
--
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 5/6] libavformat/: constify values from av_dict_get().

2021-10-01 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are 
internal to AVDictionary.


Signed-off-by: Chad Fraleigh 
---
 libavformat/aiffenc.c   |  2 +-
 libavformat/apetag.c|  2 +-
 libavformat/asfenc.c|  8 +++
 libavformat/au.c|  2 +-
 libavformat/avidec.c|  2 +-
 libavformat/avienc.c|  2 +-
 libavformat/avio.c  |  4 ++--
 libavformat/cafenc.c|  2 +-
 libavformat/dashenc.c   |  6 ++---
 libavformat/dvenc.c |  2 +-
 libavformat/ffmetaenc.c |  2 +-
 libavformat/fifo.c  |  2 +-
 libavformat/flacdec.c   |  2 +-
 libavformat/flacenc.c   |  4 ++--
 libavformat/flvdec.c|  2 +-
 libavformat/flvenc.c|  2 +-
 libavformat/gxfenc.c|  2 +-
 libavformat/hls.c   |  4 ++--
 libavformat/http.c  |  8 +++
 libavformat/id3v2.c |  6 ++---
 libavformat/id3v2enc.c  |  8 +++
 libavformat/matroskadec.c   |  2 +-
 libavformat/metadata.c  |  2 +-
 libavformat/mov.c   |  6 ++---
 libavformat/movenc.c| 44 ++---
 libavformat/mp3enc.c|  6 ++---
 libavformat/mpegtsenc.c |  6 ++---
 libavformat/mux.c   |  2 +-
 libavformat/mxfenc.c| 14 ++--
 libavformat/nutenc.c|  6 ++---
 libavformat/riffenc.c   |  2 +-
 libavformat/rmenc.c |  2 +-
 libavformat/sapenc.c|  2 +-
 libavformat/sdp.c   |  2 +-
 libavformat/segment.c   |  4 ++--
 libavformat/smjpegenc.c |  2 +-
 libavformat/soxenc.c|  2 +-
 libavformat/ttmlenc.c   |  2 +-
 libavformat/utils.c |  4 ++--
 libavformat/vorbiscomment.c |  6 ++---
 libavformat/wavenc.c|  4 ++--
 libavformat/webmdashenc.c   | 28 +++
 libavformat/wtvenc.c|  4 ++--
 43 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 24bc17400e..1f8e0dd670 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -82,7 +82,7 @@ static int put_id3v2_tags(AVFormatContext *s, 
AIFFOutputContext *aiff)

  static void put_meta(AVFormatContext *s, const char *key, uint32_t id)
 {
-AVDictionaryEntry *tag;
+const AVDictionaryEntry *tag;
 AVIOContext *pb = s->pb;
  if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 6f82fbe202..d94356f5a0 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -174,7 +174,7 @@ static int string_is_ascii(const uint8_t *str)
  int ff_ape_write_tag(AVFormatContext *s)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 int size, ret, count = 0;
 AVIOContext *dyn_bc;
 uint8_t *dyn_buf;
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index a0510df7dc..8632877117 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -355,7 +355,7 @@ static int asf_write_markers(AVFormatContext *s)
  for (unsigned i = 0; i < s->nb_chapters; i++) {
 AVChapter *c = s->chapters[i];
-AVDictionaryEntry *t = av_dict_get(c->metadata, "title", NULL, 0);
+const AVDictionaryEntry *t = av_dict_get(c->metadata, "title", 
NULL, 0);

 int64_t pres_time = av_rescale_q(c->start, c->time_base, scale);
 uint64_t offset;
 int32_t send_time = get_send_time(asf, pres_time, );
@@ -389,7 +389,7 @@ static int asf_write_header1(AVFormatContext *s, 
int64_t file_size,

 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
-AVDictionaryEntry *tags[5];
+const AVDictionaryEntry *tags[5];
 int header_size, extra_size, extra_size2, wav_extra_size;
 int has_title, has_aspect_ratio = 0;
 int metadata_count;
@@ -420,7 +420,7 @@ static int asf_write_header1(AVFormatContext *s, 
int64_t file_size,

 for (unsigned n = 0; n < s->nb_streams; n++) {
 AVStream *const st = s->streams[n];
 AVCodecParameters *const par = st->codecpar;
-AVDictionaryEntry *entry;
+const AVDictionaryEntry *entry;
  avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit 
pts in ms */
 @@ -599,7 +599,7 @@ static int asf_write_header1(AVFormatContext *s, 
int64_t file_size,

 end_header(pb, hpos);
 }
 if (metadata_count) {
-AVDictionaryEntry *tag = NULL;
+const AVDictionaryEntry *tag = NULL;
 hpos = put_header(pb, _asf_extended_content_header);
 avio_wl16(pb, metadata_count);
 while ((tag = av_dict_get(s->metadata, "", tag, 
AV_DICT_IGNORE_SUFFIX))) {

diff --git a/libavformat/au.c b/libavformat/au.c
index 9bd408f65c..a408e55e36 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -258,7 +258,7 @@ static int au_get_annotations(AVFormatContext *s, 
AVBPrint *annotations)

 };
 int cnt = 0;
 AVDictionary *m = s->metadata;
-AVDictio

[FFmpeg-devel] [PATCH 4/6] libavfilter/: constify values from av_dict_get().

2021-10-01 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are 
internal to AVDictionary.


Signed-off-by: Chad Fraleigh 
---
 libavfilter/avfilter.c  | 2 +-
 libavfilter/f_bench.c   | 2 +-
 libavfilter/f_drawgraph.c   | 2 +-
 libavfilter/f_metadata.c| 2 +-
 libavfilter/f_select.c  | 4 ++--
 libavfilter/vf_cover_rect.c | 2 +-
 libavfilter/vf_drawtext.c   | 2 +-
 libavfilter/vf_scale.c  | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index f325918021..c0573d53c9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -939,7 +939,7 @@ int avfilter_init_dict(AVFilterContext *ctx, 
AVDictionary **options)

 int avfilter_init_str(AVFilterContext *filter, const char *args)
 {
 AVDictionary *options = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 int ret = 0;
  if (args && *args) {
diff --git a/libavfilter/f_bench.c b/libavfilter/f_bench.c
index f7098adaf4..16ca17723b 100644
--- a/libavfilter/f_bench.c
+++ b/libavfilter/f_bench.c
@@ -69,7 +69,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 if (s->action == ACTION_START) {
 av_dict_set_int(>metadata, START_TIME_KEY, t, 0);
 } else if (s->action == ACTION_STOP) {
-AVDictionaryEntry *e = av_dict_get(in->metadata, 
START_TIME_KEY, NULL, 0);
+const AVDictionaryEntry *e = av_dict_get(in->metadata, 
START_TIME_KEY, NULL, 0);

 if (e) {
 const int64_t start = strtoll(e->value, NULL, 0);
 const int64_t diff = t - start;
diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c
index 9996eb3b0e..7cc1efb3d7 100644
--- a/libavfilter/f_drawgraph.c
+++ b/libavfilter/f_drawgraph.c
@@ -163,7 +163,7 @@ static int filter_frame(AVFilterLink *inlink, 
AVFrame *in)

 DrawGraphContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 AVDictionary *metadata;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 AVFrame *out = s->out;
 AVFrame *clone = NULL;
 int64_t in_pts, out_pts;
diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c
index cecfe62a9c..ee87a2b37f 100644
--- a/libavfilter/f_metadata.c
+++ b/libavfilter/f_metadata.c
@@ -306,7 +306,7 @@ static int filter_frame(AVFilterLink *inlink, 
AVFrame *frame)

 AVFilterLink *outlink = ctx->outputs[0];
 MetadataContext *s = ctx->priv;
 AVDictionary **metadata = >metadata;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
  e = av_dict_get(*metadata, !s->key ? "" : s->key, NULL,
 !s->key ? AV_DICT_IGNORE_SUFFIX: 0);
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 187e98a1a7..ab26676e57 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -304,8 +304,8 @@ static double get_scene_score(AVFilterContext *ctx, 
AVFrame *frame)

 static double get_concatdec_select(AVFrame *frame, int64_t pts)
 {
 AVDictionary *metadata = frame->metadata;
-AVDictionaryEntry *start_time_entry = av_dict_get(metadata, 
"lavf.concatdec.start_time", NULL, 0);
-AVDictionaryEntry *duration_entry = av_dict_get(metadata, 
"lavf.concatdec.duration", NULL, 0);
+const AVDictionaryEntry *start_time_entry = av_dict_get(metadata, 
"lavf.concatdec.start_time", NULL, 0);
+const AVDictionaryEntry *duration_entry = av_dict_get(metadata, 
"lavf.concatdec.duration", NULL, 0);

 if (start_time_entry) {
 int64_t start_time = strtoll(start_time_entry->value, NULL, 10);
 if (pts >= start_time) {
diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
index 0a8c10e06d..d3a9755234 100644
--- a/libavfilter/vf_cover_rect.c
+++ b/libavfilter/vf_cover_rect.c
@@ -135,7 +135,7 @@ static int filter_frame(AVFilterLink *inlink, 
AVFrame *in)

 {
 AVFilterContext *ctx = inlink->dst;
 CoverContext *cover = ctx->priv;
-AVDictionaryEntry *ex, *ey, *ew, *eh;
+const AVDictionaryEntry *ex, *ey, *ew, *eh;
 int x = -1, y = -1, w = -1, h = -1;
 char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = 
NULL;

 diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index b1ea58f30a..197163f426 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1032,7 +1032,7 @@ static int func_metadata(AVFilterContext *ctx, 
AVBPrint *bp,

  char *fct, unsigned argc, char **argv, int tag)
 {
 DrawTextContext *s = ctx->priv;
-AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0);
+const AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], 
NULL, 0);

  if (e && e->value)
 av_bprintf(bp, "%s", e->value);
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index a1902a13cf..698fbc4768 100644
--- a/libavfilter/vf_s

[FFmpeg-devel] [PATCH 3/6] libavcodec/: constify values from av_dict_get().

2021-10-01 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are 
internal to AVDictionary.


Signed-off-by: Chad Fraleigh 
---
 libavcodec/libaomenc.c | 2 +-
 libavcodec/libvpxenc.c | 4 ++--
 libavcodec/libx264.c   | 2 +-
 libavcodec/libx265.c   | 2 +-
 libavcodec/mjpegdec.c  | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 800fda0591..85e8fc0f0b 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -882,7 +882,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
  #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
  while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int ret = aom_codec_set_option(>encoder, en->key, 
en->value);

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 10e5a22fa9..ea92eb6221 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -910,7 +910,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 vpx_codec_caps_t codec_caps = vpx_codec_get_caps(iface);
 vpx_svc_extra_cfg_t svc_params;
 #endif
-AVDictionaryEntry* en = NULL;
+const AVDictionaryEntry* en = NULL;
  ctx->discard_hdr10_plus = 1;
 av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
@@ -1671,7 +1671,7 @@ static int vpx_encode(AVCodecContext *avctx, 
AVPacket *pkt,

 if (frame->pict_type == AV_PICTURE_TYPE_I)
 flags |= VPX_EFLAG_FORCE_KF;
 if (frame->metadata) {
-AVDictionaryEntry* en = av_dict_get(frame->metadata, 
"vp8-flags", NULL, 0);
+const AVDictionaryEntry* en = av_dict_get(frame->metadata, 
"vp8-flags", NULL, 0);

 if (en) {
 flags |= strtoul(en->value, NULL, 10);
 }
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 0f886713e3..e255432604 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -901,7 +901,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
 #endif
  {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 while (en = av_dict_get(x4->x264_params, "", en, 
AV_DICT_IGNORE_SUFFIX)) {
if ((ret = x264_param_parse(>params, en->key, 
en->value)) < 0) {

av_log(avctx, AV_LOG_WARNING,
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 7dd70a3450..ec50b8a77f 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -363,7 +363,7 @@ static av_cold int 
libx265_encode_init(AVCodecContext *avctx)

 }
  {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 while ((en = av_dict_get(ctx->x265_opts, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int parse_ret = ctx->api->param_parse(ctx->params, 
en->key, en->value);

 diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7f89641660..b22895cfe6 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2407,7 +2407,7 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)

 int i, index;
 int ret = 0;
 int is16bit;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
  s->force_pal8 = 0;
 -- 2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/6] fftools/: constify values from av_dict_get().

2021-10-01 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are 
internal to AVDictionary.


Signed-off-by: Chad Fraleigh 
---
 fftools/cmdutils.c  | 2 +-
 fftools/ffmpeg.c| 6 +++---
 fftools/ffmpeg_filter.c | 6 +++---
 fftools/ffmpeg_opt.c| 8 
 fftools/ffplay.c| 8 
 fftools/ffprobe.c   | 8 
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 2c8e98982f..d351ceb7fa 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -2106,7 +2106,7 @@ AVDictionary *filter_codec_opts(AVDictionary 
*opts, enum AVCodecID codec_id,
 AVFormatContext *s, AVStream *st, 
const AVCodec *codec)

 {
 AVDictionary*ret = NULL;
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
 intflags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
   : AV_OPT_FLAG_DECODING_PARAM;
 char  prefix = 0;
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 98c2421938..edbf3ac52a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -677,7 +677,7 @@ static void ffmpeg_cleanup(int ret)
  void remove_avoptions(AVDictionary **a, AVDictionary *b)
 {
-AVDictionaryEntry *t = NULL;
+const AVDictionaryEntry *t = NULL;
  while ((t = av_dict_get(b, "", t, AV_DICT_IGNORE_SUFFIX))) {
 av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE);
@@ -686,7 +686,7 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b)
  void assert_avoptions(AVDictionary *m)
 {
-AVDictionaryEntry *t;
+const AVDictionaryEntry *t;
 if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
 exit_program(1);
@@ -3243,7 +3243,7 @@ static int 
init_output_stream_streamcopy(OutputStream *ost)

  static void set_encoder_id(OutputFile *of, OutputStream *ost)
 {
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
  uint8_t *encoder_string;
 int encoder_string_len;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b798459946..c70903295f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -86,7 +86,7 @@ static enum AVPixelFormat choose_pixel_fmt(AVStream 
*st, AVCodecContext *enc_ctx

 static char *choose_pix_fmts(OutputFilter *ofilter)
 {
 OutputStream *ost = ofilter->ost;
-AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, 
"strict", NULL, 0);
+const AVDictionaryEntry *strict_dict = 
av_dict_get(ost->encoder_opts, "strict", NULL, 0);

 if (strict_dict)
 // used by choose_pixel_fmt() and below
 av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
@@ -437,7 +437,7 @@ static int configure_output_video_filter(FilterGraph 
*fg, OutputFilter *ofilter,

 if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
 char args[255];
 AVFilterContext *filter;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
  snprintf(args, sizeof(args), "%d:%d",
  ofilter->width, ofilter->height);
@@ -994,7 +994,7 @@ int configure_filtergraph(FilterGraph *fg)
 if (simple) {
 OutputStream *ost = fg->outputs[0]->ost;
 char args[512];
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
  if (filter_nbthreads) {
 ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1d6d29cfc9..147048e914 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -249,7 +249,7 @@ static int show_hwaccels(void *optctx, const char 
*opt, const char *arg)
 /* return a copy of the input with the stream specifiers removed from 
the keys */

 static AVDictionary *strip_specifiers(AVDictionary *dict)
 {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 AVDictionary*ret = NULL;
  while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) {
@@ -1069,7 +1069,7 @@ static void dump_attachment(AVStream *st, const 
char *filename)

 {
 int ret;
 AVIOContext *out = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
  if (!st->codecpar->extradata_size) {
 av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream 
#%d:%d.\n",
@@ -1105,7 +1105,7 @@ static int open_input_file(OptionsContext *o, 
const char *filename)

 int err, i, ret;
 int64_t timestamp;
 AVDictionary *unused_opts = NULL;
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 char *   video_codec_name = NULL;
 char *   audio_codec_name = NULL;
 char *subtitle_codec_name = NULL;
@@ -2204,7 +2204,7 @@ static int open_output_fi

[FFmpeg-devel] [PATCH 1/6] doc/examples/metadata.c: constify values from av_dict_get().

2021-10-01 Thread Chad Fraleigh
Treat values returned from av_dict_get() as const, since they are 
internal to AVDictionary.


Signed-off-by: Chad Fraleigh 
---
 doc/examples/metadata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/examples/metadata.c b/doc/examples/metadata.c
index b6cfa6bd36..7c44009a24 100644
--- a/doc/examples/metadata.c
+++ b/doc/examples/metadata.c
@@ -34,7 +34,7 @@
 int main (int argc, char **argv)
 {
 AVFormatContext *fmt_ctx = NULL;
-AVDictionaryEntry *tag = NULL;
+const AVDictionaryEntry *tag = NULL;
 int ret;
  if (argc != 2) {
--
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] Question regarding ogg cover art implementation

2021-08-22 Thread Chad Fraleigh

On 8/22/2021 4:49 PM, Jesse Obic wrote:

I'm looking at implementing https://trac.ffmpeg.org/ticket/4448 
, and I understand what I need to 
do but I'm on the fence about how I should go about doing it.


For the OGG container, cover art is embedded into the file by adding a 
METADATA_BLOCK_PICTURE tag in the vorbis comment section. The data of 
this tag is a base64 representation of the FLAC embedded image data 
structure, which includes the data of the image itself.


I looked at how vorbis comments are currently written, and it's lead me 
to `ff_vorbiscomment_write`. It takes in an AVDictionary for metadata, 
and an array of AVChapters for chapter writing. This is where I get a 
bit concerned.


I see two options as to how I could handle this:


1. Place the METADATA_BLOCK_PICTURE tag in the metadata AVDictionary.

This would be the easiest functionality wise, however it feels like a 
bad idea in my gut because the dictionary would be housing a value that 
is 1.33 * the size of the image(s) being embedded. So for example, if 
you wished to embed a 12 MB image it would require a 16MB malloc which 
doesn't feel right.


Would allocating 16M really be a lot, given typically there wouldn't be 
many of them?



2. Change ff_vorbiscomment_write to take in an array of AVStream / 
AVPacket to write it directly to the output IO stream


As far as I know this would classify as an API/ABI change. However it 
would mean that I don't have to allocate such a huge array upfront, and 
can encode smaller chunks at a time as I write them to the output stream.


To mitigate it, it could be created as a new function with the 
additional parameters, and the old function pointing towards the new one 
instead. I'm not entirely sure how APIs / ABIs are exposed and consumed 
in C, so I'm not sure if this will fix the issue.


What if.. LOB value reference support was added to AVDictionary, via a 
av_dict_set_lob() function and AVDictionaryEntry->lob field. And anytime 
av_dict_get() is called without a AV_DICT_NO_RESOLVE flag, it would 
simply do a lazy resolve if it lob != NULL and fill in value field (if 
not already resolved, of course). This would allow a LOB aware callers 
to stream it when it is a LOB (use 'value' when not NULL). It should 
even be API/ABI change safe (unless making AVDictionaryEntry bigger 
counts as a break).


Anyway.. just a third option.


Oh, and on a side note: av_dict_get() should _probably_ be changed to 
return a const AVDictionaryEntry * at some point, since it is internal 
and really should never be modified by the caller.


___
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".


Re: [FFmpeg-devel] [PATCH] [fateserver] Cleanup and security strengthening

2021-08-22 Thread Chad Fraleigh

On 8/22/2021 11:18 AM, Michael Niedermayer wrote:

On Sun, Aug 15, 2021 at 11:24:47AM +0200, Nicolas George wrote:

Nicolas George (12021-08-08):

Here is a patch series for fateserver, to fix warnings and enable Perl's
taint checks, thus protecting against a whole class of security issues.


I would appreciate somebody looks at the code before I deploy it and we
re-enable the server.


noone in the whole community cares about the server or everyone trusts you
to never make a mistake. At least when limited to people knowing perl and
having time.

seriously, if someone has time and knows perl, please look over this,
even if by the time you do, this has already been applied.

The sooner someone goes over this the sooner the fateserver is online
again


It mostly looks good (from a perl perspective).

Just 3 questionable items..

-<>-<>-

-if ($ENV{HTTP_ACCEPT_ENCODING} =~ /gzip/) {
-print "Content-Encoding: gzip\r\n";
+if (ready_for_gzip) {
 $cat = 'cat';
 }

The old code outputs "\r\n", where ready_for_gzip() outputs "\r\n\r\n". 
Will this be an issue, or should it have done that in the first place?


-<>-<>-

+sub ready_for_gzip() {
+my $ae = $ENV{HTTP_ACCEPT_ENCODING};
+if (defined($ae) && $ae =~ /gzip/) {

It is checking for 'gzip' as a substring, rather than a whole word. If 
it was passed a [hypothetical] encoding type contains the substring gzip 
(e.g. "bigzip"), it could trigger in incompatible output encoding. 
However, it's not any worse than it was previously.


Perhaps changing it to match /\bgzip\b/ ?

-<>-<>-

 sub ready_for_gzip() {
+# Under CGI, $PATH is safe
+($ENV{PATH}) = $ENV{PATH} =~ /(.*)/s;

It is untainting the PATH as "hidden" side effect of calling 
ready_for_gzip(). While technically it works, it feels a little kludgy 
compared to untainting it at the beginning of each taint-enabled script.



___
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".


Re: [FFmpeg-devel] [PATCH] avutils/opt: fix discarded-qualifiers compiler warning

2021-03-09 Thread Chad Fraleigh

On 3/9/2021 5:30 AM, Nuo Mi wrote:

On Tue, Mar 9, 2021 at 3:17 AM Chad Fraleigh  wrote:


On 2/14/2021 10:12 AM, Nuo Mi wrote:

On Mon, Feb 15, 2021 at 2:08 AM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:


Nuo Mi:

---
   libavutil/opt.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 590146b5fb..c554e9c063 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1735,7 +1735,7 @@ const AVClass *av_opt_child_class_iterate(const

AVClass *parent, void **iter)

   #if FF_API_CHILD_CLASS_NEXT
   FF_DISABLE_DEPRECATION_WARNINGS
   if (parent->child_class_next) {
-*iter = parent->child_class_next(*iter);
+*iter = (void*)parent->child_class_next(*iter);
   return *iter;
   }
   FF_ENABLE_DEPRECATION_WARNINGS


This doesn't look like a fix; you just silenced a warning.


Yes, but this the only way if we do not change the function signature.


Since a major release is "coming up", now could be the time to fix the
signature to '(..., const void **iter)' and eliminate the non-const cast
kludge across the board for these cases.


Are we plan to remove all warnings before the release?
Or more aggressively, is it feasible to treat all warnings as errors in the
future? :)


I was thinking of just the 14 or so opt iterator functions which are 
assign to an AVClass.child_class_iterate (and related code in opt.c / 
opt.h / their iterate callers), so they no longer have to do a de-const 
(void *) cast to update *iter.


Though, it seems av_filter_iterate() and av_bsf_iterate() (maybe 
others?) would need to (/should?) be changed too, as they do the same 
non-const argument and are directly chained by child_class_iterate 
functions.

___
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".

Re: [FFmpeg-devel] [PATCH] avutils/opt: fix discarded-qualifiers compiler warning

2021-03-08 Thread Chad Fraleigh

On 2/14/2021 10:12 AM, Nuo Mi wrote:

On Mon, Feb 15, 2021 at 2:08 AM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:


Nuo Mi:

---
  libavutil/opt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 590146b5fb..c554e9c063 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1735,7 +1735,7 @@ const AVClass *av_opt_child_class_iterate(const

AVClass *parent, void **iter)

  #if FF_API_CHILD_CLASS_NEXT
  FF_DISABLE_DEPRECATION_WARNINGS
  if (parent->child_class_next) {
-*iter = parent->child_class_next(*iter);
+*iter = (void*)parent->child_class_next(*iter);
  return *iter;
  }
  FF_ENABLE_DEPRECATION_WARNINGS


This doesn't look like a fix; you just silenced a warning.


Yes, but this the only way if we do not change the function signature.


Since a major release is "coming up", now could be the time to fix the 
signature to '(..., const void **iter)' and eliminate the non-const cast 
kludge across the board for these cases.



-Chad
___
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".

Re: [FFmpeg-devel] [PATCH V2 1/7] libavdevice/v4l2.c: fix build warning for [-Wformat-truncation=]

2021-02-25 Thread Chad Fraleigh



On 2/24/2021 10:38 PM, Guo, Yejun wrote:

Here is the warning message:
src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be truncated 
writing up to 255 bytes into a region of size 251 [-Wformat-truncation=]
  snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
   ^~
src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261 bytes 
into a destination of size 256
  snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
  ^~~~

Signed-off-by: Guo, Yejun 
---
  libavdevice/v4l2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 365bacd771..e11d10d20e 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, 
AVDeviceInfoList *device_l
  return ret;
  }
  while ((entry = readdir(dir))) {
-char device_name[256];
+char device_name[512];


Is there a portable path max constant that would be better for cases 
like this, rather than just picking another arbitrary buffer size?



  
  if (!v4l2_is_v4l_dev(entry->d_name))

  continue;


___
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".

Re: [FFmpeg-devel] [PATCH] avutils/opt: fix discarded-qualifiers compiler warning

2021-02-14 Thread Chad Fraleigh

On 2/14/2021 10:16 AM, Andreas Rheinhardt wrote:

Nuo Mi:

On Mon, Feb 15, 2021 at 2:08 AM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:


Nuo Mi:

---
  libavutil/opt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 590146b5fb..c554e9c063 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1735,7 +1735,7 @@ const AVClass *av_opt_child_class_iterate(const

AVClass *parent, void **iter)

  #if FF_API_CHILD_CLASS_NEXT
  FF_DISABLE_DEPRECATION_WARNINGS
  if (parent->child_class_next) {
-*iter = parent->child_class_next(*iter);
+*iter = (void*)parent->child_class_next(*iter);
  return *iter;
  }
  FF_ENABLE_DEPRECATION_WARNINGS


This doesn't look like a fix; you just silenced a warning.


Yes, but this the only way if we do not change the function signature.


Suppressing a warning that something isn't right (i.e. that maybe the 
function signature *should* be changed) probably isn't ideal, except as 
a last resort. The fact that the documentation literally says to do the 
cast this patch is trying to do only compounds the problem.


I can understand wanting to use 'void *' for the context, in order to 
hide the underlying implementation. But since the documentation has 
already implied an implementation, hiding it may be moot. However, in 
any implementation, it really should be 'const void **', as iteration 
should have no internal side effects.


This leads back to the original statement of not covering up the problem 
(i.e. no nothing now -- but not just because it's deprecated) and 
encourage a signature change to be done (at an appropriate API breakage 
point).




There is another way: Do nothing. The code in question is deprecated and
will therefore eventually be removed.

___
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".

Re: [FFmpeg-devel] [PATCH 2/8] avformat/mov: Support size = 1 and size = 0 special cases in probing

2021-02-06 Thread Chad Fraleigh

On 2/6/2021 9:22 AM, Michael Niedermayer wrote:

Signed-off-by: Michael Niedermayer 
---
  libavformat/mov.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9406e42f49..70f76caff5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7113,6 +7113,11 @@ static int mov_probe(const AVProbeData *p)
  if ((offset + 8) > (unsigned int)p->buf_size)
  break;
  size = AV_RB32(p->buf + offset);
+if (size == 1 && offset + 16 > (unsigned int)p->buf_size) {
+size = AV_RB64(p->buf+offset + 8);


Just curious, what happens when size == 1 and the buffer is too small? 
Is leaving it as a size of 1 still valid, or should it be handled as a 
format error (e.g. abort the loop)?




+} else if (size == 0) {
+size = p->buf_size - offset;
+}
  tag = AV_RL32(p->buf + offset + 4);
  switch(tag) {
  /* check for obvious tags */


___
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".

Re: [FFmpeg-devel] [PATCH] avformat/hls: change sequence number type to int64_t

2021-01-15 Thread Chad Fraleigh


On 1/15/2021 3:41 AM, Zhao Zhili wrote:

Fix atoi() overflow for large EXT-X-MEDIA-SEQUENCE.

The spec says the type of sequence number is uint64_t. Use int64_t
here since current implementation requires it to be signed integer,
and hlsenc use int64_t too.
---
  libavformat/hls.c | 49 ---
  1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 619e4800de..56f1103a11 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,13 +112,13 @@ struct playlist {


...


  if (is_http && !in && c->http_persistent && c->playlist_pb) {
  in = c->playlist_pb;
@@ -811,7 +811,7 @@ static int parse_playlist(HLSContext *c, const char *url,
  ret = ensure_playlist(c, , url);
  if (ret < 0)
  goto fail;
-pls->start_seq_no = atoi(ptr);
+pls->start_seq_no = strtoll(ptr, NULL, 10);


Would it be better it use strtoull() to correctly parse the spec'd 
value, then check if it is in int64_t range before assigning the 
implementation's sequence number (and handling out of range values 
appropriately)?




  } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", )) {


...
___
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".

Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: add memory alloc checks

2021-01-07 Thread Chad Fraleigh



On 1/7/2021 2:43 AM, lance.lmw...@gmail.com wrote:

From: Limin Wang 

Signed-off-by: Limin Wang 
---
  libavformat/udp.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 798b789..e6d1235 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -891,6 +891,10 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
  if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && 
s->circular_buffer_size)) {
  /* start the task going */
  s->fifo = av_fifo_alloc(s->circular_buffer_size);
+if (s->fifo) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}


Is this suppose to be  "if (!s->fifo)"  [i.e. fail on NULL] instead?



  ret = pthread_mutex_init(>mutex, NULL);
  if (ret != 0) {
  av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
strerror(ret));


___
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".

Re: [FFmpeg-devel] Patch for IPC SHM

2019-07-23 Thread Chad Fraleigh


On 7/22/2019 11:14 AM, aran.clau...@wwu.edu wrote:


+static void rm_shmid(AVFormatContext *s) {
+XCBGrabContext *c = s->priv_data;
+if(c->shmid != -1) {
+  shmctl(c->shmid, IPC_RMID, 0);
+  c->shmid == -1;

 ^^
  Assignment/compare operator mismatch.



+}
+}
+

___
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".