<div dir="ltr">I try to experiment videoconvert_convert_matrix8 function.<div><br></div><div><div>#define CLIP(X) ( (X) > 255 ? 255 : (X) < 0 ? 0 : X)</div><div>#define RGB2Y(R, G, B) CLIP(( ( 66 * (R) + 129 * (G) + 25 * (B) + 128) >> 8) + 16)</div>
<div>#define RGB2U(R, G, B) CLIP(( ( -38 * (R) - 74 * (G) + 112 * (B) + 128) >> 8) + 128)</div><div>#define RGB2V(R, G, B) CLIP(( ( 112 * (R) - 94 * (G) - 18 * (B) + 128) >> 8) + 128)</div><div><br></div><div>
static void</div><div>videoconvert_convert_matrix8 (VideoConvert * convert, gpointer pixels)</div><div>{</div><div> int i,t;</div><div> int y, u, v;</div><div> int r, g, b;</div><div> guint8 *p = pixels;</div><div><br>
</div><div> for (i = 0; i < convert->width; i++) {</div><div> t=i*4;</div><div> y=t+1; </div><div> u=y+1;</div><div> v=u+1;</div><div> r=p[t+1];</div><div> g=p[t+2];</div><div> b=p[t+3];</div><div>
p[t] = RGB2Y(r,g,b);</div><div> p[u] = RGB2U(r,g,b);</div><div> p[v] = RGB2V(r,g,b);</div><div> }</div><div>}</div></div><div><br></div><div><br></div><div>gst-launch-1.0 -e matroskamux name=muxer ! progressreport ! queue ! filesink location=/home/pont/disk/rec_2014-06-17_161811.mkv \ ximagesrc use-damage=0 ! queue ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=NV12,framerate=25/1 ! queue ! omxh264enc ! h264parse ! queue ! muxer.video_0<br>
</div><div><br></div><div>Before</div><div><br></div><div><div>perf stat -p `pidof gst-launch-1.0` -d -a </div><div>^C</div><div> Performance counter stats for process id '18980':</div><div><br></div><div> 30384.173422 task-clock # 0.481 CPUs utilized </div>
<div> 27,332 context-switches # 0.900 K/sec </div><div> 5,241 cpu-migrations # 0.172 K/sec </div><div> 1,642 page-faults # 0.054 K/sec </div>
<div> 90,790,820,778 cycles # 2.988 GHz </div><div> 25,993,859,696 stalled-cycles-frontend # 28.63% frontend cycles idle </div><div> <not supported> stalled-cycles-backend </div>
<div> 245,329,236,634 instructions # 2.70 insns per cycle </div><div> # 0.11 stalled cycles per insn</div><div> 17,607,065,972 branches # 579.481 M/sec </div>
<div> 31,268,606 branch-misses # 0.18% of all branches </div><div> <not supported> L1-dcache-loads:HG </div><div> 704,453,875 L1-dcache-load-misses:HG # 0.00% of all L1-dcache hits </div>
<div> 333,110,129 LLC-loads:HG # 10.963 M/sec </div><div> <not supported> LLC-load-misses:HG </div><div><br></div><div> 63.130500236 seconds time elapsed</div></div>
<div><br></div><div><br></div><div>after</div><div><br></div><div><div>perf stat -p `pidof gst-launch-1.0` -d -a </div><div>^C</div><div> Performance counter stats for process id '18804':</div><div><br></div><div>
21621.851703 task-clock # 0.364 CPUs utilized </div><div> 22,496 context-switches # 0.001 M/sec </div><div> 2,712 cpu-migrations # 0.125 K/sec </div>
<div> 1,547 page-faults # 0.072 K/sec </div><div> 67,110,958,855 cycles # 3.104 GHz </div><div> 12,420,679,145 stalled-cycles-frontend # 18.51% frontend cycles idle </div>
<div> <not supported> stalled-cycles-backend </div><div> 202,995,433,561 instructions # 3.02 insns per cycle </div><div> # 0.06 stalled cycles per insn</div>
<div> 7,312,441,083 branches # 338.197 M/sec </div><div> 26,623,263 branch-misses # 0.36% of all branches </div><div> <not supported> L1-dcache-loads:HG </div>
<div> 658,903,226 L1-dcache-load-misses:HG # 0.00% of all L1-dcache hits </div><div> 309,353,254 LLC-loads:HG # 14.307 M/sec </div><div> <not supported> LLC-load-misses:HG </div>
<div><br></div><div> 59.371335826 seconds time elapsed</div></div><div><br></div><div><br></div><div>20% is a nice boost as for me.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-20 5:09 GMT+00:00 Edward Hervey <span dir="ltr"><<a href="mailto:bilboed@bilboed.com" target="_blank">bilboed@bilboed.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Since:<br>
* your biggest cpu usage is videoconvert and x264<br>
* You are most likely using a multi-core system<br>
<br>
I would strongly recommend putting queue element before/after<br>
videoconvert and x264:<br>
... ! queue ! videoconvert ! queue ! <capsfilter> ! <videoencoder> !<br>
queue ! ...<br>
<br>
That will essentially decouple videoconvert processing and h264<br>
encoding into dedicated threads.<br>
<span class="HOEnZb"><font color="#888888"><br>
Edward<br>
</font></span><div class="HOEnZb"><div class="h5">><br>
><br>
><br>
> OMX<br>
> gst-launch-1.0 -e matroskamux name=muxer ! progressreport ! filesink<br>
> location=/home/pont/disk/rec_2014-05-19_165945.mkv \ ximagesrc<br>
> use-damage=0 ! video/x-raw,format=BGRx ! videoconvert !<br>
> video/x-raw,format=NV12,framerate=25/1 ! omxh264enc ! h264parse !<br>
> queue ! muxer.video_0<br>
><br>
><br>
><br>
> VAAPI<br>
> gst-launch-1.0 -e matroskamux name=muxer ! progressreport ! filesink<br>
> location=/home/pont/disk/rec_2014-05-19_170015.mkv \ ximagesrc<br>
> use-damage=0 ! video/x-raw,format=BGRx ! videoconvert !<br>
> video/x-raw,format=NV12,framerate=25/1 ! vaapiencode_h264 ! queue !<br>
> muxer.video_0<br>
><br>
><br>
><br>
> Software<br>
> gst-launch-1.0 -e matroskamux name=muxer ! progressreport ! filesink<br>
> location=/home/pont/disk/rec_2014-05-19_170044.mkv \ ximagesrc<br>
> use-damage=0 ! video/x-raw,format=BGRx ! videoconvert !<br>
> video/x-raw,format=NV12,framerate=25/1 ! x264enc speed-preset=faster !<br>
> queue ! muxer.video_0<br>
><br>
><br>
><br>
> pert top for Gstreamer software fullhd 25fps<br>
> Samples: 297K of event 'cycles', Event count (approx.): 99651686548<br>
><br>
><br>
> 23.51% libgstvideoconvert.so [.]<br>
> videoconvert_convert_matrix8<br>
> 23.44% libx264.so.142 [.]<br>
> x264_add8x8_idct_avx2.skip_prologue<br>
> 10.35% libx264.so.142 [.] 0x000000000009ce74<br>
> 8.45% libx264.so.142 [.]<br>
> x264_add8x8_idct_avx.skip_prologue<br>
> 2.97% orcexec.47KToS [.] 0x00000000000000c4<br>
> 2.62% intel_drv.so [.] 0x0000000000035dde<br>
> 2.45% libgstvideo-1.0.so.0.204.0 [.]<br>
> video_chroma_down_h2_guint8<br>
> 2.39% libgstvideo-1.0.so.0.204.0 [.]<br>
> video_chroma_down_v2_guint8<br>
> 2.23% libx264.so.142 [.]<br>
> x264_macroblock_cache_load_progressive<br>
> 2.21% libx264.so.142 [.] x264_me_search_ref<br>
> 1.31% libx264.so.142 [.] x264_macroblock_analyse<br>
> 1.27% libx264.so.142 [.]<br>
> x264_sub8x8_dct_avx.skip_prologue<br>
> 1.11% libx264.so.142 [.]<br>
> x264_mb_predict_mv_ref16x16<br>
> 0.93% libx264.so.142 [.] x264_macroblock_cache_save<br>
> 0.61% libx264.so.142 [.]<br>
> x264_mb_predict_mv_direct16x16<br>
> 0.56% libx264.so.142 [.] x264_macroblock_probe_skip<br>
><br>
><br>
><br>
><br>
> perf top for simple screen recorder fullhd 25 fps<br>
> Samples: 243K of event 'cycles', Event count (approx.): 63217744816<br>
><br>
><br>
> 33.70% libx264.so.142 [.]<br>
> x264_add8x8_idct_avx2.skip_prologue<br>
> 13.57% libx264.so.142 [.] 0x000000000001a7b6<br>
> 11.25% libx264.so.142 [.]<br>
> x264_add8x8_idct_avx.skip_prologue<br>
> 3.62% intel_drv.so [.] 0x00000000000168c9<br>
> 3.54% simplescreenrecorder [.]<br>
> Convert_BGRA_YUV420_SSSE3(unsigned int, unsigned int, unsigned char<br>
> const*, int, unsigned char* const*, int const*)<br>
> 3.34% libx264.so.142 [.] x264_me_search_ref<br>
> 3.27% libx264.so.142 [.]<br>
> x264_macroblock_cache_load_progressive<br>
> 1.92% libx264.so.142 [.] x264_macroblock_analyse<br>
> 1.66% libx264.so.142 [.]<br>
> x264_sub8x8_dct_avx.skip_prologue<br>
> 1.61% libx264.so.142 [.]<br>
> x264_mb_predict_mv_ref16x16<br>
> 1.42% libx264.so.142 [.] x264_macroblock_cache_save<br>
> 0.91% libx264.so.142 [.]<br>
> x264_mb_predict_mv_direct16x16<br>
> 0.76% libpepflashplayer.so [.] 0x00000000001f4980<br>
> 0.64% libx264.so.142 [.] x264_macroblock_probe_skip<br>
> 0.54% libx264.so.142 [.] x264_ratecontrol_mb_qp<br>
> 0.54% perf [.] 0x0000000000067856<br>
> 0.43% i965_dri.so [.] 0x00000000002e59a9<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> gstreamer-devel mailing list<br>
> <a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br>
</div></div><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br></div>