From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D2A15404F5 for ; Tue, 21 Dec 2021 01:52:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CFD6868AF57; Tue, 21 Dec 2021 03:52:41 +0200 (EET) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 859CE6804B9 for ; Tue, 21 Dec 2021 03:52:35 +0200 (EET) Received: by mail-pg1-f178.google.com with SMTP id m15so10912516pgu.11 for ; Mon, 20 Dec 2021 17:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=5pYeVGM6usX7/yED0U4RG6ITnhwVVpBIBUzjrWrvKyE=; b=IS32xm1a/OnTggU25VRaBVOqf8tEGJWVBBa1+IQN2s2u91Xz9/JYPSu3AkVVCSQGft ASuwgtPG93q6hd01aCXAU3LlHDAR7YGH+84GiUl8Otf/xTqGFC0SigfZ4fw1ff3Pz2K2 /3S6orvbp/nT3Gh+e/mOuteh9efaUkven/GjC4sFwzFJRJ8XxO2oIhrs0qe8uL+/PZAE UNCySNs0G5wDq4ALQoxFF5OU4YtBKMPwDHAqVG6LgHWxoR0RY6Bp7mhLdELaBxKz2DCA ycFuUtweGEcH6DndtU52qJBVa4ksNWigoJRxjmk6QVSrq9vRWFDX5RhZoo2ODkZm/r3Z O6og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=5pYeVGM6usX7/yED0U4RG6ITnhwVVpBIBUzjrWrvKyE=; b=lm+3ioH7QCpR698Ninwar5NWWdODNcaCdhvBeItFI+SwoBTur2pxRNyC1rBLPkK/+A ifQOiHVIrUgYEPTYxTsBRTwGROovx7UxIonkJUvlaYRutRgTgQ7HURD9IA65vmZv2mo7 HqLL8SbeXDLfkIDLCdhCx1ri/FvoTOLaVd43dkAilhjuR88kHYA8BN19G8BY3ansWgHl q6ki8wP0/nxbJvNQCgeVvI6XEyPzCkK60wzcH5BXh/ckd1ogkn7+zXTohcJ1wvc5nLpE J8l4Q2vaxZY4yMdvhUOU9+M4V40MEnyhiXQTzVGEQd4pAcd5E4sgLQR4clltev2kdQ+z imiw== X-Gm-Message-State: AOAM533ux7wReKvQ3JUbVDtq1rEL+aCQZLpu0PTNein2Vy3Velk4y/Wr usR602pxPPGIgfYJ6WRCrQObo2+lu+g= X-Google-Smtp-Source: ABdhPJyXEsHxFoMnFPIBlo1RYKK94BfBswKIkNX8+km8bwQmwsz8NckB6Fwx+QLBrhqx+4uc6/Qdjw== X-Received: by 2002:aa7:9482:0:b0:4ba:d167:ffec with SMTP id z2-20020aa79482000000b004bad167ffecmr779224pfk.57.1640051553420; Mon, 20 Dec 2021 17:52:33 -0800 (PST) Received: from gmail.com ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id f19sm19658488pfv.76.2021.12.20.17.52.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 17:52:31 -0800 (PST) Date: Tue, 21 Dec 2021 09:52:28 +0800 From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Message-ID: <20211221015228.GB18955@gmail.com> Mail-Followup-To: ffmpeg-devel@ffmpeg.org References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libx26[45]: Don't forward old x26[45] SEI's 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, Dec 20, 2021 at 07:27:30PM +0100, Andreas Rheinhardt wrote: > Currently, user data unregistered SEIs found in input are > forwarded as side-data to encoders; for the libx26[45] encoders > these are included in the reencoded output (even including x264 SEIs > in H.265 and vice versa). > This makes tools like mediainfo display the wrong (old) encoding > parameters and basically makes these SEI messages useless. > This commit therefore filters the SEI messages by some known, > recognized encoders away. > This fixes tickets #9500 and #9557. I prefer to add an option so that we can disable the forwarded for user data unregistered if need. It's better to disable it default. Most of user data unregistered have their own private format, it's not preferable to forward it to new encoder directly. > > Signed-off-by: Andreas Rheinhardt > --- > 1. Obviously, having to maintain a list of recognized encoders and > their uuids is horrible; but I didn't see another way. > 2. nvenc is probably also affected by this; but I couldn't test it > anyway, so someone else will have to fix it. > 3. How could it happen that no one noticed this issue when the SEI > patches were applied? > > libavcodec/Makefile | 6 +++--- > libavcodec/libx264.c | 3 ++- > libavcodec/libx265.c | 3 ++- > libavcodec/sei.c | 38 ++++++++++++++++++++++++++++++++++++++ > libavcodec/sei.h | 9 +++++++++ > 5 files changed, 54 insertions(+), 5 deletions(-) > create mode 100644 libavcodec/sei.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index fb90ecea84..969311947f 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1066,9 +1066,9 @@ OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o > OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o > OBJS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.o libwebpenc.o > OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o libwebpenc_animencoder.o > -OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o > -OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o > -OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o > +OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o sei.o > +OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o sei.o > +OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o sei.o > OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o > OBJS-$(CONFIG_LIBXAVS2_ENCODER) += libxavs2.o > OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > index 2b680abf21..27920ba295 100644 > --- a/libavcodec/libx264.c > +++ b/libavcodec/libx264.c > @@ -468,7 +468,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, > AVFrameSideData *side_data = frame->side_data[j]; > void *tmp; > x264_sei_payload_t *sei_payload; > - if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED) > + if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED || > + side_data->size < 16 || ff_sei_is_encoder_uuid(side_data->data)) > continue; > tmp = av_fast_realloc(sei->payloads, &sei_data_size, (sei->num_payloads + 1) * sizeof(*sei_payload)); > if (!tmp) { > diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c > index 7dd70a3450..bb2133f4a4 100644 > --- a/libavcodec/libx265.c > +++ b/libavcodec/libx265.c > @@ -548,7 +548,8 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, > void *tmp; > x265_sei_payload *sei_payload; > > - if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED) > + if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED || > + side_data->size < 16 || ff_sei_is_encoder_uuid(side_data->data)) > continue; > > tmp = av_fast_realloc(ctx->sei_data, > diff --git a/libavcodec/sei.c b/libavcodec/sei.c > new file mode 100644 > index 0000000000..8678704e6f > --- /dev/null > +++ b/libavcodec/sei.c > @@ -0,0 +1,38 @@ > +/* > + * Filtering of H.26[45] encoder user data unregistered SEI messages > + * Copyright (C) 2021 Andreas Rheinhardt > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include > +#include > +#include "sei.h" > + > +int ff_sei_is_encoder_uuid(const uint8_t uuid[16]) > +{ > + static const uint8_t x264_uuid[] = { > + 0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7, > + 0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef > + }; > + static const uint8_t x265_uuid[] = { > + 0x2c, 0xa2, 0xde, 0x09, 0xb5, 0x17, 0x47, 0xdb, > + 0xbb, 0x55, 0xa4, 0xfe, 0x7f, 0xc2, 0xfc, 0x4e > + }; > + return !memcmp(uuid, x264_uuid, sizeof(x264_uuid)) || > + !memcmp(uuid, x265_uuid, sizeof(x265_uuid)); > +} > diff --git a/libavcodec/sei.h b/libavcodec/sei.h > index 5513590b51..e143e0f045 100644 > --- a/libavcodec/sei.h > +++ b/libavcodec/sei.h > @@ -19,6 +19,8 @@ > #ifndef AVCODEC_SEI_H > #define AVCODEC_SEI_H > > +#include > + > // SEI payload types form a common namespace between the H.264, H.265 > // and H.266 standards. A given payload type always has the same > // meaning, but some names have different payload types in different > @@ -137,4 +139,11 @@ enum { > SEI_TYPE_SAMPLE_ASPECT_RATIO_INFO = 204, > }; > > +/** > + * Returns 0 iff the uuid does not match the uuid of > + * a user_data_unregistered SEI message emitted by > + * a recognized encoder. > + */ > +int ff_sei_is_encoder_uuid(const uint8_t uuid[16]); > + > #endif /* AVCODEC_SEI_H */ > -- > 2.32.0 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".