stride

Can anyone help in understanding AVFrame.linesize[]?

99封情书 提交于 2019-12-18 03:04:39
问题 I tried to find what each cell of AVFrame.linesize[] means, but I didn't found. As I understood linesize[0] is the width, linesize[1] is the height. If I'm right what does other cells mean? why after avcodec_decode_video2(codecCtxDecode, frameDecoded, &frameFinished, &packet); only linesize[0] has the value and other cells are always 0? UPDATED I think AVFrame.data[i] and AVFrame.linesize[i] are the data of specific color in the row and the length of the row, am I correct? 回答1: In the case of

How to understand numpy strides for layman?

烈酒焚心 提交于 2019-12-17 18:19:52
问题 I am currently going through numpy and there is a topic in numpy called "strides". I understand what it is. But how does it work? I did not find any useful information online. Can anyone let me understand in a layman's terms? 回答1: The actual data of a numpy array is stored in a homogeneous and contiguous block of memory called data buffer. For more information see NumPy internals. Using the (default) row-major order, a 2D array looks like this: To map the indices i,j,k,... of a

Extract every n-th element from TCL list [closed]

我是研究僧i 提交于 2019-12-13 08:19:34
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year . we can extract every n-th element of a TCL list by foreach loop. But is there a single line generic TCL cmd that will do the trick? Something like lindex with a '-stride' option. 回答1: If you have lmap (Tcl 8.5 version in the links below) you can do this: lmap [lrepeat $n a] $list {set a} Example: set

Is there a standard, strided version of memcpy?

吃可爱长大的小学妹 提交于 2019-12-08 15:00:47
问题 I have a column vector A which is 10 elements long. I have a matrix B which is 10 by 10. The memory storage for B is column major. I would like to overwrite the first row in B with the column vector A. Clearly, I can do: for ( int i=0; i < 10; i++ ) { B[0 + 10 * i] = A[i]; } where I've left the zero in 0 + 10 * i to highlight that B uses column-major storage (zero is the row-index). After some shenanigans in CUDA-land tonight, I had a thought that there might be a CPU function to perform a

Correct stride formula for BITMAP

房东的猫 提交于 2019-12-07 22:18:35
问题 Calculating Surface Stride In an uncompressed bitmap, the stride is the number of bytes needed to go from the start of one row of pixels to the start of the next row. The above is from BITMAPINFOHEADER structure and makes absolute sense. The same site gives the following formula to calculate stride though: For uncompressed RGB formats, the minimum stride is always the image width in bytes, rounded up to the nearest DWORD. You can use the following formula to calculate the stride: stride = (((

MPI - Sending segments of an array

情到浓时终转凉″ 提交于 2019-12-05 01:13:09
问题 So I have an array of doubles. I would like to send, say every 5th double, to the receiving process. So essentially, I need a way of sending specific doubles with strides between them. Is there a function to do this, apart from storing the doubles into a send buffer? Would it be better to make my own derived type? 回答1: You should definitely create an MPI data type; it gives the MPI library an opportunity to avoid the extra copy for marshaling from the array, and it's pretty straightforward to

Using Stride in Swift 2.0

左心房为你撑大大i 提交于 2019-12-03 08:16:43
问题 I'm trying to figure out how to use the Stride features in Swift. It seems to have changed again, since Xcode 7.0 beta 6. Previously I could use let strideAmount = stride(from: 0, to: items.count, by: splitSize) let sets = strideAmount.map({ clients[$0..<advance($0, splitSize, items.count)] }) Now, despite the code hint I cannot figure out how to use this feature. Any examples would be helpful thanks. I've looked at examples, but I cannot come to grips with how to use it. All I get from the

Using Stride in Swift 2.0

好久不见. 提交于 2019-12-02 21:58:06
I'm trying to figure out how to use the Stride features in Swift. It seems to have changed again, since Xcode 7.0 beta 6. Previously I could use let strideAmount = stride(from: 0, to: items.count, by: splitSize) let sets = strideAmount.map({ clients[$0..<advance($0, splitSize, items.count)] }) Now, despite the code hint I cannot figure out how to use this feature. Any examples would be helpful thanks. I've looked at examples , but I cannot come to grips with how to use it. All I get from the Apple Docs are limited. Thanks It changed a bit, here is the new syntax: 0.stride(to: 10, by: 2) and

Swift 2.2 decrementing specific for loop in Swift 3

送分小仙女□ 提交于 2019-12-02 07:50:54
I have the task to refactor an iOS app to Swift 3. However, there is a for loop, in C-style, that does more than just looping an array backwards (it's mandatory to be backwards). This is a sample code. The principle is the same. let array = ["hello", "world", nil, "foo", nil, "bar", "Peter Griffin"] var threeLetterWords = 0 for var i = array.count-1; i >= 0 && array[i].characters.count == 3; --i, ++threeLetterWords { } print("Found words: \(threeLetterWords)") // should say `Found words: 2` I tried with stride(from:through:by:) but I can't increment threeLetterWords as it seems important to

It is possible to get an IntPtr from an int[] array?

China☆狼群 提交于 2019-12-01 17:07:27
Greetings. In C#: If I have an int[] array declared like this int[] array = new array[size]; there is an way to get the IntPtr from this array? The thing is that I'm using the EmguCV framework, and there is an constructor to create an image which takes an IntPtr to the pixel data, in order to build an image from an array (int[]). Image<Gray,Int32> result = new Image<Gray,int>(bitmap.Width,bitmap.Height,stride,"**array.toPointer??**"); By the way if someone could told me how to calculate the stride, that would be great. You should be able to do this without unsafe code using GCHandle . Here is