From patchwork Mon May 1 11:44:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 41430 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp3133352pzb; Mon, 1 May 2023 04:45:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7H8dWEH30q84Djee0XHEwb85CS51EaQsuLewylitkGYRfKZhjh75flImMvSrxcvxAUEykZ X-Received: by 2002:a17:907:1625:b0:94f:8f37:d54 with SMTP id hb37-20020a170907162500b0094f8f370d54mr12994239ejc.44.1682941540136; Mon, 01 May 2023 04:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682941540; cv=none; d=google.com; s=arc-20160816; b=qyyUKxIMz169B0IoPUhcHzJbpgECev54KGBClyD9Fw4vB7zAznW+cnOqGxLKbTNets 9EJlvNb3XPOSghDwGniSI6q3jVVw8djVelCtpZvB0Oirm5+Qd3TkYDm69YD7BwyOzTy/ NB7/9Ym8+Te14ZAkAzHUD2zaQqGZIJpEA1Bh4cITqfqgf0xYw8giLVwIS0hf/CcMBz1i 1sRPyFYNi9m5q0tVQnCzzWVKQI+pz/yx9/uMExM5NzH0D0Hnzt5dU+9iZnKlxP99vCnF gT63R5gh1IxNLW/xw70P9WPabjPY5K1Ki9eDINRzLUW1yD00Td4N59pymWLiymgsPljX 9T1w== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=/opbqCZ7XZN3mF9XtdVQ9sYyGwFSXG7IL0mY2lHT6NU=; b=LzcFBV5vjBtCHz8tPKtDDV69zIFHZQIL7uBAsMsh6ig899axttKvOA1iXTtHyE6zih oWn/ucCShVE0DHaMucICYXErAfUO050Qw3WWutglZftcA+8YhR6vk9VOb+ylZMmueHHT 3iyeUeeleiB3/uZsyw3o4uJj8IgkD5FPGOC/FTT8zld0TTLq2VFc+gLJ18efUrWX2fZx MpMMuF1ngN7h6K9yQv3qZgR5JY3aT/0zLv+aq1Ipu+gZnVbHRgdqxIxa7qBYM2Z4B76S cM7LJ13Ci1ZVCVb3gIppnwG7S1+JguWM50M4EXTFPaKJlEDa8lCX9xA5USGW69BGuyuo ugaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=M+jUazc9; 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 h14-20020a170906398e00b009538282b816si19653188eje.75.2023.05.01.04.45.39; Mon, 01 May 2023 04:45: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=20221208 header.b=M+jUazc9; 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 1C7A768C0A3; Mon, 1 May 2023 14:45:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C65668BF55 for ; Mon, 1 May 2023 14:45:29 +0300 (EEST) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-50bc22805d3so2241932a12.1 for ; Mon, 01 May 2023 04:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682941528; x=1685533528; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I1Gk0PmBb9BURtvvcjbeUZnBXxk5iurC2ff+GLKJmOA=; b=M+jUazc9A39OwJqxIoYxsc+w7TkF/WRXJlp19r1vICBSinQa9x8M/LNGSyVMBF0CnQ wEU4b3wxWE4vLzzqvUgGBovO/HV8p+E/2Y2dVGXnyrkzej1NIzW/PvSExYHAc+PBMFf0 O2BlVcZ1hd4b86rS1ns2dGMdbCNA+4kIwKIqj2p3sIMDx1Y3yyJ6plnIEudqB0yT55wp uZvKR/T900e64Fpo7x/ZXPXDxBHM6DZ/X2ux8W/JgpkIv+vcNDRa7St71TvQXA7xAqIS nEKtMK/RbRsH9LhDzRxo0mDOb/8bdNl4w1ABZjNrhPk9tpwhVMRtUhWYfvzuA16DpmTr UtiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682941528; x=1685533528; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I1Gk0PmBb9BURtvvcjbeUZnBXxk5iurC2ff+GLKJmOA=; b=HNtUgDBt30Nk/RemmSiXExcdjqQIEbdexC0srTXF6Nqdj5hWQb9EnlFlzztV3b7ZAm z09T1SkZMtSbwGrKLg5xrB54AGPdeMvoxYPqNHkP706SP7ZwopIHKg0bWTyuTo3ejSqw 1T+UsXD9aBgRfrR6tDWVNh7xfqF2zTdA4WV8+wqxsi7jm6go83OeYxgwQv/SKJjcXDl1 rGeTDh9BYozSnBpu+66mHJOpik1BaVgjQDe2aCzI96erG/pq6dNo2L8KacOGptIVYFdu VOcbMDgCsD8KVmkIkmV6VRP8on56jNQfizh7kvjkUHJrp0DSw95J2fn11RsJG0AxrceF u5KA== X-Gm-Message-State: AC+VfDwV05MXGitaV2hKWuPM44v10Fpnfl3cOatwqhBFxJJBOOPCk1kY OVxYwN/Jo9eemSTB8avocItgZ4E+XPp11g== X-Received: by 2002:a50:ef0a:0:b0:50b:caae:ae6e with SMTP id m10-20020a50ef0a000000b0050bcaaeae6emr563335eds.17.1682941528458; Mon, 01 May 2023 04:45:28 -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 f15-20020a056402150f00b00506adf55ae2sm12024942edw.6.2023.05.01.04.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 04:45:27 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 May 2023 13:44:54 +0200 Message-Id: <20230501114456.13898-1-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop 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: UmEZGYvMzSpE This new API allows to remove an entry and obtain ownership of the key/value that was associated with the removed entry. --- doc/APIchanges | 4 ++++ libavutil/dict.c | 27 +++++++++++++++++++++++++++ libavutil/dict.h | 20 ++++++++++++++++++++ libavutil/tests/dict.c | 34 ++++++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- tests/ref/fate/dict | 12 ++++++++++++ 6 files changed, 98 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0b609e3d3b..5b807873b7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-04-29 - xxxxxxxxxx - lavu 58.7.100 - dict.c + Add av_dict_pop() to remove an entry from a dict + and get ownership of the removed key/value. + 2023-04-10 - xxxxxxxxxx - lavu 58.6.100 - frame.h av_frame_get_plane_buffer() now accepts const AVFrame*. diff --git a/libavutil/dict.c b/libavutil/dict.c index f673977a98..ac41771994 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, return av_dict_set(pm, key, valuestr, flags); } +int av_dict_pop(AVDictionary **pm, const char *key, + char **out_key, char **out_value, int flags) +{ + AVDictionary *m = *pm; + AVDictionaryEntry *entry = NULL; + entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags); + if (!entry) + return AVERROR(ENOENT); + + if (out_key) + *out_key = entry->key; + else + av_free(entry->key); + + if (out_value) + *out_value = entry->value; + else + av_free(entry->value); + + *entry = m->elems[--m->count]; + if (m && !m->count) { + av_freep(&m->elems); + av_freep(pm); + } + return 0; +} + static int parse_key_value_pair(AVDictionary **pm, const char **buf, const char *key_val_sep, const char *pairs_sep, int flags) diff --git a/libavutil/dict.h b/libavutil/dict.h index 713c9e361a..b2ab55a026 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -172,6 +172,26 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags */ int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags); +/** + * Remove the entry with the given key from the dictionary. + * + * Search for an entry matching `key` and remove it, if found. Optionally + * the found key and/or value can be returned using the `out_key`/`out_value` + * arguments. + * + * If more than one entry matches, only one entry is removed and returned + * on each call. Which entry is returned first in that case is undefined. + * + * @param pm Pointer to a pointer to a dictionary struct. + * @param key Entry key to match. + * @param out_key Pointer whose pointee will be set to the matched + * entry key. Must be freed by the caller. May be NULL. + * @param out_value Pointer whose pointee will be set to the matched + * entry value. Must be freed by the caller. May be NULL. + */ +int av_dict_pop(AVDictionary **pm, const char *key, + char **out_key, char **out_value, int flags); + /** * Parse the key/value pairs list and add the parsed entries to a dictionary. * diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c index bececefb31..0652794b97 100644 --- a/libavutil/tests/dict.c +++ b/libavutil/tests/dict.c @@ -158,5 +158,39 @@ int main(void) printf("%s\n", e->value); av_dict_free(&dict); + char *key, *val = NULL; + int ret; + printf("\nTesting av_dict_pop() with existing AVDictionaryEntry.key as key\n"); + av_dict_set(&dict, "test-key", "test-value", 0); + ret = av_dict_pop(&dict, "test-key", &key, &val, 0); + printf("%s: %s (Return code: %i)\n", + (key) ? key : "(null)", + (val) ? val : "(null)", ret); + e = av_dict_get(dict, "test-key", NULL, 0); + printf("%s\n", (e) ? e->value : "(null)"); + av_freep(&key); + av_freep(&val); + + printf("\nTesting av_dict_pop() with nonexistent key\n"); + ret = av_dict_pop(&dict, "test-key", &key, &val, 0); + printf("%s: %s (Return code: %i)\n", + (key) ? key : "(null)", + (val) ? val : "(null)", ret); + e = av_dict_get(dict, "test-key", NULL, 0); + printf("%s\n", (e) ? e->value : "(null)"); + av_freep(&key); + av_freep(&val); + + printf("\nTesting av_dict_pop() with prefix key match\n"); + av_dict_set(&dict, "prefix-test-key", "test-value", 0); + ret = av_dict_pop(&dict, "prefix-test", &key, &val, AV_DICT_IGNORE_SUFFIX); + printf("%s: %s (Return code: %i)\n", + (key) ? key : "(null)", + (val) ? val : "(null)", ret); + e = av_dict_get(dict, "prefix-test", NULL, AV_DICT_IGNORE_SUFFIX); + printf("%s\n", (e) ? e->value : "(null)"); + av_freep(&key); + av_freep(&val); + return 0; } diff --git a/libavutil/version.h b/libavutil/version.h index 40f92af055..b8d1ef06a8 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 58 -#define LIBAVUTIL_VERSION_MINOR 6 +#define LIBAVUTIL_VERSION_MINOR 7 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/tests/ref/fate/dict b/tests/ref/fate/dict index 7205e4c845..bdb097cb03 100644 --- a/tests/ref/fate/dict +++ b/tests/ref/fate/dict @@ -48,3 +48,15 @@ Testing av_dict_set_int() Testing av_dict_set() with existing AVDictionaryEntry.key as key new val OK new val OK + +Testing av_dict_pop() with existing AVDictionaryEntry.key as key +test-key: test-value (Return code: 0) +(null) + +Testing av_dict_pop() with nonexistent key +(null): (null) (Return code: -2) +(null) + +Testing av_dict_pop() with prefix key match +prefix-test-key: test-value (Return code: 0) +(null) From patchwork Mon May 1 11:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 41431 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp3133418pzb; Mon, 1 May 2023 04:45:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PQ7BcY+c7opNiUozjH9bEalJa2fkpR6/9Q8wq2ctc+tjYZPkoD+hDBIySrrw3ex45A3kw X-Received: by 2002:a17:907:97c9:b0:953:43a1:1988 with SMTP id js9-20020a17090797c900b0095343a11988mr10444566ejc.46.1682941548776; Mon, 01 May 2023 04:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682941548; cv=none; d=google.com; s=arc-20160816; b=lKw5gZthzXsWb3xnjn1lmJzlZ0zfEGwTWa5IiSDO7psvbBHw8eBrqbZl3DWNU5w5Mi GKl7rSyrQx7T8Gvb3Sd/oHWrerTjDg1l37aFoXTiyBwWswrao/AamCnmpCBg2l8oE5aM AdkYEdcuEo/25VubF3xQRQw3QomfyyBLEiMuk/QrlW5kTTqlu05kSJRFn2qw+rPwwHjF iOix2NJ6HGQ4B/DjjKFEuwplIpf5qngRI2yxbMKpnHrv26IjpTvS0XlknV1cX19kDTxs b+T/jn7wqXhKT5qS9vw9oWwY1Zy9P4++6vFgDwTGpQzyB70XO/zMvG08PPLDw/Q3Kz7j N2SQ== 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=f7ker/tIZ0EgVCxBhfm3fuEuZGFlIh4EGmI19Ta7uTY=; b=aVVCmpcW5h5EI5/2HUWWQN3kJBC3aG5RJURJJtMB5WYrFLRt6N/fUrVCJPG/Rl+Mbw 37fu0T0tcfXa7STno/sIwejqvBUhJCRyEkSBzR3WuPrI7iYL0yD15WKK44320HyWwkPN C5i11VygO0iZKFUVU0l8HLJD9mOzdZSs+DKInVYnncNZ6C0dqpet4OqlMu63xqB3kw3t lqQ3Jw+AFYxRaaMFCAdKxdkBcZpjptJ0OqOse9UVWneu9Aaglhzd0aLKNXjb33bFY/PL AD87PtpOKCaiun5C2zFWRr/A0dyvevnyI1MqS+uNr4MJrgHAV7fiKsa0bp0z4j8ChqVd fcKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=QjgG3GRz; 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 c11-20020a170906528b00b0095388276b97si19807006ejm.420.2023.05.01.04.45.48; Mon, 01 May 2023 04:45:48 -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=20221208 header.b=QjgG3GRz; 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 6075968C0A7; Mon, 1 May 2023 14:45:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B16268BF55 for ; Mon, 1 May 2023 14:45:30 +0300 (EEST) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-50bcb00a4c2so300852a12.1 for ; Mon, 01 May 2023 04:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682941529; x=1685533529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HAKiW7LeftOMyO2NsippwASjzYykGzfItlfghOxejVQ=; b=QjgG3GRzlecMSMkHj7DhnAHXHF7+8DVivY/4yMcaC5LDqY1eAxUQrG7XDssERKGIUO AYqSomo/aufcVtrocx3hJU7GP4OutGfSTTxBxE6CwcgNqljsEuFP+bvW6rrYeQ6JjEfm 1ll5eDNSt3wYDi9IfTCTfehxUZf7r29tke8EH04aNjVn94C6SdaSo7CMMSYKdBw+1aLF Z1Sc3vw0+5X8PHsyYP1Vio7+Qy1d6yq5xmVm4I5v8q60ScgWHXjV1ayM38ChBhZaEkPP pC3GDATu4Gm6E6QeSQzRY2kjngUC0ud4DdV6gkoqhK2o8jAhMmP16NI3oMYCK9jgBoFA 1b3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682941529; x=1685533529; 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:message-id:reply-to; bh=HAKiW7LeftOMyO2NsippwASjzYykGzfItlfghOxejVQ=; b=Kip4Qhjw17kRJXYftNQEwOnlEbsH2dRf8pJRkPXMkng80J1j9CjzNhp0sJSSa5mFy0 iSEoJInoMHIbvrYB/n4Wz+rmfaY/vsZc3F3tHr1nRNLnIQEHwI2cb13LyLZAB1znH8ce PydpiZj8O9kDwTFZM+iziZbZoIObdihuabpWXj5gCGeTv8RDe5rXvpQ01YVuTH8lKg7b /DaPmlhy1FrwxzbpoWifjfYyaY6IFRprlGEVLfQWBY9NDU0NIpduUY38vl4zQTJNwOta CUmpvGgVZV1PeGibF3xxsCi1b044IrB6YCD81lBg6xCzbKqY255YDCtgkxcX3ZJSvj9h oT+g== X-Gm-Message-State: AC+VfDw4DapAYyfWgbFp2m+UnSVJlPGVyVFmi9dVOhLM1euifMJ0bTzs MEfg17095cOs2nYB1Pdtv6JN+0t859s0XQ== X-Received: by 2002:aa7:c985:0:b0:50b:c42b:b737 with SMTP id c5-20020aa7c985000000b0050bc42bb737mr2551590edt.37.1682941529557; Mon, 01 May 2023 04:45:29 -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 f15-20020a056402150f00b00506adf55ae2sm12024942edw.6.2023.05.01.04.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 04:45:29 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 May 2023 13:44:55 +0200 Message-Id: <20230501114456.13898-2-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230501114456.13898-1-epirat07@gmail.com> References: <20230501114456.13898-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/tee: use av_dict_pop 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: Ti9mzOKff3b2 This is a well-defined way to "steal" the value of the dict entry. --- libavformat/tee.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/tee.c b/libavformat/tee.c index cb555f52fd..70f3f2eb29 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -157,6 +157,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) { int i, ret; AVDictionary *options = NULL, *bsf_options = NULL; + char *entry_val = NULL; AVDictionaryEntry *entry; char *filename; char *format = NULL, *select = NULL, *on_fail = NULL; @@ -171,15 +172,15 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) return ret; #define CONSUME_OPTION(option, field, action) do { \ - if ((entry = av_dict_get(options, option, NULL, 0))) { \ - field = entry->value; \ + if ((!av_dict_pop(&options, option, NULL, &entry_val, 0))) { \ + field = entry_val; \ { action } \ - av_dict_set(&options, option, NULL, 0); \ + av_freep(&entry_val); \ } \ } while (0) #define STEAL_OPTION(option, field) \ CONSUME_OPTION(option, field, \ - entry->value = NULL; /* prevent it from being freed */) + entry_val = NULL; /* prevent it from being freed */) #define PROCESS_OPTION(option, field, function, on_error) \ CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } goto end; }) From patchwork Mon May 1 11:44:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 41432 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp3133471pzb; Mon, 1 May 2023 04:45:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ411IbGiEm+GbAD7ONOHOcM6ts7zU2Kf6p9XvDJyM6FwrIq3wOd/wZgg/ESaXAxYGw8oHLn X-Received: by 2002:aa7:c61a:0:b0:504:98f1:464c with SMTP id h26-20020aa7c61a000000b0050498f1464cmr4902392edq.23.1682941557597; Mon, 01 May 2023 04:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682941557; cv=none; d=google.com; s=arc-20160816; b=kyz6CQbHnN0gxxvCa7BVosbwX+4z8LcT1WtxzrzcXXLVMkBA7CMgeN5+tR2BBXvKlb OUbTOQwSinzGxUxHSWFeYj+b6QV2itq5wVsCpY4iKUy1OAMUUyc/Y6V603hoPMl8SX4K 6B/H7NLLJW9Q6wgWchNFTX3CeEWMeEV37m383h5q7YK3I1b5NZN38HExkfF1ezjAxMty l5uUuau0auu/S2QLf9yVnyA/TzjfwOdCaZh8Qr90N5QH2bokbgZdNyRp1bBvSzh5g7vp A9F7utw7qEeGL0ExsLyPnpLD2bbyO4S8CT3Q/IdVptadVn+ZDGS5zjeHMm+tGteIN9Um /vGQ== 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=TUaippMVJXWTxysoMs9j7JX+5c5ejKyCzKZtFxyM0s0=; b=Gg4yL+SkElqnnANQxCOsgli0jVdYsf09TKGfk5UyerwpHQhzpv/j+B8Z+DR2vkEz2J g+2twI1th6GwpbT8O/ZjjuVIbypI9zDk98xRDam0U454A+r0fGcVbioGBjxkcyIFcMnn qxnTCvC8dXYrIwVR2lvDkXVvuRYm7jVSURgdY9wbsxHvFLbRozChBL0kA5HndPEsF958 N4CWivp4klUn5xndYta0KNsYwx2qXEozMDkajwsyfoRlkErAFQmFgyqGnLjYGIrKvhLt WkOlzAKmhmE/KM0c2fsCo1qdOY3P/LLSWciKHU54DEpdtaogP6UEnvMs1WSMrvhipeKu 9RoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=CjvGyjGN; 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 s13-20020a056402164d00b0050bc630a948si1349245edx.263.2023.05.01.04.45.57; Mon, 01 May 2023 04:45:57 -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=20221208 header.b=CjvGyjGN; 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 558E468C0BA; Mon, 1 May 2023 14:45:38 +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 9C01468C09A for ; Mon, 1 May 2023 14:45:31 +0300 (EEST) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-50bc4bc2880so1603217a12.2 for ; Mon, 01 May 2023 04:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682941531; x=1685533531; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WIYwsXiDUHpheYzdKLQNpLNVOu1HAUB049kztYRXl0w=; b=CjvGyjGNLFVADhEHW5SDA7DVQ5fkOZtzmGkbDt1CY54b2l92xxN3PT+LRZbAUBmjMF PCtiv+RjZ8VxodapQ6HDmrNaOjMGJqxTtwqyttPqp0xkTyLO6FzyKpBGAEFe1fbww1mF /pmG9mbGLbPgrxltRPmd2sStTm+kgP6FWW8vBvQdjw7B1FGutHdj3mXFFUlQI4xeN9rk spAv9krWOcj3zpTOrJyg1zqE01KXkziI+r5JYW8fS2E96pCK9IvAQ7lsnhWU6sq/CTKy IIk9FoQqizK5hgRQhMjrYlfzLFoEK4Z/UrHAHQSlA06J5jiPxhKXFSBdpQG5jfz6ld6w XgDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682941531; x=1685533531; 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:message-id:reply-to; bh=WIYwsXiDUHpheYzdKLQNpLNVOu1HAUB049kztYRXl0w=; b=XWLjrfCvoMnELqS5BdCtx6ik0nwlrSpb+tGQd0w86gy53SYYdZppxSyvsFgU7f7BA0 HPCRo54s0pZ5Q8Ovl8P7X5CiVr41sgSF5ll7943aKMKqStRr51UM48Z1DsgiYaUPogVx 3XtmKjrLSQ0IcuL3FdvRHesV7GS8byRBoYUC/LfXn22uJmQj0u8IRNgkBL9UXyV+v4ge 1mo9ixBfKTIuNR81vsMUxplF8Fh+Jz+JHRutIWEBBLs5WvRqm3h8qiXi79IqlQ7GbFKH hkwgZzar6DqnyVdOgjTRq12dkEvndhkLN0RZFiyf9PSCQgnHG3RMDNsinXOEFf/zupnh BTvg== X-Gm-Message-State: AC+VfDyInh+k8Sq+60rinw0JgeuIc/ZpWlgGnio7hNUh8VRz7/Yqu4d0 BMb6nzvNIb2TLG2XvOot78j11oAoK0meZg== X-Received: by 2002:aa7:c61a:0:b0:504:98f1:464c with SMTP id h26-20020aa7c61a000000b0050498f1464cmr4901762edq.23.1682941530733; Mon, 01 May 2023 04:45:30 -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 f15-20020a056402150f00b00506adf55ae2sm12024942edw.6.2023.05.01.04.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 04:45:30 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 May 2023 13:44:56 +0200 Message-Id: <20230501114456.13898-3-epirat07@gmail.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230501114456.13898-1-epirat07@gmail.com> References: <20230501114456.13898-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avutil/dict: constify av_dict_get return 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: 1LIr8FNPv/od --- doc/examples/qsv_transcode.c | 2 +- libavcodec/libaomenc.c | 2 +- libavcodec/libkvazaar.c | 2 +- libavcodec/libsvtav1.c | 2 +- libavcodec/libvpxenc.c | 2 +- libavcodec/libx264.c | 2 +- libavcodec/libx265.c | 2 +- libavcodec/mjpegdec.c | 2 +- libavcodec/qsvenc.c | 2 +- libavfilter/avfilter.c | 2 +- libavfilter/f_bench.c | 2 +- libavfilter/f_drawgraph.c | 2 +- libavfilter/f_select.c | 4 +-- libavfilter/vf_cover_rect.c | 2 +- libavfilter/vf_drawtext.c | 2 +- libavformat/aiffenc.c | 2 +- libavformat/argo_asf.c | 2 +- libavformat/asfenc.c | 6 ++-- libavformat/au.c | 2 +- libavformat/avformat.h | 2 +- libavformat/avidec.c | 2 +- libavformat/avienc.c | 2 +- libavformat/avio.c | 4 +-- libavformat/dashenc.c | 6 ++-- libavformat/dvenc.c | 2 +- libavformat/flacdec.c | 2 +- libavformat/flacenc.c | 6 ++-- libavformat/flvdec.c | 2 +- libavformat/gxfenc.c | 2 +- libavformat/http.c | 8 +++--- libavformat/id3v2.c | 6 ++-- libavformat/id3v2enc.c | 2 +- libavformat/imfdec.c | 2 +- libavformat/matroskadec.c | 2 +- libavformat/mov.c | 6 ++-- libavformat/movenc.c | 46 +++++++++++++++--------------- libavformat/mp3enc.c | 6 ++-- libavformat/mpegtsenc.c | 6 ++-- libavformat/mux.c | 2 +- libavformat/mux_utils.c | 2 +- libavformat/mxfenc.c | 14 ++++----- libavformat/riffenc.c | 2 +- libavformat/rmenc.c | 2 +- libavformat/sapenc.c | 2 +- libavformat/sdp.c | 2 +- libavformat/segment.c | 4 +-- libavformat/soxenc.c | 2 +- libavformat/tee.c | 2 +- libavformat/ttmlenc.c | 4 +-- libavformat/wavenc.c | 4 +-- libavformat/webmdashenc.c | 30 +++++++++---------- libavutil/dict.c | 9 +++++- libavutil/dict.h | 5 ++++ libavutil/hwcontext_cuda.c | 2 +- libavutil/hwcontext_qsv.c | 2 +- libavutil/hwcontext_vulkan.c | 8 +++--- libavutil/version.h | 1 + tests/api/api-threadmessage-test.c | 2 +- 58 files changed, 136 insertions(+), 123 deletions(-) diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c index 48128b200c..cc4c203d94 100644 --- a/doc/examples/qsv_transcode.c +++ b/doc/examples/qsv_transcode.c @@ -87,7 +87,7 @@ static int dynamic_set_parameter(AVCodecContext *avctx) frame_number++; if (current_setting_number < setting_number && frame_number == dynamic_setting[current_setting_number].frame_number) { - AVDictionaryEntry *e = NULL; + const AVDictionaryEntry *e = NULL; ret = str_to_dict(dynamic_setting[current_setting_number++].optstr, &opts); if (ret < 0) { fprintf(stderr, "The dynamic parameter is wrong\n"); diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 0b88102c77..8a32f31677 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -999,7 +999,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(&ctx->encoder, en->key, en->value); diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index 168486f4ec..f9f3ce8e52 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -103,7 +103,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx) if (ctx->kvz_params) { AVDictionary *dict = NULL; if (!av_dict_parse_string(&dict, ctx->kvz_params, "=", ",", 0)) { - AVDictionaryEntry *entry = NULL; + const AVDictionaryEntry *entry = NULL; while ((entry = av_dict_get(dict, "", entry, AV_DICT_IGNORE_SUFFIX))) { if (!api->config_parse(cfg, entry->key, entry->value)) { av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n", diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 9174e2753c..e959c1cab0 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -151,7 +151,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, { SvtContext *svt_enc = avctx->priv_data; const AVPixFmtDescriptor *desc; - AVDictionaryEntry *en = NULL; + const AVDictionaryEntry *en = NULL; // Update param from options #if FF_API_SVTAV1_OPTS diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index a20e949842..29fdc3f9d4 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1734,7 +1734,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 cfdd422236..2eec1c0913 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -1082,7 +1082,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(&x4->params, en->key, en->value)) < 0) { av_log(avctx, AV_LOG_WARNING, diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 420d0953af..ddba5c6dbc 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -421,7 +421,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 01537d4774..04c3cf0430 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2359,7 +2359,7 @@ int ff_mjpeg_decode_frame_from_buf(AVCodecContext *avctx, AVFrame *frame, int i, index; int ret = 0; int is16bit; - AVDictionaryEntry *e = NULL; + const AVDictionaryEntry *e = NULL; s->force_pal8 = 0; diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index c975302b4f..cf411ca520 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -2046,7 +2046,7 @@ static int set_roi_encode_ctrl(AVCodecContext *avctx, const AVFrame *frame, static void set_skip_frame_encode_ctrl(AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl *enc_ctrl) { - AVDictionaryEntry* skip_frame_dict = NULL; + const AVDictionaryEntry* skip_frame_dict = NULL; if (!frame->metadata) return; skip_frame_dict = av_dict_get(frame->metadata, "qsv_skip_frame", NULL, 0); diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 8d5702a0c8..60224c93ef 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -897,7 +897,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 9b55194dbc..ca1adf4ae6 100644 --- a/libavfilter/f_bench.c +++ b/libavfilter/f_bench.c @@ -71,7 +71,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (s->action == ACTION_START) { av_dict_set_int(&in->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 d29a7fb60a..69d8ba9993 100644 --- a/libavfilter/f_drawgraph.c +++ b/libavfilter/f_drawgraph.c @@ -165,7 +165,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, in_duration; diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index d76c248fc5..b01526371a 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -308,8 +308,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 642747a351..b219ae2948 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -125,7 +125,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 ret, 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 71ab851462..d2973f2d96 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1047,7 +1047,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/libavformat/aiffenc.c b/libavformat/aiffenc.c index 11a5b18d57..b2ca6c9ce7 100644 --- a/libavformat/aiffenc.c +++ b/libavformat/aiffenc.c @@ -83,7 +83,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/argo_asf.c b/libavformat/argo_asf.c index 5f38b68b6a..f83f9b2e2a 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -360,7 +360,7 @@ static int argo_asf_write_header(AVFormatContext *s) .num_chunks = 1, .chunk_offset = ASF_FILE_HEADER_SIZE }; - AVDictionaryEntry *t; + const AVDictionaryEntry *t; const char *name, *end; size_t len; diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 244c7e7a27..8810d64980 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -331,7 +331,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, &offset); @@ -361,7 +361,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; @@ -392,7 +392,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 */ diff --git a/libavformat/au.c b/libavformat/au.c index 3bf2150258..68b665aeb7 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -261,7 +261,7 @@ static int au_get_annotations(AVFormatContext *s, AVBPrint *annotations) }; int cnt = 0; AVDictionary *m = s->metadata; - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; for (int i = 0; i < FF_ARRAY_ELEMS(keys); i++) { t = av_dict_get(m, keys[i], NULL, 0); diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1916aa2dc5..95f52a639c 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -146,7 +146,7 @@ * consumed). The calling program can handle such unrecognized options as it * wishes, e.g. * @code - * AVDictionaryEntry *e; + * const AVDictionaryEntry *e; * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { * fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key); * abort(); diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 7a3fad6392..0cf9174013 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -507,7 +507,7 @@ static int avi_read_header(AVFormatContext *s) uint64_t list_end = 0; int64_t pos; int ret; - AVDictionaryEntry *dict_entry; + const AVDictionaryEntry *dict_entry; avi->stream_index = -1; diff --git a/libavformat/avienc.c b/libavformat/avienc.c index a61e5c3109..b62258f693 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -266,7 +266,7 @@ static int avi_write_header(AVFormatContext *s) AVCodecParameters *video_par; AVStream *video_st = NULL; int64_t list1, list2, strh, strf; - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; int padding; if (s->nb_streams > AVI_MAX_STREAM_COUNT) { diff --git a/libavformat/avio.c b/libavformat/avio.c index ab1c19a58d..0082977f2d 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -167,7 +167,7 @@ int ffurl_connect(URLContext *uc, AVDictionary **options) { int err; AVDictionary *tmp_opts = NULL; - AVDictionaryEntry *e; + const AVDictionaryEntry *e; if (!options) options = &tmp_opts; @@ -309,7 +309,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, URLContext *parent) { AVDictionary *tmp_opts = NULL; - AVDictionaryEntry *e; + const AVDictionaryEntry *e; int ret = ffurl_alloc(puc, filename, flags, int_cb); if (ret < 0) return ret; diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 17fe5f430c..283747c63d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -800,7 +800,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind { DASHContext *c = s->priv_data; AdaptationSet *as = &c->as[as_index]; - AVDictionaryEntry *lang, *role; + const AVDictionaryEntry *lang, *role; int i; avio_printf(out, "\t\turl); int use_rename = proto && !strcmp(proto, "file"); static unsigned int warned_non_file = 0; - AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0); + const AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0); AVDictionary *opts = NULL; if (!use_rename && !warned_non_file++) @@ -1372,7 +1372,7 @@ static int write_manifest(AVFormatContext *s, int final) static int dict_copy_entry(AVDictionary **dst, const AVDictionary *src, const char *key) { - AVDictionaryEntry *entry = av_dict_get(src, key, NULL, 0); + const AVDictionaryEntry *entry = av_dict_get(src, key, NULL, 0); if (entry) av_dict_set(dst, key, entry->value, AV_DICT_DONT_OVERWRITE); return 0; diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 29d2dc47ac..246d190961 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -390,7 +390,7 @@ static int dv_write_header(AVFormatContext *s) { AVRational rate; DVMuxContext *dvc = s->priv_data; - AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + const AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); if (!dv_init_mux(s)) { av_log(s, AV_LOG_ERROR, "Can't initialize DV format!\n" diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index b58ec03963..773fddc4fd 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -176,7 +176,7 @@ static int flac_read_header(AVFormatContext *s) } /* process supported blocks other than STREAMINFO */ if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) { - AVDictionaryEntry *chmask; + const AVDictionaryEntry *chmask; ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1); if (ret < 0) { diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index a8beec7750..fab7b34fa8 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -85,7 +85,7 @@ static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt) AVIOContext *pb = s->pb; const AVPixFmtDescriptor *pixdesc; const CodecMime *mime = ff_id3v2_mime_tags; - AVDictionaryEntry *e; + const AVDictionaryEntry *e; const char *mimetype = NULL, *desc = ""; const AVStream *st = s->streams[pkt->stream_index]; int i, mimelen, desclen, type = 0, blocklen; @@ -243,8 +243,8 @@ static int flac_init(struct AVFormatContext *s) if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && !(par->ch_layout.u.mask & ~0x3ffffULL) && !ff_flac_is_native_layout(par->ch_layout.u.mask)) { - AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", - NULL, 0); + const AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", + NULL, 0); if (chmask) { av_log(s, AV_LOG_WARNING, "A WAVEFORMATEXTENSIBLE_CHANNEL_MASK is " diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d83edff727..abb282da56 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -1268,7 +1268,7 @@ retry_duration: } if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264)) { - AVDictionaryEntry *t; + const AVDictionaryEntry *t; if (st->codecpar->extradata) { if ((ret = flv_queue_extradata(flv, s->pb, stream_type, size)) < 0) diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c index 7495924722..93bfed8246 100644 --- a/libavformat/gxfenc.c +++ b/libavformat/gxfenc.c @@ -688,7 +688,7 @@ static int gxf_write_header(AVFormatContext *s) uint8_t tracks[255] = {0}; int i, media_info = 0; int ret; - AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + const AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) { av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome\n"); diff --git a/libavformat/http.c b/libavformat/http.c index 0817aafb5b..c18a4d7e58 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -309,7 +309,7 @@ static int http_should_reconnect(HTTPContext *s, int err) static char *redirect_cache_get(HTTPContext *s) { - AVDictionaryEntry *re; + const AVDictionaryEntry *re; int64_t expiry; char *delim; @@ -960,7 +960,7 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict) static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) { AVDictionary *new_params = NULL; - AVDictionaryEntry *e, *cookie_entry; + const AVDictionaryEntry *e, *cookie_entry; char *eql, *name; // ensure the cookie is parsable @@ -978,7 +978,7 @@ static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) if ((e = av_dict_get(new_params, "expires", NULL, 0)) && e->value) { struct tm new_tm = {0}; if (!parse_set_cookie_expiry_time(e->value, &new_tm)) { - AVDictionaryEntry *e2; + const AVDictionaryEntry *e2; // if the cookie has already expired ignore it if (av_timegm(&new_tm) < av_gettime() / 1000000) { @@ -1256,7 +1256,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path, *cookies = NULL; while ((cookie = av_strtok(next, "\n", &saveptr)) && !ret) { AVDictionary *cookie_params = NULL; - AVDictionaryEntry *cookie_entry, *e; + const AVDictionaryEntry *cookie_entry, *e; next = NULL; // store the cookie in a dict in case it is updated in the response diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index cb31864045..8d201cb63a 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -536,9 +536,9 @@ static int is_number(const char *str) return !*str; } -static AVDictionaryEntry *get_date_tag(AVDictionary *m, const char *tag) +static const AVDictionaryEntry *get_date_tag(AVDictionary *m, const char *tag) { - AVDictionaryEntry *t; + const AVDictionaryEntry *t; if ((t = av_dict_get(m, tag, NULL, AV_DICT_MATCH_CASE)) && strlen(t->value) == 4 && is_number(t->value)) return t; @@ -547,7 +547,7 @@ static AVDictionaryEntry *get_date_tag(AVDictionary *m, const char *tag) static void merge_date(AVDictionary **m) { - AVDictionaryEntry *t; + const AVDictionaryEntry *t; char date[17] = { 0 }; // YYYY-MM-DD hh:mm if (!(t = get_date_tag(*m, "TYER")) && diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c index ac907c2758..6d646e3f29 100644 --- a/libavformat/id3v2enc.c +++ b/libavformat/id3v2enc.c @@ -352,7 +352,7 @@ int ff_id3v2_write_metadata(AVFormatContext *s, ID3v2EncContext *id3) int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt) { AVStream *st = s->streams[pkt->stream_index]; - AVDictionaryEntry *e; + const AVDictionaryEntry *e; AVIOContext *dyn_buf; uint8_t *buf; diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 7d04d0d853..a7c39ee4f3 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -631,7 +631,7 @@ static int imf_read_header(AVFormatContext *s) IMFContext *c = s->priv_data; char *asset_map_path; char *tmp_str; - AVDictionaryEntry* tcr; + const AVDictionaryEntry* tcr; char tc_buf[AV_TIMECODE_STR_SIZE]; int ret = 0; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 49950956b6..9af4900814 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -2083,7 +2083,7 @@ static int matroska_parse_flac(AVFormatContext *s, /* check for the channel mask */ if (block_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) { AVDictionary *dict = NULL; - AVDictionaryEntry *chmask; + const AVDictionaryEntry *chmask; ff_vorbis_comment(s, &dict, p, block_size, 0); chmask = av_dict_get(dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0); diff --git a/libavformat/mov.c b/libavformat/mov.c index 057fd872b1..40f4749ea8 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2340,7 +2340,7 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, int bits_per_sample, flags; uint16_t version = avio_rb16(pb); uint32_t id = 0; - AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); + const AVDictionaryEntry *compatible_brands = av_dict_get(c->fc->metadata, "compatible_brands", NULL, AV_DICT_MATCH_CASE); int channel_count; avio_rb16(pb); /* revision level */ @@ -8462,7 +8462,7 @@ static void export_orphan_timecode(AVFormatContext *s) if (st->codecpar->codec_tag == MKTAG('t','m','c','d') && !tmcd_is_referenced(s, i + 1)) { - AVDictionaryEntry *tcr = av_dict_get(st->metadata, "timecode", NULL, 0); + const AVDictionaryEntry *tcr = av_dict_get(st->metadata, "timecode", NULL, 0); if (tcr) { av_dict_set(&s->metadata, "timecode", tcr->value, 0); break; @@ -8625,7 +8625,7 @@ static int mov_read_header(AVFormatContext *s) AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; if (sc->timecode_track > 0) { - AVDictionaryEntry *tcr; + const AVDictionaryEntry *tcr; int tmcd_st_id = -1; for (j = 0; j < s->nb_streams; j++) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c370922c7d..f5f3299cf1 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2194,7 +2194,7 @@ static int mov_write_mdcv_tag(AVIOContext *pb, MOVTrack *track) static void find_compressor(char * compressor_name, int len, MOVTrack *track) { - AVDictionaryEntry *encoder; + const AVDictionaryEntry *encoder; int xdcam_res = (track->par->width == 1280 && track->par->height == 720) || (track->par->width == 1440 && track->par->height == 1080) || (track->par->width == 1920 && track->par->height == 1080); @@ -2490,7 +2490,7 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) #if 1 int frame_duration; int nb_frames; - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; if (!track->st->avg_frame_rate.num || !track->st->avg_frame_rate.den) { av_log(NULL, AV_LOG_ERROR, "avg_frame_rate not set for tmcd track.\n"); @@ -2988,7 +2988,7 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra // hdlr.name is used by some players to identify the content title // of the track. So if an alternate handler description is // specified, use it. - AVDictionaryEntry *t; + const AVDictionaryEntry *t; t = av_dict_get(track->st->metadata, "handler_name", NULL, 0); if (t && utf8len(t->value)) descr = t->value; @@ -3639,7 +3639,7 @@ static int mov_write_track_metadata(AVIOContext *pb, AVStream *st, const char *tag, const char *str) { int64_t pos = avio_tell(pb); - AVDictionaryEntry *t = av_dict_get(st->metadata, str, NULL, 0); + const AVDictionaryEntry *t = av_dict_get(st->metadata, str, NULL, 0); if (!t || !utf8len(t->value)) return 0; @@ -3952,11 +3952,11 @@ static int mov_write_string_tag(AVIOContext *pb, const char *name, return size; } -static AVDictionaryEntry *get_metadata_lang(AVFormatContext *s, +static const AVDictionaryEntry *get_metadata_lang(AVFormatContext *s, const char *tag, int *lang) { int l, len, len2; - AVDictionaryEntry *t, *t2 = NULL; + const AVDictionaryEntry *t, *t2 = NULL; char tag2[16]; *lang = 0; @@ -3982,7 +3982,7 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb, int long_style) { int lang; - AVDictionaryEntry *t = get_metadata_lang(s, tag, &lang); + const AVDictionaryEntry *t = get_metadata_lang(s, tag, &lang); if (!t) return 0; return mov_write_string_tag(pb, name, t->value, lang, long_style); @@ -3991,7 +3991,7 @@ static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb, /* iTunes bpm number */ static int mov_write_tmpo_tag(AVIOContext *pb, AVFormatContext *s) { - AVDictionaryEntry *t = av_dict_get(s->metadata, "tmpo", NULL, 0); + const AVDictionaryEntry *t = av_dict_get(s->metadata, "tmpo", NULL, 0); int size = 0, tmpo = t ? atoi(t->value) : 0; if (tmpo) { size = 26; @@ -4013,7 +4013,7 @@ static int mov_write_loci_tag(AVFormatContext *s, AVIOContext *pb) int64_t pos = avio_tell(pb); double latitude, longitude, altitude; int32_t latitude_fix, longitude_fix, altitude_fix; - AVDictionaryEntry *t = get_metadata_lang(s, "location", &lang); + const AVDictionaryEntry *t = get_metadata_lang(s, "location", &lang); const char *ptr, *place = ""; char *end; static const char *astronomical_body = "earth"; @@ -4061,9 +4061,9 @@ static int mov_write_loci_tag(AVFormatContext *s, AVIOContext *pb) static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s, int disc) { - AVDictionaryEntry *t = av_dict_get(s->metadata, - disc ? "disc" : "track", - NULL, 0); + const AVDictionaryEntry *t = av_dict_get(s->metadata, + disc ? "disc" : "track", + NULL, 0); int size = 0, track = t ? atoi(t->value) : 0; if (track) { int tracks = 0; @@ -4089,7 +4089,7 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, const char *name, const char *tag, int len) { - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; uint8_t num; int size = 24 + len; @@ -4281,7 +4281,7 @@ static int mov_write_raw_metadata_tag(AVFormatContext *s, AVIOContext *pb, const char *name, const char *key) { int len; - AVDictionaryEntry *t; + const AVDictionaryEntry *t; if (!(t = av_dict_get(s->metadata, key, NULL, 0))) return 0; @@ -4319,7 +4319,7 @@ static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s, const char *tag, const char *str) { int64_t pos = avio_tell(pb); - AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0); + const AVDictionaryEntry *t = av_dict_get(s->metadata, str, NULL, 0); if (!t || !utf8len(t->value)) return 0; avio_wb32(pb, 0); /* size */ @@ -4350,7 +4350,7 @@ static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < nb_chapters; i++) { AVChapter *c = s->chapters[i]; - AVDictionaryEntry *t; + const AVDictionaryEntry *t; avio_wb64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000})); if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { @@ -4436,7 +4436,7 @@ static void mov_write_psp_udta_tag(AVIOContext *pb, static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s) { - AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0); + const AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0); int64_t pos, pos2; if (title) { @@ -4673,7 +4673,7 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat char track_name_buf[32] = { 0 }; AVStream *st = track->st; - AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); + const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && !is_cover_image(st)) { type = "video"; @@ -6673,7 +6673,7 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum) for (i = 0; i < s->nb_chapters; i++) { AVChapter *c = s->chapters[i]; - AVDictionaryEntry *t; + const AVDictionaryEntry *t; int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,mov->movie_timescale}); pkt->pts = pkt->dts = av_rescale_q(c->start, c->time_base, (AVRational){1,mov->movie_timescale}); @@ -7068,13 +7068,13 @@ static int mov_init(AVFormatContext *s) if ( mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == MODE_MP4) || mov->write_tmcd == 1) { - AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode", - NULL, 0); + const AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode", + NULL, 0); /* +1 tmcd track for each video stream with a timecode */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - AVDictionaryEntry *t = global_tcr; + const AVDictionaryEntry *t = global_tcr; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && (t || (t=av_dict_get(st->metadata, "timecode", NULL, 0)))) { AVTimecode tc; @@ -7130,7 +7130,7 @@ static int mov_init(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st= s->streams[i]; MOVTrack *track= &mov->tracks[i]; - AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); + const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); track->st = st; track->par = st->codecpar; diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 5e81f72a59..41ade128ed 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -41,7 +41,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key, uint8_t *buf, int buf_size) { - AVDictionaryEntry *tag; + const AVDictionaryEntry *tag; if ((tag = av_dict_get(s->metadata, key, NULL, 0))) av_strlcpy(buf, tag->value, buf_size); return !!tag; @@ -50,7 +50,7 @@ static int id3v1_set_string(AVFormatContext *s, const char *key, // refer to: http://id3.org/ID3v1 static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf) { - AVDictionaryEntry *tag; + const AVDictionaryEntry *tag; int i, count = 0; memset(buf, 0, ID3v1_TAG_SIZE); /* fail safe */ @@ -145,7 +145,7 @@ static int mp3_write_xing(AVFormatContext *s) { MP3Context *mp3 = s->priv_data; AVCodecParameters *par = s->streams[mp3->audio_stream_idx]->codecpar; - AVDictionaryEntry *enc = av_dict_get(s->streams[mp3->audio_stream_idx]->metadata, "encoder", NULL, 0); + const AVDictionaryEntry *enc = av_dict_get(s->streams[mp3->audio_stream_idx]->metadata, "encoder", NULL, 0); AVIOContext *dyn_ctx; int32_t header; MPADecodeHeader mpah; diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 700fc549df..6f1062b2d9 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -529,7 +529,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MpegTSWriteStream *ts_st = st->priv_data; - AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); + const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); const char default_language[] = "und"; const char *language = lang && strlen(lang->value) >= 3 ? lang->value : default_language; enum AVCodecID codec_id = st->codecpar->codec_id; @@ -986,7 +986,7 @@ static MpegTSService *mpegts_add_service(AVFormatContext *s, int sid, { MpegTSWrite *ts = s->priv_data; MpegTSService *service; - AVDictionaryEntry *title, *provider; + const AVDictionaryEntry *title, *provider; char default_service_name[32]; const char *service_name; const char *provider_name; @@ -1088,7 +1088,7 @@ static void select_pcr_streams(AVFormatContext *s) static int mpegts_init(AVFormatContext *s) { MpegTSWrite *ts = s->priv_data; - AVDictionaryEntry *provider; + const AVDictionaryEntry *provider; const char *provider_name; int i, j; int ret; diff --git a/libavformat/mux.c b/libavformat/mux.c index 415bd3948f..cfb1269ff5 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -185,7 +185,7 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) FFFormatContext *const si = ffformatcontext(s); AVDictionary *tmp = NULL; const FFOutputFormat *of = ffofmt(s->oformat); - AVDictionaryEntry *e; + const AVDictionaryEntry *e; int ret = 0; if (options) diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c index 3e63b8039a..af1ce420e7 100644 --- a/libavformat/mux_utils.c +++ b/libavformat/mux_utils.c @@ -125,7 +125,7 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds) { - AVDictionaryEntry *entry; + const AVDictionaryEntry *entry; int64_t parsed_timestamp; int ret; if ((entry = av_dict_get(s->metadata, "creation_time", NULL, 0))) { diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index d8252ed68f..e9eb801aa5 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -799,9 +799,9 @@ static void mxf_write_identification(AVFormatContext *s) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; - AVDictionaryEntry *com_entry = av_dict_get(s->metadata, "company_name", NULL, 0); - AVDictionaryEntry *product_entry = av_dict_get(s->metadata, "product_name", NULL, 0); - AVDictionaryEntry *version_entry = av_dict_get(s->metadata, "product_version", NULL, 0); + const AVDictionaryEntry *com_entry = av_dict_get(s->metadata, "company_name", NULL, 0); + const AVDictionaryEntry *product_entry = av_dict_get(s->metadata, "product_name", NULL, 0); + const AVDictionaryEntry *version_entry = av_dict_get(s->metadata, "product_version", NULL, 0); const char *company = com_entry ? com_entry->value : "FFmpeg"; const char *product = product_entry ? product_entry->value : !IS_OPATOM(s) ? "OP1a Muxer" : "OPAtom Muxer"; const char *platform = s->flags & AVFMT_FLAG_BITEXACT ? "Lavf" : PLATFORM_IDENT; @@ -1649,7 +1649,7 @@ static int mxf_write_tagged_value(AVFormatContext *s, const char* name, const ch static int mxf_write_user_comments(AVFormatContext *s, const AVDictionary *m) { MXFContext *mxf = s->priv_data; - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; int count = 0; while ((t = av_dict_get(m, "comment_", t, AV_DICT_IGNORE_SUFFIX))) { @@ -1789,7 +1789,7 @@ static int mxf_write_essence_container_data(AVFormatContext *s) static int mxf_write_header_metadata_sets(AVFormatContext *s) { MXFContext *mxf = s->priv_data; - AVDictionaryEntry *entry = NULL; + const AVDictionaryEntry *entry = NULL; AVStream *st = NULL; int i; MXFPackage packages[3] = {{0}}; @@ -2652,7 +2652,7 @@ static void mxf_gen_umid(AVFormatContext *s) static int mxf_init_timecode(AVFormatContext *s, AVStream *st, AVRational tbc) { MXFContext *mxf = s->priv_data; - AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + const AVDictionaryEntry *tcr = av_dict_get(s->metadata, "timecode", NULL, 0); if (!ff_mxf_get_content_package_rate(tbc)) { if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { @@ -2854,7 +2854,7 @@ static int mxf_init(AVFormatContext *s) if (ret < 0) return ret; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { - AVDictionaryEntry *e = av_dict_get(st->metadata, "data_type", NULL, 0); + const AVDictionaryEntry *e = av_dict_get(st->metadata, "data_type", NULL, 0); if (e && !strcmp(e->value, "vbi_vanc_smpte_436M")) { sc->index = INDEX_S436M; } else { diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index 179b0f12cb..d5c9eb8c2e 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -336,7 +336,7 @@ void ff_riff_write_info(AVFormatContext *s) AVIOContext *pb = s->pb; int i; int64_t list_pos; - AVDictionaryEntry *t = NULL; + const AVDictionaryEntry *t = NULL; ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL); diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c index 0d001224cb..a1f9d9ee15 100644 --- a/libavformat/rmenc.c +++ b/libavformat/rmenc.c @@ -77,7 +77,7 @@ static int rv10_write_header(AVFormatContext *ctx, int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i; int bit_rate, v, duration, flags; int data_offset; - AVDictionaryEntry *tag; + const AVDictionaryEntry *tag; ffio_wfourcc(s, ".RMF"); avio_wb32(s,18); /* header size */ diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 28839b837f..714ff1e148 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -77,7 +77,7 @@ static int sap_write_header(AVFormatContext *s) struct sockaddr_storage localaddr; socklen_t addrlen = sizeof(localaddr); int udp_fd; - AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0); + const AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0); if (!ff_network_init()) return AVERROR(EIO); diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 6888936290..61e57894a0 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -837,7 +837,7 @@ int ff_sdp_write_media(char *buff, int size, const AVStream *st, int idx, int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size) { - AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0); + const AVDictionaryEntry *title = av_dict_get(ac[0]->metadata, "title", NULL, 0); struct sdp_session_level s = { 0 }; int i, j, port, ttl, is_multicast, index = 0; char dst[32], dst_type[5]; diff --git a/libavformat/segment.c b/libavformat/segment.c index 2a82f39f31..1fb52c7f16 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -355,7 +355,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last) int ret = 0; AVTimecode tc; AVRational rate; - AVDictionaryEntry *tcr; + const AVDictionaryEntry *tcr; char buf[AV_TIMECODE_STR_SIZE]; int i; int err; @@ -441,7 +441,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last) char st_buf[AV_TIMECODE_STR_SIZE]; AVTimecode st_tc; AVRational st_rate = s->streams[i]->avg_frame_rate; - AVDictionaryEntry *st_tcr = av_dict_get(s->streams[i]->metadata, "timecode", NULL, 0); + const AVDictionaryEntry *st_tcr = av_dict_get(s->streams[i]->metadata, "timecode", NULL, 0); if (st_tcr) { if ((av_timecode_init_from_string(&st_tc, st_rate, st_tcr->value, s) < 0)) { av_log(s, AV_LOG_WARNING, "Could not increment stream %d timecode, error occurred during timecode creation.\n", i); diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index 062b4a3fae..b10168c91f 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -47,7 +47,7 @@ static int sox_write_header(AVFormatContext *s) SoXContext *sox = s->priv_data; AVIOContext *pb = s->pb; AVCodecParameters *par = s->streams[0]->codecpar; - AVDictionaryEntry *comment; + const AVDictionaryEntry *comment; size_t comment_len = 0, comment_size; comment = av_dict_get(s->metadata, "comment", NULL, 0); diff --git a/libavformat/tee.c b/libavformat/tee.c index 70f3f2eb29..2aa2934677 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave) int i, ret; AVDictionary *options = NULL, *bsf_options = NULL; char *entry_val = NULL; - AVDictionaryEntry *entry; + const AVDictionaryEntry *entry; char *filename; char *format = NULL, *select = NULL, *on_fail = NULL; char *use_fifo = NULL, *fifo_options_str = NULL; diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c index 212994be50..41020c2537 100644 --- a/libavformat/ttmlenc.c +++ b/libavformat/ttmlenc.c @@ -136,8 +136,8 @@ static int ttml_write_header(AVFormatContext *ctx) AVStream *st = ctx->streams[0]; AVIOContext *pb = ctx->pb; - AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, - 0); + const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, + 0); const char *printed_lang = (lang && lang->value) ? lang->value : ""; ttml_ctx->input_type = ff_is_ttml_stream_paragraph_based(st->codecpar) ? diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c index c12c090934..345f21293c 100644 --- a/libavformat/wavenc.c +++ b/libavformat/wavenc.c @@ -91,7 +91,7 @@ typedef struct WAVMuxContext { #if CONFIG_WAV_MUXER static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, int maxlen) { - AVDictionaryEntry *tag; + const AVDictionaryEntry *tag; size_t len = 0; if (tag = av_dict_get(s->metadata, key, NULL, 0)) { @@ -105,7 +105,7 @@ static inline void bwf_write_bext_string(AVFormatContext *s, const char *key, in static void bwf_write_bext_chunk(AVFormatContext *s) { - AVDictionaryEntry *tmp_tag; + const AVDictionaryEntry *tmp_tag; uint64_t time_reference = 0; int64_t bext = ff_start_tag(s->pb, "bext"); diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 0d6c4a2072..e085227ddd 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -71,7 +71,7 @@ static double get_duration(AVFormatContext *s) int i = 0; double max = 0.0; for (i = 0; i < s->nb_streams; i++) { - AVDictionaryEntry *duration = av_dict_get(s->streams[i]->metadata, + const AVDictionaryEntry *duration = av_dict_get(s->streams[i]->metadata, DURATION, NULL, 0); if (!duration || atof(duration->value) < 0) continue; if (atof(duration->value) > max) max = atof(duration->value); @@ -130,11 +130,11 @@ static void write_footer(AVFormatContext *s) static int subsegment_alignment(AVFormatContext *s, const AdaptationSet *as) { int i; - AVDictionaryEntry *gold = av_dict_get(s->streams[as->streams[0]]->metadata, + const AVDictionaryEntry *gold = av_dict_get(s->streams[as->streams[0]]->metadata, CUE_TIMESTAMPS, NULL, 0); if (!gold) return 0; for (i = 1; i < as->nb_streams; i++) { - AVDictionaryEntry *ts = av_dict_get(s->streams[as->streams[i]]->metadata, + const AVDictionaryEntry *ts = av_dict_get(s->streams[as->streams[i]]->metadata, CUE_TIMESTAMPS, NULL, 0); if (!ts || !av_strstart(ts->value, gold->value, NULL)) return 0; } @@ -145,13 +145,13 @@ static int bitstream_switching(AVFormatContext *s, const AdaptationSet *as) { int i; const AVStream *gold_st = s->streams[as->streams[0]]; - AVDictionaryEntry *gold_track_num = av_dict_get(gold_st->metadata, + const AVDictionaryEntry *gold_track_num = av_dict_get(gold_st->metadata, TRACK_NUMBER, NULL, 0); AVCodecParameters *gold_par = gold_st->codecpar; if (!gold_track_num) return 0; for (i = 1; i < as->nb_streams; i++) { const AVStream *st = s->streams[as->streams[i]]; - AVDictionaryEntry *track_num = av_dict_get(st->metadata, + const AVDictionaryEntry *track_num = av_dict_get(st->metadata, TRACK_NUMBER, NULL, 0); AVCodecParameters *par = st->codecpar; if (!track_num || @@ -177,7 +177,7 @@ static int write_representation(AVFormatContext *s, AVStream *st, char *id, WebMDashMuxContext *w = s->priv_data; AVIOContext *pb = s->pb; const AVCodecParameters *par = st->codecpar; - AVDictionaryEntry *bandwidth = av_dict_get(st->metadata, BANDWIDTH, NULL, 0); + const AVDictionaryEntry *bandwidth = av_dict_get(st->metadata, BANDWIDTH, NULL, 0); const char *bandwidth_str; avio_printf(pb, ""); } else { - AVDictionaryEntry *irange = av_dict_get(st->metadata, INITIALIZATION_RANGE, NULL, 0); - AVDictionaryEntry *cues_start = av_dict_get(st->metadata, CUES_START, NULL, 0); - AVDictionaryEntry *cues_end = av_dict_get(st->metadata, CUES_END, NULL, 0); - AVDictionaryEntry *filename = av_dict_get(st->metadata, FILENAME, NULL, 0); + const AVDictionaryEntry *irange = av_dict_get(st->metadata, INITIALIZATION_RANGE, NULL, 0); + const AVDictionaryEntry *cues_start = av_dict_get(st->metadata, CUES_START, NULL, 0); + const AVDictionaryEntry *cues_end = av_dict_get(st->metadata, CUES_END, NULL, 0); + const AVDictionaryEntry *filename = av_dict_get(st->metadata, FILENAME, NULL, 0); if (!irange || !cues_start || !cues_end || !filename) return AVERROR(EINVAL); @@ -307,7 +307,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index) AdaptationSet *as = &w->as[as_index]; const AVStream *st = s->streams[as->streams[0]]; AVCodecParameters *par = st->codecpar; - AVDictionaryEntry *lang; + const AVDictionaryEntry *lang; AVIOContext *pb = s->pb; int i; static const char boolean[2][6] = { "false", "true" }; @@ -347,15 +347,15 @@ static int write_adaptation_set(AVFormatContext *s, int as_index) boolean[w->is_live || subsegment_alignment(s, as)]); for (i = 0; i < as->nb_streams; i++) { - AVDictionaryEntry *kf = av_dict_get(s->streams[as->streams[i]]->metadata, - CLUSTER_KEYFRAME, NULL, 0); + const AVDictionaryEntry *kf = av_dict_get(s->streams[as->streams[i]]->metadata, + CLUSTER_KEYFRAME, NULL, 0); if (!w->is_live && (!kf || !strncmp(kf->value, "0", 1))) subsegmentStartsWithSAP = 0; } avio_printf(pb, " subsegmentStartsWithSAP=\"%d\"", subsegmentStartsWithSAP); avio_printf(pb, ">\n"); if (w->is_live) { - AVDictionaryEntry *filename = + const AVDictionaryEntry *filename = av_dict_get(st->metadata, FILENAME, NULL, 0); char *underscore_pos, *period_pos; int ret; @@ -383,7 +383,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index) AVStream *st = s->streams[as->streams[i]]; int ret; if (w->is_live) { - AVDictionaryEntry *filename = + const AVDictionaryEntry *filename = av_dict_get(st->metadata, FILENAME, NULL, 0); if (!filename) return AVERROR(EINVAL); diff --git a/libavutil/dict.c b/libavutil/dict.c index ac41771994..ca5026905c 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -57,6 +57,9 @@ const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m, return &m->elems[i]; } +#if !FF_API_AV_DICT_GET_NOT_CONST +const +#endif AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) { @@ -78,7 +81,11 @@ AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, continue; if (s[j] && !(flags & AV_DICT_IGNORE_SUFFIX)) continue; + #if FF_API_AV_DICT_GET_NOT_CONST return (AVDictionaryEntry *)entry; + #else + return entry; + #endif } return NULL; } @@ -100,7 +107,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, goto err_out; } if (!(flags & AV_DICT_MULTIKEY)) { - tag = av_dict_get(m, key, NULL, flags); + tag = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags); } if (flags & AV_DICT_DONT_STRDUP_KEY) copy_key = (void *)key; diff --git a/libavutil/dict.h b/libavutil/dict.h index b2ab55a026..984c12311b 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -32,6 +32,8 @@ #include +#include "version.h" + /** * @addtogroup lavu_dict AVDictionary * @ingroup lavu_data @@ -107,6 +109,9 @@ typedef struct AVDictionary AVDictionary; * * @return Found entry or NULL in case no matching entry was found in the dictionary */ +#if !FF_API_AV_DICT_GET_NOT_CONST +const +#endif AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 5ae7711c94..ed698aa6f7 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -379,7 +379,7 @@ static int cuda_context_init(AVHWDeviceContext *device_ctx, int flags) { static int cuda_flags_from_opts(AVHWDeviceContext *device_ctx, AVDictionary *opts, int *flags) { - AVDictionaryEntry *primary_ctx_opt = av_dict_get(opts, "primary_ctx", NULL, 0); + const AVDictionaryEntry *primary_ctx_opt = av_dict_get(opts, "primary_ctx", NULL, 0); if (primary_ctx_opt && strtol(primary_ctx_opt->value, NULL, 10)) { av_log(device_ctx, AV_LOG_VERBOSE, "Using CUDA primary device context\n"); diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 6780428875..a00bec89ec 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -2106,7 +2106,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 ffd4f5dec4..f3429fc39f 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -438,7 +438,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; @@ -566,14 +566,14 @@ static int check_validation_layers(AVHWDeviceContext *ctx, AVDictionary *opts, uint32_t sup_layer_count; VkLayerProperties *sup_layers; - AVDictionaryEntry *user_layers; + const AVDictionaryEntry *user_layers; char *user_layers_str = NULL; char *save, *token; const char **enabled_layers = NULL; uint32_t enabled_layers_count = 0; - AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0); + const AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0); int debug = debug_opt && strtol(debug_opt->value, NULL, 10); /* If `debug=0`, enable no layers at all. */ @@ -1313,7 +1313,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; FFVulkanFunctions *vk = &p->vkfn; AVVulkanDeviceContext *hwctx = ctx->hwctx; diff --git a/libavutil/version.h b/libavutil/version.h index b8d1ef06a8..31c0403466 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -115,6 +115,7 @@ #define FF_API_FRAME_PICTURE_NUMBER (LIBAVUTIL_VERSION_MAJOR < 59) #define FF_API_HDR_VIVID_THREE_SPLINE (LIBAVUTIL_VERSION_MAJOR < 59) #define FF_API_FRAME_PKT (LIBAVUTIL_VERSION_MAJOR < 59) +#define FF_API_AV_DICT_GET_NOT_CONST (LIBAVUTIL_VERSION_MAJOR < 59) /** * @} diff --git a/tests/api/api-threadmessage-test.c b/tests/api/api-threadmessage-test.c index c96b473c43..c37c081249 100644 --- a/tests/api/api-threadmessage-test.c +++ b/tests/api/api-threadmessage-test.c @@ -137,7 +137,7 @@ static void *receiver_thread(void *arg) } else { struct message msg; AVDictionary *meta; - AVDictionaryEntry *e; + const AVDictionaryEntry *e; ret = av_thread_message_queue_recv(rd->queue, &msg, 0); if (ret < 0)