Created
April 7, 2016 10:34
-
-
Save andreaskoepf/410714ee31843cea7f51bd5aff4559c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function YUV422toYUV(input, w, h) | |
local yuv_result = torch.ByteTensor(3, h, w) | |
local x = input:view(h, w, 2) | |
yuv_result[1] = x[{{},{},1}] -- copy Y part | |
local u = yuv_result[2] | |
local v = yuv_result[3] | |
local uv = x[{{},{},2}]:reshape(h,w/2,2) | |
local u_ = uv[{{},{},1}] | |
local v_ = uv[{{},{},2}] | |
u:view(h,w/2, 2)[{{},{},1}] = u_ | |
u:view(h,w/2, 2)[{{},{},2}] = u_ | |
v:view(h,w/2, 2)[{{},{},1}] = v_ | |
v:view(h,w/2, 2)[{{},{},2}] = v_ | |
return yuv_result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment