Also rewrite the code so that a variable that is only used depending upon CONFIG_LIBVPX_VP9_ENCODER is not declared outside of the #if block. (The variable was declared with av_uninit, but it should have been av_unused, as the former does not work for all compilers.)
Unified · Split
| @@ -357,19 +357,20 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo, · 356 unmodified lines | |||
| 357 | const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc; | 357 | const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc; |
| 358 | 358 | ||
| 359 | FrameData fd = { .pts = frame->pts }; | 359 | FrameData fd = { .pts = frame->pts }; |
| 360 | |||
| 361 | AVFrameSideData *av_uninit(sd); | ||
| 362 | int ret; | 360 | int ret; |
| 363 | 361 | ||
| 364 | #if CONFIG_LIBVPX_VP9_ENCODER | 362 | #if CONFIG_LIBVPX_VP9_ENCODER |
| 365 | // Keep HDR10+ if it has bit depth higher than 8 and | 363 | if (avctx->codec_id == AV_CODEC_ID_VP9 && |
| 366 | // it has PQ trc (SMPTE2084). | 364 | // Keep HDR10+ if it has bit depth higher than 8 and |
| 367 | sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS); | 365 | // it has PQ trc (SMPTE2084). |
| 368 | if (avctx->codec_id == AV_CODEC_ID_VP9 && sd && | ||
| 369 | enccfg->g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) { | 366 | enccfg->g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) { |
| 370 | fd.hdr10_plus = av_buffer_ref(sd->buf); | 367 | const AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS); |
| 371 | if (!fd.hdr10_plus) | 368 | |
| 372 | return AVERROR(ENOMEM); | 369 | if (sd) { |
| 370 | fd.hdr10_plus = av_buffer_ref(sd->buf); | ||
| 371 | if (!fd.hdr10_plus) | ||
| 372 | return AVERROR(ENOMEM); | ||
| 373 | } | ||
| 373 | } | 374 | } |
| 374 | #endif | 375 | #endif |
| 375 | 376 | ||