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 A0C8640A56 for ; Sat, 25 Dec 2021 14:48:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 812C868B0FB; Sat, 25 Dec 2021 16:48:17 +0200 (EET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8899368B04A for ; Sat, 25 Dec 2021 16:48:11 +0200 (EET) Received: by mail-pf1-f177.google.com with SMTP id c2so9924333pfc.1 for ; Sat, 25 Dec 2021 06:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vMOoQl2MT7pdRhSmnQe0Y4DJKQ7VoEp9+7vVBoD70rg=; b=BH7QDopp2Rek8+7M3e+O/mAE1tIAGWG/HuJveTgrflAXB/BG0D6bJPILIH7cH3xgyG zgqG8luVUBdLaONqUVDUwMyQ2tvZ+fXF1+RlJeX1iSjTwuRP3VsJGSZP+izBcoJYnktm N14k/Zqepu7uiLyHN7PUE7J7fsHMtdSZzKsJE7OboX/nuEMKNj9z0Tu/GvWe5FRK/lAV oaINGoZe9QvpjIbvsE5fYteCUMM29ds42AOgPxr0vQTGDIGavzbemcikrnG+DZjNB/Ub 8dRvDr9cqoJeR/8ZIulNU42NSmH15eyHMNyIRvnlaw83HS734k18eL6tWJoEw/Vqfcbr IoSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vMOoQl2MT7pdRhSmnQe0Y4DJKQ7VoEp9+7vVBoD70rg=; b=3tXp4Ck5BxSa4SUjHdeyqjrdJnXv4h3TdqpSbO3R8djrDf4d04n/9GG0ioTmXDEdZr c+tysiaeRrWIp8iZYh4GVJ7L4WayF6CDX31tJVJbDw6J+qTQxM2E0j8WpJAdlJyjSQy6 DQv3fWST5wDOKqfXL8rOscpeNa9C/MHAVC4zTSAebJJToEpYc696s5P3bubwAM7NxadG bq7TCDWe5PoheAgDmJZL/Flu0akN+5DPMPtSpilZ+hq8jFtu9wLk018r14D4MFT2CO4O rS/iXLQ25sBvB574P4cCV81Oq+7EumyI1bU+f5i563YCuTsJq756m/z/6eg1GJuz1pwa 56DQ== X-Gm-Message-State: AOAM533GF+ufC8TqonSxRBevZbtni/7THRkD51/bsYAxlEJPet6VN9ma O8fr/6xpbX91mNq2qnBvRA0F4FGySv0= X-Google-Smtp-Source: ABdhPJziPs0/O2s9wTV/dWudYH/R5cO3hI+Yfm+v6aRZrxsvHKKTQVVrnGcd7yuGZ4kg1TSExwwWHQ== X-Received: by 2002:a63:1d15:: with SMTP id d21mr9502253pgd.541.1640443688668; Sat, 25 Dec 2021 06:48:08 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id on7sm12124919pjb.50.2021.12.25.06.48.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Dec 2021 06:48:08 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Dec 2021 22:46:52 +0800 Message-Id: <1640443613-26238-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1640247094-9784-1-git-send-email-lance.lmwang@gmail.com> References: <1640247094-9784-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 1/2] avcodec/libx26[45]: add udu_sei option to import user data unregistered SEIs X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 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: From: Limin Wang Most of user data unregistered SEIs are privated data which defined by user/ encoder. currently, the user data unregistered SEIs found in input are forwarded as side-data to encoders directly, it'll cause the reencoded output including some useless UDU SEIs. I prefer to add one option to enable/disable it and default is off after I saw the patch by Andreas Rheinhardt: https://patchwork.ffmpeg.org/project/ffmpeg/patch/AM7PR03MB66607C2DB65E1AD49D975CF18F7B9@AM7PR03MB6660.eurprd03.prod.outlook.com/ How to test by cli: ffmpeg -y -f lavfi -i testsrc -c:v libx264 -frames:v 1 a.ts ffmpeg -y -i a.ts -c:v libx264 -udu_sei 1 b.ts ffmpeg -y -i a.ts -c:v libx264 -udu_sei 0 c.ts # check the user data unregistered SEIs, you'll see two UDU SEIs for b.ts. # and mediainfo will show with wrong encoding setting info ffmpeg -i b.ts -vf showinfo -f null - ffmpeg -i c.ts -vf showinfo -f null - This fixes tickets #9500 and #9557. --- doc/encoders.texi | 6 ++++++ libavcodec/libx264.c | 5 ++++- libavcodec/libx265.c | 4 ++++ libavcodec/version.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 8a7589c..e3b61de 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2660,6 +2660,9 @@ ffmpeg -i foo.mpg -c:v libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv Import closed captions (which must be ATSC compatible format) into output. Only the mpeg2 and h264 decoders provide these. Default is 1 (on). +@item udu_sei @var{boolean} +Import user data unregistered SEI if available into output. Default is 0 (off). + @item x264-params (N.A.) Override the x264 configuration using a :-separated list of key=value parameters. @@ -2741,6 +2744,9 @@ Quantizer curve compression factor Normally, when forcing a I-frame type, the encoder can select any type of I-frame. This option forces it to choose an IDR-frame. +@item udu_sei @var{boolean} +Import user data unregistered SEI if available into output. Default is 0 (off). + @item x265-params Set x265 options using a list of @var{key}=@var{value} couples separated by ":". See @command{x265 --help} for a list of options. diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 2b680ab..9836818 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -104,6 +104,7 @@ typedef struct X264Context { int chroma_offset; int scenechange_threshold; int noise_reduction; + int udu_sei; AVDictionary *x264_params; @@ -464,6 +465,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, } } + if (x4->udu_sei) { for (int j = 0; j < frame->nb_side_data; j++) { AVFrameSideData *side_data = frame->side_data[j]; void *tmp; @@ -487,6 +489,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, sei_payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED; sei->num_payloads++; } + } } do { @@ -1168,7 +1171,7 @@ static const AVOption options[] = { { "chromaoffset", "QP difference between chroma and luma", OFFSET(chroma_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, VE }, { "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE }, { "noise_reduction", "Noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX, VE }, - + { "udu_sei", "Use user data unregistered SEI if available", OFFSET(udu_sei), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE }, { NULL }, }; diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 7dd70a3..47d0103 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -54,6 +54,7 @@ typedef struct libx265Context { void *sei_data; int sei_data_size; + int udu_sei; /** * If the encoder does not support ROI then warn the first time we @@ -543,6 +544,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, memcpy(x265pic.userData, &pic->reordered_opaque, sizeof(pic->reordered_opaque)); } + if (ctx->udu_sei) { for (i = 0; i < pic->nb_side_data; i++) { AVFrameSideData *side_data = pic->side_data[i]; void *tmp; @@ -568,6 +570,7 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, sei_payload->payloadType = SEI_TYPE_USER_DATA_UNREGISTERED; sei->numPayloads++; } + } } ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, @@ -708,6 +711,7 @@ static const AVOption options[] = { { "preset", "set the x265 preset", OFFSET(preset), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { "tune", "set the x265 tune parameter", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { "profile", "set the x265 profile", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, + { "udu_sei", "Use user data unregistered SEI if available", OFFSET(udu_sei), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE }, { NULL } }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 580b099..45c6d13 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 59 #define LIBAVCODEC_VERSION_MINOR 15 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 1.8.3.1 _______________________________________________ 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".