buffer

How to set encoder buffer size created by MediaCodec

狂风中的少年 提交于 2021-02-18 11:57:13
问题 I am trying to use Nexus to test encoding with Mediacodec APIs. I can see the inputBuffers provided by the encoder is 119040 (by logging inputBuffers.capacity). But the size of the frame, i.e. input, is 460800. I got error message at inputBuffer.put with buffer overflow . So I was about to set the input buffer to 460800. The API I could find is BufferInfo.set . However, I cannot find a way to attach this setting to the encoder. Could someone help? Thanks!!! encoder = MediaCodec

c++ flushing the buffer

点点圈 提交于 2021-02-16 14:59:28
问题 I know there are many buffer questions on here but I can't seem find a clear answer on this. std::cout << "write to screen" << std::endl; I know this code will write to the screen and flush the buffer because of the "endl", but if I wrote this: std::cout << "write to screen"; Wouldn't the buffer be flushed regardless since the text has been outputted to the screen? 回答1: Wouldn't the buffer be flushed regardless since the text has been outputted to the screen? Assuming that you have seen the

What is the behavior of %(limit)[^\n] in scanf ? It is safety from overflow?

断了今生、忘了曾经 提交于 2021-02-16 05:24:44
问题 The format %(limit)[^\n] for scanf function is unsafe ? (where (limit) is the length -1 of the string) If it is unsafe, why ? And there is a safe way to implement a function that catch strings just using scanf() ? On Linux Programmer's Manual, (typing man scanf on terminal), the s format said: Matches a sequence of non-white-space characters; the next pointer must be a pointer to character array that is long enough to hold the input sequence and the terminating null byte ('\0'),which is added

is std::copy faster than std::cout for output?

非 Y 不嫁゛ 提交于 2021-02-11 12:01:15
问题 std::vector<int> v{2,4,6,8,10,12,14,16,18,20}; // print the numbers std::copy(v.cbegin(), v.cend(), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; here std::copy is used to write to std out. Is this faster than using std::cout for the vector elements in a for loop like for(auto element: v) std::cout << element << " "; I could't find much information about how they would write to output buffers for both. 回答1: To give an rough idea on the relative performance of the two, see

How to clear cin Buffer in c++

删除回忆录丶 提交于 2021-02-08 11:55:25
问题 I have gone through many existing answers here StackOverflow, but I am still stuck. code: int c; cin >> c; if(cin.fail()) { cout << "Wrong Input"; cin.clear(); cin.ignore(INT_MAX, '\n'); } else { cout << c*2; } If I enter wring input e.g s instead of an integer, it outputs Wrong Input . However, if I enter an integer, and then I enter a string, it ignores the string and keep outputting the previous integer result, hence it does not clears the cin buffer, and the old value of c keeps on

C++ How to actually use pubsetbuf in ofstream?

妖精的绣舞 提交于 2021-02-08 10:48:44
问题 I have a program that writes a temporary file to be used with gnuplot. The file varies in size and it can get to several hundreds of kB, if not MB. Everytime it's written to disk, strace only shows some 8kB at a time. I would like to avoid unnecessary disk writes by setting a buffer greater than this. One of the answers here, on SO, said that 128kB is about the maximum before it starts behaving badly. I have searched and found out that I can modify the buffer, something like this: int sz

C++ How to actually use pubsetbuf in ofstream?

蹲街弑〆低调 提交于 2021-02-08 10:44:12
问题 I have a program that writes a temporary file to be used with gnuplot. The file varies in size and it can get to several hundreds of kB, if not MB. Everytime it's written to disk, strace only shows some 8kB at a time. I would like to avoid unnecessary disk writes by setting a buffer greater than this. One of the answers here, on SO, said that 128kB is about the maximum before it starts behaving badly. I have searched and found out that I can modify the buffer, something like this: int sz

Thread locking when flushing jsp file

六眼飞鱼酱① 提交于 2021-02-07 12:51:58
问题 Under heavy load I see lot of threads getting locked when GZipping and decompressing the JSP file. The thread dump looks like below. Seems to be coming from "header.jsp" which is of size 14Kb. http-0.0.0.0-8080-304" daemon prio=3 tid=0x0000000008bcc000 nid=0x302 runnable [0xfffffd7de7bc2000] java.lang.Thread.State: RUNNABLE at java.util.zip.Deflater.deflateBytes(Native Method) at java.util.zip.Deflater.deflate(Deflater.java:306) - locked <0xfffffd7e589078e8> (a java.util.zip.ZStreamRef) at

StreamReader and buffer in C#

Deadly 提交于 2021-02-07 12:38:34
问题 I've a question about buffer usage with StreamReader. Here: http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx you can see: "When reading from a Stream, it is more efficient to use a buffer that is the same size as the internal buffer of the stream.". According to this weblog , the internal buffer size of a StreamReader is 2k, so I can efficiently read a file of some kbs using the Read() avoiding the Read(Char[], Int32, Int32) . Moreover, even if a file is big I can construct

StreamReader and buffer in C#

社会主义新天地 提交于 2021-02-07 12:38:30
问题 I've a question about buffer usage with StreamReader. Here: http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx you can see: "When reading from a Stream, it is more efficient to use a buffer that is the same size as the internal buffer of the stream.". According to this weblog , the internal buffer size of a StreamReader is 2k, so I can efficiently read a file of some kbs using the Read() avoiding the Read(Char[], Int32, Int32) . Moreover, even if a file is big I can construct