Henrik Kjellander 0f59a88b32 modules/video_processing: refactor interface->include + more.
Moved/renamed:
webrtc/modules/video_processing/main/interface -> webrtc/modules/video_processing/include
webrtc/modules/video_processing/main/source/* -> webrtc/modules/video_processing
webrtc/modules/video_processing/main/test/unit_test -> webrtc/modules/video_processing/test

No downstream code seems to use this module.

BUG=webrtc:5095
TESTED=git cl try -c --bot=android_compile_rel --bot=linux_compile_rel --bot=win_compile_rel --bot=mac_compile_rel --bot=ios_rel --bot=linux_gn_rel --bot=win_x64_gn_rel --bot=mac_x64_gn_rel --bot=android_gn_rel -m tryserver.webrtc
R=pbos@webrtc.org, stefan@webrtc.org

Review URL: https://codereview.webrtc.org/1410663004 .

Cr-Commit-Position: refs/heads/master@{#10697}
2015-11-18 21:31:33 +00:00

46 lines
1.1 KiB
Matlab

function [Y,U,V] = readYUV420file(filename, width, height)
% [Y,U,V] = readYUVfile(filename, width, height)
fid = fopen(filename,'rb');
if fid==-1
error(['Cannot open file ' filename]);
end
% Number of pixels per image
nPx=width*height;
% nPx bytes luminance, nPx/4 bytes U, nPx/4 bytes V
frameSizeBytes = nPx*1.5;
% calculate number of frames
fseek(fid,0,'eof'); % move to end of file
fileLen=ftell(fid); % number of bytes
fseek(fid,0,'bof'); % rewind to start
% calculate number of frames
numFrames = floor(fileLen/frameSizeBytes);
Y=uint8(zeros(height,width,numFrames));
U=uint8(zeros(height/2,width/2,numFrames));
V=uint8(zeros(height/2,width/2,numFrames));
[X,nBytes]=fread(fid, frameSizeBytes, 'uchar');
for k=1:numFrames
% Store luminance
Y(:,:,k)=uint8(reshape(X(1:nPx), width, height).');
% Store U channel
U(:,:,k)=uint8(reshape(X(nPx + (1:nPx/4)), width/2, height/2).');
% Store V channel
V(:,:,k)=uint8(reshape(X(nPx + nPx/4 + (1:nPx/4)), width/2, height/2).');
% Read next frame
[X,nBytes]=fread(fid, frameSizeBytes, 'uchar');
end
fclose(fid);