From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libx26[45]: Don't forward old x26[45] SEI's Date: Tue, 21 Dec 2021 09:52:28 +0800 Message-ID: <20211221015228.GB18955@gmail.com> (raw) In-Reply-To: <AM7PR03MB66607C2DB65E1AD49D975CF18F7B9@AM7PR03MB6660.eurprd03.prod.outlook.com> 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 <andreas.rheinhardt@outlook.com> > --- > 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 <andreas.rheinhardt@outlook.com> > + * > + * 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 <stdint.h> > +#include <string.h> > +#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 <stdint.h> > + > // 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".
next prev parent reply other threads:[~2021-12-21 1:52 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-20 18:22 [FFmpeg-devel] [PATCH 1/2] avcodec/libx264: Don't unnecessarily add in-band extradata Andreas Rheinhardt 2021-12-20 18:27 ` [FFmpeg-devel] [PATCH 2/2] avcodec/libx26[45]: Don't forward old x26[45] SEI's Andreas Rheinhardt 2021-12-21 1:52 ` lance.lmwang [this message] 2021-12-21 1:42 ` [FFmpeg-devel] [PATCH 1/2] avcodec/libx264: Don't unnecessarily add in-band extradata lance.lmwang
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211221015228.GB18955@gmail.com \ --to=lance.lmwang@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git