From patchwork Mon Mar 4 13:06:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46747 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2788372pzb; Mon, 4 Mar 2024 05:07:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWrWOjUdv0x9jN5QPIYH+XzBqlejPyjJWx39xEv2NP77blFLdQVD6l4g1UEkU8P2c32uO849FvZUhlNWfwcoxIsTqyzx6yC/6zclA== X-Google-Smtp-Source: AGHT+IEoGRxoQFu8iylHU0eg5pJ2wzQ5NsZL9rxj3TubSiK2PHaBiE6BRh8gAS+xUk/+2I1smIuD X-Received: by 2002:aa7:cfd9:0:b0:567:58a8:ca61 with SMTP id r25-20020aa7cfd9000000b0056758a8ca61mr1226787edy.1.1709557638950; Mon, 04 Mar 2024 05:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557638; cv=none; d=google.com; s=arc-20160816; b=zUJhd+XiC3Mbm+HsTPNdW4qSjnSxZYKGYabt9EpD/dOUVBbeHXQCessWUue6b5xhDE X+czGzCxGgNop9sK978Xe/38YIIwTpuXJGOQ+teyh9hInoi8NJ3Oq5BeZc9uXLOiksEW Si4h+X93/hFgwmWRRfjN/sdbk75xJw1R3gqtShnmDNIHnGKw4/d89Bm7VeqcNi4V96zL ej7EvoQ+ddfib+T0ru34W14jfSOdXOuNmnnSZ4f6QOGvzT6s63BGWYUaMkgYarr+uONp 7RgN45j+RMWwlyGC4gc5uHox1IPAPAzK0+GFgTFZBEUKHFSFVklFNSiyBlJgP5AOB2+T a7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=eJTLp2cQITmhY56qNQEL3I3Vqd4ktm3W6pQ7aFxypaA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Ijjjp7ZFfwphB/W5vT/4f4svh1e3CYHOdKdsXiQ7t65htzamIYeYo2b+fYRZ29onBk esu1EObBOtBqqsyncj2Z2QFNdXD97imvP/Ir8vRal9BSRR0yiOtOKd457TEyrsJ5iQLf ONOJa1CGwNChpMlADrCk7yh1omqw31D1QvvdPjCwgDvE4TZGr0mk41eVsBrm8ztO75ja VRlIQd/mn7zomR0QvwDOJhbDbe+LnJ1MQHwiZ6zXYe6hzouLWYqmuTJ5i07ZlNmbfEGp pm3DOPNlQsNcW+sM8z7iCJE6jDgo4HGDzxNWXADPM/HOlbL09wosslQX1UU8ZFqVH1Et KLFg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=ZMIVKbUk; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u25-20020a509519000000b005670e6bf8b1si1900935eda.686.2024.03.04.05.07.18; Mon, 04 Mar 2024 05:07:18 -0800 (PST) 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=@khirnov.net header.s=mail header.b=ZMIVKbUk; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CB6E368D452; Mon, 4 Mar 2024 15:07:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA92668D35D for ; Mon, 4 Mar 2024 15:07:08 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=ZMIVKbUk; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1AF494D78 for ; Mon, 4 Mar 2024 14:07:07 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id zpECdzo0PblK for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=pc/P0BtVmYjHuWV5PF95zU4LZ3s/q/N4h4TSHkymCFo=; h=From:To:Subject:Date:From; b=ZMIVKbUkWQTu0VRxfodeGoC0TdN3x4YnBGVBDYsyeCnE3lhXVs7SzjeDSwf6XaD8N OF4ODpLQ7ZPCq2kQ3hVjsyNADAO8X1NsiNSH0jCjacFVv8XVRhJEqFOkROVgfIEY4s 89yL7MMuLeAhsl1NbEmFczE8+rBZlAuGcyIb0q5kiNNap/Svr8//aIWUueWZU4gOL0 DPv0xRrWd/YO3liV1aXH4T8pBieTRqJZStn29a5ytFprhG7SDt4NHxgyz1VgS1Xk4y N6pxk0euxnN2KNGgHLd5NSIJ/WxhworZIiZTH2YZk/r5dU+NDIo4m+JCprTSR/Tyfx V7g3pZmt7LAZQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 126984D3D for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D7C7E3A0357 for ; Mon, 4 Mar 2024 14:06:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:16 +0100 Message-ID: <20240304130657.30631-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/29] lavu/opt: factor per-type dispatch out of av_opt_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MgwJgRj9f/qT Will be useful in following commits. --- libavutil/opt.c | 220 ++++++++++++++++++++++++++---------------------- 1 file changed, 121 insertions(+), 99 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index d68184c2cc..dac00478ee 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -844,13 +844,123 @@ static void format_duration(char *buf, size_t size, int64_t d) *(--e) = 0; } +static int opt_get_elem(const AVOption *o, uint8_t **pbuf, size_t buf_len, + void *dst, int search_flags) +{ + int ret; + + switch (o->type) { + case AV_OPT_TYPE_BOOL: + ret = snprintf(*pbuf, buf_len, "%s", get_bool_name(*(int *)dst)); + break; + case AV_OPT_TYPE_FLAGS: + ret = snprintf(*pbuf, buf_len, "0x%08X", *(int *)dst); + break; + case AV_OPT_TYPE_INT: + ret = snprintf(*pbuf, buf_len, "%d", *(int *)dst); + break; + case AV_OPT_TYPE_INT64: + ret = snprintf(*pbuf, buf_len, "%"PRId64, *(int64_t *)dst); + break; + case AV_OPT_TYPE_UINT64: + ret = snprintf(*pbuf, buf_len, "%"PRIu64, *(uint64_t *)dst); + break; + case AV_OPT_TYPE_FLOAT: + ret = snprintf(*pbuf, buf_len, "%f", *(float *)dst); + break; + case AV_OPT_TYPE_DOUBLE: + ret = snprintf(*pbuf, buf_len, "%f", *(double *)dst); + break; + case AV_OPT_TYPE_VIDEO_RATE: + case AV_OPT_TYPE_RATIONAL: + ret = snprintf(*pbuf, buf_len, "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den); + break; + case AV_OPT_TYPE_CONST: + ret = snprintf(*pbuf, buf_len, "%"PRId64, o->default_val.i64); + break; + case AV_OPT_TYPE_STRING: + if (*(uint8_t **)dst) { + *pbuf = av_strdup(*(uint8_t **)dst); + } else if (search_flags & AV_OPT_ALLOW_NULL) { + *pbuf = NULL; + return 0; + } else { + *pbuf = av_strdup(""); + } + return *pbuf ? 0 : AVERROR(ENOMEM); + case AV_OPT_TYPE_BINARY: { + const uint8_t *bin; + int len; + + if (!*(uint8_t **)dst && (search_flags & AV_OPT_ALLOW_NULL)) { + *pbuf = NULL; + return 0; + } + len = *(int *)(((uint8_t *)dst) + sizeof(uint8_t *)); + if ((uint64_t)len * 2 + 1 > INT_MAX) + return AVERROR(EINVAL); + if (!(*pbuf = av_malloc(len * 2 + 1))) + return AVERROR(ENOMEM); + if (!len) { + *pbuf[0] = '\0'; + return 0; + } + bin = *(uint8_t **)dst; + for (int i = 0; i < len; i++) + snprintf(*pbuf + i * 2, 3, "%02X", bin[i]); + return 0; + } + case AV_OPT_TYPE_IMAGE_SIZE: + ret = snprintf(*pbuf, buf_len, "%dx%d", ((int *)dst)[0], ((int *)dst)[1]); + break; + case AV_OPT_TYPE_PIXEL_FMT: + ret = snprintf(*pbuf, buf_len, "%s", (char *)av_x_if_null(av_get_pix_fmt_name(*(enum AVPixelFormat *)dst), "none")); + break; + case AV_OPT_TYPE_SAMPLE_FMT: + ret = snprintf(*pbuf, buf_len, "%s", (char *)av_x_if_null(av_get_sample_fmt_name(*(enum AVSampleFormat *)dst), "none")); + break; + case AV_OPT_TYPE_DURATION: { + int64_t i64 = *(int64_t *)dst; + format_duration(*pbuf, buf_len, i64); + ret = strlen(*pbuf); // no overflow possible, checked by an assert + break; + } + case AV_OPT_TYPE_COLOR: + ret = snprintf(*pbuf, buf_len, "0x%02x%02x%02x%02x", + (int)((uint8_t *)dst)[0], (int)((uint8_t *)dst)[1], + (int)((uint8_t *)dst)[2], (int)((uint8_t *)dst)[3]); + break; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + case AV_OPT_TYPE_CHANNEL_LAYOUT: { + int64_t i64 = *(int64_t *)dst; + ret = snprintf(*pbuf, buf_len, "0x%"PRIx64, i64); + break; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + case AV_OPT_TYPE_CHLAYOUT: + ret = av_channel_layout_describe(dst, *pbuf, buf_len); + break; + case AV_OPT_TYPE_DICT: + if (!*(AVDictionary **)dst && (search_flags & AV_OPT_ALLOW_NULL)) { + *pbuf = NULL; + return 0; + } + return av_dict_get_string(*(AVDictionary **)dst, (char **)pbuf, '=', ':'); + default: + return AVERROR(EINVAL); + } + + return ret; +} + int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) { void *dst, *target_obj; const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); - uint8_t *bin, buf[128]; - int len, i, ret; - int64_t i64; + uint8_t *out, buf[128]; + int ret; if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST)) return AVERROR_OPTION_NOT_FOUND; @@ -861,107 +971,19 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) dst = (uint8_t *)target_obj + o->offset; buf[0] = 0; - switch (o->type) { - case AV_OPT_TYPE_BOOL: - ret = snprintf(buf, sizeof(buf), "%s", get_bool_name(*(int *)dst)); - break; - case AV_OPT_TYPE_FLAGS: - ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst); - break; - case AV_OPT_TYPE_INT: - ret = snprintf(buf, sizeof(buf), "%d", *(int *)dst); - break; - case AV_OPT_TYPE_INT64: - ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t *)dst); - break; - case AV_OPT_TYPE_UINT64: - ret = snprintf(buf, sizeof(buf), "%"PRIu64, *(uint64_t *)dst); - break; - case AV_OPT_TYPE_FLOAT: - ret = snprintf(buf, sizeof(buf), "%f", *(float *)dst); - break; - case AV_OPT_TYPE_DOUBLE: - ret = snprintf(buf, sizeof(buf), "%f", *(double *)dst); - break; - case AV_OPT_TYPE_VIDEO_RATE: - case AV_OPT_TYPE_RATIONAL: - ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den); - break; - case AV_OPT_TYPE_CONST: - ret = snprintf(buf, sizeof(buf), "%"PRId64, o->default_val.i64); - break; - case AV_OPT_TYPE_STRING: - if (*(uint8_t **)dst) { - *out_val = av_strdup(*(uint8_t **)dst); - } else if (search_flags & AV_OPT_ALLOW_NULL) { - *out_val = NULL; - return 0; - } else { - *out_val = av_strdup(""); - } - return *out_val ? 0 : AVERROR(ENOMEM); - case AV_OPT_TYPE_BINARY: - if (!*(uint8_t **)dst && (search_flags & AV_OPT_ALLOW_NULL)) { - *out_val = NULL; - return 0; - } - len = *(int *)(((uint8_t *)dst) + sizeof(uint8_t *)); - if ((uint64_t)len * 2 + 1 > INT_MAX) - return AVERROR(EINVAL); - if (!(*out_val = av_malloc(len * 2 + 1))) - return AVERROR(ENOMEM); - if (!len) { - *out_val[0] = '\0'; - return 0; - } - bin = *(uint8_t **)dst; - for (i = 0; i < len; i++) - snprintf(*out_val + i * 2, 3, "%02X", bin[i]); - return 0; - case AV_OPT_TYPE_IMAGE_SIZE: - ret = snprintf(buf, sizeof(buf), "%dx%d", ((int *)dst)[0], ((int *)dst)[1]); - break; - case AV_OPT_TYPE_PIXEL_FMT: - ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_pix_fmt_name(*(enum AVPixelFormat *)dst), "none")); - break; - case AV_OPT_TYPE_SAMPLE_FMT: - ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_sample_fmt_name(*(enum AVSampleFormat *)dst), "none")); - break; - case AV_OPT_TYPE_DURATION: - i64 = *(int64_t *)dst; - format_duration(buf, sizeof(buf), i64); - ret = strlen(buf); // no overflow possible, checked by an assert - break; - case AV_OPT_TYPE_COLOR: - ret = snprintf(buf, sizeof(buf), "0x%02x%02x%02x%02x", - (int)((uint8_t *)dst)[0], (int)((uint8_t *)dst)[1], - (int)((uint8_t *)dst)[2], (int)((uint8_t *)dst)[3]); - break; -#if FF_API_OLD_CHANNEL_LAYOUT -FF_DISABLE_DEPRECATION_WARNINGS - case AV_OPT_TYPE_CHANNEL_LAYOUT: - i64 = *(int64_t *)dst; - ret = snprintf(buf, sizeof(buf), "0x%"PRIx64, i64); - break; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - case AV_OPT_TYPE_CHLAYOUT: - ret = av_channel_layout_describe(dst, buf, sizeof(buf)); - break; - case AV_OPT_TYPE_DICT: - if (!*(AVDictionary **)dst && (search_flags & AV_OPT_ALLOW_NULL)) { - *out_val = NULL; - return 0; - } - return av_dict_get_string(*(AVDictionary **)dst, (char **)out_val, '=', ':'); - default: - return AVERROR(EINVAL); + out = buf; + ret = opt_get_elem(o, &out, sizeof(buf), dst, search_flags); + if (ret < 0) + return ret; + if (out != buf) { + *out_val = out; + return 0; } if (ret >= sizeof(buf)) return AVERROR(EINVAL); - *out_val = av_strdup(buf); + *out_val = av_strdup(out); return *out_val ? 0 : AVERROR(ENOMEM); } From patchwork Mon Mar 4 13:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46750 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2788638pzb; Mon, 4 Mar 2024 05:07:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVdUmhpCo0XORKWCjsPbpdqpuov/4WhqEPOT8OMVtUgO+SzIxEvbCRykpb3oHpJaM5I0VgyiDY3Nu/QT/uyI5eSSx1FVmidntcDJg== X-Google-Smtp-Source: AGHT+IHxS6fBCS5zZk7iU6rfYzvF0zuXnab10i4UiKguzwYMmkrWzRWZtwkUbakagwZTGMqsJmGV X-Received: by 2002:a50:9512:0:b0:566:d28c:a422 with SMTP id u18-20020a509512000000b00566d28ca422mr5539175eda.3.1709557661039; Mon, 04 Mar 2024 05:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557661; cv=none; d=google.com; s=arc-20160816; b=ezIVhz+xHK0IuX4cDknvGwqBcm5Kgn2t9Lm4KKJ6Be+qhBoKaA/WSTtOFf2LoOHoYh 1J9ss0enbC4vUIWKV/rU6MYThCPt2//lweY31VPAwo2L3p/sl5fAVMBqXI4RwqDLZOlJ WG9tAK9TJeV0/3HQBP2lLtxb814M9QmIPPWNwk1Mj0WcmUhtCyeE2jbP1r8L/9b5cjPU i6N8A7PyNNIIf0y/y2OQ5S5JNP0pdqWYKj21cJqYzrBjBqZqm0yEXZ9ohYRz/7ZeeYIT yfar/FMeGmgnulQPnT1slom1nt8i6q+awjDPYq0U+mCLn4p3mbLNiSU3d6CCvrFvtPeZ qB7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=HDSVhYr0wMTCoL32jxngqFHYp34e9D7kmKePJ4j4JHc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=fCSsbTDhv5wJnYYK+8d1m4lqM9cvL7sfL56dbBpF+QXlqY+x9/WAhgyvmB7SoB6EmH j/lUPfDqPZ6u+0XZK3uVxE440KS6kHeqRz5gBadr1EJn3sI1ZHoAm/jPpnISfOuYYtEG +mGM4GVIpPPsoh5pVRP4m8r3fM+/VjTVr7qqcZNcuZQVn5JTD/O4p7TAuGSrP8Lqgdje 0aiPmpkCJKjvmFi8bosXqaNLjv0QSjvCyqr9GakbDrH28f5rvwFH1S6SePp3xwC4S1FS PI3WRgHCOR8mQCPEkFTJYbT8i5IEln0yFSmlR/6lmcUk65JGT5UU1nGlTT+6SDaiyepi WJig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=bLnICyVW; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eb14-20020a0564020d0e00b005662ce42344si3877865edb.147.2024.03.04.05.07.40; Mon, 04 Mar 2024 05:07:41 -0800 (PST) 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=@khirnov.net header.s=mail header.b=bLnICyVW; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D834568D441; Mon, 4 Mar 2024 15:07:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C097468D382 for ; Mon, 4 Mar 2024 15:07:08 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=bLnICyVW; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1AE4D4D76 for ; Mon, 4 Mar 2024 14:07:07 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 1udIAVAw65nY for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=0T1FQjmGPDb8Vlc3Ni1BIvDQoniFDeFG8j3KxAliRPg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bLnICyVWaDdt469s89TtHsG2ckwFBUi6EeltonEomcqeP19CmOBR6McS2ZrFBbDon +hwZPSMyGx387jJxqacX/YHc9w/nenEKtSaxRygvWiqQq4LQCyyGC5dzaxYsXL4FK5 jMwXgYtNibWi2pZUCc8bwDpCHb0+ayB1AjazEmy8IHmRJPw+UNbeIuu/l9n8XgL71g 9F1trQGulTjU5/yPngbtClBRICqrUHpRxzRllXer3lWUAoAg76OSKixI7zj3Qc+QCB pfLNKlIkdYNWjR2wYDVGosTgbTgOq+kfCn5wZ3/JVC3dbyxOv8S12ArK3ye+QBzdJJ vVAw8pd04oxJw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 1027B10B9 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E4D223A0582 for ; Mon, 4 Mar 2024 14:06:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:17 +0100 Message-ID: <20240304130657.30631-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/29] lavu/opt: factor per-type dispatch out of av_opt_set() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mPyBMF8A872L Will be useful in following commits. --- libavutil/opt.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index dac00478ee..b372c76120 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -494,13 +494,11 @@ static int set_string_channel_layout(void *obj, const AVOption *o, return av_channel_layout_from_string(channel_layout, val); } -int av_opt_set(void *obj, const char *name, const char *val, int search_flags) +static int opt_set_elem(void *obj, void *target_obj, const AVOption *o, + const char *val, void *dst) { - int ret = 0; - void *dst, *target_obj; - const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); - if (!o || !target_obj) - return AVERROR_OPTION_NOT_FOUND; + int ret; + FF_DISABLE_DEPRECATION_WARNINGS if (!val && (o->type != AV_OPT_TYPE_STRING && o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT && @@ -513,13 +511,6 @@ FF_DISABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); FF_ENABLE_DEPRECATION_WARNINGS - if (o->flags & AV_OPT_FLAG_READONLY) - return AVERROR(EINVAL); - - if (o->flags & AV_OPT_FLAG_DEPRECATED) - av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", name, o->help); - - dst = ((uint8_t *)target_obj) + o->offset; switch (o->type) { case AV_OPT_TYPE_BOOL: return set_string_bool(obj, o, val, dst); @@ -599,6 +590,24 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); } +int av_opt_set(void *obj, const char *name, const char *val, int search_flags) +{ + void *dst, *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + if (!o || !target_obj) + return AVERROR_OPTION_NOT_FOUND; + + if (o->flags & AV_OPT_FLAG_READONLY) + return AVERROR(EINVAL); + + if (o->flags & AV_OPT_FLAG_DEPRECATED) + av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", name, o->help); + + dst = ((uint8_t *)target_obj) + o->offset; + + return opt_set_elem(obj, target_obj, o, val, dst); +} + #define OPT_EVAL_NUMBER(name, opttype, vartype) \ int av_opt_eval_ ## name(void *obj, const AVOption *o, \ const char *val, vartype *name ## _out) \ From patchwork Mon Mar 4 13:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46749 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2788484pzb; Mon, 4 Mar 2024 05:07:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUpJswaOm4bQoWMw2C6m/Vzp7cOk1Eu7YG8VeMJRegJFM07hlJrQO5aWUUT1kHT0dDRmEhZEaWUO+Vi8bXRlF1GRoinAqPa3IcPVQ== X-Google-Smtp-Source: AGHT+IE6/7bCgdreb74nrB3Yxspr03XQCsP99MKOvgbJd3MdbpoK+ZcxDersWOh/CJkk0oSSi+fu X-Received: by 2002:a17:906:7118:b0:a45:5a30:a3f2 with SMTP id x24-20020a170906711800b00a455a30a3f2mr1405685ejj.52.1709557649591; Mon, 04 Mar 2024 05:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557649; cv=none; d=google.com; s=arc-20160816; b=AbxtdjtafPug73+/zK7gk1QcbATXmn4h2PbJW+9TOLmEUS+B9aYYAFR5QB190iuSxM U3Px9ql887+TOscZuAwAE5YCHOqVtSz6CA74I1bKFEtYPCe9CkzSbw5dzkmU0SGcAwWc 0ZwQCJFD+oOtjbpDjnaKkuIrue9aXGqvYD/90IF1u/FSbvfEcedrLmpUhYf8diM1nP0Q qQVy456a1wK7Xi2CnePU/hfTFNDe6MMPh/x/aR7xWhzl+DrSdLFtHSVjpyWqTXnjGnpv V8k2PIFG0YRaiFm8n/sdxY0OORB273JQbYh01/nkBTUr51q8ISL3TqveGredYtTOM1Al ksRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=CHQ36GDiEIZjsJh08B4f5cGxOVENurM21jlDTKD/RfE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PHGCYr5lN08MaHRZRiouZmVHgRDNgPc+shtp098qpP+vtNqj7nzXNvQWAKR38L+5Bg tU32jU1QyCYUA0LdsvhJnRSzTnYSlMb7PCBT7WorcoLeD9uEbCIrg5X/CDP81oEtC74N rDRDQejNMF/a79Mer9cMifzfv+kmt97/Aowx8AaC8ZN6Ki6qSy8WAWcoAvj7hBYAHYqJ cQ/JYEFEBPEL6UJeKfMg42qEiXSCaofdMglMJHRPjzlfcjvLAHBYfiMmd5IuJo7LK7FD ZtIYEilKxXhQE5Xplm3clzkze4qT07+bdI4vRwmIkS/tCC/VYUJnuANkX1JZV82tL5lh LGLA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=gsnlHVUI; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id wv6-20020a170907080600b00a3e616874f3si4153881ejb.993.2024.03.04.05.07.28; Mon, 04 Mar 2024 05:07:29 -0800 (PST) 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=@khirnov.net header.s=mail header.b=gsnlHVUI; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C2F5568D35D; Mon, 4 Mar 2024 15:07:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE20A68D36E for ; Mon, 4 Mar 2024 15:07:08 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=gsnlHVUI; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2C3424D42 for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 9u-KkEtHclRa for ; Mon, 4 Mar 2024 14:07:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=aZS/tmQsLzXyN39C0Pgl4bZjlhYHyB+XNrUDoV3vCpg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gsnlHVUIYiD4POVGxRzN88rFtdoXZfvjZHW0p7PreQtzf9HzhYcoZ6t5d/z3nwGT+ m16Xyfv4w54PdTZ7jJ75EhXdfrHwNI6i4eiFlsOrbyqcCJ2lQhGIMSBUTx5Lx8mZCe o+G4OG5yTPxV6TPL2mzs3mnGCjo6j8FvSQAB2G6wZPhTdpG+UI2mJPNZsPy621KNWS 9KbswoFfLsVIV7PGv3bRHwxLlVAs4/y0iosi+V9wty2zyJj6dpztE1L90jriLtGm13 pxaeEobz7oGHYTkdtWINDYMnCYXe/hW8MnBWXF19EWMwOaxQpVzQ+j5+U3OEJHX2sl rQFMByhXkMNdw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 4B42E4D46 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id EFE283A076E for ; Mon, 4 Mar 2024 14:06:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:18 +0100 Message-ID: <20240304130657.30631-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/29] libavutil/opt: rework figuring out option sizes 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JDLEjKc4hy7/ Replace the opt_size() function, currently only called from av_opt_copy(), with * a constant array of element sizes * a function that signals whether an option type is POD (i.e. memcpyable) or not Will be useful in following commits. --- libavutil/opt.c | 100 +++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index b372c76120..051a121331 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -56,6 +56,56 @@ const AVOption *av_opt_next(const void *obj, const AVOption *last) return NULL; } +static const size_t opt_elem_size[] = { + [AV_OPT_TYPE_FLAGS] = sizeof(unsigned), + [AV_OPT_TYPE_INT] = sizeof(int), + [AV_OPT_TYPE_INT64] = sizeof(int64_t), + [AV_OPT_TYPE_UINT64] = sizeof(uint64_t), + [AV_OPT_TYPE_DOUBLE] = sizeof(double), + [AV_OPT_TYPE_FLOAT] = sizeof(float), + [AV_OPT_TYPE_STRING] = sizeof(char *), + [AV_OPT_TYPE_RATIONAL] = sizeof(AVRational), + [AV_OPT_TYPE_BINARY] = sizeof(uint8_t *), + [AV_OPT_TYPE_DICT] = sizeof(AVDictionary *), + [AV_OPT_TYPE_IMAGE_SIZE] = sizeof(int[2]), + [AV_OPT_TYPE_VIDEO_RATE] = sizeof(AVRational), + [AV_OPT_TYPE_PIXEL_FMT] = sizeof(int), + [AV_OPT_TYPE_SAMPLE_FMT] = sizeof(int), + [AV_OPT_TYPE_DURATION] = sizeof(int64_t), + [AV_OPT_TYPE_COLOR] = sizeof(uint8_t[4]), +#if FF_API_OLD_CHANNEL_LAYOUT + [AV_OPT_TYPE_CHANNEL_LAYOUT]= sizeof(uint64_t), +#endif + [AV_OPT_TYPE_CHLAYOUT] = sizeof(AVChannelLayout), + [AV_OPT_TYPE_BOOL] = sizeof(int), +}; + +// option is plain old data +static int opt_is_pod(enum AVOptionType type) +{ + switch (type) { + case AV_OPT_TYPE_FLAGS: + case AV_OPT_TYPE_INT: + case AV_OPT_TYPE_INT64: + case AV_OPT_TYPE_DOUBLE: + case AV_OPT_TYPE_FLOAT: + case AV_OPT_TYPE_RATIONAL: + case AV_OPT_TYPE_UINT64: + case AV_OPT_TYPE_IMAGE_SIZE: + case AV_OPT_TYPE_PIXEL_FMT: + case AV_OPT_TYPE_SAMPLE_FMT: + case AV_OPT_TYPE_VIDEO_RATE: + case AV_OPT_TYPE_DURATION: + case AV_OPT_TYPE_COLOR: +#if FF_API_OLD_CHANNEL_LAYOUT + case AV_OPT_TYPE_CHANNEL_LAYOUT: +#endif + case AV_OPT_TYPE_BOOL: + return 1; + } + return 0; +} + static int read_number(const AVOption *o, const void *dst, double *num, int *den, int64_t *intnum) { switch (o->type) { @@ -1850,45 +1900,6 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name) return (uint8_t*)obj + opt->offset; } -static int opt_size(enum AVOptionType type) -{ - switch(type) { - case AV_OPT_TYPE_BOOL: - case AV_OPT_TYPE_INT: - case AV_OPT_TYPE_FLAGS: - return sizeof(int); - case AV_OPT_TYPE_DURATION: -#if FF_API_OLD_CHANNEL_LAYOUT -FF_DISABLE_DEPRECATION_WARNINGS - case AV_OPT_TYPE_CHANNEL_LAYOUT: -FF_ENABLE_DEPRECATION_WARNINGS -#endif - case AV_OPT_TYPE_INT64: - case AV_OPT_TYPE_UINT64: - return sizeof(int64_t); - case AV_OPT_TYPE_DOUBLE: - return sizeof(double); - case AV_OPT_TYPE_FLOAT: - return sizeof(float); - case AV_OPT_TYPE_STRING: - return sizeof(uint8_t*); - case AV_OPT_TYPE_VIDEO_RATE: - case AV_OPT_TYPE_RATIONAL: - return sizeof(AVRational); - case AV_OPT_TYPE_BINARY: - return sizeof(uint8_t*) + sizeof(int); - case AV_OPT_TYPE_IMAGE_SIZE: - return sizeof(int[2]); - case AV_OPT_TYPE_PIXEL_FMT: - return sizeof(enum AVPixelFormat); - case AV_OPT_TYPE_SAMPLE_FMT: - return sizeof(enum AVSampleFormat); - case AV_OPT_TYPE_COLOR: - return 4; - } - return AVERROR(EINVAL); -} - int av_opt_copy(void *dst, const void *src) { const AVOption *o = NULL; @@ -1939,12 +1950,13 @@ int av_opt_copy(void *dst, const void *src) } else if (o->type == AV_OPT_TYPE_CHLAYOUT) { if (field_dst != field_src) ret = av_channel_layout_copy(field_dst, field_src); + } else if (opt_is_pod(o->type)) { + size_t size = opt_elem_size[o->type]; + memcpy(field_dst, field_src, size); } else { - int size = opt_size(o->type); - if (size < 0) - ret = size; - else - memcpy(field_dst, field_src, size); + av_log(dst, AV_LOG_ERROR, "Unhandled option type: %d\n", + o->type); + ret = AVERROR(EINVAL); } } return ret; From patchwork Mon Mar 4 13:06:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46748 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789921pzb; Mon, 4 Mar 2024 05:09:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXrQPMgGBNeCYturkqEMz8pIVAdDAUE6X+S0+NTB/TWul3kg7Wb9yXglmbowFilymhH6ThLpdSmCAxngJMYSFgDHZ/5VU48Rx4JSw== X-Google-Smtp-Source: AGHT+IHAZ/Ubrjx1aK9CHT0lFKCHGz0jBzcvuKZux2O4p8Acc0rSoRheh8r3mselTozOrdDe/YRb X-Received: by 2002:a17:906:cb90:b0:a44:cd4:95e0 with SMTP id mf16-20020a170906cb9000b00a440cd495e0mr7727674ejb.1.1709557781356; Mon, 04 Mar 2024 05:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557781; cv=none; d=google.com; s=arc-20160816; b=pvwCajoyPnKA4jJvKW6AVzq9TkZt3izN25ICQQrbwKS16+kBL8Qojor0b6lH92MYwR byKtnFfVwQcmXFHb8k4A9TSvGo4RgdlRTSeEge3bhiiVG7u3E7r4RUOc0kyyBCr88erA NRrGavxTExYzkp51ofyaX7Y+uobR03Rwn+dbCzql6Ci4SRx7bMfKgZsMgXqF0O/N0nHD vSKTiDeRjEzKVc630e3mx3kINiVVEnnyeEj0yrJzA5OYThelbvxgtZROU1Fb+A7p1rHd 1pGrg0+QdTcJyl3+QbDJk9aWz6U25r42PE2wnjwZsUvKslljOcmJccSSHdV67nYLb5Hk pXIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=K8PcK4rNac99E6gqx9VC+PkNXQRX2AGKzIPL4HNL6eI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=T3r3tgtf2NETHmg8VbOoy0od7sCJxKtfk6IxDnDUdhoGjIPOc0+2G6gam/sF6zr6U+ AFzvzhGCqlxGxFUETLC7aKkMJpOlzAZ6S/5ekTjltjTWopnSc9BrOuo+/JbgbSEr4dFD ZfVhAmMwirQX7l/T7cZPmJYnMbqffE9JXelr/TdbVGfsukeks5ZErlrs2nz33f4SGxjb oLrfFy89Mk2DcrUCmIuWidVne0GE8PL7oexk1Bx/0elWibL4SSxqL/WUaaxi/7L/JoaD B6nbZXCu3fwwOm83guyQRymxLE5DQV+9t0Arcs7thunXgwcONXFm31bWXSMgF3dpI8u1 sXLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=Ceb9JyYn; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id mb20-20020a170906eb1400b00a438cbd7cd3si3848615ejb.190.2024.03.04.05.09.40; Mon, 04 Mar 2024 05:09:41 -0800 (PST) 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=@khirnov.net header.s=mail header.b=Ceb9JyYn; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43E7968D489; Mon, 4 Mar 2024 15:07:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 70C4968D441 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Ceb9JyYn; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id D12194D46 for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id F3ztiH84Y-Zu for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=7KJQlgqGHZcD/TRASSee7vALsrd93V27XT0QQ6H9FSE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ceb9JyYnAXBJPS08ZhY4TJBA1G+qeTdaLnuEoln1YpkxiPI7FytmXPn3YQavq4nit oTfJllCWsmmxnE4BzrFLTEsGCi0zHxcrsXjDyh9329ZDkuR2w/6m8Ze9t8BCSEXTVT YRrNMZqbJt2/cZAW2XFLkfMDvvww+MSrRcNseordYApCdKExbH+i5KqIbTD6uYwHYH vy4LdLegeLXs8YyeQYMdn7LvwVyik60y0EvkLifQSiw0JUA1rm3jOFrZGM0vpRkC2X Vg0ORhwHoBng1Fb3MKpVTU/cnPiBply6hxynkWnlsqHIhPdKzxaWY5XTD0tmNRlS2z ObY4EVFuN1mtA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 546094D4D for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 07B2D3A0A6B for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:19 +0100 Message-ID: <20240304130657.30631-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/29] lavu/opt: factor per-type dispatch out of av_opt_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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qHHSsI9OmUIz Will be useful in following commits. --- libavutil/opt.c | 89 ++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 051a121331..d18a1c63b7 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1900,6 +1900,51 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name) return (uint8_t*)obj + opt->offset; } +static int opt_copy_elem(void *logctx, enum AVOptionType type, + void *dst, const void *src) +{ + uint8_t **dst8 = (uint8_t **)dst; + const uint8_t **src8 = (const uint8_t **)src; + + if (type == AV_OPT_TYPE_STRING) { + if (*dst8 != *src8) + av_freep(dst8); + *dst8 = av_strdup(*src8); + if (*src8 && !*dst8) + return AVERROR(ENOMEM); + } else if (type == AV_OPT_TYPE_BINARY) { + int len = *(const int *)(src8 + 1); + if (*dst8 != *src8) + av_freep(dst8); + *dst8 = av_memdup(*src8, len); + if (len && !*dst8) { + *(int *)(dst8 + 1) = 0; + return AVERROR(ENOMEM); + } + *(int *)(dst8 + 1) = len; + } else if (type == AV_OPT_TYPE_CONST) { + // do nothing + } else if (type == AV_OPT_TYPE_DICT) { + AVDictionary **sdict = (AVDictionary **)src; + AVDictionary **ddict = (AVDictionary **)dst; + if (*sdict != *ddict) + av_dict_free(ddict); + *ddict = NULL; + return av_dict_copy(ddict, *sdict, 0); + } else if (type == AV_OPT_TYPE_CHLAYOUT) { + if (dst != src) + return av_channel_layout_copy(dst, src); + } else if (opt_is_pod(type)) { + size_t size = opt_elem_size[type]; + memcpy(dst, src, size); + } else { + av_log(logctx, AV_LOG_ERROR, "Unhandled option type: %d\n", type); + return AVERROR(EINVAL); + } + + return 0; +} + int av_opt_copy(void *dst, const void *src) { const AVOption *o = NULL; @@ -1916,48 +1961,10 @@ int av_opt_copy(void *dst, const void *src) while ((o = av_opt_next(src, o))) { void *field_dst = (uint8_t *)dst + o->offset; void *field_src = (uint8_t *)src + o->offset; - uint8_t **field_dst8 = (uint8_t **)field_dst; - uint8_t **field_src8 = (uint8_t **)field_src; - if (o->type == AV_OPT_TYPE_STRING) { - if (*field_dst8 != *field_src8) - av_freep(field_dst8); - *field_dst8 = av_strdup(*field_src8); - if (*field_src8 && !*field_dst8) - ret = AVERROR(ENOMEM); - } else if (o->type == AV_OPT_TYPE_BINARY) { - int len = *(int *)(field_src8 + 1); - if (*field_dst8 != *field_src8) - av_freep(field_dst8); - *field_dst8 = av_memdup(*field_src8, len); - if (len && !*field_dst8) { - ret = AVERROR(ENOMEM); - len = 0; - } - *(int *)(field_dst8 + 1) = len; - } else if (o->type == AV_OPT_TYPE_CONST) { - // do nothing - } else if (o->type == AV_OPT_TYPE_DICT) { - AVDictionary **sdict = (AVDictionary **) field_src; - AVDictionary **ddict = (AVDictionary **) field_dst; - int ret2; - if (*sdict != *ddict) - av_dict_free(ddict); - *ddict = NULL; - ret2 = av_dict_copy(ddict, *sdict, 0); - if (ret2 < 0) - ret = ret2; - } else if (o->type == AV_OPT_TYPE_CHLAYOUT) { - if (field_dst != field_src) - ret = av_channel_layout_copy(field_dst, field_src); - } else if (opt_is_pod(o->type)) { - size_t size = opt_elem_size[o->type]; - memcpy(field_dst, field_src, size); - } else { - av_log(dst, AV_LOG_ERROR, "Unhandled option type: %d\n", - o->type); - ret = AVERROR(EINVAL); - } + int err = opt_copy_elem(dst, o->type, field_dst, field_src); + if (err < 0) + ret = err; } return ret; } From patchwork Mon Mar 4 13:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46757 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789382pzb; Mon, 4 Mar 2024 05:08:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXdfSFScAHGwiRX+aYJw+fif/V8buW7fvxa2kQu+xilot0QwLu4CPUJSpZxcbvAqIc9LmoqmXDx9uA/cVyw0cgkoRZAgzKbw+3UKw== X-Google-Smtp-Source: AGHT+IGf7zBifC6obCiW19Ms/mmg34fey2MDWz7YmIV8lYFUzqjwUKdXSyLmQ1qTUJdXugOewgDj X-Received: by 2002:a17:907:a786:b0:a43:6ba0:522b with SMTP id vx6-20020a170907a78600b00a436ba0522bmr5788503ejc.1.1709557733958; Mon, 04 Mar 2024 05:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557733; cv=none; d=google.com; s=arc-20160816; b=B+2zVWDW3WPuOg83Vsp1PvT6RaKGM96QC42MN3GZiJZZhA4wGd6mTAbOOsvYw+2Kri 3xzCZmoR5OacYlCWiRsal3pqERycrKdEpTYFhGf7YDCSKvuZea9lxDaqjd1UA1Ih9IjO ndqKYkaODHpu2qyVqh/pQWUPN3VA6ql9fPRPgO/m5hTacYEL/t8EXuZTXh6lSKgUz/X0 Wz9Z148+gTpQKAd3VYhegt6TdymFa8NGytj9aWmW+/aFkUA5+B+0UwPqDDGIPRDMFynN OrVpghGY5csxtfxqkk4vd+jDIVJx+KvANSvs+7DNIiMVbNN2j43KWFQXQT4I8m9ekYvI C/rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=gfISCa/igjMZ8bLIahtr1nZPNqPgVQKKVP3NULqRP94=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=sfES0WRl3/hWgw9VpNE1MvWkojACOP1Q0hRyeKmBlFYcKobk1ryh7ydpCoXAQPgKPk IUZGoX+nulYdmBjUCJJCsbFNOujc8tuLfJ+OD5S4Fb69pAyo9lnHtpxSdO1mGjF26On5 ABR3WCmu00h/DA2CNDPNbO5X2pqJvmg8HX7jsxnjquPpQbxP3vT6rZSSVoG0J99Dtwz0 FwWoXZoTECR/dEDRhxcB5StDBuAk0N2BBto2gH7xIzKApSLJ5WEKj2xcsZurbaxc5T8L gLr04G6sDGTV5JEj0qNnX3Ps3U+mSYx/FlBAaiTpENBDw9pmbo/KeGUJydZiuxE9Pmnp VXNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=L6JnEC2x; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lj27-20020a170906f9db00b00a3f89681212si3830721ejb.101.2024.03.04.05.08.51; Mon, 04 Mar 2024 05:08:53 -0800 (PST) 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=@khirnov.net header.s=mail header.b=L6JnEC2x; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1A02C68D446; Mon, 4 Mar 2024 15:07:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C44568D43B for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=L6JnEC2x; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id EA8864D3E for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 4u5llzm96hVy for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=Itn1Z2BVuifxV3igR8UIKPpOb+btRTjIEigEcFT+OD8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L6JnEC2x84Plb28TQkj9vNo7h/EH60iOfjyAV9k2c9boMibauMSjV1iGHydkzDKJs 6wgsX/9aerbMHkj//3/eTpZH5n2wDtnGtvOpUF21LNW/H0irhMNHJ9yZ3jzKecQRcO qT7p/ztDLjdklmVjhDh32fcOIwr+y7pNJHenNHcdt0AGxQZ/qdTos6c6h2rGcbhGn2 rRsV1VlUbR1TsnO19grEO+hUrE+lL+ETYAfnzFYaRgVCKL9SoZAv6q0V10+Z2eUH8p 3ULJ72LmfmcIqe7knHW021rAIAeBpi8Md6rsJX1+n4bHvak7f/qlw8wnnZ2Tbj2PkA Ue+4sz/oh7JJQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 671774D52 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 134463A0B9C for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:20 +0100 Message-ID: <20240304130657.30631-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/29] lavu/opt: distinguish between native and foreign access for AVOption fields 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: o3OJTmt1057a Native access is from the code that declared the options, foreign access is from code that is using the options. Forbid foreign access to AVOption.offset/default_val, for which there is no good reason, and which should allow us more freedom in extending their semantics in a compatible way. --- libavutil/opt.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libavutil/opt.h b/libavutil/opt.h index e34b8506f8..e402f6a0a0 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -43,6 +43,16 @@ * ("objects"). An option can have a help text, a type and a range of possible * values. Options may then be enumerated, read and written to. * + * There are two modes of access to members of AVOption and its child structs. + * One is called 'native access', and refers to access from the code that + * declares the AVOption in question. The other is 'foreign access', and refers + * to access from other code. + * + * Certain struct members in this header are documented as 'native access only' + * or similar - it means that only the code that declared the AVOption in + * question is allowed to access the field. This allows us to extend the + * semantics of those fields without breaking API compatibility. + * * @section avoptions_implement Implementing AVOptions * This section describes how to add AVOptions capabilities to a struct. * @@ -301,6 +311,8 @@ typedef struct AVOption { const char *help; /** + * Native access only. + * * The offset relative to the context structure where the option * value is stored. It should be 0 for named constants. */ @@ -308,6 +320,8 @@ typedef struct AVOption { enum AVOptionType type; /** + * Native access only. + * * the default value for scalar options */ union { From patchwork Mon Mar 4 13:06:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46752 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2788867pzb; Mon, 4 Mar 2024 05:08:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWTwktIbtjrKjy8pO8wNWG1NvW2kNiJ11lCRlcvmjOlGuKjpAtiM8cKPEg92bTgN4np2PRlN6BMM15dNkpZH7HAZo5TpyLExUVG+A== X-Google-Smtp-Source: AGHT+IFAx4S4VwBeD8f1mwHeoKD+bKvmRx1zVtUbS2hR3433dYLlEu7a0CnfcKYybS/z2u+cTLZh X-Received: by 2002:a50:c943:0:b0:566:14e3:2262 with SMTP id p3-20020a50c943000000b0056614e32262mr5728602edh.36.1709557683479; Mon, 04 Mar 2024 05:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557683; cv=none; d=google.com; s=arc-20160816; b=QnoL5zvGZ3jNRCBzahsoAlremdgjyuAug6G3qBBqgHrN6POi8IFY76Wz58vnMz0J6O p6Fz4WcTEsQO42U5DVQ8jMDxMJGinCgH9KoFVs2lXT6mysEzn80JQMl+l4VwHwCoSC6P SRpSTfdqy4PMHrzMljERZBBWwoSn4v0BRi0H5Ix4jCVpx2aB0G9M0Yu0TIO/MBhpSfR/ 3gpk4CMQsEb7gtQby3WxNlE5+quoV64WGXwPSR3VY3MRBiC9spx43bDqW6kEQnE7gO8O 99XUc4tIWe4pCJ7Ebt/Ah6hpci4XW6kOO6N91/IcJaZIh9cOWIP/WU5t0+jeUc7XKZ/m 1+dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=5MmZZSTuLVU6pQ8ngRaYAZnZKn9hrNfZmsTb1tJK7EE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Yal/bW3XzhEPhVOosfte205uLbF25/BM0aLJdwu45yd3T1cl7ZsBJhPMX11ILz6lAC wlwaJfqsgwSgIdhi4B2feNw6W0AXTd/NPO9t0OMb/TJV7wGjEBm0LNmM8FZFa1CBiAkj TK8CW6Txo7Oqsu4RnEyCRTsury1B6gNtfez/tJwyVl1hPTo7X+ndwZHCOneSSqVTEF19 Zi9BKYaMYKvg+dyvUHv0w8eJslP5zd5EGv5EVc2YNAP/0Zkai6d1K7HCrVqXSfVh989c IzJcoP0EAkZ/74W+zG/78xoPChOJptR09bW9Y8R9PuM4uDuaR3mJ7xVm7zv/eyuw81iC le6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=PEj8CgDl; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u10-20020a50a40a000000b00565dd87bd1bsi4019386edb.618.2024.03.04.05.08.02; Mon, 04 Mar 2024 05:08:03 -0800 (PST) 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=@khirnov.net header.s=mail header.b=PEj8CgDl; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DD70B68D445; Mon, 4 Mar 2024 15:07:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C7CFE68D3B7 for ; Mon, 4 Mar 2024 15:07:08 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=PEj8CgDl; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 793BA10B9 for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id UNuDM3gZ2MEZ for ; Mon, 4 Mar 2024 14:07:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=1nnSBeXZB2NrORqw4Soo2vE3oc+yacZHR+w9qaT4cOE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PEj8CgDl6lYN5m+Buw3Gt4bXJiHqcMc4L1efursR6AvCxGnMkBmDrR/aJTI/AZfrq DJkgNsK6hoE8ESbSqFey7BG4EAAgeyNi1GAdPHMJ2JrbFIM6Gf4dgjzIsDnrYizEPM shF7N2sd8cHcTn2A+BteadNf/ZlHfW8RIsMFfVvQyijW+++FpgFviPPoIjqKtLR18s yuivdsAcsF3ZDqj98pBLQUh8pBE5Sty3MleB2+kJmHzfb7ZFRRsGDX1x05mIKUTKvS MoFKbGOAFlCb6RP4RbQ0+JFraYlIvHCKNfw8qZ6fnTDGdDZMw1x5Njq/PlGfGkbAQ9 /CdDJ7zk+3BDA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 384A84D3E for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1F4163A0C79 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:21 +0100 Message-ID: <20240304130657.30631-6-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/29] lavu/opt: add array options 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: E+U6tBU8S5hg --- doc/APIchanges | 3 + libavutil/opt.c | 362 +++++++++++++++++++++++++++++++++++++----- libavutil/opt.h | 62 +++++++- libavutil/tests/opt.c | 51 ++++++ tests/ref/fate/opt | 35 +++- 5 files changed, 468 insertions(+), 45 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7d46ebb006..3209614ed6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2024-02-xx - xxxxxxxxxx - lavu 58.xx.100 - opt.h + Add AV_OPT_TYPE_FLAG_ARRAY and AVOptionArrayDef. + 2024-02-28 - xxxxxxxxxx - swr 4.14.100 - swresample.h swr_convert() now accepts arrays of const pointers (to input and output). diff --git a/libavutil/opt.c b/libavutil/opt.c index d18a1c63b7..6a5e3c7174 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -43,6 +43,8 @@ #include +#define TYPE_BASE(type) ((type) & ~AV_OPT_TYPE_FLAG_ARRAY) + const AVOption *av_opt_next(const void *obj, const AVOption *last) { const AVClass *class; @@ -106,6 +108,54 @@ static int opt_is_pod(enum AVOptionType type) return 0; } +static uint8_t opt_array_sep(const AVOption *o) +{ + const AVOptionArrayDef *d = o->default_val.arr; + av_assert1(o->type & AV_OPT_TYPE_FLAG_ARRAY); + return (d && d->sep) ? d->sep : ','; +} + +static void *opt_array_pelem(const AVOption *o, void *array, unsigned idx) +{ + av_assert1(o->type & AV_OPT_TYPE_FLAG_ARRAY); + return (uint8_t *)array + idx * opt_elem_size[TYPE_BASE(o->type)]; +} + +static unsigned *opt_array_pcount(const void *parray) +{ + return (unsigned *)((const void * const *)parray + 1); +} + +static void opt_free_elem(const AVOption *o, void *ptr) +{ + switch (TYPE_BASE(o->type)) { + case AV_OPT_TYPE_STRING: + case AV_OPT_TYPE_BINARY: + av_freep(ptr); + break; + + case AV_OPT_TYPE_DICT: + av_dict_free((AVDictionary **)ptr); + break; + + case AV_OPT_TYPE_CHLAYOUT: + av_channel_layout_uninit((AVChannelLayout *)ptr); + break; + + default: + break; + } +} + +static void opt_free_array(const AVOption *o, void *parray, unsigned *count) +{ + for (unsigned i = 0; i < *count; i++) + opt_free_elem(o, opt_array_pelem(o, *(void **)parray, i)); + + av_freep(parray); + *count = 0; +} + static int read_number(const AVOption *o, const void *dst, double *num, int *den, int64_t *intnum) { switch (o->type) { @@ -151,14 +201,16 @@ FF_ENABLE_DEPRECATION_WARNINGS static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum) { - if (o->type != AV_OPT_TYPE_FLAGS && + const enum AVOptionType type = TYPE_BASE(o->type); + + if (type != AV_OPT_TYPE_FLAGS && (!den || o->max * den < num * intnum || o->min * den > num * intnum)) { num = den ? num * intnum / den : (num && intnum ? INFINITY : NAN); av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range [%g - %g]\n", num, o->name, o->min, o->max); return AVERROR(ERANGE); } - if (o->type == AV_OPT_TYPE_FLAGS) { + if (type == AV_OPT_TYPE_FLAGS) { double d = num*intnum/den; if (d < -1.5 || d > 0xFFFFFFFF+0.5 || (llrint(d*256) & 255)) { av_log(obj, AV_LOG_ERROR, @@ -168,7 +220,7 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int } } - switch (o->type) { + switch (type) { case AV_OPT_TYPE_PIXEL_FMT: *(enum AVPixelFormat *)dst = llrint(num / den) * intnum; break; @@ -287,9 +339,10 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst) { + const enum AVOptionType type = TYPE_BASE(o->type); int ret = 0; - if (o->type == AV_OPT_TYPE_RATIONAL || o->type == AV_OPT_TYPE_VIDEO_RATE) { + if (type == AV_OPT_TYPE_RATIONAL || type == AV_OPT_TYPE_VIDEO_RATE) { int num, den; char c; if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) { @@ -306,7 +359,7 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con double d; int64_t intnum = 1; - if (o->type == AV_OPT_TYPE_FLAGS) { + if (type == AV_OPT_TYPE_FLAGS) { if (*val == '+' || *val == '-') cmd = *(val++); for (; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++) @@ -362,7 +415,7 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con } } } - if (o->type == AV_OPT_TYPE_FLAGS) { + if (type == AV_OPT_TYPE_FLAGS) { intnum = *(unsigned int*)dst; if (cmd == '+') d = intnum | (int64_t)d; @@ -547,21 +600,22 @@ static int set_string_channel_layout(void *obj, const AVOption *o, static int opt_set_elem(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst) { + const enum AVOptionType type = TYPE_BASE(o->type); int ret; FF_DISABLE_DEPRECATION_WARNINGS - if (!val && (o->type != AV_OPT_TYPE_STRING && - o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT && - o->type != AV_OPT_TYPE_IMAGE_SIZE && - o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR && + if (!val && (type != AV_OPT_TYPE_STRING && + type != AV_OPT_TYPE_PIXEL_FMT && type != AV_OPT_TYPE_SAMPLE_FMT && + type != AV_OPT_TYPE_IMAGE_SIZE && + type != AV_OPT_TYPE_DURATION && type != AV_OPT_TYPE_COLOR && #if FF_API_OLD_CHANNEL_LAYOUT - o->type != AV_OPT_TYPE_CHANNEL_LAYOUT && + type != AV_OPT_TYPE_CHANNEL_LAYOUT && #endif - o->type != AV_OPT_TYPE_BOOL)) + type != AV_OPT_TYPE_BOOL)) return AVERROR(EINVAL); FF_ENABLE_DEPRECATION_WARNINGS - switch (o->type) { + switch (type) { case AV_OPT_TYPE_BOOL: return set_string_bool(obj, o, val, dst); case AV_OPT_TYPE_STRING: @@ -640,6 +694,85 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); } +static int opt_set_array(void *obj, void *target_obj, const AVOption *o, + const char *val, void *dst) +{ + const AVOptionArrayDef *arr = o->default_val.arr; + const size_t elem_size = opt_elem_size[TYPE_BASE(o->type)]; + const uint8_t sep = opt_array_sep(o); + uint8_t *str = NULL; + + void *elems = NULL; + unsigned nb_elems = 0; + int ret; + + if (val && *val) { + str = av_malloc(strlen(val) + 1); + if (!str) + return AVERROR(ENOMEM); + } + + // split and unescape the string + while (val && *val) { + uint8_t *p = str; + void *tmp; + + if (arr && arr->size_max && nb_elems >= arr->size_max) { + av_log(obj, AV_LOG_ERROR, + "Cannot assign more than %u elements to array option %s\n", + arr->size_max, o->name); + ret = AVERROR(EINVAL); + goto fail; + } + + for (; *val; val++, p++) { + if (*val == '\\' && val[1]) + val++; + else if (*val == sep) { + val++; + break; + } + *p = *val; + } + *p = 0; + + tmp = av_realloc_array(elems, nb_elems + 1, elem_size); + if (!tmp) { + ret = AVERROR(ENOMEM); + goto fail; + } + elems = tmp; + + tmp = opt_array_pelem(o, elems, nb_elems); + memset(tmp, 0, elem_size); + + ret = opt_set_elem(obj, target_obj, o, str, tmp); + if (ret < 0) + goto fail; + nb_elems++; + } + av_freep(&str); + + opt_free_array(o, dst, opt_array_pcount(dst)); + + if (arr && nb_elems < arr->size_min) { + av_log(obj, AV_LOG_ERROR, + "Cannot assign fewer than %u elements to array option %s\n", + arr->size_min, o->name); + ret = AVERROR(EINVAL); + goto fail; + } + + *((void **)dst) = elems; + *opt_array_pcount(dst) = nb_elems; + + return 0; +fail: + av_freep(&str); + opt_free_array(o, &elems, &nb_elems); + return ret; +} + int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { void *dst, *target_obj; @@ -655,7 +788,8 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) dst = ((uint8_t *)target_obj) + o->offset; - return opt_set_elem(obj, target_obj, o, val, dst); + return ((o->type & AV_OPT_TYPE_FLAG_ARRAY) ? + opt_set_array : opt_set_elem)(obj, target_obj, o, val, dst); } #define OPT_EVAL_NUMBER(name, opttype, vartype) \ @@ -683,7 +817,7 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t if (!o || !target_obj) return AVERROR_OPTION_NOT_FOUND; - if (o->flags & AV_OPT_FLAG_READONLY) + if ((o->flags & AV_OPT_FLAG_READONLY) || (o->type & AV_OPT_TYPE_FLAG_ARRAY)) return AVERROR(EINVAL); dst = ((uint8_t *)target_obj) + o->offset; @@ -766,7 +900,8 @@ int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int searc return AVERROR_OPTION_NOT_FOUND; if (o->type != AV_OPT_TYPE_VIDEO_RATE) { av_log(obj, AV_LOG_ERROR, - "The value set by option '%s' is not a video rate.\n", o->name); + "The value set by option '%s' is not a video rate.\n", + o->name); return AVERROR(EINVAL); } if (val.num <= 0 || val.den <= 0) @@ -908,7 +1043,7 @@ static int opt_get_elem(const AVOption *o, uint8_t **pbuf, size_t buf_len, { int ret; - switch (o->type) { + switch (TYPE_BASE(o->type)) { case AV_OPT_TYPE_BOOL: ret = snprintf(*pbuf, buf_len, "%s", get_bool_name(*(int *)dst)); break; @@ -1014,6 +1149,66 @@ FF_ENABLE_DEPRECATION_WARNINGS return ret; } +static int opt_get_array(const AVOption *o, void *dst, uint8_t **out_val) +{ + const unsigned count = *opt_array_pcount(dst); + const uint8_t sep = opt_array_sep(o); + + uint8_t *str = NULL; + size_t str_len = 0; + int ret; + + *out_val = NULL; + + for (unsigned i = 0; i < count; i++) { + uint8_t buf[128], *out = buf; + size_t out_len; + + ret = opt_get_elem(o, &out, sizeof(buf), + opt_array_pelem(o, *(void **)dst, i), 0); + if (ret < 0) + goto fail; + + out_len = strlen(out); + if (out_len > SIZE_MAX / 2 - !!i || + !!i + out_len * 2 > SIZE_MAX - str_len - 1) { + ret = AVERROR(ERANGE); + goto fail; + } + + // terminator escaping separator + // ↓ ↓ ↓ + ret = av_reallocp(&str, str_len + 1 + out_len * 2 + !!i); + if (ret < 0) + goto fail; + + // add separator if needed + if (i) + str[str_len++] = sep; + + // escape the element + for (unsigned j = 0; j < out_len; j++) { + uint8_t val = out[j]; + if (val == sep || val == '\\') + str[str_len++] = '\\'; + str[str_len++] = val; + } + str[str_len] = 0; + +fail: + if (out != buf) + av_freep(&out); + if (ret < 0) { + av_freep(&str); + return ret; + } + } + + *out_val = str; + + return 0; +} + int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) { void *dst, *target_obj; @@ -1029,8 +1224,19 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) dst = (uint8_t *)target_obj + o->offset; - buf[0] = 0; + if (o->type & AV_OPT_TYPE_FLAG_ARRAY) { + ret = opt_get_array(o, dst, out_val); + if (ret < 0) + return ret; + if (!*out_val && !(search_flags & AV_OPT_ALLOW_NULL)) { + *out_val = av_strdup(""); + if (!*out_val) + return AVERROR(ENOMEM); + } + return 0; + } + buf[0] = 0; out = buf; ret = opt_get_elem(o, &out, sizeof(buf), dst, search_flags); if (ret < 0) @@ -1053,6 +1259,8 @@ static int get_number(void *obj, const char *name, double *num, int *den, int64_ const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); if (!o || !target_obj) return AVERROR_OPTION_NOT_FOUND; + if (o->type & AV_OPT_TYPE_FLAG_ARRAY) + return AVERROR(EINVAL); dst = ((uint8_t *)target_obj) + o->offset; @@ -1110,7 +1318,7 @@ int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_ return AVERROR_OPTION_NOT_FOUND; if (o->type != AV_OPT_TYPE_IMAGE_SIZE) { av_log(obj, AV_LOG_ERROR, - "The value for option '%s' is not an image size.\n", name); + "The value for option '%s' is not a image size.\n", name); return AVERROR(EINVAL); } @@ -1174,7 +1382,7 @@ int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int return AVERROR_OPTION_NOT_FOUND; if (o->type != AV_OPT_TYPE_CHANNEL_LAYOUT) { av_log(obj, AV_LOG_ERROR, - "The value for option '%s' is not a channel layout.\n", name); + "The value for option '%s' is not a scalar channel layout.\n", name); return AVERROR(EINVAL); } @@ -1341,11 +1549,16 @@ static void log_type(void *av_log_obj, const AVOption *o, [AV_OPT_TYPE_CHLAYOUT] = "", [AV_OPT_TYPE_BOOL] = "", }; + const enum AVOptionType type = TYPE_BASE(o->type); - if (o->type == AV_OPT_TYPE_CONST && parent_type == AV_OPT_TYPE_INT) + if (o->type == AV_OPT_TYPE_CONST && TYPE_BASE(parent_type) == AV_OPT_TYPE_INT) av_log(av_log_obj, AV_LOG_INFO, "%-12"PRId64" ", o->default_val.i64); - else if (o->type < FF_ARRAY_ELEMS(desc) && desc[o->type]) - av_log(av_log_obj, AV_LOG_INFO, "%-12s ", desc[o->type]); + else if (type < FF_ARRAY_ELEMS(desc) && desc[type]) { + if (o->type & AV_OPT_TYPE_FLAG_ARRAY) + av_log(av_log_obj, AV_LOG_INFO, "[%-10s]", desc[type]); + else + av_log(av_log_obj, AV_LOG_INFO, "%-12s ", desc[type]); + } else av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); } @@ -1363,6 +1576,13 @@ static void log_default(void *obj, void *av_log_obj, const AVOption *opt) !opt->default_val.str) return; + if (opt->type & AV_OPT_TYPE_FLAG_ARRAY) { + const AVOptionArrayDef *arr = opt->default_val.arr; + if (arr && arr->def) + av_log(av_log_obj, AV_LOG_INFO, " (default %s)", arr->def); + return; + } + av_log(av_log_obj, AV_LOG_INFO, " (default "); switch (opt->type) { case AV_OPT_TYPE_BOOL: @@ -1530,6 +1750,21 @@ void av_opt_set_defaults2(void *s, int mask, int flags) if (opt->flags & AV_OPT_FLAG_READONLY) continue; + if (opt->type & AV_OPT_TYPE_FLAG_ARRAY) { + const AVOptionArrayDef *arr = opt->default_val.arr; + const char sep = opt_array_sep(opt); + + av_assert0(sep && sep != '\\' && + (sep < 'a' || sep > 'z') && + (sep < 'A' || sep > 'Z') && + (sep < '0' || sep > '9')); + + if (arr && arr->def) + opt_set_array(s, s, opt, arr->def, dst); + + continue; + } + switch (opt->type) { case AV_OPT_TYPE_CONST: /* Nothing to be done here */ @@ -1777,23 +2012,12 @@ void av_opt_free(void *obj) { const AVOption *o = NULL; while ((o = av_opt_next(obj, o))) { - switch (o->type) { - case AV_OPT_TYPE_STRING: - case AV_OPT_TYPE_BINARY: - av_freep((uint8_t *)obj + o->offset); - break; + void *pitem = (uint8_t *)obj + o->offset; - case AV_OPT_TYPE_DICT: - av_dict_free((AVDictionary **)(((uint8_t *)obj) + o->offset)); - break; - - case AV_OPT_TYPE_CHLAYOUT: - av_channel_layout_uninit((AVChannelLayout *)(((uint8_t *)obj) + o->offset)); - break; - - default: - break; - } + if (o->type & AV_OPT_TYPE_FLAG_ARRAY) + opt_free_array(o, pitem, opt_array_pcount(pitem)); + else + opt_free_elem(o, pitem); } } @@ -1895,7 +2119,9 @@ const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter) void *av_opt_ptr(const AVClass *class, void *obj, const char *name) { const AVOption *opt= av_opt_find2(&class, name, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ, NULL); - if(!opt) + + // no direct access to array-type options + if (!opt || (opt->type & AV_OPT_TYPE_FLAG_ARRAY)) return NULL; return (uint8_t*)obj + opt->offset; } @@ -1945,6 +2171,40 @@ static int opt_copy_elem(void *logctx, enum AVOptionType type, return 0; } +static int opt_copy_array(void *logctx, const AVOption *o, + void **pdst, const void * const *psrc) +{ + unsigned nb_elems = *opt_array_pcount(psrc); + void *dst = NULL; + int ret; + + if (*pdst == *psrc) { + *pdst = NULL; + *opt_array_pcount(pdst) = 0; + } + + opt_free_array(o, pdst, opt_array_pcount(pdst)); + + dst = av_calloc(nb_elems, opt_elem_size[TYPE_BASE(o->type)]); + if (!dst) + return AVERROR(ENOMEM); + + for (unsigned i = 0; i < nb_elems; i++) { + ret = opt_copy_elem(logctx, TYPE_BASE(o->type), + opt_array_pelem(o, dst, i), + opt_array_pelem(o, *(void**)psrc, i)); + if (ret < 0) { + opt_free_array(o, &dst, &nb_elems); + return ret; + } + } + + *pdst = dst; + *opt_array_pcount(pdst) = nb_elems; + + return 0; +} + int av_opt_copy(void *dst, const void *src) { const AVOption *o = NULL; @@ -1962,7 +2222,9 @@ int av_opt_copy(void *dst, const void *src) void *field_dst = (uint8_t *)dst + o->offset; void *field_src = (uint8_t *)src + o->offset; - int err = opt_copy_elem(dst, o->type, field_dst, field_src); + int err = (o->type & AV_OPT_TYPE_FLAG_ARRAY) ? + opt_copy_array(dst, o, field_dst, field_src) : + opt_copy_elem (dst, o->type, field_dst, field_src); if (err < 0) ret = err; } @@ -2096,6 +2358,24 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o) dst = ((uint8_t*)obj) + o->offset; + if (o->type & AV_OPT_TYPE_FLAG_ARRAY) { + const char *def = o->default_val.arr ? o->default_val.arr->def : NULL; + uint8_t *val; + + ret = opt_get_array(o, dst, &val); + if (ret < 0) + return ret; + + if (!!val != !!def) + ret = 0; + else if (val) + ret = !strcmp(val, def); + + av_freep(&val); + + return ret; + } + switch (o->type) { case AV_OPT_TYPE_CONST: return 1; diff --git a/libavutil/opt.h b/libavutil/opt.h index e402f6a0a0..77797b3fbe 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -253,6 +253,17 @@ enum AVOptionType{ #endif AV_OPT_TYPE_BOOL, AV_OPT_TYPE_CHLAYOUT, + + /** + * May be combined with another regular option type to declare an array + * option. + * + * For array options, @ref AVOption.offset should refer to a pointer + * corresponding to the option type. The pointer should be immediately + * followed by an unsigned int that will store the number of elements in the + * array. + */ + AV_OPT_TYPE_FLAG_ARRAY = (1 << 16), }; /** @@ -298,6 +309,46 @@ enum AVOptionType{ */ #define AV_OPT_FLAG_CHILD_CONSTS (1 << 18) +/** + * Must be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options. + */ +typedef struct AVOptionArrayDef { + /** + * Must be set to sizeof(AVOptionArrayDef), in order to allow extending this + * struct without breaking ABI. + */ + size_t sizeof_self; + + /** + * Native access only. + * + * Default value of the option, as would be serialized by av_opt_get() (i.e. + * using the value of sep as the separator). + */ + const char *def; + + /** + * Minimum number of elements in the array. When this field is non-zero, def + * must be non-NULL and contain at least this number of elements. + */ + unsigned size_min; + /** + * Maximum number of elements in the array, 0 when unlimited. + */ + unsigned size_max; + + /** + * Separator between array elements in string representations of this + * option, used by av_opt_set() and av_opt_get(). It must be a printable + * ASCII character, excluding alphanumeric and the backslash. A comma is + * used when sep=0. + * + * The separator and the backslash must be backslash-escaped in order to + * appear in string representations of the option value. + */ + uint8_t sep; +} AVOptionArrayDef; + /** * AVOption */ @@ -320,8 +371,7 @@ typedef struct AVOption { enum AVOptionType type; /** - * Native access only. - * + * Native access only, except when documented otherwise. * the default value for scalar options */ union { @@ -330,6 +380,14 @@ typedef struct AVOption { const char *str; /* TODO those are unused now */ AVRational q; + + /** + * Used for AV_OPT_TYPE_FLAG_ARRAY options. May be NULL. + * + * Foreign access to some members allowed, as noted in AVOptionArrayDef + * documentation. + */ + const AVOptionArrayDef *arr; } default_val; double min; ///< minimum valid value for the option double max; ///< maximum valid value for the option diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c index e2582cc93d..37437320cf 100644 --- a/libavutil/tests/opt.c +++ b/libavutil/tests/opt.c @@ -57,6 +57,15 @@ typedef struct TestContext { int bool3; AVDictionary *dict1; AVDictionary *dict2; + + int **array_int; + unsigned nb_array_int; + + char **array_str; + unsigned nb_array_str; + + AVDictionary **array_dict; + unsigned nb_array_dict; } TestContext; #define OFFSET(x) offsetof(TestContext, x) @@ -65,6 +74,17 @@ typedef struct TestContext { #define TEST_FLAG_LAME 02 #define TEST_FLAG_MU 04 +static const AVOptionArrayDef array_str = { + .sizeof_self = sizeof(AVOptionArrayDef), + .sep = '|', + .def = "str0|str\\|1|str\\\\2", +}; + +static const AVOptionArrayDef array_dict = { + .sizeof_self = sizeof(AVOptionArrayDef), + .def = "k00=v\\\\\\\\00:k01=v\\,01,k10=v\\\\=1\\\\:0", +}; + static const AVOption test_options[]= { {"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, 1 }, {"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, 1 }, @@ -93,6 +113,10 @@ static const AVOption test_options[]= { {"bool3", "set boolean value", OFFSET(bool3), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 1 }, {"dict1", "set dictionary value", OFFSET(dict1), AV_OPT_TYPE_DICT, { .str = NULL}, 0, 0, 1 }, {"dict2", "set dictionary value", OFFSET(dict2), AV_OPT_TYPE_DICT, { .str = "happy=':-)'"}, 0, 0, 1 }, + {"array_int", "array of ints", OFFSET(array_int), AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = AV_OPT_FLAG_RUNTIME_PARAM }, + {"array_str", "array of strings", OFFSET(array_str), AV_OPT_TYPE_STRING | AV_OPT_TYPE_FLAG_ARRAY, { .arr = &array_str }, .flags = AV_OPT_FLAG_RUNTIME_PARAM }, + // there are three levels of escaping - C string, array option, dict - so 8 backslashes are needed to get a literal one inside a dict key/val + {"array_dict", "array of dicts", OFFSET(array_dict), AV_OPT_TYPE_DICT | AV_OPT_TYPE_FLAG_ARRAY, { .arr = &array_dict }, .flags = AV_OPT_FLAG_RUNTIME_PARAM }, { NULL }, }; @@ -146,6 +170,17 @@ int main(void) printf("flt=%.6f\n", test_ctx.flt); printf("dbl=%.6f\n", test_ctx.dbl); + for (unsigned i = 0; i < test_ctx.nb_array_str; i++) + printf("array_str[%u]=%s\n", i, test_ctx.array_str[i]); + + for (unsigned i = 0; i < test_ctx.nb_array_dict; i++) { + AVDictionary *d = test_ctx.array_dict[i]; + const AVDictionaryEntry *e = NULL; + + while ((e = av_dict_iterate(d, e))) + printf("array_dict[%u]: %s\t%s\n", i, e->key, e->value); + } + av_opt_show2(&test_ctx, NULL, -1, 0); av_opt_free(&test_ctx); @@ -177,6 +212,9 @@ int main(void) TestContext test_ctx = { 0 }; TestContext test2_ctx = { 0 }; const AVOption *o = NULL; + char *val = NULL; + int ret; + test_ctx.class = &test_class; test2_ctx.class = &test_class; @@ -209,6 +247,17 @@ int main(void) av_free(value1); av_free(value2); } + + // av_opt_set(NULL) with an array option resets it + ret = av_opt_set(&test_ctx, "array_dict", NULL, 0); + printf("av_opt_set(\"array_dict\", NULL) -> %d\n", ret); + printf("array_dict=%sNULL; nb_array_dict=%u\n", + test_ctx.array_dict ? "non-" : "", test_ctx.nb_array_dict); + + // av_opt_get() on an empty array should return a NULL string + ret = av_opt_get(&test_ctx, "array_dict", AV_OPT_ALLOW_NULL, (uint8_t**)&val); + printf("av_opt_get(\"array_dict\") -> %s\n", val ? val : "NULL"); + av_opt_free(&test_ctx); av_opt_free(&test2_ctx); } @@ -303,6 +352,8 @@ int main(void) "bool1=true", "bool2=auto", "dict1='happy=\\:-):sad=\\:-('", + "array_int=0,32,2147483647", + "array_int=2147483648", // out of range, should fail }; test_ctx.class = &test_class; diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt index 832f9cc8a9..f4fce1bd49 100644 --- a/tests/ref/fate/opt +++ b/tests/ref/fate/opt @@ -17,6 +17,12 @@ binary_size=4 num64=1 flt=0.333333 dbl=0.333333 +array_str[0]=str0 +array_str[1]=str|1 +array_str[2]=str\2 +array_dict[0]: k00 v\00 +array_dict[0]: k01 v,01 +array_dict[1]: k10 v=1:0 TestContext AVOptions: -num E.......... set num (from 0 to 100) (default 0) -toggle E.......... set toggle (from 0 to 1) (default 1) @@ -45,6 +51,9 @@ TestContext AVOptions: -bool3 E.......... set boolean value (default false) -dict1 E.......... set dictionary value -dict2 E.......... set dictionary value (default "happy=':-)'") + -array_int [ ].........T. array of ints + -array_str [ ].........T. array of strings (default str0|str\|1|str\\2) + -array_dict [].........T. array of dicts (default k00=v\\\\00:k01=v\,01,k10=v\\=1\\:0) Testing av_opt_is_set_to_default() name: num default:1 error: @@ -74,6 +83,9 @@ name: bool2 default:0 error: name: bool3 default:1 error: name: dict1 default:1 error: name: dict2 default:0 error: +name: array_int default:0 error: +name: array_str default:0 error: +name:array_dict default:0 error: name: num default:1 error: name: toggle default:1 error: name: rational default:1 error: @@ -101,6 +113,9 @@ name: bool2 default:1 error: name: bool3 default:1 error: name: dict1 default:1 error: name: dict2 default:1 error: +name: array_int default:0 error: +name: array_str default:1 error: +name:array_dict default:1 error: Testing av_opt_get/av_opt_set() name: num get: 0 set: OK get: 0 OK @@ -127,9 +142,15 @@ name: bool2 get: true set: OK get: true name: bool3 get: false set: OK get: false OK name: dict1 get: set: OK get: OK name: dict2 get: happy=\:-) set: OK get: happy=\:-) OK +name: array_int get: set: OK get: OK +name: array_str get: str0|str\|1|str\\2 set: OK get: str0|str\|1|str\\2 OK +name: array_dict get: k00=v\\\\00:k01=v\,01,k10=v\\=1\\:0 set: OK get: k00=v\\\\00:k01=v\,01,k10=v\\=1\\:0 OK +av_opt_set("array_dict", NULL) -> 0 +array_dict=NULL; nb_array_dict=0 +av_opt_get("array_dict") -> NULL Test av_opt_serialize() -num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-) +num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-),array_int=,array_str=str0|str\\|1|str\\\\2,array_dict=k00\=v\\\\\\\\00:k01\=v\\\,01\,k10\=v\\\\\=1\\\\:0 Setting entry with key 'num' to value '0' Setting entry with key 'toggle' to value '1' Setting entry with key 'rational' to value '1/1' @@ -154,7 +175,10 @@ Setting entry with key 'bool2' to value 'true' Setting entry with key 'bool3' to value 'false' Setting entry with key 'dict1' to value '' Setting entry with key 'dict2' to value 'happy=\:-)' -num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-) +Setting entry with key 'array_int' to value '' +Setting entry with key 'array_str' to value 'str0|str\|1|str\\2' +Setting entry with key 'array_dict' to value 'k00=v\\\\00:k01=v\,01,k10=v\\=1\\:0' +num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-),array_int=,array_str=str0|str\\|1|str\\\\2,array_dict=k00\=v\\\\\\\\00:k01\=v\\\,01\,k10\=v\\\\\=1\\\\:0 Testing av_set_options_string() Setting options string '' @@ -378,6 +402,13 @@ OK 'bool2=auto' Setting options string 'dict1='happy=\:-):sad=\:-('' Setting entry with key 'dict1' to value 'happy=\:-):sad=\:-(' OK 'dict1='happy=\:-):sad=\:-('' +Setting options string 'array_int=0,32,2147483647' +Setting entry with key 'array_int' to value '0,32,2147483647' +OK 'array_int=0,32,2147483647' +Setting options string 'array_int=2147483648' +Setting entry with key 'array_int' to value '2147483648' +Value 2147483648.000000 for parameter 'array_int' out of range [0 - 2.14748e+09] +Error 'array_int=2147483648' Testing av_opt_set_from_string() Setting options string '' From patchwork Mon Mar 4 13:06:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46761 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789813pzb; Mon, 4 Mar 2024 05:09:31 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW0TYHYrary3stEjYee5FjH5aU/DCCZNTMNoYpZNj0sXLfZBHftqfqHF7IXnIiCYa748FGxmr8yZSufxlJSAErmX4MynTFHEzqzHA== X-Google-Smtp-Source: AGHT+IFGFzeeJcrP4/QmqiXP41koVNE6h2393qptVUz98pcj5up9R3VkBM2alMsvM4bK/wfqZxvH X-Received: by 2002:a05:6402:308e:b0:567:26ba:d207 with SMTP id de14-20020a056402308e00b0056726bad207mr3121733edb.18.1709557771680; Mon, 04 Mar 2024 05:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557771; cv=none; d=google.com; s=arc-20160816; b=x1tVp+GLAGMedCgHEdVGqM4ZExngVtvzfW2Lc7zVlO6GFAaWOe5IId9eqZQ5lkinIA 8IzN746SbC/74kqS+PHY0Id0i7U62EaLBwuwbwooV+P8DXfvTb/SYrNK2TIANC1RhhyT aIx5dsKSuxsmXwYPPsJGcuFERHt4YMVQJNUZkteOS3sErnOHbqygvW8tfTbhWee5knlb qsRSME/0M7NFc1Krw6vbB1dK4K7sWZk+EU00vIkZVzwtvpd9rseFLCw2q9jAziR7erCR 83Gdwt7y7MxkHlpy8pgyC16vCHDamCWYWAPEHX9roXXfeIEp7z3zwt2bKe9/GTe7xUce rfIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=EZbYXJw7munCNzOfHUU5ahJvbsc57WS83pCqzfbza7c=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=eRWu6TfU5PD5ldBguucfo5C1/9HQqbImgZPkjF5gE3I3UZQlYiInhNjqkooRciAep0 gRnUcqUmp5eNLZgYWNMNQeBmGqp/9iqbSnxfJyH7wS/ZB+ejPnJIAssYlAKtMeu3U0Uj /CeU3aP7+ypLFkNF3wnyKFdZlh7H414j0An6M+bEkYpB1Qlqzk1bx/Bd8VjJobMnaCX+ ccQPOlvmt0j+cAPjfWvWPnHt0+O+n229bW3dIeI5Lggb5HHTtia7oLKuFE4xTRNtMPGM b6Jz4b6lI8SUqoO2qgEmPip8pWpzhVKH2zYhgBA5pcpGWajeayGGuz66z+1zZBjb+GF9 UGkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=UOn4eQZP; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s9-20020a056402520900b00566c2066151si3330613edd.535.2024.03.04.05.09.31; Mon, 04 Mar 2024 05:09:31 -0800 (PST) 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=@khirnov.net header.s=mail header.b=UOn4eQZP; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 39CF668D48F; Mon, 4 Mar 2024 15:07:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6E5FF68D43F for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=UOn4eQZP; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 9BFA04D3D for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id pLFwCP13vUzN for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=VU4REOAJjd/GcvYpIj1BplyrHTcvSqmUydQ/dEXZsCo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UOn4eQZPsiAIiFUoSHhvq/8az1gZFJesq3sHyR1wmcmieuh2355xikDigRSX7Rl6l +wQUWvaZWbghchc+PSG6ZRjrRnE44vzyRgez7OWeZPKFKjh8kWNBm9VDe/6WvfJzi3 yLwneLW5Y2By2/siSnPbJ846XeAgpBzEx+bGhJC+MWdIf3UGe+7dlC1XdN/NzCspg1 JsyFdAmQaF4C6QQqKJ8Qfocz5VNNrksZ7x/Uh3jPf6LLB7hug18vLUV7ZTyh6s1sVZ pQvucaMZAdRDbY1it639AhZAqN4oq+zGD80xOwkO2FNCE8gsvV+qTMD1EwJtHmTJDJ AoqAW3eOER3rw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6B3DB4D54 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2DAA03A0C7C for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:22 +0100 Message-ID: <20240304130657.30631-7-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/29] lavc: add a decoder option for configuring side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: faOtDVK1jrXl This and the following commits fix #10857 --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 20 ++++++++++++++++++++ libavcodec/decode.c | 36 ++++++++++++++++++++++++++++++++++++ libavcodec/options_table.h | 13 +++++++++++++ 4 files changed, 72 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index 3209614ed6..5d8585d8ba 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2024-02-xx - xxxxxxxxxx - lavc 60.xx.100 - avcodec.h + Add AVCodecContext.[nb_]side_data_prefer_global. + 2024-02-xx - xxxxxxxxxx - lavu 58.xx.100 - opt.h Add AV_OPT_TYPE_FLAG_ARRAY and AVOptionArrayDef. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 43859251cc..307a3e99db 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2120,6 +2120,26 @@ typedef struct AVCodecContext { * an error. */ int64_t frame_num; + + /** + * Decoding only. May be set by the caller before avcodec_open2() to an + * av_malloc()'ed array (or via AVOptions). Owned and freed by the decoder + * afterwards. + * + * By default, when some side data type is present both in global + * user-supplied coded_side_data and inside the coded bitstream, avcodec + * will propagate the latter to the decoded frame. + * + * This array contains a list of AVPacketSideDataType for which this + * preference should be switched, i.e. avcodec will prefer global side data + * over those in stored in the bytestream. It may also contain a single -1, + * in which case the preference is switched for all side data types. + */ + int *side_data_prefer_global; + /** + * Number of entries in side_data_prefer_global. + */ + unsigned nb_side_data_prefer_global; } AVCodecContext; /** diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 7c67b18bc4..5c80ef9cd0 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -60,6 +60,12 @@ typedef struct DecodeContext { * The caller has submitted a NULL packet on input. */ int draining_started; + + /** + * Bitmask indicating for which side data types we prefer global + * side data over per-packet. + */ + uint64_t side_data_pref_mask; } DecodeContext; static DecodeContext *decode_ctx(AVCodecInternal *avci) @@ -1744,6 +1750,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int ff_decode_preinit(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); int ret = 0; /* if the decoder init function was already called previously, @@ -1804,6 +1811,35 @@ int ff_decode_preinit(AVCodecContext *avctx) avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; } + if (avctx->nb_side_data_prefer_global == 1 && + avctx->side_data_prefer_global[0] == -1) + dc->side_data_pref_mask = ~0ULL; + else { + for (unsigned i = 0; i < avctx->nb_side_data_prefer_global; i++) { + int val = avctx->side_data_prefer_global[i]; + + if (val < 0 || val >= AV_PKT_DATA_NB) { + av_log(avctx, AV_LOG_ERROR, "Invalid side data type: %d\n", val); + return AVERROR(EINVAL); + } + + for (unsigned j = 0; j < FF_ARRAY_ELEMS(sd_global_map); j++) { + if (sd_global_map[j].packet == val) { + val = sd_global_map[j].frame; + + // this code will need to be changed when we have more than + // 64 frame side data types + if (val >= 64) { + av_log(avctx, AV_LOG_ERROR, "Side data type too big\n"); + return AVERROR_BUG; + } + + dc->side_data_pref_mask |= 1ULL << val; + } + } + } + } + avci->in_pkt = av_packet_alloc(); avci->last_pkt_props = av_packet_alloc(); if (!avci->in_pkt || !avci->last_pkt_props) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index ac32d8928a..3ff03d1cf0 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -42,6 +42,8 @@ #define D AV_OPT_FLAG_DECODING_PARAM #define CC AV_OPT_FLAG_CHILD_CONSTS +#define AR AV_OPT_TYPE_FLAG_ARRAY + #define AV_CODEC_DEFAULT_BITRATE 200*1000 static const AVOption avcodec_options[] = { @@ -405,6 +407,17 @@ static const AVOption avcodec_options[] = { {"unsafe_output", "allow potentially unsafe hwaccel frame output that might require special care to process successfully", 0, AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_UNSAFE_OUTPUT }, INT_MIN, INT_MAX, V | D, .unit = "hwaccel_flags"}, {"extra_hw_frames", "Number of extra hardware frames to allocate for the user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, V|D }, {"discard_damaged_percentage", "Percentage of damaged samples to discard a frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 100, V|D }, +{"side_data_prefer_global", "Comma-separated list of side data types for which global headers are preferred over frame-level data", + OFFSET(side_data_prefer_global), AV_OPT_TYPE_INT | AR, .min = -1, .max = INT_MAX, .flags = V|A|S|D, .unit = "side_data_pkt" }, + {"replaygain", .default_val.i64 = AV_PKT_DATA_REPLAYGAIN, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"displaymatrix", .default_val.i64 = AV_PKT_DATA_DISPLAYMATRIX, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"spherical", .default_val.i64 = AV_PKT_DATA_SPHERICAL, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"stereo3d", .default_val.i64 = AV_PKT_DATA_STEREO3D, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"audio_service_type", .default_val.i64 = AV_PKT_DATA_AUDIO_SERVICE_TYPE, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"mastering_display_metadata", .default_val.i64 = AV_PKT_DATA_MASTERING_DISPLAY_METADATA, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"content_light_level", .default_val.i64 = AV_PKT_DATA_CONTENT_LIGHT_LEVEL, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"icc_profile", .default_val.i64 = AV_PKT_DATA_ICC_PROFILE, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, + {"dynamic_hdr10_plus", .default_val.i64 = AV_PKT_DATA_DYNAMIC_HDR10_PLUS, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, {NULL}, }; From patchwork Mon Mar 4 13:06:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46751 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2788744pzb; Mon, 4 Mar 2024 05:07:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV2r0o7Pbmj3SlepbrGiHM7E6Kac3BeiDWBIIJpYnkiZ85qUl7XU0mDtT85oBAAa/GyZq+ek9pphVeARUVc6czQk/OY86mSE9lboA== X-Google-Smtp-Source: AGHT+IFe12ORqEeMayO7o8AXMYG2GuOUQXFHNbqjJp946huMHR/s63AH/fWuOL3D/+546sGT4yMr X-Received: by 2002:a17:906:24d4:b0:a44:74c6:ab6a with SMTP id f20-20020a17090624d400b00a4474c6ab6amr6807153ejb.18.1709557671737; Mon, 04 Mar 2024 05:07:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557671; cv=none; d=google.com; s=arc-20160816; b=euuhyQDVlyLSbHGaLiXKPOkrBFvgkKNqVmFs1bnlxEiB7UkrTvD//dEsjhRB80UWCl AzVZyt20mybV9L90yX4rHYpaSc4R4kJy9GRBUVIZ5eIG6JyO/8uh2Nr37WL+6iRozTgN Z7fljg3a8+5ONpiow6VlVbtrEW3fxoxVxaaAPc6BLlsn6I7BgGcKQE93pqCI8k1yZVjQ OcALROVIGpRw8GdwHcaaWu6nckwKLE4nvQF4zwthH2Quak931bqravUVilnssZHreqzf XH0dvSHRBvkzZ+Sz5QuKNnbt0e/mKwWJEcji8jASzicQATndBIAMlyq/kcKSZCg5vTP8 CWRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=CzOU+CSOALSCSBuMyeaWdqYuJCHE8OL1dT0QeYRvl9c=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=CJDImKeA5ozAuF2qwqVo2Qq7ODqM68XYlNtX0YH+8KVTUVNKkKCP0eeeO5E57awKQG Y3iTVI6IslD9N+A7TjqKTpjCyBvgM95iUGinMEXIlVCEqnIjs4MbSNQDrrNaiRc3ksGr Nku+FFRQMYOTWov6fzvOMeHZFwb52djkmiM1O1RfaICCKFJmJZH08daWE4YxppMiX1Lo 3cCcTvmlr+y+snhWEm92XMtB3Op+HLfQmpne1x6N+FU83Bt8n2ZDspJya7UThttoo1Yl xMsmzyooug2CADiGw2IOKKtOVmXQudqbm8+9czyONicXK5MOzktBozHz7HMps+g+84gG VVpg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=a3Pq810z; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j3-20020a170906474300b00a45322c32f0si1063793ejs.485.2024.03.04.05.07.51; Mon, 04 Mar 2024 05:07:51 -0800 (PST) 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=@khirnov.net header.s=mail header.b=a3Pq810z; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E777668D475; Mon, 4 Mar 2024 15:07:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C37DB68D3A9 for ; Mon, 4 Mar 2024 15:07:08 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=a3Pq810z; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C8A034D4C for ; Mon, 4 Mar 2024 14:07:07 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id VprrrcVSGfWo for ; Mon, 4 Mar 2024 14:07:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=eLMoH5353mquqMr+oUxgL3bROM94gBVzMBkggM/e8z8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=a3Pq810zH5zPwXLg5re7cmhsnVTVYk33BzoQ0A4rkZ5QCd7TmKYs/s/KecBMZAFpH giVgrSV936M+VcJMfuEGXRYk2ecJsa6G1qXvrpxXVLb1FHfQFrzsWbQF7KRl6XNyCh 1apdfDOtzXe91EWc21XxmMLfQu1sXUhJ5CruFXmdeXl6X7R/gnXiLHoWIDegzPIfYy efImVQ8pwfIRbOQN6b3vnXNGciIuiani9MJMO+Jm7SY2TBZtljJ/t6CcEZ20pZ0mdz Qa+BzU0i16FsMtlExgQ4ftPNV5pt/CpnPNqBs0vSrpEaKWu0CaICWigudMwgZrBZgc 6dB3Q7KXVwqaA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 3B6A24D42 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 393CD3A0DA6 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:23 +0100 Message-ID: <20240304130657.30631-8-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/29] avcodec: add internal side data wrappers 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sHCu95/2G2Dh From: Niklas Haas The signature of these wrappers is more complicated due to a need to distinguish between "failed allocating side data" and "side data was already present". Signed-off-by: Anton Khirnov --- libavcodec/decode.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/decode.h | 20 ++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 5c80ef9cd0..f3e8b72be7 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1857,6 +1857,72 @@ int ff_decode_preinit(AVCodecContext *avctx) return 0; } +/** + * Check side data preference and clear existing side data from frame + * if needed. + * + * @retval 0 side data of this type can be added to frame + * @retval 1 side data of this type should not be added to frame + */ +static int side_data_pref(const AVCodecContext *avctx, AVFrame *frame, + enum AVFrameSideDataType type) +{ + DecodeContext *dc = decode_ctx(avctx->internal); + + // Note: could be skipped for `type` without corresponding packet sd + if (av_frame_get_side_data(frame, type)) { + if (dc->side_data_pref_mask & (1ULL << type)) + return 1; + av_frame_remove_side_data(frame, type); + } + + return 0; +} + + +int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, + enum AVFrameSideDataType type, size_t size, + AVFrameSideData **psd) +{ + AVFrameSideData *sd; + + if (side_data_pref(avctx, frame, type)) { + if (psd) + *psd = NULL; + return 0; + } + + sd = av_frame_new_side_data(frame, type, size); + if (psd) + *psd = sd; + + return sd ? 0 : AVERROR(ENOMEM); +} + +int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, + AVFrame *frame, enum AVFrameSideDataType type, + AVBufferRef **buf, AVFrameSideData **psd) +{ + AVFrameSideData *sd = NULL; + int ret = 0; + + if (side_data_pref(avctx, frame, type)) + goto finish; + + sd = av_frame_new_side_data_from_buf(frame, type, *buf); + if (sd) + *buf = NULL; + else + ret = AVERROR(ENOMEM); + +finish: + av_buffer_unref(buf); + if (psd) + *psd = sd; + + return ret; +} + int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) { size_t size; diff --git a/libavcodec/decode.h b/libavcodec/decode.h index daf1a67444..b269b5a43b 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -155,4 +155,24 @@ int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_pr const AVPacketSideData *ff_get_coded_side_data(const AVCodecContext *avctx, enum AVPacketSideDataType type); +/** + * Wrapper around av_frame_new_side_data, which rejects side data overridden by + * the demuxer. Returns 0 on success, and a negative error code otherwise. + * If successful and sd is not NULL, *sd may either contain a pointer to the new + * side data, or NULL in case the side data was already present. + */ +int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, + enum AVFrameSideDataType type, size_t size, + AVFrameSideData **sd); + +/** + * Similar to `ff_frame_new_side_data`, but using an existing buffer ref. + * + * *buf is ALWAYS consumed by this function and NULL written in its place, even + * on failure. + */ +int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, + AVFrame *frame, enum AVFrameSideDataType type, + AVBufferRef **buf, AVFrameSideData **sd); + #endif /* AVCODEC_DECODE_H */ From patchwork Mon Mar 4 13:06:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46758 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789485pzb; Mon, 4 Mar 2024 05:09:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWl2BFviPpIzMn+lhRBzX93dECOFkTuV2RfIxx7zW7XiknsDjS1IJvkO9Co31gh5CZa6jcfTS4NjXTiyhGZ/mQfsdJmc3H2PLWpWA== X-Google-Smtp-Source: AGHT+IGOjGIwqKh7RS6rp0J7Hm69FCCZ+HL5IFSuHJSr4ex9qcauB1r8hZRGfSIhOhgv6LCuUmG9 X-Received: by 2002:a17:906:11ce:b0:a44:1fcf:9b9c with SMTP id o14-20020a17090611ce00b00a441fcf9b9cmr5935757eja.51.1709557741499; Mon, 04 Mar 2024 05:09:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557741; cv=none; d=google.com; s=arc-20160816; b=XWrazom9CV5d9+M/4jGHxTVTEpYW0bMfCowGRHC8ko617e6qCE5HWM6IZ3sFtIYK82 xSbmFCGQoFuDL05i7796Ng4MRVAtTC+bGT8Dkmg1TchCszWe8Fb3qVuP8mPNALz/t+xc eB4Q9zoJtqd+mB/DCbnMreYdERr4Yc1W9Y8NJrqAqhcmC2rt+jPIEZUk+Q5C84y+0LWa nrdXuBaR3OoRGpQB26/a2vCHbzD/U6jPYU1XhvZreaBVYWEaQxWnoLg1i57BY9bAbAVs ti/tZRxlNpWWwtLoyhQabpIwPuI5Ggj7ykIys0jlryCejtk4Nsfp4MwcHHOyhRIHh5K2 Bvbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=QYI7mrupt7gFhMVBzz8gwlPqQaQHCd2f5zo2fYiXj14=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=m+UfL1c20M3myo+tdEhRe1q60mkbFp2sIFcfymDSg450lh3/a10YN99jOKVLm3qBld a+pt2nCdA9Dhuo5hCTQRTMS2DY1DGRiRTDlZ4Aw5ZFtNKky/DYQa8BXob0/ZxIJ7abKt 5XHYkj627mp3OO0KNDccET7LC0JATcYCd5zBYTn1SosvTp7e590Yj47URs5ddeNOIuCv B52E0nUoH8NrPMZfrVMkcjFr5bS1/k9NL42Wxyx0YE2vGefa7ZxHr9k/eMESk/Usg7DS s8tLwIvMTpKVUTOX508/w2HODIT3CdyyDhAUC0IJEW6gTdHvMl+GSLc0V30KZ14IQQZP yAUg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=Jq8oCw6H; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id pj17-20020a170906d79100b00a443cb3efb3si3982205ejb.795.2024.03.04.05.09.01; Mon, 04 Mar 2024 05:09:01 -0800 (PST) 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=@khirnov.net header.s=mail header.b=Jq8oCw6H; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0811A68D450; Mon, 4 Mar 2024 15:07:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 686FC68D439 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Jq8oCw6H; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 77F064D52 for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id TIGa9beIqEYm for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=Cm29a1RiIiiniy8cMsuxqld0ojoTAILEKPXsxe9rWxY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Jq8oCw6H9mNPlEJEOQin9FN/aZ6Mr4JP//bbVTiIV1m7e4utpieDcY/Amb/B5dnFD uG9lBQsnXu3xyYWgviDeAgHM5v3wRMQ7+VsjLuu709JQf8y48hUPB0YsC4iTQAN8D4 HMkAEIxRSVzHM9Ad3OPGHS6kB9zMA2ELFI5cqLAFOreIlDeCPLRNbu476P4LfdwxIV R8Yx+EzXO48Q2KvRoDlRcDtQF/RyXY50rH1UlwxqO9pUO0G3s8mhO1k1h8YgGtGWKY ndX3BpCBW7Kiam2W9UYJf2VnJq6rFFOVrVoIDqGSzygcs9S6PjDtVijPO2dg+6I/0y +suslv9HOgZ+A== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 7635E4D58 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 45C7E3A0F49 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:24 +0100 Message-ID: <20240304130657.30631-9-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/29] lavc: add content light/mastering display side data wrappers 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FNK5I/3zSV50 --- libavcodec/decode.c | 25 +++++++++++++++++++++++++ libavcodec/decode.h | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index f3e8b72be7..105c9c5c39 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -35,6 +35,7 @@ #include "libavutil/hwcontext.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" +#include "libavutil/mastering_display_metadata.h" #include "avcodec.h" #include "avcodec_internal.h" @@ -1923,6 +1924,30 @@ finish: return ret; } +int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, + AVMasteringDisplayMetadata **mdm) +{ + if (side_data_pref(avctx, frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) { + *mdm = NULL; + return 0; + } + + *mdm = av_mastering_display_metadata_create_side_data(frame); + return *mdm ? 0 : AVERROR(ENOMEM); +} + +int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, + AVContentLightMetadata **clm) +{ + if (side_data_pref(avctx, frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL)) { + *clm = NULL; + return 0; + } + + *clm = av_content_light_metadata_create_side_data(frame); + return *clm ? 0 : AVERROR(ENOMEM); +} + int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) { size_t size; diff --git a/libavcodec/decode.h b/libavcodec/decode.h index b269b5a43b..4ffbd9db8e 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -175,4 +175,25 @@ int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf, AVFrameSideData **sd); +struct AVMasteringDisplayMetadata; +struct AVContentLightMetadata; + +/** + * Wrapper around av_mastering_display_metadata_create_side_data(), which + * rejects side data overridden by the demuxer. Returns 0 on success, and a + * negative error code otherwise. If successful, *mdm may either be a pointer to + * the new side data, or NULL in case the side data was already present. + */ +int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, + struct AVMasteringDisplayMetadata **mdm); + +/** + * Wrapper around av_content_light_metadata_create_side_data(), which + * rejects side data overridden by the demuxer. Returns 0 on success, and a + * negative error code otherwise. If successful, *clm may either be a pointer to + * the new side data, or NULL in case the side data was already present. + */ +int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, + struct AVContentLightMetadata **clm); + #endif /* AVCODEC_DECODE_H */ From patchwork Mon Mar 4 13:06:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46754 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789086pzb; Mon, 4 Mar 2024 05:08:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV75TKVJ54dOyI5Bjs3vn5zkgGAFy34eK6mOh9y7nHDZ7O9s89TXPqUod/bGjH7rkmjpM91JATU+YpD4Iipr6QfrZn5dDaPE3IEoA== X-Google-Smtp-Source: AGHT+IERqSXwQ82FmJxwmssCmueDVuuHKJCzslnsx0wa5GLNgjGQE5tDgqc3whreLffrTJYkuopA X-Received: by 2002:ac2:53ab:0:b0:513:3db6:43f7 with SMTP id j11-20020ac253ab000000b005133db643f7mr3837080lfh.6.1709557703552; Mon, 04 Mar 2024 05:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557703; cv=none; d=google.com; s=arc-20160816; b=w5fms8aLfWo1W0muF+7M33z4K+S35IptEi24MP4uNC1vjK5s22a09YZEg1I6nh1D6a pKfTbJU9WYVU6pa5I4vaJ2Db6kUekowOgJy01nsrjaqbs78hq3WLa3/vZFyckk4mljdy Z+MoZllxsyYilY+YEoGogwV0NxGfc5Z096pwyoASheMuFmtEtg0Wb7xM9g3G6O9gdIAX WFSk4dSidSlKYe5VZ5dp+GIRv7ZTEpAsfyaQwBtPSBgbcNGo8prdQjaMasF/OvjEtL2c JabRcQ3+/s0fn7Fq2/Do6SsyT2CK4RK8RhqFJE3ZNdQYBICHrxkvTL+fm3T0VI0FaRJe rXtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=Be8DyXwAJnc7pqMJduJ6Y4hG33b5lNt70dkxyLeciGQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=IBLyWoqywq+ytlEJRF+C5zHx5h/gDSD+0vKVT2yNhZ7Yn/VYacmiaDAec7tEyvTGht ezzSdpHVf1gkU8dOYXxrmNEGj8VxrcJQbAgeT75tXAkZSYX/28M8zo0FFwAc+yRf7FhM zi+yYaN43Xl3/3+bjuyQfGMIcoD9qobJHRyJSEpbckrqLvuF0Sz0VrF55sZWkUi+J+Cy 3XlmwR/6v6NiAqdxx1Wl+XLyySwHcEjJ75HKcPJWkmKk0pNwkmVa0jrpDviQiJWjVxfU kUnlM52kcbJ+z4GPmIjWIbcCLi72NyKNseFHCL22jCuE+R3DGi+4B/uJluK9PiM8DhbF atXQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b="q9sRO/ux"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a3-20020a1709066d4300b00a3e5ef2d569si3810562ejt.1023.2024.03.04.05.08.23; Mon, 04 Mar 2024 05:08:23 -0800 (PST) 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=@khirnov.net header.s=mail header.b="q9sRO/ux"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6953568D455; Mon, 4 Mar 2024 15:07:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 67E8368D407 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=q9sRO/ux; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 26F914D49 for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id OKSUmOYU1Ogj for ; Mon, 4 Mar 2024 14:07:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=OA70GScSe5y+bL5b3jC0cY03XFwQguTLuQI8kadhCrE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q9sRO/uxTzDnVUYcwglZsgTfoOOHeNsgz5ePR3+FH+STTGWFYMpfm0L1fwIuG4wRu 2SZ+mFacB30CL3y3yz3oDtOX0QsZruFohxBpQFgYbVhSNhnKIUZXgf3xBB/rw6HOGR kvMfQA1t7nDeCxmCdCdstoVumzISD0qsmOf51jjMwTwQK/hcT+e1/eRaAIVghiKCvK Lt5E/5STTOcQG9Lkq0VnoFdxhalgVGitm8q1hhqcLU7rmud5zR882nG3+losp9R+ab hTQExm/jwYV9DC/4RN7p5UOzB1X5olM6098qYuCWpcah6CiUte8WOgnlsr4r0rqizn Tynbtp3SEhxVg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6EE464D56 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 51C7E3A0F55 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:25 +0100 Message-ID: <20240304130657.30631-10-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/29] avcodec/av1dec: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7A7QnnSUuANq From: Niklas Haas --- libavcodec/av1dec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 704b9d6298..af80ee0b17 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -954,8 +954,9 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, if (!ret) break; - if (!av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, buf)) - av_buffer_unref(&buf); + ret = ff_frame_new_side_data_from_buf(avctx, frame, AV_FRAME_DATA_A53_CC, &buf, NULL); + if (ret < 0) + return ret; avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; break; From patchwork Mon Mar 4 13:06:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46753 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2788986pzb; Mon, 4 Mar 2024 05:08:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVy5GLJ78IOTlJa0yFMASimUq5SlN1hRbdtdsrHWP7Mwpzoacc2xO3aRY6cT8e60GWi1ivu1Jzok8f0IoYFeBnUgl5OfQkaqtGLcQ== X-Google-Smtp-Source: AGHT+IECOOHSjDx9QvMz67rK96wHhJ4ig5pGsqu52+v1P104wfW2eiRs5K5m54rJi3CNAqYAHsfv X-Received: by 2002:a17:907:a603:b0:a3e:9bce:b5b1 with SMTP id vt3-20020a170907a60300b00a3e9bceb5b1mr7326360ejc.5.1709557694253; Mon, 04 Mar 2024 05:08:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557694; cv=none; d=google.com; s=arc-20160816; b=DnCeh5ApOr1NmaGYOygvyRQTiYGQ7WbDDoLIK4IT1L2mc9pwalLck6ZOJphEv9VVgQ 0o/utF9B/zbxXKI2/+yWS/xjs47TgztXB0qQqjc66ZCtNZ4yoFmmmG0KQaUaRg1Vba0o NMPmBnvBLRWMroIxxYv4HtdXReWVJPhU+cZROAYWB3Yza/yq11Op1Y1s3NcJ1obuBc/K hAFbPA1WwwCErjdsr6PFbBY89lCLb0kdGx+0FQ2Atv4s0PNeXyzJIMuXKPTjo99Y1gUi SmddplSV5YG4EF/lKwq05y6tVKBtWIKYAAr7N6b4fht6D08rjH7PqHStpJuSnzEIPwGN 7Jxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=vxsDYvlU1xXrBsDnwH+cdQAngAgufeDxqdaM0J5IxrU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=b6Pjpozx016quM5l+8sAJUXfxRMVo3W23hxNJm5qopkebTlYhXU7QQ+/gkHCXOj/OX NyCgQV+pkeRQji6COLPPV6/Ew9gKCxEi59tAf9R62ud/HZhxOn7Sw90v4UHePnjtpfAA jN2+6ZkfzDjf0ejJf2+KFdPTKJu2Nn8pfJIu3sFHsWRhmoCXRwoaGzF6r5vVOr2uvPpX /7+3VrJ9s79DceTQ5CEPvVxzRfpNdmh6pA9Y0J39m6Lvpym84uZA3lz7JFvnTpBxvbtp qCswHSzqvHhqLC0mrbMKl+5k4ofDXKLODhOyUkDsIxWixA4G9LcO0J1zPrK/CsGDCgOa LKDQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=IpNaGLSw; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f17-20020a170906139100b00a436d77dac5si4035707ejc.41.2024.03.04.05.08.13; Mon, 04 Mar 2024 05:08:14 -0800 (PST) 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=@khirnov.net header.s=mail header.b=IpNaGLSw; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9A9EE68D44F; Mon, 4 Mar 2024 15:07:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 680D368D436 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=IpNaGLSw; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 41E6A4D4D for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id u26B1fIgKSIw for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=7cXRQ/RSLlS1a64ID7ypeyNga0UUbqD0+UrzvPHerkQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IpNaGLSwj48uUJsIIZM2Wcq8Nz/OqePVn4M0MFZ/rjA1XHC+dX0LlbabIji5FC5bG 5ASB/TnUsvFp/5/sdnYWlMBNDyvDOFVKhTZEtNuvU/yQfIxpcBTIjdrqz1/TM3m0Pe c5SLBD0Y+ibYD8OySBZUYKwrrz0gy6CIYEjVZmzILjiM93ovqxRqycPd4e/bESFxId DdeIGytDFiWsg3KJ19BoZhbzquCAjzDqyyyz2paRym1BhFh6A8aJ7nuDiqtjVQqyxp n915AQ0J0w6lYJBwRCZkA2I6ulyb8Hkre/kFgJZUb0+cL0tww/t1fqwl7cVkdxZpIr IrOb9OlkTiaPw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 7C79F4D59 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5D60A3A0FB8 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:26 +0100 Message-ID: <20240304130657.30631-11-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/29] avcodec/cri: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: r6fkE/7Z6l0r From: Niklas Haas This function was already ignoring OOM errors. --- libavcodec/cri.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cri.c b/libavcodec/cri.c index c4eb468610..990e52ac99 100644 --- a/libavcodec/cri.c +++ b/libavcodec/cri.c @@ -398,8 +398,8 @@ skip: } if (hflip || vflip) { - rotation = av_frame_new_side_data(p, AV_FRAME_DATA_DISPLAYMATRIX, - sizeof(int32_t) * 9); + ff_frame_new_side_data(avctx, p, AV_FRAME_DATA_DISPLAYMATRIX, + sizeof(int32_t) * 9, &rotation); if (rotation) { av_display_rotation_set((int32_t *)rotation->data, 0.f); av_display_matrix_flip((int32_t *)rotation->data, hflip, vflip); From patchwork Mon Mar 4 13:06:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46756 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789288pzb; Mon, 4 Mar 2024 05:08:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXFAoQUQfXBCn7cPONiadquGzq8H+672GEs/vXKvGBKNF/46nKOcJwm5nLouiU+XgthLb742ZTW+YEIabTifLUOOiJP8LRUUxCL9A== X-Google-Smtp-Source: AGHT+IEz63S3Fi4oxCEYe+G++D/5CvY9LnNLOS/BOQ1X9wd0Sr4Hfbu3j37pVqqynK3UostmavG7 X-Received: by 2002:a17:906:f750:b0:a3f:2b6f:6d57 with SMTP id jp16-20020a170906f75000b00a3f2b6f6d57mr6169487ejb.29.1709557722254; Mon, 04 Mar 2024 05:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557722; cv=none; d=google.com; s=arc-20160816; b=DkbudgS1UEbljL3O3jfat5sXHndqiM9kn6T3wxeDBZYAnGTM2+ti+BdleSnlWXMoYr 3o0mdsoK2lR+mquznm+W0SrOirW2qRqAomd/DatcrxsmlIGJWb2wgpLpT+VLjqoQ+uKr euWRsEqm2MO5SHERNREro+Syh1expki+pOKCbvCVu4Vv7VQLR3f7MmllBdoPpx7PAgKI EnsbTcdK4I5tFJEO34oCbgk6nUGychJzl+5R+Lw6HWNB3aylceFSDVXhKAbhzKv0IKrT vBA7K/my5jcQ0UdAybiQfRnXTvLvgsTqMaCsK0VbBZDMl+puyRTaTioihKDnxfZtJjf5 DYLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=IqcaPTiGS8hpWT6zCxD9Tj2VSSpozum8AraehIVxz2Q=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=LdVwu02n0d+ucH1IpHK/sHNygaxPPpvLHnvNSZ6lJKCMGQZLZQFIXeLdGLEC3ba6vk u8wp0UzfO7Gm46+H3jZaJr8fRuF4J9uMKbLyfFzNCSiEOVi8R0Wq9wv0OuyjwfdzJiPX G3W1VKR82CxRx/IrCPZRjMg3GPUPcO1w2FHqak8W0VK13TINVDlq/QQCx3iFNdStG86Q n7ZhLQhtq8mETfrTIbxjb19TzpiXnWJHlxHmdTI+kDX7m1LWbBWw/m67PXUbWSqqJnKN FN1SAjr8LXDjQtA/Z19hzBhnDQPF8YKn/hbCq3kdvU8KBO+2jnvofpQQvITQiASGoUbL ESDQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=e9Grjy4f; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qk31-20020a1709077f9f00b00a4515b49cb3si1348557ejc.90.2024.03.04.05.08.41; Mon, 04 Mar 2024 05:08:42 -0800 (PST) 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=@khirnov.net header.s=mail header.b=e9Grjy4f; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 342C868D3B7; Mon, 4 Mar 2024 15:07:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 683AF68D437 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=e9Grjy4f; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 905D34D54 for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 0299J4uVVHrq for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=1aJR+LwluwoSUi0bZzPp50PDeXNkqGaSR32ThKESvvE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=e9Grjy4fa6e/BzrUeyEV9/gqfa9PnDakYcV5XS7KnzWaWooB5mSHLgorLvVJPO699 UMPCg6izM5uqKMXHyJkjlWZ6w9ZsinWYPdUb/inoZFLPz2JEFHH2dQPlOzNjdEnSNv WhjDhSLS5Qa61YN19aJFpJcIIgJhE78+rt+PUG2dKezE5W2Ds7FVbYXJK88JE8cUce qcr8c/Uele9f66P1Oj9JVHTxDppEARu7EFZ3SUXd8fd+GktrcUsiGbohAjOQwGmS4h RTHikDqfQTiP7nXlJ5Ow59qCyfgfRqIuNyszGT5oxmnQX70TjXS4R91KpJ6h4yO4m2 GcpcTtMkkhM8g== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 8DC364D5C for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 692F73A1050 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:27 +0100 Message-ID: <20240304130657.30631-12-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/29] avcodec/h264_slice: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OnfOzQ51l7qi From: Niklas Haas If the time code side data is overridden by the packet level, we also make sure not to update `out->metadata` to a mismatched timecode. --- libavcodec/h264_slice.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 8464a0b34c..f30ff33188 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1257,26 +1257,27 @@ static int h264_export_frame_props(H264Context *h) if (h->sei.picture_timing.timecode_cnt > 0) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; + AVFrameSideData *tcside; + ret = ff_frame_new_side_data(h->avctx, out, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t)*4, &tcside); + if (ret < 0) + return ret; - AVFrameSideData *tcside = av_frame_new_side_data(out, - AV_FRAME_DATA_S12M_TIMECODE, - sizeof(uint32_t)*4); - if (!tcside) - return AVERROR(ENOMEM); + if (tcside) { + tc_sd = (uint32_t*)tcside->data; + tc_sd[0] = h->sei.picture_timing.timecode_cnt; - tc_sd = (uint32_t*)tcside->data; - tc_sd[0] = h->sei.picture_timing.timecode_cnt; + for (int i = 0; i < tc_sd[0]; i++) { + int drop = h->sei.picture_timing.timecode[i].dropframe; + int hh = h->sei.picture_timing.timecode[i].hours; + int mm = h->sei.picture_timing.timecode[i].minutes; + int ss = h->sei.picture_timing.timecode[i].seconds; + int ff = h->sei.picture_timing.timecode[i].frame; - for (int i = 0; i < tc_sd[0]; i++) { - int drop = h->sei.picture_timing.timecode[i].dropframe; - int hh = h->sei.picture_timing.timecode[i].hours; - int mm = h->sei.picture_timing.timecode[i].minutes; - int ss = h->sei.picture_timing.timecode[i].seconds; - int ff = h->sei.picture_timing.timecode[i].frame; - - tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); - av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0); - av_dict_set(&out->metadata, "timecode", tcbuf, 0); + tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); + av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0); + av_dict_set(&out->metadata, "timecode", tcbuf, 0); + } } h->sei.picture_timing.timecode_cnt = 0; } From patchwork Mon Mar 4 13:06:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46760 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789701pzb; Mon, 4 Mar 2024 05:09:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUra+BoCrEm3Cv+NSdpLXeDA1+SNelcGzNmRFyxs+SfFR2x9aDIyD/wcdnNczT4gxo/+Zu30PMxizQvqagWsS2zSYarerZbusma5Q== X-Google-Smtp-Source: AGHT+IFitNFEIOnwfAGjD8z4xFMFCUYjnIF0VSL/L5TtT8z0wPnR2Q2YAMA0FDyBKbPO21sG7YbM X-Received: by 2002:a19:f612:0:b0:513:30fb:d64 with SMTP id x18-20020a19f612000000b0051330fb0d64mr4848340lfe.44.1709557761860; Mon, 04 Mar 2024 05:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557761; cv=none; d=google.com; s=arc-20160816; b=N9tChzsvF+6y/6RxG7lMefOen3zvAj8/HBQNpiq/zkSm4xnCvkDrYtvrn839QIsL/0 /+z8JbJ9fdp0lfNJ+YurlRbK4SjAAIWXH/+XwGsn2snQ2YL2ak2i6EZ3uIvUS5khdSrO wsfoNQcat6Dfy8DEMNu/hDM7GJJmbplTGGR0n2T+XdkRuws/HJbsQEtF3l0SjjgxgIkn fl/dB+Gtv+z6LGf+RRScH4W7bVO1NT4avpuZTHeDmhLGzpf6Dv60f6X37DycGXX96QK0 X3bKZ7+tMz2hjN0gxB8YsqPeF4c5eRDwi40B5WOcSsgzHzySbMLB+d60xa2NGp6M40+N Ka2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=x8cpzSGcYKD+8rF/Czj1hNGqmLTbWRQBmrYuhVQlAFA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=GFjwtpZzIYIg2ll6fSzKtgHfsDyzKz49bgORUVwiUz0MsTgYpJchqkybi0drbwTjGW dh3rIiuN6smt++bJLV6xs2Or8DJFTLkUp6m3rJ5Rm5QtSumn3BIaiUuRzz508iOqZkIw FSHi0+aBVXzTtk1HQFXunF8nMnr+6pfCUbqWkbu/JF+UnlQh9PmSP0FuGfZi/g9ftJq7 1wM4WeSHoKlLBslM5SrvsHE1J0QrbY+7bUJxR1IqAkQc6/diGHC7m+uQ6coe6jDP3i1T /6SvvXySN6FsrcNTET/5McnpCH6fWWE9uyiMR5Wd/Dka5k2UD+X5hNqnTvTiyD/MzfDu XmJA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=X9vIXZ5r; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cw22-20020a056402229600b005653ef43be5si3811575edb.464.2024.03.04.05.09.21; Mon, 04 Mar 2024 05:09:21 -0800 (PST) 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=@khirnov.net header.s=mail header.b=X9vIXZ5r; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4105168D48A; Mon, 4 Mar 2024 15:07:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 715B068D442 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=X9vIXZ5r; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C4B594D56 for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id i7Qy89Ocgfal for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=JAy0+m5/awN0/cjJzWqB6IJvE98Lte3cUM7lsIK+kIc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X9vIXZ5rX0m9mV6NDwMP0i+9/8QrB1axdvKorEsanG7zYXObwUsXuhcmubL8Em+mN iH+uYlOO8H8vL51GLjJDBLyOtKOQYPCJIqlwLu4+o0OnAwC5BS/yv8XqqKtvUfVzHI iMjL1KFhfTU2zANPq7cqiW0OVUCRs/MpTKhLT3Fb7v1BKEaT0YUwqfyPAC+2KVUnMW 5PWsKhCfz5fRoVEOpMsZjoPMPbfItKlT+Ylu6Be5uI5ZBnnTe12bn3SowHL9EpPu0t DRVLVhvgF8ZiBx89WL2PlSi52wz92Gx807uTHb/PHrmXy5x0skBvfU2GsCVPPvNPMW tjXAdvKBEL8oQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 8DCD14D5D for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 74CCF3A11EF for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:28 +0100 Message-ID: <20240304130657.30631-13-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/29] lavc/hevcdec: pass an actual codec context to ff_h2645_sei_to_frame() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gdTPRb2uAwAG Needed by following commit. --- libavcodec/hevcdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index b5311ae510..17c6a9212f 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2778,7 +2778,7 @@ static int set_side_data(HEVCContext *s) s->sei.common.content_light.present--; } - ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, NULL, + ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, s->avctx, &s->ps.sps->vui.common, s->ps.sps->bit_depth, s->ps.sps->bit_depth_chroma, s->ref->poc /* no poc_offset in HEVC */); From patchwork Mon Mar 4 13:06:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46759 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789586pzb; Mon, 4 Mar 2024 05:09:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW5goNAt0bgPSR3p0C84Q42lLsF5l5FbJWeGaAxmbed/RnrBYm60BT3e+Fq7TqHEUvjuhJU/5kUKynwlgicP85FP1y0EFWvLx6Jig== X-Google-Smtp-Source: AGHT+IEzMDtrEs0zni/kwjODaSX1gXHJQm8Kpg/MHrhKhf/fqWCM55ZDP3SLdc4EGIOk0OqD0nM/ X-Received: by 2002:aa7:dbcb:0:b0:567:683:11bb with SMTP id v11-20020aa7dbcb000000b00567068311bbmr4781008edt.20.1709557751052; Mon, 04 Mar 2024 05:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557751; cv=none; d=google.com; s=arc-20160816; b=dlUr1YQ9FOD3BwrpT87PEyRq/fd6K8uaNgLxnETtxLI8BN4pWlxK3i5zOX93EKY8iO XRNqSy8A0BJuErK3YLdranRNPPKfJWhMyg/kpquzvDqz5vqwAI4S5/Jy+372AynDtTmm LzymYia9PQ+j80dEDRY7wC0tTzNKOsbLqKWV+9R9SkMmCN6Qf/xw59caxdcBzMioQ0tV FGrxtLfFZyYDzZVE32j89gc5FMYsUCA5vdBbXTUk193oodhRclEuGVv7LTm3QyEgokLT 0cRt2DlL9tzRznewIytosPHujtFIr0pAhRsntDz/cMyVT956jOOGQFUnSl6GhFvjWxqg KXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=0lML2+WO1iuYIRaWITZKCotVTEUV+UIpBtEI5jcGmwk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=jf1q0ES0IQlgh/lPrBa+I/5ZturY7jox6hJf7OgfMOfRASiH9c6OZfOMXRx5zk+hWJ Jkih57gzs7OgoA3R6kDSFDvv0dIChUaRuNz8LYaEysb7sz+gyQp8fAbad8XbODUZqynf R7EUn9/R1gn1bXidQ1IEkRSScQseWioXflGlTpZgpQhpbsqxZmcGDAjkYYSixdpfyXxe BBctvzfvBM20z1lY/bgk/4brcSQUl7tdSoYfdUID6Qie9ED7gp9Hgk/pVtOBCludtcVB L8/Jg7DedZUAqQDg9+mzsBiTQK3z9aJbMbQZwws3ENC4JZwmjaqbrnbObfFkf6R3ulvK WoLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=nJ5oCGhv; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dz15-20020a0564021d4f00b005676b7b8f08si267974edb.50.2024.03.04.05.09.10; Mon, 04 Mar 2024 05:09:11 -0800 (PST) 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=@khirnov.net header.s=mail header.b=nJ5oCGhv; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36A8768D3A9; Mon, 4 Mar 2024 15:07:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6AA2668D43A for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=nJ5oCGhv; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 21D634D59 for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id zBIkWVdO88Pz for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=/V9LVu36ekTmKu1qkc6uNNng3yp5qW8xf6EiDKQhdfo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nJ5oCGhvGpwUtjmE8yLNcgHBHkO9ra7SJ9HLAEzR2W2JIotSDu0TuJOyshogCq+BI UDQheJesabtP/oFcOimPIfCaCD76IMJRZcsWlNxelc0gDaMvmKgjBJhVj9IuZ6uHGF 0m607ib5YzrsDkdudp1ZJVjDyVD8NU+QmQjGuZxLEo43lPjRm8c5+o90qAggzQ9z0U Uyp3yU0T4jWLqN5nceOOGLBtjpHcQERnIqqLTCgcyXa3giCbFp/v9SttpuTjI+tdcj 7+tpf9oHOaCC0D2ODtiRxqXnz2oNVoUWXe/cL59//6TINricOVmEL90WEA0OrMCh9j AACzjBjdj64Sw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 940894D5E for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 807373A131E for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:29 +0100 Message-ID: <20240304130657.30631-14-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/29] avcodec/hevcdec: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Y2L6pb9Ta6fB From: Niklas Haas If the time code side data is overridden by the packet level, we also make sure not to update `out->metadata` to a mismatched timecode. Signed-off-by: Anton Khirnov --- libavcodec/hevcdec.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 17c6a9212f..76aa6b4588 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2788,24 +2788,27 @@ static int set_side_data(HEVCContext *s) if (s->sei.timecode.present) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; - AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, - sizeof(uint32_t) * 4); - if (!tcside) - return AVERROR(ENOMEM); + AVFrameSideData *tcside; + ret = ff_frame_new_side_data(s->avctx, out, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t) * 4, &tcside); + if (ret < 0) + return ret; - tc_sd = (uint32_t*)tcside->data; - tc_sd[0] = s->sei.timecode.num_clock_ts; + if (tcside) { + tc_sd = (uint32_t*)tcside->data; + tc_sd[0] = s->sei.timecode.num_clock_ts; - for (int i = 0; i < tc_sd[0]; i++) { - int drop = s->sei.timecode.cnt_dropped_flag[i]; - int hh = s->sei.timecode.hours_value[i]; - int mm = s->sei.timecode.minutes_value[i]; - int ss = s->sei.timecode.seconds_value[i]; - int ff = s->sei.timecode.n_frames[i]; + for (int i = 0; i < tc_sd[0]; i++) { + int drop = s->sei.timecode.cnt_dropped_flag[i]; + int hh = s->sei.timecode.hours_value[i]; + int mm = s->sei.timecode.minutes_value[i]; + int ss = s->sei.timecode.seconds_value[i]; + int ff = s->sei.timecode.n_frames[i]; - tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); - av_timecode_make_smpte_tc_string2(tcbuf, s->avctx->framerate, tc_sd[i + 1], 0, 0); - av_dict_set(&out->metadata, "timecode", tcbuf, 0); + tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); + av_timecode_make_smpte_tc_string2(tcbuf, s->avctx->framerate, tc_sd[i + 1], 0, 0); + av_dict_set(&out->metadata, "timecode", tcbuf, 0); + } } s->sei.timecode.num_clock_ts = 0; @@ -2816,10 +2819,9 @@ static int set_side_data(HEVCContext *s) if (!info_ref) return AVERROR(ENOMEM); - if (!av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_DYNAMIC_HDR_PLUS, info_ref)) { - av_buffer_unref(&info_ref); - return AVERROR(ENOMEM); - } + ret = ff_frame_new_side_data_from_buf(s->avctx, out, AV_FRAME_DATA_DYNAMIC_HDR_PLUS, &info_ref, NULL); + if (ret < 0) + return ret; } if (s->rpu_buf) { From patchwork Mon Mar 4 13:06:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46755 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2789192pzb; Mon, 4 Mar 2024 05:08:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV1zNyistoQ641oNycR6Ij5vivpRKiWgOqrknWn1uC7/KRZcDgK8RWqiXLIBgAyp2Oboa3NPr6Yki2NwAJ6KVI/pet3hvKiHVuj7w== X-Google-Smtp-Source: AGHT+IHQPfZ64PQqJXHzqc3vKovlWsGZmCdxDdV09H7+NrN7cWZf0VZUUkCDw5342FW3ew+i3Nlc X-Received: by 2002:a05:6402:3590:b0:566:fe55:ecf0 with SMTP id y16-20020a056402359000b00566fe55ecf0mr4790617edc.3.1709557712960; Mon, 04 Mar 2024 05:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557712; cv=none; d=google.com; s=arc-20160816; b=dUHLR9nKOir+UKJ6Z7k4CVAQL5USsUSmghHCPXTBBVV3hYTFRUiX9mJ6STIEg92Mo3 bIKKB1XUbikrrn9q2kN+vhc2CeH1UUin/vE+bj3CE/Z4+LbDwF7PSfsgVf7qUGlj8pKO qKVAsJLVmBdGfNqi9raZ6uOhP2zhcfehJHL1ShhaXko+VTXaDCR2qDnlOXGPZc+xpP1l WAnsTbyx7NjACCl34zufkr3GVmfdjnhHTld1qZ0/DgjouqywN9B5PkmzXu1ko2yPexes 3tBh8L4Yuh5T7doHzdN5HYrdPJnvi9g0hji8lElGrSWOsuwlLquQ74CZpLnpuaLrJ4Lk Xcwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=GpCG8iaHFVlyCsbHvdBZg8IJiowVZ8YWlgF+q4yA9VE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Nc60pfCzi5Wm3gErSsFsVk9oaL04go9qc1F/HHWJCUh7e52tXa4/yE4bsg2amXVr8T fMYhSNFCwoagu/9o0S124D5jZm/HEwySHtgPkzF0eE6aw3IoM2P9nTZRLnNCPsd5Xdqy PANQ2d58vyzyCZzVXMkiELfKeucqwg9rfXXocAa9aAOxkUoQSKbZWbVWV522LQE5HLkx OsiTatDAUeZ/aU8Wr8RO/QSS7aVXseSjDybhhza/QuB7LJifbJdeowrjXAa97QGvP8RC ZP/nd5y2FqqCqccxEsRTWCH4anK7FYFZSyAeAnWmSkqXJiGvdkAnILaOc38TTAyJVP3q SE5g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=paMoOB2L; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w15-20020a056402268f00b00565d5d87a2bsi3939526edd.629.2024.03.04.05.08.32; Mon, 04 Mar 2024 05:08:32 -0800 (PST) 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=@khirnov.net header.s=mail header.b=paMoOB2L; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F98568D43F; Mon, 4 Mar 2024 15:07:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6745768D382 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=paMoOB2L; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DACCA4D58 for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id rrD7VOT33Zrt for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=ciQ5gyAqgs95XHY9PB5rTpex1reQIcOAMvas3ofOtk0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=paMoOB2LamSp7E/HkSuJfcuG8IlTEHquFAtyjT8qUjSpb3/1+kSSi6nctcu7pyJk7 QUIB4U/FRonNmv4kKaAESOT76nwky3rLmys7gNkUEh/ZU5kLE8CGDilP5Mvy2wtFX4 2yK0sTyblaC9c9OCFWG1/+ofpRxE+T75FPFadhZv8p6YrjUPt86EaDARTRDVFLeVNH iE5atC3z663sWOczL9sm5eCKlfSRUoEFu1cZpI8C05TyeP9QZF6roPhAUki6ejp3F1 6DH9wjmZPDPsWOqBVBTSdFmQp3CyzRqs0HeYUY7+yF6+wj0SUuw1LcY21Ytj5V/N+k taYWdYnqSntVA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 982274D61 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 8C24B3A134E for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:30 +0100 Message-ID: <20240304130657.30631-15-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/29] avcodec/libjxldec: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IlmMwnN/xMhB From: Niklas Haas Also fixes a memory leak where the side data was previously not properly cleaned up on OOM. Signed-off-by: Anton Khirnov --- libavcodec/libjxldec.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index b830eee784..d57a27418f 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -483,11 +483,9 @@ static int libjxl_receive_frame(AVCodecContext *avctx, AVFrame *frame) /* full image is one frame, even if animated */ av_log(avctx, AV_LOG_DEBUG, "FULL_IMAGE event emitted\n"); if (ctx->iccp) { - AVFrameSideData *sd = av_frame_new_side_data_from_buf(ctx->frame, AV_FRAME_DATA_ICC_PROFILE, ctx->iccp); - if (!sd) - return AVERROR(ENOMEM); - /* ownership is transfered, and it is not ref-ed */ - ctx->iccp = NULL; + ret = ff_frame_new_side_data_from_buf(avctx, ctx->frame, AV_FRAME_DATA_ICC_PROFILE, &ctx->iccp, NULL); + if (ret < 0) + return ret; } if (ctx->basic_info.have_animation) { ctx->frame->pts = av_rescale_q(ctx->accumulated_pts, ctx->anim_timebase, avctx->pkt_timebase); From patchwork Mon Mar 4 13:06:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46774 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2791248pzb; Mon, 4 Mar 2024 05:11:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU+rhCcqkUb+iaKHODrMjA3O7kV0zcDZTwONeD/TmOb8HAg4jQdpvNp1C7dsXm0eh0dJ2p0NwQ8wwofpldlneZNukh7IQ4+99n5oA== X-Google-Smtp-Source: AGHT+IGDhZy3J+v443iRHb6tWJhkxiXmNE7LdkecKqi37/1QUh9yA2JGG7FqKUBIDQ10zK+TVr4W X-Received: by 2002:a17:906:d114:b0:a45:1787:aee1 with SMTP id b20-20020a170906d11400b00a451787aee1mr2808899ejz.14.1709557902348; Mon, 04 Mar 2024 05:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557902; cv=none; d=google.com; s=arc-20160816; b=bDqa4Eid8vvT644cmsLtDbAfxaFVOoHzEWzVbtWynXVqYjkRV9+fp1KiShPllE5jxq 002QxD2zP32Al6VG2En6hXdwdZiPUWjpb78/2XYB9ZD2gC+AmvqToNNUD9zIJrvuTfe1 O59zMCeqAA5fNOf2+0qOLCWUY8kve9YJu8MiunNskc3KU52l6GCoCWV+PFo19AG8grOC 40T/JH/pepIcKP1qy/JHzvut+kCgVw2E8feC8XsS3ot65iDfxNTmNecNg4Kyt4Lc9pzS 6mNSfz1imNMeKGU5fOE58J7gDvpT07gw8e+TcgRy3LpkypynzM2kNiJhfirLF/2xACl4 97Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=9rCi7oXBDf2OgRVDArHDHZOpyR6CCKn9SIrEY/2YMi0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=RP2Mj5vWv+DQzRQ6OrBeDfIKk0yQhmXXmEjHG6BrHxI6GPc5kKvPNBjW8/X2uqFSUC YtIiVHnxnmw5hO6W2E79DcuadE2iVsYe2UHVCkwj+L3ADc/cl1WgDry5DH9jABll5sjE tjCnivYnhxNDynTNW8t2fVFdwvKQR4nHsyiE3iAEV4JQWAKBNryMHXesP7Wzm1j40lHR 3MiM3jDTucwcI0qvHgB12bPgX9ki4P8M+nmBBMDQQlTonmYqqah8bPetq231IwBWkm4P BnPEHd/9DhbhiC6jGoILEZyJpzwRktWuYdO8u5L0kjnaBtRDbtdPvqDbym2iat+9y1MZ SjhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=hIvImVnW; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kl13-20020a170907994d00b00a4581ea669fsi192790ejc.794.2024.03.04.05.11.42; Mon, 04 Mar 2024 05:11:42 -0800 (PST) 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=@khirnov.net header.s=mail header.b=hIvImVnW; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 311A968D4DA; Mon, 4 Mar 2024 15:07:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C923968D451 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=hIvImVnW; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 895964D79 for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id RsDbNMY3dhC7 for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557627; bh=tgdk/gGqyYTAocBW3OwID5r4auLUu3OhEhePApN3bHg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hIvImVnWH5Y4cDbRaf16hiXyDREElJzYEBQJLAz9DX1lloNU/DEW/ebIWlk2Ztwng 7H9K7YeZiVIR4BTiRb2Ps/Vy5AlrOnDdY9sH9UupsErdkRf20eBVCUEvxI3kPGcr3x 6d+KYvwEyy8024bR4bX9n8gYB02kiJUd0pHVcX6DmxFCKw5M4dUdox/VmDgKFHV99A 3INMLoTsfxfQF6CMwhUeDtpumHy6t3WpXcgRdjCIZnpzNmd/0zD+FHxELvRu92BwHC EbwO2zTw15Krs02xTR+0A6fmj5ButDulx+M7NKqPkXgDfxnq01ijqi4ArQL0Cs1sKW 4Asxf8W2oLjQA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A28814D62 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 97CD73A157E for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:31 +0100 Message-ID: <20240304130657.30631-16-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/29] avcodec/mjpegdec: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: i0Gb1X6xYpMp From: Niklas Haas --- libavcodec/mjpegdec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 81f724d230..43b36d0a8f 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2840,16 +2840,18 @@ the_end: for (i = 0; i < s->iccnum; i++) total_size += s->iccentries[i].length; - sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, total_size); - if (!sd) { + ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_ICC_PROFILE, total_size, &sd); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate frame side data\n"); - return AVERROR(ENOMEM); + return ret; } - /* Reassemble the parts, which are now in-order. */ - for (i = 0; i < s->iccnum; i++) { - memcpy(sd->data + offset, s->iccentries[i].data, s->iccentries[i].length); - offset += s->iccentries[i].length; + if (sd) { + /* Reassemble the parts, which are now in-order. */ + for (i = 0; i < s->iccnum; i++) { + memcpy(sd->data + offset, s->iccentries[i].data, s->iccentries[i].length); + offset += s->iccentries[i].length; + } } } From patchwork Mon Mar 4 13:06:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46765 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790322pzb; Mon, 4 Mar 2024 05:10:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXt1yweoOGf5nRywiIuGgfMkHGHD/x7fqTFn3Ctua5h/slNlkHLYx7pZ/RonVNWAqjI/YT5J+jS9mf2qZFoHxMVp4ytBbKk/neZBA== X-Google-Smtp-Source: AGHT+IH5robwNjGbOK9a2OKaN8btsC1N6lJMrp7l2ySAzXODATA0ZrlzSurvyd12wWyNuKZEtaxz X-Received: by 2002:a05:6402:901:b0:566:be4a:21ec with SMTP id g1-20020a056402090100b00566be4a21ecmr8674831edz.16.1709557819421; Mon, 04 Mar 2024 05:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557819; cv=none; d=google.com; s=arc-20160816; b=QNyzLKaRylijuo7gn9ECU5QLddQvFQSSthnQ6/UE/cMN6M6jVNRIp8kCl4CgrOA2Hf DAHOXXb8GB02Qr+REebavNuOt86XdNcB8fBEO3NwyZt8bmqDrckeAzj50xiE6wzMyiBp /F/rJPQt/6fICTNwJ4PNi1pxRX+oFDF+gO6jIWZNVxgnCsd6wstCKEaidQLYVlCgt9Mu 7vNo4QKRPfvdOu7kjU1+6STF1YAINYbYD08jUj3/sdQQLUGSRi+ePO76Blx4c1npTVdn uj06KWgHedvOMXK51GpTKW1LRgUAkcOMc4Yz5Fe2Nh7VxDranqSX7ziFSTCkhICSZ8a6 5S1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=gcQySKUNvE+Pam2Acidtu7BKAhfW5frxFk1/2G7R+mk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=qPOtknd+8ZK7M8Xv2HnkLGRIp37+fNRzcgmsuSYEJ89r+YQ+oAypcu/HiVjW9ee2u6 92ydW9D9fwwqUHob//zM7Xu08CmrgYuBHgmpVBuyYRcaOiuMWfRlC6OhU++kM10kNRZD 3zoDcDElQLtJNPMbTZ6LNVIe5+n8aXQprKtLYOc1mydlrAAmqAdJkuYUXKeoxu+ydmDz Cg1kmI5dzuh150ljTMe6QYJ8wO92DYSWjqvfKucX75vteH47Da6op4nqe6hD7c4g3Bjj 0iN3IcZ6P0c9+hVFLddE1t8s/93Kiht8verqi3MBi3388lPbPDZ2CZQ5gQ1Qhrx5M0Xc 1oCQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=Bq3dLERD; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g10-20020a056402320a00b005675de9b4b4si558295eda.572.2024.03.04.05.10.19; Mon, 04 Mar 2024 05:10:19 -0800 (PST) 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=@khirnov.net header.s=mail header.b=Bq3dLERD; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6329368D4A5; Mon, 4 Mar 2024 15:07:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81FFF68D445 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Bq3dLERD; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 6F9574D5D for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Aq1OJogOOtSa for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=J7HYUt+uUlCyKt/CVcXxnqAflxKg0WHez8eCvHKwA18=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Bq3dLERDaQQaXVf4ireBO5RSHuszMfxBWSudCFlWPflxICKr8vbeiyakr0+ZFqB6o nCzdWidI1taEdu9z9VcJnUfOqxLICJ6A6nFR2eZWGzTSR9/aCgCbG3HGhiZ791Wm8X X8OCV5SzbAfh363IAN4I7erUVbbI3ZaAppzAN79sebvUcRxhX2mqJu3iHM15jbxzNI M7xtbKpJK0s/MpGspeVLkitT1jKTdFSb3mFSE51wAHxW0nLAgT4pkZ3N6GtXI1EvYH oYj2XAjCv59Fv1TkZCThVqFBe/8IoGTOoKmU5Kn1VQUezZxgqft1geccGG4jEqeNZV MiONKx58i6gJA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A2A144D64 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A3A013A1581 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:32 +0100 Message-ID: <20240304130657.30631-17-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/29] avcodec/mpeg12dec: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: xeN41mkwcz36 From: Niklas Haas We only need to consider side data types that may possibly come from the packet. Signed-off-by: Anton Khirnov --- libavcodec/mpeg12dec.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index d07eed8744..3a2f17e508 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1306,20 +1306,20 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) } } - pan_scan = av_frame_new_side_data(s->current_picture_ptr->f, - AV_FRAME_DATA_PANSCAN, - sizeof(s1->pan_scan)); - if (!pan_scan) - return AVERROR(ENOMEM); - memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan)); + ret = ff_frame_new_side_data(s->avctx, s->current_picture_ptr->f, + AV_FRAME_DATA_PANSCAN, sizeof(s1->pan_scan), + &pan_scan); + if (ret < 0) + return ret; + if (pan_scan) + memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan)); if (s1->a53_buf_ref) { - AVFrameSideData *sd = av_frame_new_side_data_from_buf( - s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC, - s1->a53_buf_ref); - if (!sd) - av_buffer_unref(&s1->a53_buf_ref); - s1->a53_buf_ref = NULL; + ret = ff_frame_new_side_data_from_buf( + s->avctx, s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC, + &s1->a53_buf_ref, NULL); + if (ret < 0) + return ret; } if (s1->has_stereo3d) { @@ -1332,13 +1332,13 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) } if (s1->has_afd) { - AVFrameSideData *sd = - av_frame_new_side_data(s->current_picture_ptr->f, - AV_FRAME_DATA_AFD, 1); - if (!sd) - return AVERROR(ENOMEM); - - *sd->data = s1->afd; + AVFrameSideData *sd; + ret = ff_frame_new_side_data(s->avctx, s->current_picture_ptr->f, + AV_FRAME_DATA_AFD, 1, &sd); + if (ret < 0) + return ret; + if (sd) + *sd->data = s1->afd; s1->has_afd = 0; } From patchwork Mon Mar 4 13:06:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46766 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790421pzb; Mon, 4 Mar 2024 05:10:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXa7kLQr3//FrlgAc3mSsV1g5/nIbVz7Q9o2Wzkhb5t+Wy8tT9kMZxAyDEQgGLmv4QwCj/nwkcveoqCpmPq+XeZ0oa37RG7lIn9Bg== X-Google-Smtp-Source: AGHT+IG2NhXMvPvCjGkTmXqTpgYAYgjeYjH6IOXe0/TYyLNsxoI3GFfSkmKOLzs07iAmMglJuR6l X-Received: by 2002:a05:6512:2f5:b0:513:19cb:be72 with SMTP id m21-20020a05651202f500b0051319cbbe72mr5791853lfq.64.1709557829051; Mon, 04 Mar 2024 05:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557829; cv=none; d=google.com; s=arc-20160816; b=CaB/NAWHNtW581M3wr6iW6LgG7yjJT8TriOY4VCJiTfDxMwdJZDFa7LoWlrm/9YP55 d9sFA3fOLbNKiHZtUIBZ8XXvTis4w6R7eMnyQ3mRGka0HI/xF04jHSlx8ZOFJL+tE+yV 795R36qSD7/JWyaCX3+J9rWkcGYzdzZf8RKuHbEjV4mFQeNxIPBQnsUglq0XaL7suKzx BZ6cWYyrSH2C22uBTmJCJCNkkorNB7g4y0twR03fStd+2E2d+Wwe9GE/LLEtYrLEKUvj umDLYfavJJVnQzL1KgrYJmu0mmbj1ArvT2wUAibVedg3VUk7NwdYb/aC1hyW9sMwk+fg 7sjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=U/QZj4C7VePgMPEw8dF5rsSAaG0l+3i21QRbqe+oAPI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=aAAiSkRWNEieSlej2ZjaGaZWkpcLT0L4EVAz06f3XOhEhBOmomB3lPpqiFRQ3p58zZ tcKuFHeklcUt8g3IGg3yguW8xMe4jNcCPj2Pl0to4YKqUSAA7uen9YTsHvuUv9IH4Zk4 jZnODcofKx8For0LHvztjR6aX8rqRB2LrMgycvV3Gw1lWUAhVnDcypbmXTw66WEpSUKa lNltcCRuzxi73EhYKYnhCthqOmr7IMhAvviVJwXmu/5SbRnls66PSVPzHy3Foa0U79HL /UrP/lGCI1N2prVu4ieYUTXr8Em4y31rR+Au4eY38R/i7brCgLxJp4fhEp0njnML8nEA QDCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=L15kr4DE; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kg23-20020a17090776f700b00a450971bc9asi1503285ejc.490.2024.03.04.05.10.28; Mon, 04 Mar 2024 05:10:29 -0800 (PST) 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=@khirnov.net header.s=mail header.b=L15kr4DE; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7020768D4AA; Mon, 4 Mar 2024 15:07:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8496968D448 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=L15kr4DE; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 196AD4D71 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id NCvIsX2xxJRc for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=XA+7t9vN7BuC5OtZr3s4MD25X7QXpD0W6yhhVs6BDAo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L15kr4DEGa00qQ5HR/3jp8YDUixeFLoLw2mys9bpdE5pOrubmlh2g4lQK6gRCT/Mz 4rQTL6WFrzH5NZGfylnv88E2TSI1CrOstUXsJTr1+ClSuC3kUqE9VGymKf5aBL1DmQ UhIuVSD5TT5eVvU2LXI8fh+KmtDDovGcvVoC2B7MFSzhMKNSPoYEiJVQhCTt3PDagr g5IRnQdd/K8rdWZ0yLKIjiNvjFDhvJmp5Qfyq3SVm7uqGgEtCIDUbthKWa6Dxc2UiX 6oVMjCNyPGGoW0DtJMiSgyJXdd4xbzmOHAq+ARDgHcw/7egcb7zSNjfvy9Z6sXE9Za MbfJqG1w867sg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A2B9C4D66 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id AF8A83A1592 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:33 +0100 Message-ID: <20240304130657.30631-18-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/29] avcodec/pngdec: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qsSCzB6OkOsg From: Niklas Haas --- libavcodec/pngdec.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 026da30c25..8f409c74b8 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -660,6 +660,7 @@ static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s, static int populate_avctx_color_fields(AVCodecContext *avctx, AVFrame *frame) { PNGDecContext *s = avctx->priv_data; + int ret; if (s->have_cicp) { if (s->cicp_primaries >= AVCOL_PRI_NB) @@ -678,11 +679,15 @@ static int populate_avctx_color_fields(AVCodecContext *avctx, AVFrame *frame) avctx->color_range = frame->color_range = AVCOL_RANGE_UNSPECIFIED; } } else if (s->iccp_data) { - AVFrameSideData *sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, s->iccp_data_len); - if (!sd) - return AVERROR(ENOMEM); - memcpy(sd->data, s->iccp_data, s->iccp_data_len); - av_dict_set(&sd->metadata, "name", s->iccp_name, 0); + AVFrameSideData *sd; + ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_ICC_PROFILE, + s->iccp_data_len, &sd); + if (ret < 0) + return ret; + if (sd) { + memcpy(sd->data, s->iccp_data, s->iccp_data_len); + av_dict_set(&sd->metadata, "name", s->iccp_name, 0); + } } else if (s->have_srgb) { avctx->color_primaries = frame->color_primaries = AVCOL_PRI_BT709; avctx->color_trc = frame->color_trc = AVCOL_TRC_IEC61966_2_1; From patchwork Mon Mar 4 13:06:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46764 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790217pzb; Mon, 4 Mar 2024 05:10:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXuDWkk/zgGi0evjRS83yLyJwy7qoEg0oZnQsk4NalkldSWM0an+oKhp8Km0/sq20w14sZZo4SlX4bipqheJL9iRrNTbrNsNfLGKw== X-Google-Smtp-Source: AGHT+IFNurDaVKlglxQp/uZmriz1PYX/e1pvobbko/Vt8OIAKxT9S/lT2B6uca/MEUfoS6LFC0vt X-Received: by 2002:a05:6512:3b06:b0:512:fc00:7c6 with SMTP id f6-20020a0565123b0600b00512fc0007c6mr6597959lfv.51.1709557809683; Mon, 04 Mar 2024 05:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557809; cv=none; d=google.com; s=arc-20160816; b=ijPPrLsEFVmbepNwLkhDQoMQ7F2eiyRuTDDAytxQsy41ZIyn03XNL40ylToTWOgl77 LsJiyb/VsvkpCKFbqL1ze59vIB/U/zIBEiLQzRnykyBCbe0LWq173D3x6NeBTX7RRV8A PlcHUsLkMS+XwuYkr40uBC2XQMTZl9KDLeU4+ch4Zz++EZ0hV4GNahKqtr0vC+ngC9yM X8IbsP66L6T0Ppagtwj2bFzpGx51lstIwNvN0lx2+m7ScuZUX7mRgMwpJ/qgA46FY8iS tSr7rIqxzNYB2igwqmUdY9kP31Fvy3UcFTyW+sbDinCvygXYm+W8+lOEeDx7/UQKyG0X ZcUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=Vn81xhBV9OQhc68k7l2HQdk1bi9GTaaPgR5h8OEwCWI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=EwApq160tuTdN7JafzqOswo6sgxgapUW7OnpNwdc1Z/sH03VFwdtgb9hVWmX3dSWc3 EipEcCjUcf62A4Zym2OSJ2FsRju0zIxG4jPsNfnbUf5WaAvHpXs+SNAls6G7/CjIM5GZ HMO4edVsbbDRqwyEkiCLZNKcI+8af9ftsG9IT1QJ/5O6GR3VdDY8LZIyZyW9gRgxoW3g QFQNL4uWtEzxIaValIAOixmj95btIqL6ny0IeTEscNKg/qDZgiqqKuJ5tg4NuRoumuih y2OlhNtMvlwG79o1jegrSTmeKMDydy8O+woCKHyasW7efsQPnYR3S6I0HdHqkE5EdvaJ zb8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=cIMp9nxw; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n14-20020a05640205ce00b0056618452b17si3985820edx.186.2024.03.04.05.10.09; Mon, 04 Mar 2024 05:10:09 -0800 (PST) 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=@khirnov.net header.s=mail header.b=cIMp9nxw; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6429868D49F; Mon, 4 Mar 2024 15:07:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 82C8C68D447 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=cIMp9nxw; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7A6324D69 for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id LskBo7jt9-JC for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=khHDHEk4yhqNAUCjyNi5P+gSIPzdHRqQ3w9yUH8aS5M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cIMp9nxwMnImoytKn/el0f30nox9sySX56bo0cc2svt3jErQjWhrH5uP8BGzjSAZA Lrswpk+9IU9HkIz2B9igc96yWE86D2OIRSj3GmLmt1dBKutfUL2VJzS3+rh6hnJGUC I7nnoScJJSXpXxqRlV3salSA7osH9cjj1cdUjCgTQgRp/coxOrXMXl/oP8wyTWURXN 4YNLp/Gv6xcK4OOUpxk3Yr9YztMN57ILrS5a24zi1NsCTWJ/nhZl3HBBQZcWM4YNjH mPTW2ZGOpUq22ZPu81KziXq7WoIp4lRTL+V4rf9nkaKVPpbDe0ZPqrdt5/gdNf7wKq 0fEeKv71A9fjA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A2C894D68 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BB1FA3A159F for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:34 +0100 Message-ID: <20240304130657.30631-19-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/29] avcodec/tiff: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: P7jE259k9dW0 From: Niklas Haas --- libavcodec/tiff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 71cb703821..cb4d378753 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1706,11 +1706,11 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) if (bytestream2_get_bytes_left(&gb_temp) < count) return AVERROR_INVALIDDATA; - sd = av_frame_new_side_data(frame, AV_FRAME_DATA_ICC_PROFILE, count); - if (!sd) - return AVERROR(ENOMEM); - - bytestream2_get_bufferu(&gb_temp, sd->data, count); + ret = ff_frame_new_side_data(s->avctx, frame, AV_FRAME_DATA_ICC_PROFILE, count, &sd); + if (ret < 0) + return ret; + if (sd) + bytestream2_get_bufferu(&gb_temp, sd->data, count); break; case TIFF_ARTIST: ADD_METADATA(count, "artist", NULL); From patchwork Mon Mar 4 13:06:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46763 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790118pzb; Mon, 4 Mar 2024 05:10:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUPbVwq+kj90HMlhcub1me4ssaQF4XcCwd1NHxeMdlEodQ+imvfZWclQzEvyFScBi4GQ4qvFMT8tR+ZyOU6o/MU2UlXn66EnnD4IA== X-Google-Smtp-Source: AGHT+IHpevGnX7iaaHmuXfG7nWsW/RsmenWrKPdha5iu+nMS4qsvnjF0oyw6v7/QCTgEP05ah+w+ X-Received: by 2002:a17:906:16ca:b0:a45:62bc:6a0d with SMTP id t10-20020a17090616ca00b00a4562bc6a0dmr1226159ejd.31.1709557799884; Mon, 04 Mar 2024 05:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557799; cv=none; d=google.com; s=arc-20160816; b=i9WDmGju2sROBlC7GqxRwA9PbBdUto0nTgoOsqfQkewqSZm5CnMdr4eN91tpZUh2ES Il0FtQE0wQ0VSdVZABHTSbwr7oayusIZ3yLf1gwrtTxNaBt9l4c9hNtKE0CnkHNXavxK UTJSaz0BCXmkXnh/G5y1KILqMvHe7OybBhjrpZdAJlZp9giR860JU9/bEARkNiAY5Qv5 MvkxW5wInv5ptizXU95avdBXiB9Vhx5xKXbCeCxIxfrk4St4r+qBItEP37C8XLzp9jvc phpSTkYj+MpqfkaYJfm/JCN67pufDQp7rfx50looTI7+jKvwJzu5WBsknxy0/a5YNe5Y sMNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=mLjNayGOoHuOaVMtDJetcElf5qswyC9XDzGCme+HHyg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Eo3vkt0n/Ob1NzoJO2I3BAggjdn8jQ7U0NwDCYUVIKp+e2s6ZeKZS/5E8IudLxX9I5 qWq9UOk35UT/xwphgRjntaCjabaab0gw44PvloP4rS/onM9TuZtrqgWmiG/sW5RXVH2Q gWJAm7aHK9oy+SHX4lRo3WQdUv0GdHAiAEnZaXHlcEW+YvaVfcg55vblgCoqNt7T2L+S RURdboaQlydMWW+IPDFY40dEmAKrt70O6ioXgKYfuvotCosr6XMJp1RGuAISDV4nKk4G PDAI0LKEKJnqujgAIy8XZKD+By9f1Y2xwEPZCG0pcEj9OLcK8wdeqYHi4mWcY9gIe6sA rfhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=eXsu4RuG; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 6-20020a170906310600b00a4555d792c6si699945ejx.695.2024.03.04.05.09.59; Mon, 04 Mar 2024 05:09:59 -0800 (PST) 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=@khirnov.net header.s=mail header.b=eXsu4RuG; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65C7368D49C; Mon, 4 Mar 2024 15:07:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8184F68D42B for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=eXsu4RuG; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2BFC04D5C for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id s3FxpK1ZHKO2 for ; Mon, 4 Mar 2024 14:07:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=9T0rIEOgnQqkMrDJmaKHN5Ao8NovfyVVglUps8oVxtM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eXsu4RuG+jEO+y/fxmoC3krKqyiYgM0aBH+inwv+553KDM6vBxm7WRj3ptGz5XZuM WahEKc3uMyddfzsLQs61iAaUJARGKARjK20lTJB6WgBTMmDklUw6u46BF++pnM64Kj RndRFOXDHNCTI47kd4e3Fj9mlZsaxSs0fGBOeB4VZPMTlDqoPhZmcBmSDYs6d+CjoU hjAA03v5K0jY8He6jU5u056FjM+i9lJFVlK/pbijA9kclX9AOucGIRZ1CZeF/bm1cI ijtV4/2+BrFdKq1WfqwqMerKdVcARYfLVfo16sxO1Cb4gMW2Ivzl1vfKMgHsNfBIhZ l7ZqlA58vnPdg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A2CD74D69 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C6E593A15C7 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:35 +0100 Message-ID: <20240304130657.30631-20-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/29] avcodec/webp: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: iOvA4as5pgzZ From: Niklas Haas --- libavcodec/webp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 54b3fde6dc..9308ea2b69 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1500,11 +1500,16 @@ exif_end: "VP8X header\n"); s->has_iccp = 1; - sd = av_frame_new_side_data(p, AV_FRAME_DATA_ICC_PROFILE, chunk_size); - if (!sd) - return AVERROR(ENOMEM); - bytestream2_get_buffer(&gb, sd->data, chunk_size); + ret = ff_frame_new_side_data(avctx, p, AV_FRAME_DATA_ICC_PROFILE, chunk_size, &sd); + if (ret < 0) + return ret; + + if (sd) { + bytestream2_get_buffer(&gb, sd->data, chunk_size); + } else { + bytestream2_skip(&gb, chunk_size); + } break; } case MKTAG('A', 'N', 'I', 'M'): From patchwork Mon Mar 4 13:06:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46773 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2791139pzb; Mon, 4 Mar 2024 05:11:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVhF0WlptvJ6fJ3WtjsXXMdD6HoVVV8vsGSJomEdJBJsTZ8pfIN43dNF0ytykodFiZ29TD8c8Jdfa3GXBP+XxjfCgLnSLy3YMINaw== X-Google-Smtp-Source: AGHT+IG6zfWHfDgylvEBEujM33qDrzfJPexgiJSIXqKaYWK7VIlOQd17ozWGYvMYkn9boKF6054Q X-Received: by 2002:a17:906:2b4e:b0:a45:622e:a0b9 with SMTP id b14-20020a1709062b4e00b00a45622ea0b9mr1115709ejg.64.1709557893869; Mon, 04 Mar 2024 05:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557893; cv=none; d=google.com; s=arc-20160816; b=IGXrzdPQ7NHWdGK5dFctbIYGHT7eKGKjKvYs0vscx/phw0IZfkiuwWySr48sFwYY2u K4qnQRq68DqSvSSTOPehJ2bd8O0TzrPAKVqfrqAT/1AqO3PS8B6zoJ31uqStnaKbsz1T 7Oio2WIUgbX7nppFQHMngoW+BBWuoN7A2IrCq6USK0tJnrC9ZyNQZiEDyAlvnu0riwHI hspsH1yWhCQ2FM/FV1mVeeS+DzUxNNRxLLWUhY+xdzrLG81be920gAVwyU9WR28wJm03 WN3Q9SjlhrSmExAXuSgoWLKXhIp5Hpdx81Z+Wr3RafjTlQ1G3s110I6KhGL3qPggyRz/ CyCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=y+of1aZpx7f73uhGiyVGSs/lV/zH8i5xuRub2UjNs9U=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=l1JNNt/rgeGyfrGe5iDUF+Y5Ri78igAK7YqEdm/0WXbuFL4IxXQWmCfbq7P53gyXmt phcUOf7AE6IqflTjgTfOCiOoQnVcbA4S/RQX6FmJxhblwrAo+WD5xbfTbshtmrShxSzt ASCM+koT1Exw0zEa8/QWzAUKwcEaPSpRGpJvHXzwWV8wNJq4Zn23K1kCwCcrFLUo40IK H3QcBUagCLVzbg7+UO/tmQTGQukiEVa0EHY3X7HlFvGcsW2nUOArWsonFYtrTOHmWyjB /oJoD4ar5G0YjzcY0PuMLlReNkt0rc9vO9SltrFdQDfjJ7eWrbD+Ee/g5RuRKU3xrqFg lH4A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b="Swxp/wAN"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a8-20020a1709064a4800b00a3f2418fcb8si3853214ejv.396.2024.03.04.05.11.33; Mon, 04 Mar 2024 05:11:33 -0800 (PST) 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=@khirnov.net header.s=mail header.b="Swxp/wAN"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AED9868D447; Mon, 4 Mar 2024 15:07:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C734A68D450 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Swxp/wAN; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id B78F24D64 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id dOH1Srh1SJ63 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=ip1I1zcNNW+YtqGnf81QxcpbDB3WTZXLkX9wbxU0/WA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Swxp/wAN6Oh9mJJKn8ECro+pCVVMZuocc+Q3wzFKE41QDuBwNGOa+Rjm4RGAXdY/L TEQZNQFfMkF8kHqrgoFxsKb8gEkf9oAk0EpS/XUTSGElmCEjlE3L3H4wp8Pmk+O+BM MoCNE1GLlhsv9n/XR1/mITFEr0qU1kZ/zlLaFn5/Rwq0W9kSZJYgJQdV/MBhDFVCnV tLbuFWLy7n8Z2MXJFoCV+x6WMU1Ux8EN/lOcIlhneqLKGns/jDqQU2yF7rUp8aA4Z4 xD/HjW+tSZlNQLPt+qfFOBcmBPUdeF2ReRpTQeeRiwr7ElA0ejogrBBYMTt+H2B+i8 HojX3/sbFDwDw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id ACE6B4D6C for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D28EC3A167C for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:36 +0100 Message-ID: <20240304130657.30631-21-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/29] avcodec/libdav1d: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: iLF2eE8Yroai From: Niklas Haas Signed-off-by: Anton Khirnov --- libavcodec/libdav1d.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 78a5c63bf4..3714137ed0 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -561,8 +561,9 @@ FF_ENABLE_DEPRECATION_WARNINGS if (!res) break; - if (!av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, buf)) - av_buffer_unref(&buf); + res = ff_frame_new_side_data_from_buf(c, frame, AV_FRAME_DATA_A53_CC, &buf, NULL); + if (res < 0) + goto fail; c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; break; From patchwork Mon Mar 4 13:06:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46772 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2791069pzb; Mon, 4 Mar 2024 05:11:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV9fgLMOS3NHN6GhJPXBkfEjTEFQg16+cjHFuffM/axAWUNaAXaVCjO1+NLPYxYVQ6vBdth2BaXzeBAl9WNq4PKcn1DzHkZdZ4eqg== X-Google-Smtp-Source: AGHT+IGpYRFzex+l1TDl/cHrXfkgxbZJR/NR0Huorfl6sqVfTBtmrcEwZKrsrFNYIqwtQaqaPhH9 X-Received: by 2002:a17:906:3846:b0:a3d:ed30:11c8 with SMTP id w6-20020a170906384600b00a3ded3011c8mr6681934ejc.15.1709557885195; Mon, 04 Mar 2024 05:11:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557885; cv=none; d=google.com; s=arc-20160816; b=ubClEkS74BbJfsAJylz0imXhHWzazayL+Znzy/Gr90sqPV7NWfs+QW1WANZvGeOIVZ oXgGVsRXF97/eUeqpWT/6kiC0pyr9LHRra9GUIspoz4aIPo7hImiQAya8iA5qtLKD0rP T2noRLoUIiW7ZRbX/M/ieoSVE6A2S76IYjbIV7Tg3anpwKVvwdNyPXTNo2kjMRtL0Hry spEpnKqjxgUjlls4TAtCaXD1y7A+lysFdM1OLkY7Ej9d3vN+YIfxYJtQ9WtJw4mEkplh gmaYHWhPXarr50oCPoXjxdwCJodvfGnaM/gGaZMTif8pmBXwiuNatIQV2y8FoRkA/26v Rb+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=EuOPPzWmh2YtIF1Iu6xw70UOLdtUlKg+1LZWKY8UM8M=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=mvtX4mX1RMtySoXdFLAdds1e456u8nrbOtqcBiHW1dYKvrqisnCF7owqTGea0Fl3qj wwBcOEyzRp+lKKKYKhfk9sfsI9KS0+DmeC07r1ozDem6xFsDzMkuANIVvy2IcWZ/14ck fSj72Y9DfZsaypemPQ7cx+UqBtJ/E5Nxgl+AuhAdkJ8KaM1UQ632E/0nQ1dAV8ZDLSOk g4PcXwa3L/7VZxZASj0FsH8HOid9N/mCMEzBXNUIN9NegyYiSs0gV31zk539zWa7c2HD MdBfTR3wvm7Z5s0NBC4EB39mmRHvpbfsFXsjfpmUDNH2yYkyhG8Ky/iyIZnbScHScFFX xfoQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=UIfEOIcC; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a3-20020a1709066d4300b00a388d084d2bsi3912568ejt.744.2024.03.04.05.11.24; Mon, 04 Mar 2024 05:11:25 -0800 (PST) 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=@khirnov.net header.s=mail header.b=UIfEOIcC; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C78CC68D459; Mon, 4 Mar 2024 15:07:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C065468D43B for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=UIfEOIcC; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 151E44D61 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id o2C5XkYsgPTC for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=GEGNEp7HIy5y2kd87yuwNys3coA8OD+ynNQ1qWusLpI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UIfEOIcCy2YIfZoDs/cCX7bXXSso+xDxszm42JCoNt0/4gmskbyb6SLJvc4JOZL+8 ZCi5Z6eWS4b4aQ1qhgpPIYRGMDWKMKQ/J0+tBwCO3QGcxFyd6pgdtdrfAmVfX5X7qK bo+DAJEmEq8v0I4kVQpb2BFmlAYQcuLHDvsyXjGaAsMU+OCnimnkvLmSqLbsoQNDbE 2X0jNUtPFyuMrbzA9pxvnowO3hENFqDjEIBCf59Ok2/4vlZWwM5SAmP+NwKQNP6JwS TbWGOMlebqWWoQnKsMRDXFuYC6zBk7tiaE/gM7NFC4k7IoWD8vSbZvCnedS6P1kBpc DnZrAEyDieoOQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id AE8DB4D6E for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id DE6233A16D3 for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:37 +0100 Message-ID: <20240304130657.30631-22-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/29] avcodec/dpx: respect side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: l4pC81lN+1OS From: Niklas Haas If the time code side data is overridden by the packet level, we also make sure not to update `p->metadata` to a mismatched timecode. --- libavcodec/dpx.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 31e4a3f82c..80616d98a2 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -287,19 +287,21 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, tc = av_bswap32(read32(&buf, endian)); if (i != 0xFFFFFFFF) { - AVFrameSideData *tcside = - av_frame_new_side_data(p, AV_FRAME_DATA_S12M_TIMECODE, - sizeof(uint32_t) * 4); - if (!tcside) - return AVERROR(ENOMEM); + AVFrameSideData *tcside; + ret = ff_frame_new_side_data(avctx, p, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t) * 4, &tcside); + if (ret < 0) + return ret; - tc_sd = (uint32_t*)tcside->data; - tc_sd[0] = 1; - tc_sd[1] = tc; + if (tcside) { + tc_sd = (uint32_t*)tcside->data; + tc_sd[0] = 1; + tc_sd[1] = tc; - av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate, - tc_sd[1], 0, 0); - av_dict_set(&p->metadata, "timecode", tcbuf, 0); + av_timecode_make_smpte_tc_string2(tcbuf, avctx->framerate, + tc_sd[1], 0, 0); + av_dict_set(&p->metadata, "timecode", tcbuf, 0); + } } } From patchwork Mon Mar 4 13:06:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46768 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790656pzb; Mon, 4 Mar 2024 05:10:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWuFv1o/JnHmF8OsBiLzdXEqS9B2ci5KPOd1YLgMjXbLq93TfvvYtn+pzJPldIy+ZGvTkWaA6CuHdeuSwCR6VYvt92L8Ci6nLvoqQ== X-Google-Smtp-Source: AGHT+IF3sV8d9E08+RYKSrP8dPdxiYCnAWTWBeYFMNql2fTEJCsR+Un9M8hamNwQgO4mcU9kzXUu X-Received: by 2002:a17:906:ca4a:b0:a3f:5c5c:33ac with SMTP id jx10-20020a170906ca4a00b00a3f5c5c33acmr6820164ejb.62.1709557848698; Mon, 04 Mar 2024 05:10:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557848; cv=none; d=google.com; s=arc-20160816; b=oZh1GdqgioFFvJ/2EbHTqCdYqt8d+4kNSntKpfLVhj6x7I0OcWM9P6dgysS6XYZZZj EZoL3x/Ver+M2ZoD4OmAmipwLLS+xYGCXozWKBue8hNa7oxfnr9Ml90iV8c4ZXORsjv3 7X6Qi2m1215/MeqrCSzvDf4+nUk/qXMXy4cFMS5IY9dmcc4BnPWLnDhPoTgG7SN1KkoJ DTxQ/yKikOhuyMS61pI6JesJH5hJTH2SgkhD1v0/QDa5PvS+bYI5jtSrcajbo3FGLpXF tZkJjDSnhe59rsV55KSv5KHuEdZyCUBSFOzm5vy+ybLp/Sxe4unClIQRkhxVe0Z6JJXj ZyoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=pjRG4+wpcUqPineno5Ft93oBjYqC7T4+6oKVXjlB4kQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=w0nzCfwoo3EVUyYWlwrjOo12f/gxJmYNvf4sFeexo/mtb17/fxvnm86EjvofTQMdbM Qe0Qrz8baM+Z1h9Oi1jIKLAIwgaU9RCFyGb2yhFWzFzGz7sycNl+BDipV2GwIU/K1qUQ gUxIVGz4fzyhDz/N5zEghQH47J17N3HuvA59yMpLVRFiz8wPRkNTgHpcmj0vBIBOXXbg to9ujWGClND6PjsjyzWz3XkA7ZJ4iOmvgb1YldXFiQq8fHnisqpBpu+tLYyQsrewsbZW 7LE/ikIeFZH0D1FmMsFQbC8+HpvVernSFgK0s1IfrsePQRXzpx3ThWXAystOT62Xf4QX lvGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=ff7ybYY3; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a14-20020a1709064a4e00b00a442e29410asi3932358ejv.234.2024.03.04.05.10.48; Mon, 04 Mar 2024 05:10:48 -0800 (PST) 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=@khirnov.net header.s=mail header.b=ff7ybYY3; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 78BB268D4B4; Mon, 4 Mar 2024 15:07:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C1D568D44C for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=ff7ybYY3; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1D70F4D66 for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 2X8r36BZMSez for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=yAAV4bHgjCHjyt03D1UvEMHi+AnwOa9/8AT4gvnCz4s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ff7ybYY3w12Bh4fNKjDAj8fywPg0vLiekZzR5nhvtBCTCf6gwMzfbr447MHPo/qT7 uGMm+n0oEai2WL9cSI1kdkG9v4j59CHxie88qZvpYXQBrX7hfcvMEqQZCV9gw2DSFf XoFdB+uXAhxHHtirfDZ4+2TVY8SGQC3hl4BDecxPFvMBhvcy0sWKX4ebumiVkYCTmm B4CEPOmn+AMg8AvYAnfogsKtopoDaTO/4pJyZMON49MrHvYaIJvfjuHaYfM4QKc1A8 lpnJLIN0hKX1O/dKBRXYuZYlbpSUEnLLDMn5BaFItQfzQCh6IvtkP/Ke6J/bHCmowr /OPNpJSqOBvUA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id C0D214D74 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id EA0B93A16DC for ; Mon, 4 Mar 2024 14:07:00 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:38 +0100 Message-ID: <20240304130657.30631-23-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/29] avcodec/mpeg12dec: use ff_frame_new_side_data 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9XF0y6ydpjaw From: Niklas Haas For consistency, even though this cannot be overriden at the packet level. --- libavcodec/mpeg12dec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 3a2f17e508..aa116336dd 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2531,15 +2531,17 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (s->timecode_frame_start != -1 && *got_output) { char tcbuf[AV_TIMECODE_STR_SIZE]; - AVFrameSideData *tcside = av_frame_new_side_data(picture, - AV_FRAME_DATA_GOP_TIMECODE, - sizeof(int64_t)); - if (!tcside) - return AVERROR(ENOMEM); - memcpy(tcside->data, &s->timecode_frame_start, sizeof(int64_t)); + AVFrameSideData *tcside; + ret = ff_frame_new_side_data(avctx, picture, AV_FRAME_DATA_GOP_TIMECODE, + sizeof(int64_t), &tcside); + if (ret < 0) + return ret; + if (tcside) { + memcpy(tcside->data, &s->timecode_frame_start, sizeof(int64_t)); - av_timecode_make_mpeg_tc_string(tcbuf, s->timecode_frame_start); - av_dict_set(&picture->metadata, "timecode", tcbuf, 0); + av_timecode_make_mpeg_tc_string(tcbuf, s->timecode_frame_start); + av_dict_set(&picture->metadata, "timecode", tcbuf, 0); + } s->timecode_frame_start = -1; } From patchwork Mon Mar 4 13:06:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46771 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790973pzb; Mon, 4 Mar 2024 05:11:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUi8ZYVO8NCkHUpi78UCB6BL8PPYRucq5BKrjuQNRmx6IdK+tJCyAhB2900FWTijjJmA5LcVZZEExoQtD9spph2V/wH61Xn27qEPw== X-Google-Smtp-Source: AGHT+IFgZMa8NOYCk9Dq4s//0W+7cwMpFyuB52zsT3CUq0A4ba9hWT2DquhUJprOuIqp+KiNaVb3 X-Received: by 2002:a05:6402:5106:b0:566:1952:afc4 with SMTP id m6-20020a056402510600b005661952afc4mr9386043edd.6.1709557876168; Mon, 04 Mar 2024 05:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557876; cv=none; d=google.com; s=arc-20160816; b=B6l3deX884jIs1p8+SEff7XANzfBvC6LpkTf5YFLjzMK65PQF1b9RP2d+G8Y+kuG01 vP6lz+NmpLB8MExg68A0rkAEIKBMf7MCY7g9O3kfMMPZo60ZycPtiMTjNZMCjZsWhw2E RMeHFMqxBTLFjlqVT4Yhpy67YyoyOzDjX22A12MpJTQHh0uGDeJT6y/P0ujenqQA79Ls 0wTq+yNExr8TrE5IfLNFImWrCoZTrdFEvGAh0AC//l+6aqkVo1uVSBZXZ91R1z2GapPh kqguRbKumZ5h0aDpY2BJgk5TAp1xqs6B0Y39P/AJrHTvsYbzYPVQfCpMjduQHdQCUn1G M3Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=frRYfhjsqOBClKgJxKHiztJnHUv/lSON8Gz4T+rA9Hs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=j5hbRzEJCmzg0Dfxg4niGu/O58ByBgnA6eRitMNpzMkrtQz2qi5koteiSVYZVcdnRh YUgeKKF7GJN0WhOhHJ9M/5nCCw4MBJntxGBzJndmLJR3yYuKD97qReDzo5GIadDmoV/O fVwIlfkvtLDpT8i9OmPDcaRG4MTItdqZyNi/so0L+FHaGofCQ6sQETKYlAvkoTQIuziD FKyjE0sDfBiBzL1YFUhdv9fklgtvzGkRnuGOYj+TulVpzRIufIOBcb4U5kdLYQj5Rej2 ReOUCqsbC2WetxdQDgaDaHLXm9s1W23FBH+I/AZXAE9bzMD4GDtxouRQq+1Xb2MdvDm+ rSFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=iA8praKp; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f1-20020a056402194100b00566b4419b46si3547054edz.663.2024.03.04.05.11.15; Mon, 04 Mar 2024 05:11:16 -0800 (PST) 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=@khirnov.net header.s=mail header.b=iA8praKp; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C412268D4C3; Mon, 4 Mar 2024 15:07:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD68868D439 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=iA8praKp; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C13AE4D68 for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Qi2FmTyADNq1 for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=M0KCYFYZIo4VrJkSFnzTEIIv4LEJdiquQJVYTtCU354=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iA8praKp4qYSEITd0p4jtcNAvebFZPBNCkh2O9CqX/WW7Z9fEwDfl+1e1uT6WAtGx v4je8NXP6iOVV5W139bcH+3F9sLJclRUpKF4G09W/0ToKQ1DuUzTxF0Ov5NgDqg1fj 44nRclZl0fKmODHAY4cKl03YmMJnfMz2v0ztLzynuTvZWajUSUqnUEJbBDyH3e1sOT rYx9dyLJ5D3XfXYaUMUwOGsipvgM3D/QCt2/Lif/gw9sGKmqKWnh7HlhM7SvLT/gZa SSBRihSFi69/2Tlcs/T8XlcNFTgUKggzxlMmuD44ZkSyH7byuVsaO4smZlIOWj2ioY grznjC8Osttzg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id BCF664D71 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 01A233A173A for ; Mon, 4 Mar 2024 14:07:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:39 +0100 Message-ID: <20240304130657.30631-24-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/29] avcodec/h2645_sei: use ff_frame_new_side_data_from_buf 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RIqmieNEtOlw From: Niklas Haas For consistency, even though this cannot be overriden at the packet level. Signed-off-by: Anton Khirnov --- libavcodec/h2645_sei.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index cb6be0594b..56539608cd 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -35,6 +35,7 @@ #include "atsc_a53.h" #include "avcodec.h" +#include "decode.h" #include "dynamic_hdr_vivid.h" #include "get_bits.h" #include "golomb.h" @@ -607,12 +608,11 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, H2645SEIUnregistered *unreg = &sei->unregistered; if (unreg->buf_ref[i]) { - AVFrameSideData *sd = av_frame_new_side_data_from_buf(frame, + int ret = ff_frame_new_side_data_from_buf(avctx, frame, AV_FRAME_DATA_SEI_UNREGISTERED, - unreg->buf_ref[i]); - if (!sd) - av_buffer_unref(&unreg->buf_ref[i]); - unreg->buf_ref[i] = NULL; + &unreg->buf_ref[i], NULL); + if (ret < 0) + return ret; } } sei->unregistered.nb_buf_ref = 0; From patchwork Mon Mar 4 13:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46762 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790023pzb; Mon, 4 Mar 2024 05:09:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUZXalNayj8ye9sKcmadMocJ3l5xp+40U3enkO+xxE662lb55iu+zNHDSzq/YOP/ja3VMF7O8akU+85YY9U6zw2szwefMGBxrk7AA== X-Google-Smtp-Source: AGHT+IFCYb+87JO76DLLpl1c/x8Q0UdlAG/7Z+tT/IgoGsP/1HIQLA5+NLT8fkYgin/t1E1RLuhQ X-Received: by 2002:a50:85c6:0:b0:566:4654:4fac with SMTP id q6-20020a5085c6000000b0056646544facmr5922483edh.5.1709557790240; Mon, 04 Mar 2024 05:09:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557790; cv=none; d=google.com; s=arc-20160816; b=Z3Hov7a4u1uzdslmy8z3UDHN1NMh934qOP7y01E1kHm+Kr6evxGVO9oVRLLSUYEXVh 96/seJ+MJMIcnGnM7L9hlp3jzrewGEZM7KgkVkipseTEHDkur9dAsDz8dygrtIs3gXVW 46SBzSkdWqgffmLR/cW0NVGEjL5zce9p2u2Zb0nvV7CTZ3tPBWW7ZUNTu8vCd031PTCg WJo4HK9NkKrJmU0FqkVvbqZsBjmAsF/gt447jAJoMJF8YolU1ptLf6ivMd5SUtY+l+Q3 dY4SNSjboLGqCOdCzAieLZEfRC5drlVPB5y0CWQs1JGKcX8DWTekJavhU1JYim1kTBwn XKuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=0uci1rwm1ZLtFlFMfXt7vWVfOjZF0VL7whdSEvNPpkc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=mRi1e6eQtYc2n4S9JQ6NvBzysFdiulxCq8t34W8R9q0DBq6mb+2IG02KDOB5U8aGJe U2AUtrQTFykmg831C7ikaeEwACsY8bBR9mRndcIzqxI4CpB3lVFzkH4F1tK3EmE5CzP/ 3fWX/SGqFIS2M+ZKdTiOxKiNUVvuG6o4YNELnyHPVbKbIkmyKqN+WYFOIqHT5QuL1b4R f2ZqqY3Mr9KiGHN6nbPiFXYRaTYkcIyAxgv3ozPdhZYFPQR0fqVkMqvYv3BJs4RfRkq5 2tVrm9oRPwDzLDvYx/bSNP/5ZPoJ0t5f9hI7jkJq2z2R9OngT7ljVfZs8N0DO82/xf9f eh1w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=DJUSSKFA; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b6-20020a056402278600b005668ffda6f2si4161290ede.5.2024.03.04.05.09.49; Mon, 04 Mar 2024 05:09:50 -0800 (PST) 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=@khirnov.net header.s=mail header.b=DJUSSKFA; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53D4E68D492; Mon, 4 Mar 2024 15:07:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 82C6768D446 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=DJUSSKFA; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id BDDAB4D5E for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id VGtjGwify6l2 for ; Mon, 4 Mar 2024 14:07:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=LYhgsMr0GNWAXNFi2S3A4R22yoenA2frxt7CWe8xIVE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DJUSSKFANtKKjFgz4j44CDbaZTApBWOYlqXChJpt6Q4l39yiU1vMA9hHNfzLiqp3T JhDSLVDdOcewVVYnBKEC2Hh+d+0QN/LIxLxg/d1Wvr4/Efrqnu6yhSOTbWiL0GeXi4 n0jzdlNW9Bo0JnK+a++6Pb1EwasUrY7C78C835UfV0aeOTxvMo1mSQbpd1l90Jgy8y rPY3CFZwCjrjkzJQ6E/kbD/Ewr+TBDS3WIzmYd7yUi35214yYw3eBA+nuKOWlAR7nZ WRVYjbG2/Hkx9wqE6eszWQdRap9o+ToHfkLX1wYYQgyOwgVsB47R6hpyPqBwBsKJbS lkapVHXKT+gEw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id AE1024D6D for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0D51D3A1752 for ; Mon, 4 Mar 2024 14:07:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:40 +0100 Message-ID: <20240304130657.30631-25-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/29] avcodec/snowdec: use ff_frame_new_side_data 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +TyEnb9DINYu From: Niklas Haas For consistency, even though this cannot be overriden at the packet level. --- libavcodec/snowdec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 70fbab9a49..97aea748b6 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -787,11 +787,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, res = av_frame_ref(picture, s->mconly_picture); if (res >= 0 && s->avmv_index) { AVFrameSideData *sd; - - sd = av_frame_new_side_data(picture, AV_FRAME_DATA_MOTION_VECTORS, s->avmv_index * sizeof(AVMotionVector)); - if (!sd) - return AVERROR(ENOMEM); - memcpy(sd->data, s->avmv, s->avmv_index * sizeof(AVMotionVector)); + res = ff_frame_new_side_data(s->avctx, picture, AV_FRAME_DATA_MOTION_VECTORS, + s->avmv_index * sizeof(AVMotionVector), &sd); + if (sd) + memcpy(sd->data, s->avmv, s->avmv_index * sizeof(AVMotionVector)); } if (res < 0) From patchwork Mon Mar 4 13:06:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46767 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790530pzb; Mon, 4 Mar 2024 05:10:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWqmkV+dvskcN52CAtoCC1UNP2X51yMnnugcBlmzil+SwElKUhZiTaAVKKq3Qr3dm/uaMIa6csyXVqReYUxk9tRpdxXIanatObnvQ== X-Google-Smtp-Source: AGHT+IENGTLWnzTUXG4gayi6Ww444c8MPkRbocttK4JGasYZqTIsuf6I3nMHqNOz4r33NUU0L6dD X-Received: by 2002:a17:907:11c1:b0:a43:4ce5:db5c with SMTP id va1-20020a17090711c100b00a434ce5db5cmr6464688ejb.16.1709557839101; Mon, 04 Mar 2024 05:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557839; cv=none; d=google.com; s=arc-20160816; b=akjnQF1NuMFPJfVqk5NE0f9SualV8u/opMEVDsveJ3hI4tN2LTRwMQT1jpjMbhXsaK 3efM5mXVacdFAug6+OqxjLJ8VnanrQkrGztYUC7zustSSUkU6DQRfBxaxGDZMN31yRco 7WqOIk9IFUwgYdIrO5enpRyM58LdOIaW1rRv0JZZEqcQXWdZ/to6/VAeyFkwVsG/p+n0 /e6hcNTHQb0xxXC3j5Uv/TsnIVa/CLzxI93d7+nBTpdt5KltIHbNS0ZNK7zaZ5rynMLQ ajyvxgQgWCVC1zLShH5hj64PgFc6bJAfFVuUQQkOxFdVIEho/LoPUHcUk9AKU5nXvD26 ezqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=wN3M+W1ZszJKnrD1yVwmR1j5yepeGwTvA8AbktcKATc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=URPpWiPUO5hOCb4Cblake6E76L83r/pw8EzG6boaG7yBq08lgGldhxcoZNnW3OCspk RWoFGPR58kkSE7yUshXf0UXJ9lu6YeBw3D1r3bpr1Gf94ECEp0IIyjESSuMVknWtROm6 86u8DjinWLbpLYOe0E7M+ex7rOmYw917/ZR3xMY4qhDmgNQWgjE3UDNWpa5CjdtEXJRz u969KZT2/pi6JzowWpblvil83dOgj3worH4shKu5Q9iwfyrwz943URshdpTHLYJbZOGR gqBbYsf6ayOKPQALmUf5C58DWNTew1qsbuQSwgZn4MAL1AjMovZ60r1Jq+ziUmb9pG1I Zf6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=lPGH9Etp; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w3-20020a17090652c300b00a43ecf0b173si3929706ejn.762.2024.03.04.05.10.38; Mon, 04 Mar 2024 05:10:39 -0800 (PST) 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=@khirnov.net header.s=mail header.b=lPGH9Etp; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7901168D4AF; Mon, 4 Mar 2024 15:07:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C9F368D436 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=lPGH9Etp; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 252A44D72 for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id O_cc2DM5lk43 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557627; bh=NFXHTreqfSwBFCpoTsuf9pyIKEChk3DV4zB2m2oHtJk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lPGH9EtpJwUyh92L6Xh8JFgoe2PqMw5R5ClvZlfLNKIo8goHa0puyUTw2COx7rBxj arRKKnrkfgCkHQUUf8vtB2NYb2iqCyqU3RwyM1QzPBzVVSxv0XEQ7txfm4ZrtHxLSy YZRW28Macucr8mD4NrAb7W8KOsk5ePpw8XonoRjhJVTQ6bO0Hg8lRw9TbeVbTE2ay3 q3TP63pf8YO7FHpZAbUYEDZgULiH6Rli2Oz+5PfYkJv2tSBC4Wsqqho+7a2W0YhJjc p+DL4FWtayVd3U8I8bLOJ49KhmpA97cSVy9anFa8TwXCmB5aIThKN4fKIHlbsVvFfC 5FXcv0fsKyKWg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 27CA94D79 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 190F33A17AC for ; Mon, 4 Mar 2024 14:07:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:41 +0100 Message-ID: <20240304130657.30631-26-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/29] avcodec/mjpegdec: use ff_frame_new_side_data 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YWyidWPYuTg6 From: Niklas Haas For consistency, even though this can't (yet) be overriden at the packet level. --- libavcodec/mjpegdec.c | 66 ++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 43b36d0a8f..4ef565fe2d 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2865,42 +2865,44 @@ the_end: if (orientation >= 2 && orientation <= 8) { int32_t *matrix; - sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); - if (!sd) { + ret = ff_frame_new_side_data(avctx, frame, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9, &sd); + if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate frame side data\n"); - return AVERROR(ENOMEM); + return ret; } - matrix = (int32_t *)sd->data; + if (sd) { + matrix = (int32_t *)sd->data; - switch (orientation) { - case 2: - av_display_rotation_set(matrix, 0.0); - av_display_matrix_flip(matrix, 1, 0); - break; - case 3: - av_display_rotation_set(matrix, 180.0); - break; - case 4: - av_display_rotation_set(matrix, 180.0); - av_display_matrix_flip(matrix, 1, 0); - break; - case 5: - av_display_rotation_set(matrix, 90.0); - av_display_matrix_flip(matrix, 1, 0); - break; - case 6: - av_display_rotation_set(matrix, 90.0); - break; - case 7: - av_display_rotation_set(matrix, -90.0); - av_display_matrix_flip(matrix, 1, 0); - break; - case 8: - av_display_rotation_set(matrix, -90.0); - break; - default: - av_assert0(0); + switch (orientation) { + case 2: + av_display_rotation_set(matrix, 0.0); + av_display_matrix_flip(matrix, 1, 0); + break; + case 3: + av_display_rotation_set(matrix, 180.0); + break; + case 4: + av_display_rotation_set(matrix, 180.0); + av_display_matrix_flip(matrix, 1, 0); + break; + case 5: + av_display_rotation_set(matrix, 90.0); + av_display_matrix_flip(matrix, 1, 0); + break; + case 6: + av_display_rotation_set(matrix, 90.0); + break; + case 7: + av_display_rotation_set(matrix, -90.0); + av_display_matrix_flip(matrix, 1, 0); + break; + case 8: + av_display_rotation_set(matrix, -90.0); + break; + default: + av_assert0(0); + } } } } From patchwork Mon Mar 4 13:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46770 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790905pzb; Mon, 4 Mar 2024 05:11:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWmE8vmxNqTLpEx0KGDi1ULDxOd7970FYyH5OglRfnEUhoHdelhJMArYC7dEAWAbsWU5VlvvpaI159VmkG7pz3MuaEpK2GMtPI/ng== X-Google-Smtp-Source: AGHT+IGDqhTPRcgKEx8GDEQpqgAPX1mqFsTZ/tb0YbYlZ7ggO2zeFCEoHBpmPT7gkAADRJ560pxa X-Received: by 2002:aa7:dcd4:0:b0:567:6f87:ed11 with SMTP id w20-20020aa7dcd4000000b005676f87ed11mr486163edu.29.1709557867455; Mon, 04 Mar 2024 05:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557867; cv=none; d=google.com; s=arc-20160816; b=jfcfzcoFf5l2EPGUXFSfFMvkjZrOmVCyve2oAj3ykI1NJ78sxRhWKcTosbvPl1kB4O i2blt9dWJXI5XRf166UKPK+IX4gH3gB8PEg0s8lU+rPEOrmyKCiNSo3uWY9gaQY09AvV +cshaKv3acIvJEgf89KRna5s6kfC4FWxe/SjodInAxl0eAw/8sQXI6kD3jdTl2Xx3PpY /ZQz4RrEfAI5bODTW2bn+1tg7iECbaT9eutBLVWgqb4gn2ReoFQsF0+2kfbIJe2mECA9 MAr8e91UKjtWWVhDVTUb0zgTyTKb6njGZDvLclHfky2PJzAp550aq/zt/FmaETEQZFub BA9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=uoACF00oNscYp22VBTf8Y4fzLPv672p2SmT5tPAKeFI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Nj5kgGHotcfX1PjKgfaMUKR1gAf8X7epM7oHmio9Ftw3nHJSvJs7TyCOEY8dEW+d4e B2M/5jExSnH7CdyahUBGba9mpnOEp1imyfjyo13foJiOjkjA34ifGn7qjjVaGd27ldS3 noUmtwbS5sM1rYwC8G4JUtROl5SamVad5ylT6GVh+MU3Dm+MrGZn1nDiaSXouhTj+MRC P/InfPRKCUiPFg+mGcZU8Grorwc10MOqpUm6H4gxMog8sfPfs23RmIO5e3o6QK3IPMkN 5PrxLKSSqbqi06f6z+zQjkPOUHJLf/OPQFbFFz6bbq1BTWK2VLdhUQn9LthQoEL3G0Hj Odnw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=Ztz1Ggx6; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w25-20020a50d799000000b005653f170aa0si3829053edi.222.2024.03.04.05.11.07; Mon, 04 Mar 2024 05:11:07 -0800 (PST) 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=@khirnov.net header.s=mail header.b=Ztz1Ggx6; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A059768D4BE; Mon, 4 Mar 2024 15:07:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9076B68D44D for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=Ztz1Ggx6; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7CD4B4D6C for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id c_RODVzHv-Ms for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557627; bh=dTLv2T2c5z8sskidsDpvGW+1CnEdqVVvfCQJomBGDIo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ztz1Ggx6636lux+/sZWRNx19uXYnIEHOrtM37qgR/zS79vXw/bFX38vsH3rS8MPV9 p7cm6s8WCibc1n+Ov0/gEd3WKGovHCZ7D9X6sedAvVVExyRL9uepZIYj1B5bFIAqnT HF4nTK9Mvc+Hj+LSJRVUkwZ6M3FXcH34pmuroXnyWZI4w/sl9LZWTYH5ZPPzHyadm4 gZ7aCSop0b9X4rBWiysaeE+53mP0IK7Z94nvF8bMsdYfhrWCWPipl72DQ8beoV+mLw FNr9SqIjhCjYV3xBKKsVgNlgPLydlHsmdTgnDmKTBgwbRrIIdWJZSITH8v+YU+p5ER BQ2roRdG2F2MQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id F15094D51 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 24B5F3A17AF for ; Mon, 4 Mar 2024 14:07:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:42 +0100 Message-ID: <20240304130657.30631-27-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 27/29] avcodec/hevcdec: switch to ff_frame_new_side_data_from_buf 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MNNUUwM/48jI From: Niklas Haas For consistency, even though this cannot be overriden at the packet level. Signed-off-by: Anton Khirnov --- libavcodec/hevcdec.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 76aa6b4588..a6b124dd2a 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2825,11 +2825,9 @@ static int set_side_data(HEVCContext *s) } if (s->rpu_buf) { - AVFrameSideData *rpu = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_DOVI_RPU_BUFFER, s->rpu_buf); - if (!rpu) - return AVERROR(ENOMEM); - - s->rpu_buf = NULL; + ret = ff_frame_new_side_data_from_buf(s->avctx, out, AV_FRAME_DATA_DOVI_RPU_BUFFER, &s->rpu_buf, NULL); + if (ret < 0) + return ret; } if ((ret = ff_dovi_attach_side_data(&s->dovi_ctx, out)) < 0) @@ -2840,10 +2838,9 @@ static int set_side_data(HEVCContext *s) if (!info_ref) return AVERROR(ENOMEM); - if (!av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_DYNAMIC_HDR_VIVID, info_ref)) { - av_buffer_unref(&info_ref); - return AVERROR(ENOMEM); - } + ret = ff_frame_new_side_data_from_buf(s->avctx, out, AV_FRAME_DATA_DYNAMIC_HDR_VIVID, &info_ref, NULL); + if (ret < 0) + return ret; } return 0; From patchwork Mon Mar 4 13:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46769 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2790785pzb; Mon, 4 Mar 2024 05:10:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXMHG5gHpglV8MnfGnS1Vs0M+Bl+wojxpJ9Vp3ylrc6Lj9UstNvuzIeKIS3rvJGNP+9Nk+7XBarO5IoznanwQCjDBHHPrS+qRuzFg== X-Google-Smtp-Source: AGHT+IHozJs/v1RKcgxDG3YdmM2sM6Du/h3Z4MVRQ5PRDWvBoWqD0y3pUomBpzQ98akZK34IzBc9 X-Received: by 2002:a17:906:f355:b0:a3f:da1c:ae4c with SMTP id hg21-20020a170906f35500b00a3fda1cae4cmr6873382ejb.54.1709557858251; Mon, 04 Mar 2024 05:10:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557858; cv=none; d=google.com; s=arc-20160816; b=ZW3UsrDHesOKxqDvBTd7Jayq8YoN8f7k0ekJ/7QlKqgXPxgX/WjKsZne+HX5rIGzvy Ir200smXweo3NUdUAjUzc3W/bEHse4eSvRENQWai7MyLV177UAUj5vjRu6zJcfnS1uVp BuPFAngsHCIru8I7osRtzFf16uTPT6atwMX/qOOI3FWh8qZ4v9AXBB5ovIWuMm9Vhl4P VIRzBx6673BeyeYD3tuACwvooHF2U86x91D7p2HOVLxzQiR3RanEYM6bZrrcz8BbW9BU 2Sx3NoUmIE40gPP7HfF6ZfomoauIDNWp/ZJEpzVvwj5NiwRW74iFsWeIbtRdZpaOQgJA 3eNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=csr3ZQpR7hgAQAQmdD4dLwzwTVLyTgRE8emRGyCpGTQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=d99/DHjcYdDUKdjGwqNDKkduLf8H60HHbVV+CmTGOnNY8d3MdlcsABWr2ttB2tH5XO axM0GbhqjIRYGYij+DIEubRa7J9CPdx3Hd3aCDyzGiVd4zz1bTgZkXFpvl8n+SdOny19 DITbvv7FYAzGJ2PrA7Saf+8iOuuutGtKVyh48W3jXG5yrUEFYWkF8qh4pWHum5CRNb5S KAVh3LEZoRq1oKGw8d1CobLOJKrCCr6Ak0L5KiLBNwHFzqj9k8HKqB6AJygbdQGymtYA uePGcAV9B5+nbM8uXqcGnk6Ov2HVs6mjpJeRf8aZCzYCOil4tDToXBp73NiwOGoMa7Jp 0IDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=dVXc4SW5; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s8-20020a170906354800b00a441a40c035si3887170eja.279.2024.03.04.05.10.57; Mon, 04 Mar 2024 05:10:58 -0800 (PST) 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=@khirnov.net header.s=mail header.b=dVXc4SW5; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 914D868D4B9; Mon, 4 Mar 2024 15:07:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 87AB068D449 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=dVXc4SW5; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C891A4D6E for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id UOiBAQGySvR9 for ; Mon, 4 Mar 2024 14:07:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557626; bh=RVrzhR7gskFiiLWNGQIW6b8OMsCx2UapVHvL/6tJaoo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dVXc4SW5DtWeYwEzACygijW7tNlNaGBkM0S8KetbCcymH6o4QItd33uBOh2n8Cv1l RDYqGih5KdEgjfklfQMuX4ZpZkuA1NutzFfgA0E6GDTOZhHThp4v/qtfhAJiVnjg/l NyU2Lpeeb3+Pbvk4HYfPfCM+Bk49Qg+PBAZA+9uJGbNiO9NLZg1doW4jLePhE8MYVn SjdO4qvc8t1AMW43DwMdOyTpNlGgN6hkJ0cDmnVdlD+l7oEkqsGddYOiFtBafQiDq+ XxVNmHKe1LTXsNCScIqxPYOPIcwlj6NzDKttoTDsXffwS+EL1LhGfbu+tJiGkeBU1o GUj0aEMu3Y/og== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id BCF8B4D72 for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 308A33A186B for ; Mon, 4 Mar 2024 14:07:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:43 +0100 Message-ID: <20240304130657.30631-28-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/29] lavc/*dec: use side data preference for mastering display/content light metadata 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FK/5SBE/i4on --- libavcodec/av1dec.c | 46 +++++++++++--------- libavcodec/h2645_sei.c | 96 +++++++++++++++++++++++------------------- libavcodec/libdav1d.c | 47 ++++++++++++--------- libavcodec/pngdec.c | 54 ++++++++++++++---------- libavcodec/qsvdec.c | 50 +++++++++++++--------- 5 files changed, 165 insertions(+), 128 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index af80ee0b17..bbb5634773 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -999,31 +999,39 @@ static int export_metadata(AVCodecContext *avctx, AVFrame *frame) int ret = 0; if (s->mdcv) { - AVMasteringDisplayMetadata *mastering = av_mastering_display_metadata_create_side_data(frame); - if (!mastering) - return AVERROR(ENOMEM); + AVMasteringDisplayMetadata *mastering; - for (int i = 0; i < 3; i++) { - mastering->display_primaries[i][0] = av_make_q(s->mdcv->primary_chromaticity_x[i], 1 << 16); - mastering->display_primaries[i][1] = av_make_q(s->mdcv->primary_chromaticity_y[i], 1 << 16); + ret = ff_decode_mastering_display_new(avctx, frame, &mastering); + if (ret < 0) + return ret; + + if (mastering) { + for (int i = 0; i < 3; i++) { + mastering->display_primaries[i][0] = av_make_q(s->mdcv->primary_chromaticity_x[i], 1 << 16); + mastering->display_primaries[i][1] = av_make_q(s->mdcv->primary_chromaticity_y[i], 1 << 16); + } + mastering->white_point[0] = av_make_q(s->mdcv->white_point_chromaticity_x, 1 << 16); + mastering->white_point[1] = av_make_q(s->mdcv->white_point_chromaticity_y, 1 << 16); + + mastering->max_luminance = av_make_q(s->mdcv->luminance_max, 1 << 8); + mastering->min_luminance = av_make_q(s->mdcv->luminance_min, 1 << 14); + + mastering->has_primaries = 1; + mastering->has_luminance = 1; } - mastering->white_point[0] = av_make_q(s->mdcv->white_point_chromaticity_x, 1 << 16); - mastering->white_point[1] = av_make_q(s->mdcv->white_point_chromaticity_y, 1 << 16); - - mastering->max_luminance = av_make_q(s->mdcv->luminance_max, 1 << 8); - mastering->min_luminance = av_make_q(s->mdcv->luminance_min, 1 << 14); - - mastering->has_primaries = 1; - mastering->has_luminance = 1; } if (s->cll) { - AVContentLightMetadata *light = av_content_light_metadata_create_side_data(frame); - if (!light) - return AVERROR(ENOMEM); + AVContentLightMetadata *light; - light->MaxCLL = s->cll->max_cll; - light->MaxFALL = s->cll->max_fall; + ret = ff_decode_content_light_new(avctx, frame, &light); + if (ret < 0) + return ret; + + if (light) { + light->MaxCLL = s->cll->max_cll; + light->MaxFALL = s->cll->max_fall; + } } while (av_fifo_read(s->itut_t35_fifo, &itut_t35, 1) >= 0) { diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index 56539608cd..a9d17cc9fd 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -516,6 +516,7 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, int seed) { H2645SEIFramePacking *fp = &sei->frame_packing; + int ret; if (fp->present && is_frame_packing_type_valid(fp->arrangement_type, codec_id) && @@ -710,56 +711,63 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, const int chroma_den = 50000; const int luma_den = 10000; int i; - AVMasteringDisplayMetadata *metadata = - av_mastering_display_metadata_create_side_data(frame); - if (!metadata) - return AVERROR(ENOMEM); + AVMasteringDisplayMetadata *metadata; - for (i = 0; i < 3; i++) { - const int j = mapping[i]; - metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0]; - metadata->display_primaries[i][0].den = chroma_den; - metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1]; - metadata->display_primaries[i][1].den = chroma_den; + ret = ff_decode_mastering_display_new(avctx, frame, &metadata); + if (ret < 0) + return ret; + + if (metadata) { + for (i = 0; i < 3; i++) { + const int j = mapping[i]; + metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0]; + metadata->display_primaries[i][0].den = chroma_den; + metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1]; + metadata->display_primaries[i][1].den = chroma_den; + } + metadata->white_point[0].num = sei->mastering_display.white_point[0]; + metadata->white_point[0].den = chroma_den; + metadata->white_point[1].num = sei->mastering_display.white_point[1]; + metadata->white_point[1].den = chroma_den; + + metadata->max_luminance.num = sei->mastering_display.max_luminance; + metadata->max_luminance.den = luma_den; + metadata->min_luminance.num = sei->mastering_display.min_luminance; + metadata->min_luminance.den = luma_den; + metadata->has_luminance = 1; + metadata->has_primaries = 1; + + av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); + av_log(avctx, AV_LOG_DEBUG, + "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", + av_q2d(metadata->display_primaries[0][0]), + av_q2d(metadata->display_primaries[0][1]), + av_q2d(metadata->display_primaries[1][0]), + av_q2d(metadata->display_primaries[1][1]), + av_q2d(metadata->display_primaries[2][0]), + av_q2d(metadata->display_primaries[2][1]), + av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1])); + av_log(avctx, AV_LOG_DEBUG, + "min_luminance=%f, max_luminance=%f\n", + av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); } - metadata->white_point[0].num = sei->mastering_display.white_point[0]; - metadata->white_point[0].den = chroma_den; - metadata->white_point[1].num = sei->mastering_display.white_point[1]; - metadata->white_point[1].den = chroma_den; - - metadata->max_luminance.num = sei->mastering_display.max_luminance; - metadata->max_luminance.den = luma_den; - metadata->min_luminance.num = sei->mastering_display.min_luminance; - metadata->min_luminance.den = luma_den; - metadata->has_luminance = 1; - metadata->has_primaries = 1; - - av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); - av_log(avctx, AV_LOG_DEBUG, - "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", - av_q2d(metadata->display_primaries[0][0]), - av_q2d(metadata->display_primaries[0][1]), - av_q2d(metadata->display_primaries[1][0]), - av_q2d(metadata->display_primaries[1][1]), - av_q2d(metadata->display_primaries[2][0]), - av_q2d(metadata->display_primaries[2][1]), - av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1])); - av_log(avctx, AV_LOG_DEBUG, - "min_luminance=%f, max_luminance=%f\n", - av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); } if (sei->content_light.present) { - AVContentLightMetadata *metadata = - av_content_light_metadata_create_side_data(frame); - if (!metadata) - return AVERROR(ENOMEM); - metadata->MaxCLL = sei->content_light.max_content_light_level; - metadata->MaxFALL = sei->content_light.max_pic_average_light_level; + AVContentLightMetadata *metadata; - av_log(avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); - av_log(avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", - metadata->MaxCLL, metadata->MaxFALL); + ret = ff_decode_content_light_new(avctx, frame, &metadata); + if (ret < 0) + return ret; + + if (metadata) { + metadata->MaxCLL = sei->content_light.max_content_light_level; + metadata->MaxFALL = sei->content_light.max_pic_average_light_level; + + av_log(avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); + av_log(avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", + metadata->MaxCLL, metadata->MaxFALL); + } } return 0; diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 3714137ed0..42d3ef00de 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -507,33 +507,38 @@ FF_ENABLE_DEPRECATION_WARNINGS } if (p->mastering_display) { - AVMasteringDisplayMetadata *mastering = av_mastering_display_metadata_create_side_data(frame); - if (!mastering) { - res = AVERROR(ENOMEM); + AVMasteringDisplayMetadata *mastering; + + res = ff_decode_mastering_display_new(c, frame, &mastering); + if (res < 0) goto fail; + + if (mastering) { + for (int i = 0; i < 3; i++) { + mastering->display_primaries[i][0] = av_make_q(p->mastering_display->primaries[i][0], 1 << 16); + mastering->display_primaries[i][1] = av_make_q(p->mastering_display->primaries[i][1], 1 << 16); + } + mastering->white_point[0] = av_make_q(p->mastering_display->white_point[0], 1 << 16); + mastering->white_point[1] = av_make_q(p->mastering_display->white_point[1], 1 << 16); + + mastering->max_luminance = av_make_q(p->mastering_display->max_luminance, 1 << 8); + mastering->min_luminance = av_make_q(p->mastering_display->min_luminance, 1 << 14); + + mastering->has_primaries = 1; + mastering->has_luminance = 1; } - - for (int i = 0; i < 3; i++) { - mastering->display_primaries[i][0] = av_make_q(p->mastering_display->primaries[i][0], 1 << 16); - mastering->display_primaries[i][1] = av_make_q(p->mastering_display->primaries[i][1], 1 << 16); - } - mastering->white_point[0] = av_make_q(p->mastering_display->white_point[0], 1 << 16); - mastering->white_point[1] = av_make_q(p->mastering_display->white_point[1], 1 << 16); - - mastering->max_luminance = av_make_q(p->mastering_display->max_luminance, 1 << 8); - mastering->min_luminance = av_make_q(p->mastering_display->min_luminance, 1 << 14); - - mastering->has_primaries = 1; - mastering->has_luminance = 1; } if (p->content_light) { - AVContentLightMetadata *light = av_content_light_metadata_create_side_data(frame); - if (!light) { - res = AVERROR(ENOMEM); + AVContentLightMetadata *light; + + res = ff_decode_content_light_new(c, frame, &light); + if (res < 0) goto fail; + + if (light) { + light->MaxCLL = p->content_light->max_content_light_level; + light->MaxFALL = p->content_light->max_frame_average_light_level; } - light->MaxCLL = p->content_light->max_content_light_level; - light->MaxFALL = p->content_light->max_frame_average_light_level; } if (p->itut_t35) { #if FF_DAV1D_VERSION_AT_LEAST(6,9) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 8f409c74b8..de50e6a5b6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -746,33 +746,41 @@ static int populate_avctx_color_fields(AVCodecContext *avctx, AVFrame *frame) avctx->bits_per_raw_sample = s->significant_bits; if (s->have_clli) { - AVContentLightMetadata *clli = - av_content_light_metadata_create_side_data(frame); - if (!clli) - return AVERROR(ENOMEM); - /* - * 0.0001 divisor value - * see: https://www.w3.org/TR/png-3/#cLLi-chunk - */ - clli->MaxCLL = s->clli_max / 10000; - clli->MaxFALL = s->clli_avg / 10000; + AVContentLightMetadata *clli; + + ret = ff_decode_content_light_new(avctx, frame, &clli); + if (ret < 0) + return ret; + + if (clli) { + /* + * 0.0001 divisor value + * see: https://www.w3.org/TR/png-3/#cLLi-chunk + */ + clli->MaxCLL = s->clli_max / 10000; + clli->MaxFALL = s->clli_avg / 10000; + } } if (s->have_mdvc) { - AVMasteringDisplayMetadata *mdvc = - av_mastering_display_metadata_create_side_data(frame); - if (!mdvc) - return AVERROR(ENOMEM); - mdvc->has_primaries = 1; - for (int i = 0; i < 3; i++) { - mdvc->display_primaries[i][0] = av_make_q(s->mdvc_primaries[i][0], 50000); - mdvc->display_primaries[i][1] = av_make_q(s->mdvc_primaries[i][1], 50000); + AVMasteringDisplayMetadata *mdvc; + + ret = ff_decode_mastering_display_new(avctx, frame, &mdvc); + if (ret < 0) + return ret; + + if (mdvc) { + mdvc->has_primaries = 1; + for (int i = 0; i < 3; i++) { + mdvc->display_primaries[i][0] = av_make_q(s->mdvc_primaries[i][0], 50000); + mdvc->display_primaries[i][1] = av_make_q(s->mdvc_primaries[i][1], 50000); + } + mdvc->white_point[0] = av_make_q(s->mdvc_white_point[0], 50000); + mdvc->white_point[1] = av_make_q(s->mdvc_white_point[1], 50000); + mdvc->has_luminance = 1; + mdvc->max_luminance = av_make_q(s->mdvc_max_lum, 10000); + mdvc->min_luminance = av_make_q(s->mdvc_min_lum, 10000); } - mdvc->white_point[0] = av_make_q(s->mdvc_white_point[0], 50000); - mdvc->white_point[1] = av_make_q(s->mdvc_white_point[1], 50000); - mdvc->has_luminance = 1; - mdvc->max_luminance = av_make_q(s->mdvc_max_lum, 10000); - mdvc->min_luminance = av_make_q(s->mdvc_min_lum, 10000); } return 0; diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index d688a17c41..4f39f6942a 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -651,42 +651,50 @@ static int qsv_export_film_grain(AVCodecContext *avctx, mfxExtAV1FilmGrainParam static int qsv_export_hdr_side_data(AVCodecContext *avctx, mfxExtMasteringDisplayColourVolume *mdcv, mfxExtContentLightLevelInfo *clli, AVFrame *frame) { + int ret; + // The SDK re-uses this flag for HDR SEI parsing if (mdcv->InsertPayloadToggle) { - AVMasteringDisplayMetadata *mastering = av_mastering_display_metadata_create_side_data(frame); + AVMasteringDisplayMetadata *mastering; const int mapping[3] = {2, 0, 1}; const int chroma_den = 50000; const int luma_den = 10000; int i; - if (!mastering) - return AVERROR(ENOMEM); + ret = ff_decode_mastering_display_new(avctx, frame, &mastering); + if (ret < 0) + return ret; - for (i = 0; i < 3; i++) { - const int j = mapping[i]; - mastering->display_primaries[i][0] = av_make_q(mdcv->DisplayPrimariesX[j], chroma_den); - mastering->display_primaries[i][1] = av_make_q(mdcv->DisplayPrimariesY[j], chroma_den); + if (mastering) { + for (i = 0; i < 3; i++) { + const int j = mapping[i]; + mastering->display_primaries[i][0] = av_make_q(mdcv->DisplayPrimariesX[j], chroma_den); + mastering->display_primaries[i][1] = av_make_q(mdcv->DisplayPrimariesY[j], chroma_den); + } + + mastering->white_point[0] = av_make_q(mdcv->WhitePointX, chroma_den); + mastering->white_point[1] = av_make_q(mdcv->WhitePointY, chroma_den); + + mastering->max_luminance = av_make_q(mdcv->MaxDisplayMasteringLuminance, luma_den); + mastering->min_luminance = av_make_q(mdcv->MinDisplayMasteringLuminance, luma_den); + + mastering->has_luminance = 1; + mastering->has_primaries = 1; } - - mastering->white_point[0] = av_make_q(mdcv->WhitePointX, chroma_den); - mastering->white_point[1] = av_make_q(mdcv->WhitePointY, chroma_den); - - mastering->max_luminance = av_make_q(mdcv->MaxDisplayMasteringLuminance, luma_den); - mastering->min_luminance = av_make_q(mdcv->MinDisplayMasteringLuminance, luma_den); - - mastering->has_luminance = 1; - mastering->has_primaries = 1; } // The SDK re-uses this flag for HDR SEI parsing if (clli->InsertPayloadToggle) { - AVContentLightMetadata *light = av_content_light_metadata_create_side_data(frame); + AVContentLightMetadata *light; - if (!light) - return AVERROR(ENOMEM); + ret = ff_decode_content_light_new(avctx, frame, &light); + if (ret < 0) + return ret; - light->MaxCLL = clli->MaxContentLightLevel; - light->MaxFALL = clli->MaxPicAverageLightLevel; + if (light) { + light->MaxCLL = clli->MaxContentLightLevel; + light->MaxFALL = clli->MaxPicAverageLightLevel; + } } return 0; From patchwork Mon Mar 4 13:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46775 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2791348pzb; Mon, 4 Mar 2024 05:11:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUaTZZDOewZtugCrRag10DuWoy4ti85yTwHBar41KNESFyyl/Dy3IVxak6jwNph0i/oX6mfchWtpKqDfJEZEivn+3eR5hJL6P1S/g== X-Google-Smtp-Source: AGHT+IHIueCPTov0gpv4fKF8jbU7nTaS6e6gaGzQbaW3JfsHqHfWXsNPDKlWSZdb5FaAAA1ZHtTi X-Received: by 2002:a17:906:119a:b0:a45:878e:b31c with SMTP id n26-20020a170906119a00b00a45878eb31cmr279469eja.53.1709557911796; Mon, 04 Mar 2024 05:11:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709557911; cv=none; d=google.com; s=arc-20160816; b=OCE4YqKMvIDj9YgBXJN2egTU7w5l/u3YAHNiE0j33MQpsxuAHID4RTJ4QDJD/WO9kM PXg7yVK2xWrQHQrYpV7SHVHR/wzV2AqMaigiR0T6JhCwJTx3n5tR+Np/KcOFJKDcqK88 iCDrS66j0XW6ZT94CA7yN08RrRnqDv4cNabsu8vg8FH+Nljlt1jFCK/x1Yq5KtCvnlGZ sc+uRnA+S7+iBsaQs2FqtPa1LqEmJhL9rgRk7j27l+vnjCfmapmmm0VP06qPfSIa48Mn PlrSI3VnfjdQycukzpxrZhnqlglLd3ZHsa+942Sl1zSZM1ZXjqPWWKYjD8ugDlF1i/Mj s73g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=xJU+jF24mkVsVSOBvAfL0aoEZoYo33A/Fcn0l41/PfE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=RAR6J/iFb9Ym69BMfKYVIhHO2meg6gKkotOkRillTIyccyrB+LwHIOXJJZgIHo/oYH 8fcJcK8bdbjLuR+kvnNhLyhrz2qXEv7E9u9aDNfUTU/y6zwrs5sxikogqMTxOaT9eS2D qyIkjhNLTxCWddwUDL7zCMpjj+rmd1kc6gx657fZyUDrntGO9stEnmRpok04aaet3tSO qEki4F+NdjsMlOoAniBF3/Z/jljchUup4GyAMsproDspELBfUqU6UM9a6iOKBSZ4yetj +M7ZULjtiQBcOiCk/1bN+FNwCT8fxloePOJwY9KWZvfoAttxKuPUO8ViDv5BzM0k+ECc 0rYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=I183qNWe; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sa41-20020a1709076d2900b00a456587602fsi515080ejc.820.2024.03.04.05.11.51; Mon, 04 Mar 2024 05:11:51 -0800 (PST) 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=@khirnov.net header.s=mail header.b=I183qNWe; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 42F8968D4E0; Mon, 4 Mar 2024 15:07:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CBE4368D453 for ; Mon, 4 Mar 2024 15:07:14 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=I183qNWe; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 40B7D4D51 for ; Mon, 4 Mar 2024 14:07:13 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id elrQu1HgxhZu for ; Mon, 4 Mar 2024 14:07:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709557627; bh=QdQS4P0FKjmWb1Vz4Z1JN0VSrn3NsuFOkHoLYwNwbjo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=I183qNWeYFmgL9wWSUUZYRBKUTBDoXRYBfU3lkmzzV5lXqFV3OVRuEQzanztc6bWb 78m9Ahk8FivLkjz+pSGSYNpQiDHWPOvt+T4Z936DoywFKetriukNNK/hwSZPl5Bh/D wedw7s+4okfzyvkHGe9mqG0QHQXg1IiVYzbDTKs8C+FJYsWSrxjqawlKE37XfmcWSb 64mBOGHLMxu9guPt+HY8yhMVguZefB8sWXNebWKBegQzu8OvPK1LcSpce3QJ5Ecr46 yD6z2p0Q6dkC+WcaOK/NHRFCCqSEuMFYCwREVkYfY7OJC3JE5PhfcIjlAnON6+p4hW JOVKqXHDemPvg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id ECDBE4D4E for ; Mon, 4 Mar 2024 14:07:06 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3C3BA3A1894 for ; Mon, 4 Mar 2024 14:07:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 14:06:44 +0100 Message-ID: <20240304130657.30631-29-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240304130657.30631-1-anton@khirnov.net> References: <20240304130657.30631-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 29/29] tests/fate/matroska: add tests for side data preference 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VZ4EzLuDHjvB Cf. #10857 --- tests/fate/matroska.mak | 6 + tests/ref/fate/matroska-side-data-pref-codec | 255 ++++++++++++++++++ tests/ref/fate/matroska-side-data-pref-global | 255 ++++++++++++++++++ 3 files changed, 516 insertions(+) create mode 100644 tests/ref/fate/matroska-side-data-pref-codec create mode 100644 tests/ref/fate/matroska-side-data-pref-global diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 9ab747184a..e9433ce730 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -264,6 +264,12 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, VP9_PARSER) \ += fate-matroska-hdr10-plus-remux fate-matroska-hdr10-plus-remux: CMD = transcode webm $(TARGET_SAMPLES)/mkv/hdr10_plus_vp9_sample.webm matroska "-map 0 -c:v copy" "-map 0 -c:v copy" "-show_packets" +fate-matroska-side-data-pref-codec: CMD = run ffprobe$(PROGSSUF)$(EXESUF) $(TARGET_SAMPLES)/mkv/hdr10tags-both.mkv \ + -show_streams -show_frames -show_entries stream=stream_side_data:frame=frame_side_data_list +fate-matroska-side-data-pref-global: CMD = run ffprobe$(PROGSSUF)$(EXESUF) $(TARGET_SAMPLES)/mkv/hdr10tags-both.mkv \ + -show_streams -show_frames -show_entries stream=stream_side_data:frame=frame_side_data_list -side_data_prefer_global mastering_display_metadata,content_light_level +FATE_MATROSKA_FFPROBE-$(call ALLYES MATROSKA_DEMUXER HEVC_DECODER) += fate-matroska-side-data-pref-codec fate-matroska-side-data-pref-global + FATE_SAMPLES_AVCONV += $(FATE_MATROSKA-yes) FATE_SAMPLES_FFPROBE += $(FATE_MATROSKA_FFPROBE-yes) FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MATROSKA_FFMPEG_FFPROBE-yes) diff --git a/tests/ref/fate/matroska-side-data-pref-codec b/tests/ref/fate/matroska-side-data-pref-codec new file mode 100644 index 0000000000..d27134d0c9 --- /dev/null +++ b/tests/ref/fate/matroska-side-data-pref-codec @@ -0,0 +1,255 @@ +[FRAME] +[SIDE_DATA] +side_data_type=H.26[45] User Data Unregistered SEI message +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=35400/50000 +red_y=14599/50000 +green_x=8500/50000 +green_y=39850/50000 +blue_x=6550/50000 +blue_y=2300/50000 +white_point_x=15634/50000 +white_point_y=16450/50000 +min_luminance=10/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/FRAME] +[STREAM] +DISPOSITION:default=1 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=0 +DISPOSITION:visual_impaired=0 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +DISPOSITION:non_diegetic=0 +DISPOSITION:captions=0 +DISPOSITION:descriptions=0 +DISPOSITION:metadata=0 +DISPOSITION:dependent=0 +DISPOSITION:still_image=0 +TAG:BPS=216040 +TAG:BPS-eng=216040 +TAG:DURATION=00:00:00.400000000 +TAG:DURATION-eng=00:00:00.400000000 +TAG:NUMBER_OF_FRAMES=10 +TAG:NUMBER_OF_FRAMES-eng=10 +TAG:NUMBER_OF_BYTES=10802 +TAG:NUMBER_OF_BYTES-eng=10802 +TAG:_STATISTICS_WRITING_APP=mkvmerge v9.0.1 ('Mask Machine') 64bit +TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.0.1 ('Mask Machine') 64bit +TAG:_STATISTICS_WRITING_DATE_UTC=2019-02-14 12:53:10 +TAG:_STATISTICS_WRITING_DATE_UTC-eng=2019-02-14 12:53:10 +TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES +TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[/STREAM] diff --git a/tests/ref/fate/matroska-side-data-pref-global b/tests/ref/fate/matroska-side-data-pref-global new file mode 100644 index 0000000000..4ff0c2d9db --- /dev/null +++ b/tests/ref/fate/matroska-side-data-pref-global @@ -0,0 +1,255 @@ +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=H.26[45] User Data Unregistered SEI message +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[FRAME] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[/FRAME] +[STREAM] +DISPOSITION:default=1 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=0 +DISPOSITION:visual_impaired=0 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +DISPOSITION:non_diegetic=0 +DISPOSITION:captions=0 +DISPOSITION:descriptions=0 +DISPOSITION:metadata=0 +DISPOSITION:dependent=0 +DISPOSITION:still_image=0 +TAG:BPS=216040 +TAG:BPS-eng=216040 +TAG:DURATION=00:00:00.400000000 +TAG:DURATION-eng=00:00:00.400000000 +TAG:NUMBER_OF_FRAMES=10 +TAG:NUMBER_OF_FRAMES-eng=10 +TAG:NUMBER_OF_BYTES=10802 +TAG:NUMBER_OF_BYTES-eng=10802 +TAG:_STATISTICS_WRITING_APP=mkvmerge v9.0.1 ('Mask Machine') 64bit +TAG:_STATISTICS_WRITING_APP-eng=mkvmerge v9.0.1 ('Mask Machine') 64bit +TAG:_STATISTICS_WRITING_DATE_UTC=2019-02-14 12:53:10 +TAG:_STATISTICS_WRITING_DATE_UTC-eng=2019-02-14 12:53:10 +TAG:_STATISTICS_TAGS=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES +TAG:_STATISTICS_TAGS-eng=BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES +[SIDE_DATA] +side_data_type=Content light level metadata +max_content=1000 +max_average=300 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=11408507/16777216 +red_y=5368709/16777216 +green_x=2222981/8388608 +green_y=11576279/16777216 +blue_x=5033165/33554432 +blue_y=16106127/268435456 +white_point_x=10492471/33554432 +white_point_y=689963/2097152 +min_luminance=5368709/536870912 +max_luminance=1000/1 +[/SIDE_DATA] +[/STREAM]