<html><head></head><body><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">Hi,</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">I have recently been working on attempting to fit a GRAY16 frame to a YUV420P10LE frame and have attempted to do so without using libswscale. I am encoding each frame utilizing libx264.</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">I so far have something somewhat correct as my Y plane seems to populated, however I am uncertain what I am doing wrong.</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace; line-height: 19px; white-space: pre; caret-color: red !important;"><span style="caret-color: red !important;"><span style="caret-color: red !important;"></span></span><div style="caret-color: red !important;"><span style="caret-color: red !important;"><span style="caret-color: red !important;">    </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">static</span><span style="caret-color: red !important;"> </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">void</span><span style="caret-color: red !important;"> </span><span style="color: rgb(220, 220, 170); caret-color: red !important;">fill_yuv_image</span><span style="caret-color: red !important;">(</span><span style="color: rgb(78, 201, 176); caret-color: red !important;">AVFrame</span><span style="caret-color: red !important;"> </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">*</span><span style="color: rgb(156, 220, 254); caret-color: red !important;">pict</span><span style="caret-color: red !important;">, </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">int</span><span style="caret-color: red !important;"> </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">frame_index</span><span style="caret-color: red !important;">,</span></span><div style="caret-color: red !important;"><span style="caret-color: red !important;">                               </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">int</span><span style="caret-color: red !important;"> </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">width</span><span style="caret-color: red !important;">, </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">int</span><span style="caret-color: red !important;"> </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">height</span><span style="caret-color: red !important;">, </span><span style="color: rgb(78, 201, 176); caret-color: red !important;">uint8_t</span><span style="caret-color: red !important;"> </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">*</span><span style="color: rgb(156, 220, 254); caret-color: red !important;">data</span><span style="caret-color: red !important;">)</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">    {</span></div><div style="caret-color: red !important;"><span style="color: rgb(106, 153, 85); caret-color: red !important;">        //data is a 1280x720x2 array, which each 2 bytes representing one 16 bit value</span></div><div style="caret-color: red !important;"><span style="color: rgb(106, 153, 85); caret-color: red !important;">        //Want each 16 bit value to be a 10 bit value with last 6 bits lopped off.</span></div><div style="caret-color: red !important;"><span style="color: rgb(106, 153, 85); caret-color: red !important;">        //I assumed that I didn't need to shift the bits in the data as this didn't seem to change anything</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">        </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">int</span><span style="caret-color: red !important;"> </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">x</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">, </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">y</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">, </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">i</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">;</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">        </span><span style="color: rgb(86, 156, 214); caret-color: red !important;">int</span><span style="caret-color: red !important;"> </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">cd</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">;</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">        </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">i</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">frame_index</span><span style="caret-color: red !important;">;</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">        </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">pict</span><span style="caret-color: red !important;">-></span><span style="color: rgb(156, 220, 254); caret-color: red !important;">data</span><span style="caret-color: red !important;">[</span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">] = </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">data</span><span style="caret-color: red !important;">;</span></div><br style="caret-color: red !important;"><div style="caret-color: red !important;"><span style="caret-color: red !important;">        </span><span style="color: rgb(197, 134, 192); caret-color: red !important;">for</span><span style="caret-color: red !important;"> (</span><span style="color: rgb(156, 220, 254); caret-color: red !important;">y</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">; </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">y</span><span style="caret-color: red !important;"> < </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">height</span><span style="caret-color: red !important;"> / </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">2</span><span style="caret-color: red !important;">; </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">y</span><span style="caret-color: red !important;">++)</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">        {</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">            </span><span style="color: rgb(197, 134, 192); caret-color: red !important;">for</span><span style="caret-color: red !important;"> (</span><span style="color: rgb(156, 220, 254); caret-color: red !important;">x</span><span style="caret-color: red !important;"> = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">0</span><span style="caret-color: red !important;">; </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">x</span><span style="caret-color: red !important;"> < </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">width</span><span style="caret-color: red !important;"> / </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">2</span><span style="caret-color: red !important;">; </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">x</span><span style="caret-color: red !important;">++)</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">            {</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">                </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">pict</span><span style="caret-color: red !important;">-></span><span style="color: rgb(156, 220, 254); caret-color: red !important;">data</span><span style="caret-color: red !important;">[</span><span style="color: rgb(181, 206, 168); caret-color: red !important;">1</span><span style="caret-color: red !important;">][</span><span style="color: rgb(156, 220, 254); caret-color: red !important;">y</span><span style="caret-color: red !important;"> * </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">pict</span><span style="caret-color: red !important;">-></span><span style="color: rgb(156, 220, 254); caret-color: red !important;">linesize</span><span style="caret-color: red !important;">[</span><span style="color: rgb(181, 206, 168); caret-color: red !important;">1</span><span style="caret-color: red !important;">] + </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">x</span><span style="caret-color: red !important;">] = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">512</span><span style="caret-color: red !important;">;</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">                </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">pict</span><span style="caret-color: red !important;">-></span><span style="color: rgb(156, 220, 254); caret-color: red !important;">data</span><span style="caret-color: red !important;">[</span><span style="color: rgb(181, 206, 168); caret-color: red !important;">2</span><span style="caret-color: red !important;">][</span><span style="color: rgb(156, 220, 254); caret-color: red !important;">y</span><span style="caret-color: red !important;"> * </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">pict</span><span style="caret-color: red !important;">-></span><span style="color: rgb(156, 220, 254); caret-color: red !important;">linesize</span><span style="caret-color: red !important;">[</span><span style="color: rgb(181, 206, 168); caret-color: red !important;">2</span><span style="caret-color: red !important;">] + </span><span style="color: rgb(156, 220, 254); caret-color: red !important;">x</span><span style="caret-color: red !important;">] = </span><span style="color: rgb(181, 206, 168); caret-color: red !important;">512</span><span style="caret-color: red !important;">;</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">            }</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">        }</span></div><span style="caret-color: red !important;">    }</span></div><span style="caret-color: red !important;"><span style="caret-color: red !important;"></span></span></div></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">I get the following result:</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">(See attached screenshot)<caret></caret></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">Most of what is shown is correct, however it is green.</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">There is also the presence of odd blocking artifacts in the background rather than one solid color.</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">How would I go about making this gray, as well as getting rid of the background blotches.</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">Please see below the output terminal while recording.</div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2</span><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] profile High 10, level 3.1, 4:2:0 10-bit</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - <a href="http://www.videolan.org/x264.html" rel="noreferrer nofollow noopener" style="caret-color: red !important;">http://www.videolan.org/x264.html</a> - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=0 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=1 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=25.0 qcomp=0.60 qpmin=0 qpmax=51 qpstep=4 ip_ratio=1.40 aq=1:1.00</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">Output #0, mp4, to 'Testing_DIR/test_lsb.mp4':</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">    Stream #0:0: Video: h264, yuv420p10le, 1280x720, q=2-31, 2000 kb/s, 30 tbn</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] frame I:3     Avg QP:40.30  size: 84131</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] frame P:177   Avg QP:45.24  size: 79629</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] frame B:270   Avg QP:47.91  size: 76124</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] consecutive B-frames: 19.3%  1.3%  2.0% 77.3%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] mb I  I16..4: 32.8% 38.1% 29.1%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] mb P  I16..4: 13.9% 30.3%  7.3%  P16..4: 14.2%  7.6%  8.6%  0.0%  0.0%    skip:18.0%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] mb B  I16..4:  7.5% 26.9%  4.7%  B16..8: 18.2%  9.6%  7.0%  direct: 4.1%  skip:22.0%  L0:41.4% L1:40.0% BI:18.6%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] 8x8 transform intra:63.8% inter:3.8%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] coded y,uvDC,uvAC intra: 81.9% 0.2% 0.0% inter: 41.7% 0.0% 0.0%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] i16 v,h,dc,p: 63% 13%  7% 17%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 54% 15% 25%  2%  1%  0%  0%  0%  2%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 31% 22%  1%  2%  1%  2%  1%  2%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] i8c dc,h,v,p: 99%  1%  1%  0%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] Weighted P-Frames: Y:0.0% UV:0.0%</span></div><div style="caret-color: red !important;"><span style="caret-color: red !important;">[libx264 @ 0x55e45b53a540] kb/s:18613.41</span></div><span style="caret-color: red !important;">Time run for in seconds: 15.026</span><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><span style="caret-color: red !important;">Let me know if you need more specific info. </span>Thank you for your time. </div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;"><br style="caret-color: red !important;"></div><div style="-webkit-text-size-adjust: auto; caret-color: rgb(255, 0, 0); color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Arial; font-size: 14px;">-asci_anything</div><br class="Apple-interchange-newline" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); -webkit-text-size-adjust: auto;"></body></html>