Download presentation
Presentation is loading. Please wait.
Published byYenny Rachman Modified over 5 years ago
1
Memory Management for Multimedia Signal Processing
Elec4622, Week 2, Term 2 A/Prof. David Taubman
2
Dynamic Arrays In 1-D In 2-D int *C = new int[4];
C[0]=3; C[1]=4; C[2]=1; C[3]=0; In 2-D int **C = new int *[4]; for (int r=0; r < 4; r++) C[r] = new int[5]; (C[1])[3] = 45; … C 3 4 1 C 45
3
Single Block of Memory Keep image contiguous in memory Advantages
int rows=4, cols=5; int *C = new int[rows*cols]; int r=1, c=3; C[cols*r+c] = 45; Advantages usually faster access (better cache utilization) only one memory de-reference operation a pixel’s neighbours have fixed memory offsets relative to the address of the pixel. C 45
4
Making Algorithms Look Natural
Visit pixels 1 by 1 and do local processing: for (r=0; r < rows; r++) for (c=0; c < cols; c++) { int *ipel = input + r*cols + c; int *opel = output + r*cols + c; int avg = ipel[0] / 2 + (ipel[-1] + ipel[1] ipel[-cols] + ipel[cols])/8; *opel = avg; } Can you see any problems?
5
Adding Extra Space Allocate more memory Notice that:
int rows=4, cols=5, stride=cols+2; int *H = new int[(rows+2)*stride]; int *C = handle + stride+1; int r=1, c=3; C[stride*r+c] = 45; ….. delete[] H; Notice that: C points to first real pixel Row and column addresses can be –ve when applied to C H C 45
6
Considerations for Video
Cannot store whole video Keep a moving window, using lists Recycle frames which drop off the window H H C H C frame_idx C frame_idx next frame_idx prev next prev next prev
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.