Suggest mpeg compression on video and guide to clear the error mentioned below. Mpeg compression on video

5 views (last 30 days)
Zigzag.m
for x = 0:((rowZigZag/(8*index))-1)
for y = 0:((columnZigZag/(8*index))-1)
Line 21: if(indicationIndex(x+1,y+1) ~= 1)
% Extracts 8x8 block which needs to be processed.
block = inputMatrix((x*8*index)+1:(x+1)*8*index, (y*8*index)+1:(y+1)*8*index);
Encoder.m
Line 217: [currentLumaDC, zigZagCurrentLumaAC] = zigZag(YQuantized, indicationMatrix, 2);
[currentCbDC, zigZagCurrentCbAC] = zigZag(CbQuantized, indicationMatrix, 1);
[currentCrDC, zigZagCurrentCrAC] = zigZag(CrQuantized, indicationMatrix, 1);
Error:
Index in position 2 exceeds array bounds (must not exceed 1).
Error in zigZag (line 21)
if(indicationIndex(x+1,y+1) ~= 1)
Error in Encoder (line 217)
[currentLumaDC, zigZagCurrentLumaAC] = zigZag(YQuantized, indicationMatrix, 2);

Accepted Answer

Piyush Dubey
Piyush Dubey on 15 Sep 2023
Hi Aberna,
I understand that you are attempting to perform mpeg compression on video files but are encountering the “Index in position 2 exceeds array bounds. error.
The error you are experiencing in the "Encoder.m" file suggests that there is an issue with the dimensions of the "indicationIndex" matrix. Specifically, the value y+1 unexpectedly exceeds the range and fails to read the data. To address this issue, the code should be debugged, verifying the state and dimensions of the matrix. You may need to perform reshaping operations to ensure effective data access. Other errors mentioned in the console are likely stemming from the error on line 21.
Please refer to the following MathWorks documentation and File Exchange repository links for more information on MPEG compression and reshaping matrices:
  1. https://www.mathworks.com/help/vision/ug/video-compression.html
  2. https://www.mathworks.com/matlabcentral/fileexchange/11291-mpeg-compression
  3. https://www.mathworks.com/help/matlab/ref/reshape.html
Hope this helps.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!