History

avcodec/libvpxenc: Only search for side data when intending to use it

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.)

Andreas Rheinhardt committed 2 years ago

Commit 1093b401 parent e465ceb1 file · +10 −9Browse files

Unified · Split

libavcodec/libvpxenc.c+10−9
@@ -357,19 +357,20 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo, · 356 unmodified lines
357357 const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc;
358358
359359 FrameData fd = { .pts = frame->pts };
360−
361− AVFrameSideData *av_uninit(sd);
362360 int ret;
363361
364362 #if CONFIG_LIBVPX_VP9_ENCODER
365− // Keep HDR10+ if it has bit depth higher than 8 and
366− // it has PQ trc (SMPTE2084).
367− sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
368− if (avctx->codec_id == AV_CODEC_ID_VP9 && sd &&
363+ if (avctx->codec_id == AV_CODEC_ID_VP9 &&
364+ // Keep HDR10+ if it has bit depth higher than 8 and
365+ // it has PQ trc (SMPTE2084).
369366 enccfg->g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) {
370− fd.hdr10_plus = av_buffer_ref(sd->buf);
371− if (!fd.hdr10_plus)
372− return AVERROR(ENOMEM);
367+ const AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
368+
369+ if (sd) {
370+ fd.hdr10_plus = av_buffer_ref(sd->buf);
371+ if (!fd.hdr10_plus)
372+ return AVERROR(ENOMEM);
373+ }
373374 }
374375 #endif
375376

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t