From: Steinar H. Gunderson Date: Tue, 24 Apr 2018 20:47:35 +0000 (+0200) Subject: Make the FFmpegCapture disconnected frames proper black. X-Git-Tag: 1.7.2~16 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=83157f6ffc2287cd861e938f85255cc0ba3506a1;hp=4c144e82c20912463cf7268723e564fa6eb8f1c0 Make the FFmpegCapture disconnected frames proper black. Less disturbing, more consistent between BGRA and Y'CbCr, and the all-zero Y'CbCr frame causes out-of-gamut (negative) RGB values that ended up confusing white balance adjustment a lot. --- diff --git a/ffmpeg_capture.cpp b/ffmpeg_capture.cpp index b7db50c..235393a 100644 --- a/ffmpeg_capture.cpp +++ b/ffmpeg_capture.cpp @@ -327,6 +327,7 @@ void FFmpegCapture::send_disconnected_frame() if (pixel_format == bmusb::PixelFormat_8BitBGRA) { video_format.stride = width * 4; video_frame.len = width * height * 4; + memset(video_frame.data, 0, video_frame.len); } else { video_format.stride = width; current_frame_ycbcr_format.luma_coefficients = YCBCR_REC_709; @@ -339,8 +340,9 @@ void FFmpegCapture::send_disconnected_frame() current_frame_ycbcr_format.cr_x_position = 0.0f; current_frame_ycbcr_format.cr_y_position = 0.0f; video_frame.len = width * height * 2; + memset(video_frame.data, 0, width * height); + memset(video_frame.data + width * height, 128, width * height); // Valid for both NV12 and planar. } - memset(video_frame.data, 0, video_frame.len); frame_callback(-1, AVRational{1, TIMEBASE}, -1, AVRational{1, TIMEBASE}, timecode++, video_frame, /*video_offset=*/0, video_format,