summaryrefslogtreecommitdiff
path: root/libavcodec/libx264.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2021-12-25 22:21:03 +0800
committerLimin Wang <lance.lmwang@gmail.com>2021-12-28 14:19:38 +0800
commit7dfc3cc713ea0dbe7aeedcc2a272a5382a36dbcd (patch)
treedee333b300c756de5012621995ae9e839dc215de /libavcodec/libx264.c
parent617452ce2c7857bdac40d4b33724e414d2712e7c (diff)
downloadffmpeg-7dfc3cc713ea0dbe7aeedcc2a272a5382a36dbcd.tar.gz
avcodec/libx26[45]: add udu_sei option to import user data unregistered SEIs
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. Reviewed-by: "zhilizhao(赵志立)" <quinkblack@foxmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavcodec/libx264.c')
-rw-r--r--libavcodec/libx264.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 2b680abf21..9836818b99 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 },
};