[Libav-user] Writing Raw GRAY16 frame to YUV420P10LE frame

asci_anything asci_anything at protonmail.com
Wed Jul 6 06:42:54 EEST 2022


Hi,

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.

I so far have something somewhat correct as my Y plane seems to populated, however I am uncertain what I am doing wrong.

staticvoidfill_yuv_image(AVFrame*pict, intframe_index,
intwidth, intheight, uint8_t*data)
{
//data is a 1280x720x2 array, which each 2 bytes representing one 16 bit value
//Want each 16 bit value to be a 10 bit value with last 6 bits lopped off.
//I assumed that I didn't need to shift the bits in the data as this didn't seem to change anything
intx = 0, y = 0, i = 0;
intcd = 0;
i = frame_index;
pict->data[0] = data;

for (y = 0; y < height / 2; y++)
{
for (x = 0; x < width / 2; x++)
{
pict->data[1][y * pict->linesize[1] + x] = 512;
pict->data[2][y * pict->linesize[2] + x] = 512;
}
} }

I get the following result:
(See attached screenshot)
Most of what is shown is correct, however it is green.
There is also the presence of odd blocking artifacts in the background rather than one solid color.

How would I go about making this gray, as well as getting rid of the background blotches.

Please see below the output terminal while recording.

[libx264 @ 0x55e45b53a540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55e45b53a540] profile High 10, level 3.1, 4:2:0 10-bit
[libx264 @ 0x55e45b53a540] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - 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
Output #0, mp4, to 'Testing_DIR/test_lsb.mp4':
Stream #0:0: Video: h264, yuv420p10le, 1280x720, q=2-31, 2000 kb/s, 30 tbn
[libx264 @ 0x55e45b53a540] frame I:3 Avg QP:40.30 size: 84131
[libx264 @ 0x55e45b53a540] frame P:177 Avg QP:45.24 size: 79629
[libx264 @ 0x55e45b53a540] frame B:270 Avg QP:47.91 size: 76124
[libx264 @ 0x55e45b53a540] consecutive B-frames: 19.3% 1.3% 2.0% 77.3%
[libx264 @ 0x55e45b53a540] mb I I16..4: 32.8% 38.1% 29.1%
[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%
[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%
[libx264 @ 0x55e45b53a540] 8x8 transform intra:63.8% inter:3.8%
[libx264 @ 0x55e45b53a540] coded y,uvDC,uvAC intra: 81.9% 0.2% 0.0% inter: 41.7% 0.0% 0.0%
[libx264 @ 0x55e45b53a540] i16 v,h,dc,p: 63% 13% 7% 17%
[libx264 @ 0x55e45b53a540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 54% 15% 25% 2% 1% 0% 0% 0% 2%
[libx264 @ 0x55e45b53a540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 31% 22% 1% 2% 1% 2% 1% 2%
[libx264 @ 0x55e45b53a540] i8c dc,h,v,p: 99% 1% 1% 0%
[libx264 @ 0x55e45b53a540] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55e45b53a540] kb/s:18613.41Time run for in seconds: 15.026

Let me know if you need more specific info. Thank you for your time.

-asci_anything
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220706/3123a523/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 034C5D85-BF76-45D8-A5BC-A3810F9CF783.jpg
Type: image/jpeg
Size: 249727 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220706/3123a523/attachment.jpg>


More information about the Libav-user mailing list