Skip to content

Commit

Permalink
avcodec/libx264: leave full range flag unchanged if unknown
Browse files Browse the repository at this point in the history
By default the x264 full range flag is set to -1. By not setting
it to something else, we can let libx264 handle the RGB case.
Additionally, change the preference order to user-specified range
first, and then any fall-back logic left for the YUVJ pix_fmts.

Fixes the capture part of #9374
  • Loading branch information
jeeb committed Aug 18, 2021
1 parent ed47a4a commit 7ca71b7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libavcodec/libx264.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,10 +857,12 @@ static av_cold int X264_init(AVCodecContext *avctx)

x4->params.i_slice_count = avctx->slices;

x4->params.vui.b_fullrange = avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
avctx->color_range == AVCOL_RANGE_JPEG;
if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED)
x4->params.vui.b_fullrange = avctx->color_range == AVCOL_RANGE_JPEG;
else if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ422P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ444P)
x4->params.vui.b_fullrange = 1;

if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED)
x4->params.vui.i_colmatrix = avctx->colorspace;
Expand Down

0 comments on commit 7ca71b7

Please sign in to comment.