Message ID | 20220708071451.133523-1-wenbin.chen@intel.com |
---|---|
State | Accepted |
Commit | 8b82c9cdc74fd227726b81a7c1768b11536c4471 |
Headers | show |
Series | [FFmpeg-devel] libavcodec/qsvenc: Change the parameter log to be thread safe | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_armv7_RPi4 | success | Make finished |
andriy/make_fate_armv7_RPi4 | success | Make fate finished |
On Fri, 2022-07-08 at 15:14 +0800, Wenbin Chen wrote: > Dividing one line log into several av_log() call is not thread safe. Now > merge these strings into one av_log() call. > > Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> > --- > libavcodec/qsvenc.c | 87 ++++++++++++++++++++++----------------------- > 1 file changed, 42 insertions(+), 45 deletions(-) > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c > index 2382c2f5f7..5729292f94 100644 > --- a/libavcodec/qsvenc.c > +++ b/libavcodec/qsvenc.c > @@ -182,6 +182,7 @@ static void dump_video_param(AVCodecContext *avctx, > QSVEncContext *q, > mfxExtCodingOption2 *co2 = NULL; > mfxExtCodingOption3 *co3 = NULL; > mfxExtHEVCTiles *exthevctiles = NULL; > + const char *tmp_str = NULL; > > if (q->co2_idx > 0) > co2 = (mfxExtCodingOption2*)coding_opts[q->co2_idx]; > @@ -195,13 +196,12 @@ static void dump_video_param(AVCodecContext *avctx, > QSVEncContext *q, > av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", > print_profile(avctx->codec_id, info->CodecProfile), info- > >CodecLevel); > > - av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: > %"PRIu16"; GopOptFlag: ", > - info->GopPicSize, info->GopRefDist); > - if (info->GopOptFlag & MFX_GOP_CLOSED) > - av_log(avctx, AV_LOG_VERBOSE, "closed "); > - if (info->GopOptFlag & MFX_GOP_STRICT) > - av_log(avctx, AV_LOG_VERBOSE, "strict "); > - av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info- > >IdrInterval); > + av_log(avctx, AV_LOG_VERBOSE, > + "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag:%s%s; > IdrInterval: %"PRIu16"\n", > + info->GopPicSize, info->GopRefDist, > + info->GopOptFlag & MFX_GOP_CLOSED ? " closed" : "", > + info->GopOptFlag & MFX_GOP_STRICT ? " strict" : "", > + info->IdrInterval); > > av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: > %s\n", > info->TargetUsage, print_ratecontrol(info->RateControlMethod)); > @@ -269,45 +269,46 @@ static void dump_video_param(AVCodecContext *avctx, > QSVEncContext *q, > av_log(avctx, AV_LOG_VERBOSE, "IntRefType: %"PRIu16"; > IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", > co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); > > - av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2- > >MaxFrameSize); > - av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %d; ", co2- > >MaxSliceSize); > - av_log(avctx, AV_LOG_VERBOSE, "\n"); > + av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; MaxSliceSize: %d\n", > + co2->MaxFrameSize, co2->MaxSliceSize); > > av_log(avctx, AV_LOG_VERBOSE, > "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", > print_threestate(co2->BitrateLimit), print_threestate(co2- > >MBBRC), > print_threestate(co2->ExtBRC)); > > - av_log(avctx, AV_LOG_VERBOSE, "Trellis: "); > if (co2->Trellis & MFX_TRELLIS_OFF) { > - av_log(avctx, AV_LOG_VERBOSE, "off"); > + av_log(avctx, AV_LOG_VERBOSE, "Trellis: off\n"); > } else if (!co2->Trellis) { > - av_log(avctx, AV_LOG_VERBOSE, "auto"); > + av_log(avctx, AV_LOG_VERBOSE, "Trellis: auto\n"); > } else { > - if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, > "I"); > - if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, > "P"); > - if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, > "B"); > + char trellis_type[4]; > + int i = 0; > + if (co2->Trellis & MFX_TRELLIS_I) trellis_type[i++] = 'I'; > + if (co2->Trellis & MFX_TRELLIS_P) trellis_type[i++] = 'P'; > + if (co2->Trellis & MFX_TRELLIS_B) trellis_type[i++] = 'B'; > + trellis_type[i] = 0; > + av_log(avctx, AV_LOG_VERBOSE, "Trellis: %s\n", trellis_type); > } > - av_log(avctx, AV_LOG_VERBOSE, "\n"); > > - av_log(avctx, AV_LOG_VERBOSE, > - "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ", > - print_threestate(co2->RepeatPPS), co2->NumMbPerSlice); > switch (co2->LookAheadDS) { > - case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, > "off"); break; > - case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, > "2x"); break; > - case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, > "4x"); break; > - default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); > break; > + case MFX_LOOKAHEAD_DS_OFF: tmp_str = "off"; break; > + case MFX_LOOKAHEAD_DS_2x: tmp_str = "2x"; break; > + case MFX_LOOKAHEAD_DS_4x: tmp_str = "4x"; break; > + default: tmp_str = "unknown"; break; > } > - av_log(avctx, AV_LOG_VERBOSE, "\n"); > + av_log(avctx, AV_LOG_VERBOSE, > + "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: %s\n", > + print_threestate(co2->RepeatPPS), co2->NumMbPerSlice, > tmp_str); > > - av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; > BRefType: ", > - print_threestate(co2->AdaptiveI), print_threestate(co2- > >AdaptiveB)); > switch (co2->BRefType) { > - case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, > "off"); break; > - case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, > "pyramid"); break; > - default: av_log(avctx, AV_LOG_VERBOSE, > "auto"); break; > + case MFX_B_REF_OFF: tmp_str = "off"; break; > + case MFX_B_REF_PYRAMID: tmp_str = "pyramid"; break; > + default: tmp_str = "auto"; break; > } > + av_log(avctx, AV_LOG_VERBOSE, > + "AdaptiveI: %s; AdaptiveB: %s; BRefType:%s\n", > + print_threestate(co2->AdaptiveI), print_threestate(co2- > >AdaptiveB), tmp_str); > > av_log(avctx, AV_LOG_VERBOSE, > "MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: > %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n", > @@ -319,14 +320,12 @@ static void dump_video_param(AVCodecContext *avctx, > QSVEncContext *q, > if (info->RateControlMethod == MFX_RATECONTROL_QVBR) > av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n", co3- > >QVBRQuality); > > - av_log(avctx, AV_LOG_VERBOSE, "PRefType: "); > switch (co3->PRefType) { > - case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, > "default"); break; > - case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, > "simple"); break; > - case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, > "pyramid"); break; > - default: av_log(avctx, AV_LOG_VERBOSE, > "unknown"); break; > + case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "PRefType: > default\n"); break; > + case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, "PRefType: > simple\n"); break; > + case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "PRefType: > pyramid\n"); break; > + default: av_log(avctx, AV_LOG_VERBOSE, "PRefType: > unknown\n"); break; > } > - av_log(avctx, AV_LOG_VERBOSE, "\n"); > > if (avctx->codec_id == AV_CODEC_ID_HEVC) > av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3- > >GPB)); > @@ -360,13 +359,12 @@ static void dump_video_vp9_param(AVCodecContext *avctx, > QSVEncContext *q, > av_log(avctx, AV_LOG_VERBOSE, "profile: %s \n", > print_profile(avctx->codec_id, info->CodecProfile)); > > - av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: > %"PRIu16"; GopOptFlag: ", > - info->GopPicSize, info->GopRefDist); > - if (info->GopOptFlag & MFX_GOP_CLOSED) > - av_log(avctx, AV_LOG_VERBOSE, "closed "); > - if (info->GopOptFlag & MFX_GOP_STRICT) > - av_log(avctx, AV_LOG_VERBOSE, "strict "); > - av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info- > >IdrInterval); > + av_log(avctx, AV_LOG_VERBOSE, > + "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag:%s%s; > IdrInterval: %"PRIu16"\n", > + info->GopPicSize, info->GopRefDist, > + info->GopOptFlag & MFX_GOP_CLOSED ? " closed" : "", > + info->GopOptFlag & MFX_GOP_STRICT ? " strict" : "", > + info->IdrInterval); > > av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: > %s\n", > info->TargetUsage, print_ratecontrol(info->RateControlMethod)); > @@ -396,8 +394,7 @@ static void dump_video_vp9_param(AVCodecContext *avctx, > QSVEncContext *q, > "IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; > IntRefQPDelta: %"PRId16"\n", > co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); > > - av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2- > >MaxFrameSize); > - av_log(avctx, AV_LOG_VERBOSE, "\n"); > + av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d\n", co2- > >MaxFrameSize); > > av_log(avctx, AV_LOG_VERBOSE, > "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", LGTM, will apply Thanks Haihao
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 2382c2f5f7..5729292f94 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -182,6 +182,7 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, mfxExtCodingOption2 *co2 = NULL; mfxExtCodingOption3 *co3 = NULL; mfxExtHEVCTiles *exthevctiles = NULL; + const char *tmp_str = NULL; if (q->co2_idx > 0) co2 = (mfxExtCodingOption2*)coding_opts[q->co2_idx]; @@ -195,13 +196,12 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); - av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ", - info->GopPicSize, info->GopRefDist); - if (info->GopOptFlag & MFX_GOP_CLOSED) - av_log(avctx, AV_LOG_VERBOSE, "closed "); - if (info->GopOptFlag & MFX_GOP_STRICT) - av_log(avctx, AV_LOG_VERBOSE, "strict "); - av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info->IdrInterval); + av_log(avctx, AV_LOG_VERBOSE, + "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag:%s%s; IdrInterval: %"PRIu16"\n", + info->GopPicSize, info->GopRefDist, + info->GopOptFlag & MFX_GOP_CLOSED ? " closed" : "", + info->GopOptFlag & MFX_GOP_STRICT ? " strict" : "", + info->IdrInterval); av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: %s\n", info->TargetUsage, print_ratecontrol(info->RateControlMethod)); @@ -269,45 +269,46 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); - av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize); - av_log(avctx, AV_LOG_VERBOSE, "MaxSliceSize: %d; ", co2->MaxSliceSize); - av_log(avctx, AV_LOG_VERBOSE, "\n"); + av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; MaxSliceSize: %d\n", + co2->MaxFrameSize, co2->MaxSliceSize); av_log(avctx, AV_LOG_VERBOSE, "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n", print_threestate(co2->BitrateLimit), print_threestate(co2->MBBRC), print_threestate(co2->ExtBRC)); - av_log(avctx, AV_LOG_VERBOSE, "Trellis: "); if (co2->Trellis & MFX_TRELLIS_OFF) { - av_log(avctx, AV_LOG_VERBOSE, "off"); + av_log(avctx, AV_LOG_VERBOSE, "Trellis: off\n"); } else if (!co2->Trellis) { - av_log(avctx, AV_LOG_VERBOSE, "auto"); + av_log(avctx, AV_LOG_VERBOSE, "Trellis: auto\n"); } else { - if (co2->Trellis & MFX_TRELLIS_I) av_log(avctx, AV_LOG_VERBOSE, "I"); - if (co2->Trellis & MFX_TRELLIS_P) av_log(avctx, AV_LOG_VERBOSE, "P"); - if (co2->Trellis & MFX_TRELLIS_B) av_log(avctx, AV_LOG_VERBOSE, "B"); + char trellis_type[4]; + int i = 0; + if (co2->Trellis & MFX_TRELLIS_I) trellis_type[i++] = 'I'; + if (co2->Trellis & MFX_TRELLIS_P) trellis_type[i++] = 'P'; + if (co2->Trellis & MFX_TRELLIS_B) trellis_type[i++] = 'B'; + trellis_type[i] = 0; + av_log(avctx, AV_LOG_VERBOSE, "Trellis: %s\n", trellis_type); } - av_log(avctx, AV_LOG_VERBOSE, "\n"); - av_log(avctx, AV_LOG_VERBOSE, - "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ", - print_threestate(co2->RepeatPPS), co2->NumMbPerSlice); switch (co2->LookAheadDS) { - case MFX_LOOKAHEAD_DS_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; - case MFX_LOOKAHEAD_DS_2x: av_log(avctx, AV_LOG_VERBOSE, "2x"); break; - case MFX_LOOKAHEAD_DS_4x: av_log(avctx, AV_LOG_VERBOSE, "4x"); break; - default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; + case MFX_LOOKAHEAD_DS_OFF: tmp_str = "off"; break; + case MFX_LOOKAHEAD_DS_2x: tmp_str = "2x"; break; + case MFX_LOOKAHEAD_DS_4x: tmp_str = "4x"; break; + default: tmp_str = "unknown"; break; } - av_log(avctx, AV_LOG_VERBOSE, "\n"); + av_log(avctx, AV_LOG_VERBOSE, + "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: %s\n", + print_threestate(co2->RepeatPPS), co2->NumMbPerSlice, tmp_str); - av_log(avctx, AV_LOG_VERBOSE, "AdaptiveI: %s; AdaptiveB: %s; BRefType: ", - print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB)); switch (co2->BRefType) { - case MFX_B_REF_OFF: av_log(avctx, AV_LOG_VERBOSE, "off"); break; - case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; - default: av_log(avctx, AV_LOG_VERBOSE, "auto"); break; + case MFX_B_REF_OFF: tmp_str = "off"; break; + case MFX_B_REF_PYRAMID: tmp_str = "pyramid"; break; + default: tmp_str = "auto"; break; } + av_log(avctx, AV_LOG_VERBOSE, + "AdaptiveI: %s; AdaptiveB: %s; BRefType:%s\n", + print_threestate(co2->AdaptiveI), print_threestate(co2->AdaptiveB), tmp_str); av_log(avctx, AV_LOG_VERBOSE, "MinQPI: %"PRIu8"; MaxQPI: %"PRIu8"; MinQPP: %"PRIu8"; MaxQPP: %"PRIu8"; MinQPB: %"PRIu8"; MaxQPB: %"PRIu8"\n", @@ -319,14 +320,12 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, if (info->RateControlMethod == MFX_RATECONTROL_QVBR) av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n", co3->QVBRQuality); - av_log(avctx, AV_LOG_VERBOSE, "PRefType: "); switch (co3->PRefType) { - case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "default"); break; - case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, "simple"); break; - case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid"); break; - default: av_log(avctx, AV_LOG_VERBOSE, "unknown"); break; + case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "PRefType: default\n"); break; + case MFX_P_REF_SIMPLE: av_log(avctx, AV_LOG_VERBOSE, "PRefType: simple\n"); break; + case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "PRefType: pyramid\n"); break; + default: av_log(avctx, AV_LOG_VERBOSE, "PRefType: unknown\n"); break; } - av_log(avctx, AV_LOG_VERBOSE, "\n"); if (avctx->codec_id == AV_CODEC_ID_HEVC) av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB)); @@ -360,13 +359,12 @@ static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "profile: %s \n", print_profile(avctx->codec_id, info->CodecProfile)); - av_log(avctx, AV_LOG_VERBOSE, "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag: ", - info->GopPicSize, info->GopRefDist); - if (info->GopOptFlag & MFX_GOP_CLOSED) - av_log(avctx, AV_LOG_VERBOSE, "closed "); - if (info->GopOptFlag & MFX_GOP_STRICT) - av_log(avctx, AV_LOG_VERBOSE, "strict "); - av_log(avctx, AV_LOG_VERBOSE, "; IdrInterval: %"PRIu16"\n", info->IdrInterval); + av_log(avctx, AV_LOG_VERBOSE, + "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag:%s%s; IdrInterval: %"PRIu16"\n", + info->GopPicSize, info->GopRefDist, + info->GopOptFlag & MFX_GOP_CLOSED ? " closed" : "", + info->GopOptFlag & MFX_GOP_STRICT ? " strict" : "", + info->IdrInterval); av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: %s\n", info->TargetUsage, print_ratecontrol(info->RateControlMethod)); @@ -396,8 +394,7 @@ static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, "IntRefType: %"PRIu16"; IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n", co2->IntRefType, co2->IntRefCycleSize, co2->IntRefQPDelta); - av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize); - av_log(avctx, AV_LOG_VERBOSE, "\n"); + av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d\n", co2->MaxFrameSize); av_log(avctx, AV_LOG_VERBOSE, "BitrateLimit: %s; MBBRC: %s; ExtBRC: %s\n",
Dividing one line log into several av_log() call is not thread safe. Now merge these strings into one av_log() call. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> --- libavcodec/qsvenc.c | 87 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 45 deletions(-)