From patchwork Sat Sep 24 14:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 38210 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1156549pzh; Sat, 24 Sep 2022 07:37:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6x7zUVTnsY+PUcJp8d6aIg4+2lYYNSmpqNJbOZX4BTYfz8Ks/H5QN4KDUdYmpTDda9I8X4 X-Received: by 2002:a17:907:7629:b0:776:a147:8524 with SMTP id jy9-20020a170907762900b00776a1478524mr11628923ejc.632.1664030241700; Sat, 24 Sep 2022 07:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664030241; cv=none; d=google.com; s=arc-20160816; b=DRoI4XfUxzFRnOItaRV6SMC8AmUeTYROQMGsYOzrs/F7LG6pymtLFPxXaTVJCLsMlc cotzXD0FfWlPZe6colc6uF8N3FIU+bvpzKRwrs/sn0aEn4U1qnhPWeGNx5Avr+e6wO71 NT0iPCUgFj3uUQEGisCdAwbYUX3QDmQ7/3solQL661B8RKMPHJcxd7ByEu0Mq79b/zzv jvUqIyVRgs1FPVGOSwwpQtTX07BjjISOohdK2fsyECcNScN/sKZvZZ3k8U08MoJojRmU iWMTqAgfvfNcFlOotuTgQtd2YfwCToU/f214wI58tom+CxNE1uMKoDTIhjlC9ZEKvAE2 LVyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=sp4Xn9VpvgKC1+gT+I6n4iduEexynkaArupuP/+7mT8=; b=dYkPgD81ft9RW4ZYXDZZ9Cq4f75rwyvu9U01+DEnZNIout3UPZNVHU998p9UX3+IE/ EOlZRNF9tdNbPw4ZKsmoSQKIjglPrr96SJafh+h9TKS1P44HtjtFSBghSGlbgkY5dhrB kXUVHF0RXhoy7Tnx2LT2EGwWXrGDQpfjHqXShFWr7D+h+4cnd1t3iQbJM59EOSWb0R/C 1+Vu0LnYMsV+iVG6TN2yr/X9s9vbuEtcqF1s7r8rTFxd9U4gaX4RoVtA82Nw2oijIXKR 2+kwghmkLUlyqYO4YLBR/ElBCDizq5yd68Yd/5x8MpDwmvUneQ5vQ4cruyK+m1KkG4Yo uZOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=VcHUKaTS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sa27-20020a1709076d1b00b007825337afeesi7486988ejc.273.2022.09.24.07.37.20; Sat, 24 Sep 2022 07:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=VcHUKaTS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 128FB68B8FD; Sat, 24 Sep 2022 17:37:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4286268B411 for ; Sat, 24 Sep 2022 17:37:10 +0300 (EEST) Received: by mail-ed1-f43.google.com with SMTP id x21so3624358edd.11 for ; Sat, 24 Sep 2022 07:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=UkuEQkGu+bvxY35c3Y82bttZvxcY/TmDGlsNt3T/fbg=; b=VcHUKaTSyX2VJzyZlvlSGVq260b06G9ziqdjXA+mAaG3jQ45LiqcBwHKq+6My1oY+k YKTroa7qor1ma3HQsHr2ZZDJUaCsiYfTrKT8JUNRbtuUaMTDpTrfNCpTtfwgPKyuVmiC DkoNRx9RlEsQNMF2GHGdT0/78YstNr2jzgIsOSsCOtcCzZekt0+cpTkHHSfPcVo9vntl 3GLMC74Qm+Tv2OdjBR9BB0Gd7rJilGqZdvDED/QsflQQusBnkgqadGZowGFQRNfD7/tm Mq9x9rxlMy369X3bUnY2dSVhLbLQdWJY80nGPkmQOXczbYtcYUrjf4c5JcgtELlUHIOL 4ZvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=UkuEQkGu+bvxY35c3Y82bttZvxcY/TmDGlsNt3T/fbg=; b=he2Grm6byTEArZGeEDpHRihUGzxY7Unt6LCdJvDjn5CqBx9341TB8aiWRIlZsNB+D/ 7MFKN20hP9y/nTT3dOZEOFm2+v2gtm60DgXRt1JMQLHwSlQ9AcYjU+Vdj1P7FLZ9unlC DUG+6tbUFbJCGMBYZR/j+G8uPEUOcjxohqSr26WjFfeBF6y1kOBxG42F1XaxleFnzfMf hwfMk+K7XqehiiRsiXIzoFOE58vceq9Rn5oCp7L+JLeLgeuEqgx0dBEpBrmdgKfLMbI8 t7wJoAWSUyh9Fj3NQqUJMUS1SSyRx7JhWd974N8X7ay3f5lZ+hD4eTWsCNZs4/SsOK0b No8g== X-Gm-Message-State: ACrzQf3Yx9O5vvffHkMxlW23hRq6FE20LA3078QcxYUIlSJiXR9zLM36 5saT/2IxukKTt3k90WhnoN6GRonhj2Ff2g== X-Received: by 2002:aa7:cb0b:0:b0:456:e744:79e5 with SMTP id s11-20020aa7cb0b000000b00456e74479e5mr4953656edt.191.1664030229578; Sat, 24 Sep 2022 07:37:09 -0700 (PDT) Received: from MBP-von-Marvin.citadel.scalie.me (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id u17-20020a50c2d1000000b0044e8d0682b2sm7970504edf.71.2022.09.24.07.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 07:37:09 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Sep 2022 16:36:55 +0200 Message-Id: <20220924143659.74756-1-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220922020216.46589-1-epirat07@gmail.com> References: <20220922020216.46589-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/5] avutil/dict: Add av_dict_iterate X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fmJxy0C1KP5k This is a more explicit iteration API rather than using the "magic" av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX) which is not really trivial to grasp what it does when casually reading through code. --- libavutil/dict.c | 19 +++++++++++++++++++ libavutil/dict.h | 46 +++++++++++++++++++++++++++++++++++---------- libavutil/version.h | 4 ++-- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index 14ad780a79..ee059d712c 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -20,6 +20,7 @@ #include +#include "avassert.h" #include "avstring.h" #include "dict.h" #include "dict_internal.h" @@ -38,6 +39,24 @@ int av_dict_count(const AVDictionary *m) return m ? m->count : 0; } +const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m, + const AVDictionaryEntry *prev) +{ + int i = 0; + + if (!m) + return NULL; + + if (prev) + i = prev - m->elems + 1; + + av_assert2(i >= 0); + if (i >= m->count) + return NULL; + + return &m->elems[i]; +} + AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) { diff --git a/libavutil/dict.h b/libavutil/dict.h index 0d1afc6c64..344afb452b 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -32,6 +32,8 @@ #include +#include "attributes.h" + /** * @addtogroup lavu_dict AVDictionary * @ingroup lavu_data @@ -43,9 +45,9 @@ * an AVDictionary, simply pass an address of a NULL pointer to * av_dict_set(). NULL can be used as an empty dictionary wherever * a pointer to an AVDictionary is required. - * Use av_dict_get() to retrieve an entry or iterate over all - * entries and finally av_dict_free() to free the dictionary - * and all its contents. + * Use av_dict_get() to retrieve an entry and av_dict_iterate() to + * iterate over all entries and finally av_dict_free() to free the + * dictionary and all its contents. * @code AVDictionary *d = NULL; // "create" an empty dictionary @@ -57,8 +59,8 @@ char *v = av_strdup("value"); // you can avoid copying them like this av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { - <....> // iterate over all entries in d + while (t = av_dict_iterate(d, t)) { + <....> // iterate over all entries in d } av_dict_free(&d); @endcode @@ -89,9 +91,6 @@ typedef struct AVDictionary AVDictionary; * The returned entry key or value must not be changed, or it will * cause undefined behavior. * - * To iterate through all the dictionary entries, you can set the matching key - * to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag. - * * @param prev Set to the previous matching element to find the next. * If set to NULL the first matching element is returned. * @param key matching key @@ -101,6 +100,33 @@ typedef struct AVDictionary AVDictionary; AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); +/** + * Iterate over a dictionary + * + * Iterates through all entries in the dictionary. + * + * @warning The returned AVDictionaryEntry key/value must not be changed. + * + * @warning As av_dict_set() invalidates all previous entries returned + * by this function, it must not be called while iterating over the dict. + * + * Typical usage: + * @code + * const AVDictionaryEntry *e = NULL; + * while ((e = av_dict_iterate(m, e))) { + * // ... + * } + * @endcode + * + * @param m The dictionary to iterate over + * @param prev Pointer to the previous AVDictionaryEntry, NULL initially + * + * @retval AVDictionaryEntry* The next element in the dictionary + * @retval NULL No more elements in the dictionary + */ +const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m, + const AVDictionaryEntry *prev); + /** * Get number of entries in dictionary. * @@ -115,8 +141,8 @@ int av_dict_count(const AVDictionary *m); * Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set, * these arguments will be freed on error. * - * Warning: Adding a new entry to a dictionary invalidates all existing entries - * previously returned with av_dict_get. + * @warning Adding a new entry to a dictionary invalidates all existing entries + * previously returned with av_dict_get() or av_dict_iterate(). * * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL * a dictionary struct is allocated and put in *pm. diff --git a/libavutil/version.h b/libavutil/version.h index 0585fa7b80..9c44cef6aa 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 102 +#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From patchwork Sat Sep 24 14:36:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 38211 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1156639pzh; Sat, 24 Sep 2022 07:37:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7J90PePpVOIPgNJLu+2BoP4NJ6FhQH94m6ZhSKRgdYCAjQMBv3APM0PEluMUxtSZHkF9Dv X-Received: by 2002:a17:907:2c4b:b0:77e:2c09:4111 with SMTP id hf11-20020a1709072c4b00b0077e2c094111mr11772328ejc.21.1664030252228; Sat, 24 Sep 2022 07:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664030252; cv=none; d=google.com; s=arc-20160816; b=IsbyRuNMUvxrykks+5QJSme6yYlE2vs//ctdLTr+9llQR9M8/0WLCG8EiyU1CNRgaI GQr9mno5l9poNDzEDGIJz//bMLbmoZMTENOmpbxx9pOUz+PLW9y1UAVONnDaMskqQOw7 kvpbTKJt+XbZB+Y3EeTEYuuzf/5hJTb/jM4926PW95sSxUXzcjE/WEPWRSm2HpMHvE3N fht0J3//3wSjiZllHQlDDx+GwEd/mqbR0+2SZ+lLYpCSMh2xajU8MX+vHB//vyhMV5jl IeHw/wQjqlLeXfb4vMrZFdv6kM4utQzEHv6DlrpzXHqpzhF0O7luqKKPRVyEvkBmHCLP DuUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=UQkQUYN/3TWm3uuSxcFhKpnjfiNTjXca2iOG6itClWg=; b=X75PRDOG/rcFnwUSjgT628LCVJiwmhcAHoR8wIcBE676uzvE9OdpTVWOu8e0HuPv3T 5tmVd68CvLNK2dU3YQiFS8F0pUv2LLppemt4EsXU/EnyOPGQpJ8mmDICdjIeTVTMp/9j GAejJFW41yPF6Ogf2dPc6Vmug0MlmtJM62vnbpwgxZciqjz+NEvyP/xLO7m4E/V5wYq6 x2pyqVXK0i3q6fM7W4Jsn4HUSe514O0QsNv/OdUjbkpw0wCGqrNBrtIA+1AuJddfenqk ZdeY2+8kOYBXMRDsm0rQhn8y7idV/ag/CufR2GtoIX/HJsy025arZZmrI6aBg+WTPzKj U2OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=IVwEwus4; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z16-20020a05640235d000b0044e78dbb615si12159779edc.379.2022.09.24.07.37.31; Sat, 24 Sep 2022 07:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=IVwEwus4; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 47BB068B973; Sat, 24 Sep 2022 17:37:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3CB7468B6AC for ; Sat, 24 Sep 2022 17:37:14 +0300 (EEST) Received: by mail-ej1-f41.google.com with SMTP id 13so5994405ejn.3 for ; Sat, 24 Sep 2022 07:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OqhVdOIJGE0bLt7Zvcq0qVDWcpr9akZSMX5yMWcmLeY=; b=IVwEwus4urZS/7iUnFpcm/aJQr5R1qbZVRwiCeeyaoDF7KCdj+sVKUw/PDrlbEOeFo RnjYTBcZKf1W/4SLqJlPnHKQNiC1CIec0JnCaeQXM5kX2XhNevJPt8eu0yOxtmFr+IhD u2f6td/8re2vJVwt1tbZ4Q8JWFVR/R21ox4CXJs+x9Nb8b9MUAcPOznmIEDAeaxY53qj Q8+UJY6mZ0NuI3an59bpz1AZLXq8Lurj1181TkHzNZwV49zcQRDa7JCg0LiYRsYLXaF+ TEYM+h47ed+WpJ9UDknzU+3hOm3/UA2snuN9PEE7/1j0SE7wLXt9BHjBKi/UV4JjI1bp ugSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OqhVdOIJGE0bLt7Zvcq0qVDWcpr9akZSMX5yMWcmLeY=; b=7ehPcsx9DKOjNPX8V/LT5UJykFaV6Hi/8/omA8DSPbHXexW6hHxQq1BUDL1LNQYfkY Yb0kHcV/wttLjkkGNePy4xvJv5ORBxyY9l4bSKz5jgw+eHhyP4/jF2N32d3lfpTWN1qO hNRAV14xZqJX5EtsGWq7dWxkQgbML0u+Odt1nU2x5jMb6ka1xncklzxrPYJc8NajwxLA Zs8rTnEljVx4JT7Itd5/mj3/Y15fWwVrhHDeNb5egg6fxwnrGV2WuXC46YPkF/rS1vLR 3IILIpxY4adlSsWlyoKnzaiwVyrlVZbVobdVmwur9T8uYyZkBjOQTH5wkMX4IvCDjR0o ovWA== X-Gm-Message-State: ACrzQf1yFWmh19hxclhHMeIS5MsVj/q/l7QyPlD4CErcJz7loGfuk8Rx GZFKrf/fWqeLQvNbo3b3NKtNtMPjC0vsDA== X-Received: by 2002:a17:907:3f28:b0:781:e093:d0db with SMTP id hq40-20020a1709073f2800b00781e093d0dbmr11212126ejc.295.1664030233676; Sat, 24 Sep 2022 07:37:13 -0700 (PDT) Received: from MBP-von-Marvin.citadel.scalie.me (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id u17-20020a50c2d1000000b0044e8d0682b2sm7970504edf.71.2022.09.24.07.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 07:37:13 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Sep 2022 16:36:56 +0200 Message-Id: <20220924143659.74756-2-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220924143659.74756-1-epirat07@gmail.com> References: <20220922020216.46589-1-epirat07@gmail.com> <20220924143659.74756-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/5] avutil/dict: Use av_dict_iterate in av_dict_get X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 5+nGFoOMRK0q --- libavutil/dict.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index ee059d712c..ea03590d0f 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -60,18 +60,14 @@ const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m, AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) { - unsigned int i, j; + const AVDictionaryEntry *entry = prev; + unsigned int j; - if (!m || !key) + if (!key) return NULL; - if (prev) - i = prev - m->elems + 1; - else - i = 0; - - for (; i < m->count; i++) { - const char *s = m->elems[i].key; + while ((entry = av_dict_iterate(m, entry))) { + const char *s = entry->key; if (flags & AV_DICT_MATCH_CASE) for (j = 0; s[j] == key[j] && key[j]; j++) ; @@ -82,7 +78,7 @@ AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, continue; if (s[j] && !(flags & AV_DICT_IGNORE_SUFFIX)) continue; - return &m->elems[i]; + return (AVDictionaryEntry *)entry; } return NULL; } From patchwork Sat Sep 24 14:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 38212 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1156696pzh; Sat, 24 Sep 2022 07:37:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KCK/Dlib1wkv+6XG8qJHyPv/BMv+L2vfIPfEnCT9tFWuAkLukdiPDKTmDGlJan6a9usTn X-Received: by 2002:a17:907:2d09:b0:781:d793:f51e with SMTP id gs9-20020a1709072d0900b00781d793f51emr11161604ejc.628.1664030260201; Sat, 24 Sep 2022 07:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664030260; cv=none; d=google.com; s=arc-20160816; b=fcHTSx5p1KudzkqtlRzyF28P42tCYgVfHQKp05Ri55Bh7pRX9B0RAETJvYxJ7btvHR PI/uUi7G5Be4GHZVxRAX7xXVTe+3bI7QKgIEZQttgByLNw2MF3IbGN6X+rMGoXa7zMer AdVHU8vZD3g8guDp/476LqY83uHFPFQpk6ryqJT0qZ/f/N7Duo5o5yGJu1yYxySYXOoK AKJdMMEVp3ISd7aNEtG/QWEymKlqbZaPRJeheI2cF1zq3uHOLF1eBJE6/QciDglCicC2 5MKXA8rcfwby8Z3xx+f32D5/ob1Nn39iiFgD1nOALh3kEfIYfq1efnYRpXSrlosY/Bwf GvJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=2mWAaf8eekjOMBzJMPJkBATvzMXzRo4fAnqdlOFMEeQ=; b=wUc6iP9NHLBuKWR8XtxdClMDUPG1Ew+kzKwIqB4wcDaumAhOo6H89CMRgaaX0UyY1E /MRGUNVn30aZZnDf6VkFi3Tw25ALAoL7WxTi++nthc76RQwgPE23j4oROFewMmkHJOz3 5AusPCzOl0PCTJHtTceCbOHZ/5FltSP1U+B7260UWaNj5An9UgiNyJn3o1G+RRflAKCm InYRKDvDN2ptojoqzaJKMkKgYx8UOv5W03nskAqhchpdt8SCF0mck8QOq9/zSV37x8AF Kdoy/Me3LxR+IsbnSUM3vWKLwCg+U6MSH7GbwHZFKMZonWgIH6dZ1vGZnNARu5Fb9ki+ 6rbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=pzyUbFjK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g37-20020a056402322500b0044ef9c83492si11437318eda.472.2022.09.24.07.37.39; Sat, 24 Sep 2022 07:37:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=pzyUbFjK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D48468B9B9; Sat, 24 Sep 2022 17:37:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC1F668B4CC for ; Sat, 24 Sep 2022 17:37:15 +0300 (EEST) Received: by mail-ed1-f52.google.com with SMTP id e18so3682239edj.3 for ; Sat, 24 Sep 2022 07:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xTQoRwkaxW50yNkv6DgExs7I+KGIR9+7ucdxtZrnTtI=; b=pzyUbFjKQID4K+/qXyJgM4LkTChAXTa5NF59LaoCTN5i9Mb+BfkpZPPEMBGKxtom7j fTFHHwoZag5xtdd2J+BgHO9f+CfjUcGzG5dbZn287p6jCGsIrrhmRbfYWHC4TNCHmwW3 pXPXQvZV16wnnQLh+jLF404X04lygMjVRZNLFWC3lczYdb/Ju6wtdswuqE/IlS46hwg0 0zzAgQxv8bY/mT1MQSlOEwroA6VhNy3bR97ppKFfQC1yd/qYV2Pl33NAadsNboKaKQ8r qPST64ZWgXSX9lk8zC855e3GlFWBEwyW/H7DxSn07sKxgfNZqFDgf9Az5PDgdQyt/ALy Tkhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xTQoRwkaxW50yNkv6DgExs7I+KGIR9+7ucdxtZrnTtI=; b=FQYdjM+Oc8T/2q4LWzjYhdpJgYWflQkg6FOOFdWwOMl1aO6lymErv18+w1xn5vIOhd EeTSaFvmECpjR/yjIrON3QCpiWOGMJjyhwo7SjPbTPKi0lDlNLJQqj7sAimpMKr92Vld Vb47/Y7dTTEMlKmc8xhhl/S1Ehzhr9K+LcEEdmVZ+vH0enpB9wStdIMrV/kljTTPJRtr 07S4gvB+O2LOHUB6eEb3WADGp0O0gPyqevKU+S+wgwCvisTYWzjy7vRob8rjNrZ1Zcdq dzjwrx/MKZ8gh4ACyTU0ryubqpyHeZzkehhi2aHkWW7cKy6+Jeb0waP1HIaoi/nYoH5K SkIA== X-Gm-Message-State: ACrzQf0PrfEN830uim/n2AAYuitYcojXJLduqx1rEBZF6KDjQOvP9u7W jzkXL50+4AQaRxAliZQ8GHgBLRoGj1YKJA== X-Received: by 2002:a05:6402:1e8d:b0:441:58db:b6a2 with SMTP id f13-20020a0564021e8d00b0044158dbb6a2mr13337952edf.277.1664030235324; Sat, 24 Sep 2022 07:37:15 -0700 (PDT) Received: from MBP-von-Marvin.citadel.scalie.me (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id u17-20020a50c2d1000000b0044e8d0682b2sm7970504edf.71.2022.09.24.07.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 07:37:14 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Sep 2022 16:36:57 +0200 Message-Id: <20220924143659.74756-3-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220924143659.74756-1-epirat07@gmail.com> References: <20220922020216.46589-1-epirat07@gmail.com> <20220924143659.74756-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/5] avutil/dict: Use av_dict_iterate in av_dict_copy X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GcrAGowpSmpA --- libavutil/dict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index ea03590d0f..3c05ed4c84 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -236,9 +236,9 @@ void av_dict_free(AVDictionary **pm) int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags) { - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; - while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX))) { + while ((t = av_dict_iterate(src, t))) { int ret = av_dict_set(dst, t->key, t->value, flags); if (ret < 0) return ret; From patchwork Sat Sep 24 14:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 38213 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1156747pzh; Sat, 24 Sep 2022 07:37:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM691IWXg5T8RJ/tBEYvIMdOAqHNbymdMlDHbm3LWTQzjp3owOvBiDUHY/tBjmGbUJh1P9D2 X-Received: by 2002:a17:906:6a8d:b0:741:6a3b:536e with SMTP id p13-20020a1709066a8d00b007416a3b536emr11366745ejr.11.1664030269038; Sat, 24 Sep 2022 07:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664030269; cv=none; d=google.com; s=arc-20160816; b=NyJIv+Oiic7sQn+nYLiiSIiTOpAD/uJs9OfVwdHTiYK3OKhxmxbSEIfK+KKjH/fa2y S3qZMyvR5XlxHyviRF9k5oudqUgQh6RQsUZvUPusicSdNg821kBtm8XBZEQQRnXW4zHk MpqzxC5jQeBVrv7PQXwsTT/MmUwVOFDzXXeWypGXccy2t2t/d2glZYrkUNPCEdOo1F7w aQsP7lHLcu8hn5/3HrCNC6sVz1V2L48oUj9JS2LdWEXc330lcY2cg3P0VVSnQGmgoEst DzylVAEBamN+sB0u9EejpouJnTaoWV/LDgj8Vd037LJOGbUSAqUocx2JjEKsXmLw2fia vhqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=ZjznEwAmZHySdVwBshnWTHlenqz4+JbDPEosxPttNHE=; b=ZV7H08FNAYiGARPkQDWOkoavMX15Ylv1him9pcjtfZ7ZixPNjb4gg/6pigAbsTUYr2 M4SGA73OD69opcCyhAuzdyXopbKJSdCOmjRGE9978OJfg3S2Jd1vIcAnTwmdsDGaXz+b LDHD71JagwmXuIbi39Vq/1aJxzag4vbrgiM8FFwEQQl7KxQQILQbYuT2fMSM1p6wdkc2 mh4HiiOwaEtUwXiSFBPN2X1e+DsYhPg5BiT9I0ABG7T/e8VsvclI9aLDSojS/IZ0flmE Qsf/Kz07YkCI2b0MGGaC918leJUDsMFRaw6y8/IJWxJQ6CbCQcpkdZdrs/XAbyjeRn/j G9dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=PfwTGYrr; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dn4-20020a17090794c400b0073d5f9aa5e9si10688758ejc.327.2022.09.24.07.37.48; Sat, 24 Sep 2022 07:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=PfwTGYrr; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9248168B9F1; Sat, 24 Sep 2022 17:37:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7CCD368B9B7 for ; Sat, 24 Sep 2022 17:37:17 +0300 (EEST) Received: by mail-ed1-f53.google.com with SMTP id 30so3662463edw.5 for ; Sat, 24 Sep 2022 07:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=DJoc8CIclbDzME7h+rdRdunwZwV+kXTv/1jrw7GkggU=; b=PfwTGYrriMK5k0QApcEtFTazQcQO2X+5XSDBP0G9dKqCTwqy5RO85Ut8G/mUIH64mk NVhciakUs95qgALw3rNdhb/fQ5AALfVncXVilK5a+1UoVOfC/fMS1Gp6jjYaYnKkpYcG ljw+KinFEfilQLsWtJNTwn6SXQcrEfh1CYbAl9uvOTnus69dg7uSJi+Ekiug+jFFPmO3 AUSz6jEoxkx3sE6uWlK9umnMEcgt5R4cM3x+59t/B5CR2stvJNMnxJ/8cyNNEt9/faLt oirTUGedr8JC7TpTyj96RjnIrYlQoYBIdj3jOvc95GQxEk1nn7bizdCB5DzHEjgak0HQ laew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=DJoc8CIclbDzME7h+rdRdunwZwV+kXTv/1jrw7GkggU=; b=iMy0/Ba+dV6KNNdlmuchinIoOLsktbuJb+jnedRIIQGXdqidUu4VMjraa6+Qi7zDOd WHlOdviueKM3aC8Wq3HHQUhdLI8W3Dvs/P8MtfepLwWXx6f/hi5hfXi3li95TrD0gqBO 64NJZnulNzGexPb2aGZb2Mv7ksuD8hskufBHIn+fa6qXG4QCR1suEcHEdbXVT3oCb/3R 2tQI2tBTDQZ4eLcNzhKwrryKzv85fLW6OJK/rA29KZdy+IboxXNYQpTBz0hMvpXmaaS+ WWKZW5ZD4JsHeRliXDZTZDhCkpgr3n4mIwQ3cAn/Sv5i1uM9WM/5jKtBW8Kj16GxRojR rMeg== X-Gm-Message-State: ACrzQf1Ehg26br+uXQwFoPPM1P2e+ZtoUhCJWyxAvh8r0WDO5Lc8JJzu KJ1KRp+DYc7Xk55cZFgcVmBs4MtrZxv+1A== X-Received: by 2002:a05:6402:1009:b0:456:f370:5263 with SMTP id c9-20020a056402100900b00456f3705263mr3334485edu.392.1664030237019; Sat, 24 Sep 2022 07:37:17 -0700 (PDT) Received: from MBP-von-Marvin.citadel.scalie.me (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id u17-20020a50c2d1000000b0044e8d0682b2sm7970504edf.71.2022.09.24.07.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 07:37:16 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Sep 2022 16:36:58 +0200 Message-Id: <20220924143659.74756-4-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220924143659.74756-1-epirat07@gmail.com> References: <20220922020216.46589-1-epirat07@gmail.com> <20220924143659.74756-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/5] avutil/dict: Use av_dict_iterate in av_dict_get_string X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: C9JIj1UwSwuD --- libavutil/dict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index 3c05ed4c84..122606e3aa 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -250,7 +250,7 @@ int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags) int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep) { - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; AVBPrint bprint; int cnt = 0; char special_chars[] = {pairs_sep, key_val_sep, '\0'}; @@ -265,7 +265,7 @@ int av_dict_get_string(const AVDictionary *m, char **buffer, } av_bprint_init(&bprint, 64, AV_BPRINT_SIZE_UNLIMITED); - while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) { + while ((t = av_dict_iterate(m, t))) { if (cnt++) av_bprint_append_data(&bprint, &pairs_sep, 1); av_bprint_escape(&bprint, t->key, special_chars, AV_ESCAPE_MODE_BACKSLASH, 0); From patchwork Sat Sep 24 14:36:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 38214 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1156822pzh; Sat, 24 Sep 2022 07:37:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4CBH+/SCwfvPHaY57eM7jloqXjUqvDYWfZUN1qTjljB7JvsNoKP1U29+zuq7WEohqkdQkF X-Received: by 2002:a17:907:3e90:b0:781:cfa5:18a with SMTP id hs16-20020a1709073e9000b00781cfa5018amr11086070ejc.511.1664030278708; Sat, 24 Sep 2022 07:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664030278; cv=none; d=google.com; s=arc-20160816; b=i7X7DjHk0L1rvSkmIAPDFF6mv7G2kd2/9RY0qzKt9ADflxDtINGoPfhCNeBvuNFq+i H1uYtkj4azOV0YScFVN/GEixLtwhT/7UuTkcQIqv0kJOZLBFbkVyYprG69Mj9eFHyp5w ZbHc+/wpQp/yXzPdvupLoe7UrKY88hrsPOnWVlYjXMVfHTDypcjrT4hfgG17SLWoEqG2 ShcAJrSRbpFPMJIEVhehXQH5A+P+Hcl8I9fktRFeP+zZhnr4BWobov3Tt6qCevhDO8aN JSandjGKiXh0R/6YsPdpMf7cwSZe5uKIm+Bbzeq9mBSsao6X0cGdgiB0pdyiEPjt0tc1 A6MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=QnFS/w/25YMjkMYt1DYXhUI1+/pFLyHl313hQ0CqLRc=; b=NtYU/U38K035PxTBdc/YDfaP8MfPT0byCLp1qVf8wVXl8MWDysVaq27Xb4xja7iaWk NOjnyozZMDhDhiWcGZWWTK1KuI3i6LQazLt1laFAdBNW8iEpp4ShorT0ZnJW1cHzpS37 W74qd3ojsiaxoGrYEFyTztORakCfFrUjjWXs46gOgEOZXi1hxO2i12+f3qtpsaq0h4kE mF2rWiqv38+e220WzmRjV8uBLOOvPpWYSqUUxwo90VTxC/o3AkSq0KL0JLemVxGvtnVD bVPLnozZGfjQ+Bsz/qdQnX8PfGn8HSz6WnLw0vdbqLW2g4eA0VC+j9fWpgHPHd3N5uIU Mikg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=hqf6zgNA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b14-20020a17090630ce00b00718d0604af4si9488459ejb.604.2022.09.24.07.37.58; Sat, 24 Sep 2022 07:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=hqf6zgNA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A04B768B9FE; Sat, 24 Sep 2022 17:37:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E677368B96D for ; Sat, 24 Sep 2022 17:37:20 +0300 (EEST) Received: by mail-ed1-f42.google.com with SMTP id y8so3630022edc.10 for ; Sat, 24 Sep 2022 07:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=k+aR8Lst5xdPqM35x57gy/aqrAXMy2jfOLk45Urjge4=; b=hqf6zgNAnnH1DIL/t30YQ64Hs02dbe/YDzOqLJQiBPmYG9dVizN/bNd8KBaSZTGN6s wvoeMGC3SaGcjOpijy2c5dF5TZz9by7YcWRSrnv0hDnrGmAtaxl38p5QVBKDpPozsQmk SmEFYsYgcliWhfu/M7mnKJ3Cu6/hXlODq00pMBgv091mH94EWWQmK82cFoIorSRSSddg IlG5ZRwP/p1cNCrznPFNlyzW8a4hD5fdbYogbXy3aq5Nvyy3U5sGG6EtGqeuFrS5kzuw 0WvwVKq2s8zy8lvTm8n+uEqd7XrHb9RhLMxfNzYJYQcPkLwyCQvJIN7h4jec7HNqHmd6 HOxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=k+aR8Lst5xdPqM35x57gy/aqrAXMy2jfOLk45Urjge4=; b=LtdBYl30pQC1n1KEDJP6flJquxxAg0rJtncfyd2LLMVNubt47v8MF7KKbTID+C/oEg P30x3+/NbR0tOI023HRwxAK44aUwVA2iZa/pKVRyGo0XaSeu7HyPLJI9LIbDs6gDQF7s Uilm+7lAAMGc1qJ/HHQhI/obBEeJX3/ynBo0FNDzyJo1DjQ72oDGcLpDyEyMp7bWoGr9 EWPHxkjaW+t7DES9GRoUc8droverMuGwoIFY2CAWYz7IEQum5hQyV5Y4YlXv+uqnqW/4 r5TRqAoF7M3hnvRloXs/FIf0pQArEWamxtN5Rqd8nk5dpYFESvwRHyC+LISLbAZsDieC tWqQ== X-Gm-Message-State: ACrzQf2A3saZiNabdWlRbeTDa2Go/oaetMPnCoz6CyjGUVzRX3QQVLah iWHhSiV/rSq75uVxQpXTx1EKVPywOdalGg== X-Received: by 2002:a05:6402:50ca:b0:451:a711:1389 with SMTP id h10-20020a05640250ca00b00451a7111389mr13319652edb.239.1664030240175; Sat, 24 Sep 2022 07:37:20 -0700 (PDT) Received: from MBP-von-Marvin.citadel.scalie.me (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id u17-20020a50c2d1000000b0044e8d0682b2sm7970504edf.71.2022.09.24.07.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 07:37:19 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Sep 2022 16:36:59 +0200 Message-Id: <20220924143659.74756-5-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220924143659.74756-1-epirat07@gmail.com> References: <20220922020216.46589-1-epirat07@gmail.com> <20220924143659.74756-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 5/5] avutil/dict: Improve documentation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VVcwRludzMVf Mostly consistent formatting and consistently ordering of warnings/notes to be next to the description. Additionally group the AV_DICT_* macros. --- libavutil/dict.h | 91 +++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/libavutil/dict.h b/libavutil/dict.h index 344afb452b..e4bc330a44 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -41,13 +41,15 @@ * @brief Simple key:value store * * @{ - * Dictionaries are used for storing key:value pairs. To create - * an AVDictionary, simply pass an address of a NULL pointer to - * av_dict_set(). NULL can be used as an empty dictionary wherever - * a pointer to an AVDictionary is required. - * Use av_dict_get() to retrieve an entry and av_dict_iterate() to - * iterate over all entries and finally av_dict_free() to free the - * dictionary and all its contents. + * Dictionaries are used for storing key-value pairs. + * + * - To **create an AVDictionary**, simply pass an address of a NULL + * pointer to av_dict_set(). NULL can be used as an empty dictionary + * wherever a pointer to an AVDictionary is required. + * - To **insert an entry**, use av_dict_set(). + * - Use av_dict_get() to **retrieve an entry**. + * - To **iterate over all entries**, use av_dict_iterate(). + * - In order to **free the dictionary and all its contents**, use av_dict_free(). * @code AVDictionary *d = NULL; // "create" an empty dictionary @@ -59,13 +61,18 @@ char *v = av_strdup("value"); // you can avoid copying them like this av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - while (t = av_dict_iterate(d, t)) { + while ((t = av_dict_iterate(d, t))) { <....> // iterate over all entries in d } av_dict_free(&d); @endcode */ +/** + * @name AVDictionary Flags + * Flags that influence behavior of the matching of keys or insertion to the dictionary. + * @{ + */ #define AV_DICT_MATCH_CASE 1 /**< Only get an entry with exact-case key match. Only relevant in av_dict_get(). */ #define AV_DICT_IGNORE_SUFFIX 2 /**< Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string. Only relevant in av_dict_get(). */ @@ -73,10 +80,13 @@ allocated with av_malloc() or another memory allocation function. */ #define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been allocated with av_malloc() or another memory allocation function. */ -#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. +#define AV_DICT_DONT_OVERWRITE 16 /**< Don't overwrite existing entries. */ #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no - delimiter is added, the strings are simply concatenated. */ + delimiter is added, the strings are simply concatenated. */ #define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */ +/** + * @} + */ typedef struct AVDictionaryEntry { char *key; @@ -91,11 +101,13 @@ typedef struct AVDictionary AVDictionary; * The returned entry key or value must not be changed, or it will * cause undefined behavior. * - * @param prev Set to the previous matching element to find the next. - * If set to NULL the first matching element is returned. - * @param key matching key - * @param flags a collection of AV_DICT_* flags controlling how the entry is retrieved - * @return found entry or NULL in case no matching entry was found in the dictionary + * @param prev Set to the previous matching element to find the next. + * If set to NULL the first matching element is returned. + * @param key Matching key + * @param flags A collection of AV_DICT_* flags controlling how the + * entry is retrieved + * + * @return Found entry or NULL in case no matching entry was found in the dictionary */ AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); @@ -144,20 +156,21 @@ int av_dict_count(const AVDictionary *m); * @warning Adding a new entry to a dictionary invalidates all existing entries * previously returned with av_dict_get() or av_dict_iterate(). * - * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL - * a dictionary struct is allocated and put in *pm. - * @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags) - * @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags). - * Passing a NULL value will cause an existing entry to be deleted. - * @return >= 0 on success otherwise an error code <0 + * @param pm Pointer to a pointer to a dictionary struct. If *pm is NULL + * a dictionary struct is allocated and put in *pm. + * @param key Entry key to add to *pm (will either be av_strduped or added as a new key depending on flags) + * @param value Entry value to add to *pm (will be av_strduped or added as a new key depending on flags). + * Passing a NULL value will cause an existing entry to be deleted. + * + * @return >= 0 on success otherwise an error code <0 */ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags); /** - * Convenience wrapper for av_dict_set that converts the value to a string + * Convenience wrapper for av_dict_set() that converts the value to a string * and stores it. * - * Note: If AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error. + * Note: If ::AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error. */ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags); @@ -167,14 +180,15 @@ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags * In case of failure, all the successfully set entries are stored in * *pm. You may need to manually free the created dictionary. * - * @param key_val_sep a 0-terminated list of characters used to separate + * @param key_val_sep A 0-terminated list of characters used to separate * key from value - * @param pairs_sep a 0-terminated list of characters used to separate + * @param pairs_sep A 0-terminated list of characters used to separate * two pairs from each other - * @param flags flags to use when adding to dictionary. - * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL + * @param flags Flags to use when adding to the dictionary. + * ::AV_DICT_DONT_STRDUP_KEY and ::AV_DICT_DONT_STRDUP_VAL * are ignored since the key/value tokens will always * be duplicated. + * * @return 0 on success, negative AVERROR code on failure */ int av_dict_parse_string(AVDictionary **pm, const char *str, @@ -183,11 +197,14 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, /** * Copy entries from one AVDictionary struct into another. - * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, - * this function will allocate a struct for you and put it in *dst - * @param src pointer to source AVDictionary struct - * @param flags flags to use when setting entries in *dst - * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag + * + * @note Metadata is read using the ::AV_DICT_IGNORE_SUFFIX flag + * + * @param dst Pointer to a pointer to a AVDictionary struct to copy into. If *dst is NULL, + * this function will allocate a struct for you and put it in *dst + * @param src Pointer to the source AVDictionary struct to copy items from. + * @param flags Flags to use when setting entries in *dst + * * @return 0 on success, negative AVERROR code on failure. If dst was allocated * by this function, callers should free the associated memory. */ @@ -206,13 +223,15 @@ void av_dict_free(AVDictionary **m); * Such string may be passed back to av_dict_parse_string(). * @note String is escaped with backslashes ('\'). * - * @param[in] m dictionary + * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. + * + * @param[in] m The dictionary * @param[out] buffer Pointer to buffer that will be allocated with string containg entries. * Buffer must be freed by the caller when is no longer needed. - * @param[in] key_val_sep character used to separate key from value - * @param[in] pairs_sep character used to separate two pairs from each other + * @param[in] key_val_sep Character used to separate key from value + * @param[in] pairs_sep Character used to separate two pairs from each other + * * @return >= 0 on success, negative on error - * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. */ int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep);