changing RGBA to YUV420(nv12) format in decode target

593 views
Skip to first unread message

RYUNHYEON KIM

unread,
Nov 16, 2020, 2:49:52 AM11/16/20
to cobalt-dev
Hi

I try to change from RGBA format to YUV420(NV12) format for reducing memory usage in 360 Video(decode_target)

Since i have exprience implementing 360 video using RGBA format with opengl, I thought it is easy to change to YUV format

But, Video Color is wrong below picture

problem.png

For debugging, I checked  below list

  • I enabled #define SB_HAS_NV12_TEXTURE_SUPPORT 1  
  • My decoder has NV12 output format and I already checked that decoder output and gpu input memory are normal NV12 format.  
Am I missing something like setting configuration? or Could anybody please give me an any advices?  

Regards,
Ryan

Toan Pham

unread,
Nov 16, 2020, 3:12:39 AM11/16/20
to RYUNHYEON KIM, cobalt-dev
What did you specify for your decode target's SbDecodeTargetFormat?

You received this message because you are subscribed to the Google Groups "cobalt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobalt-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobalt-dev/88796c78-66e2-4f28-aa90-623081f73660n%40googlegroups.com.

RYUNHYEON KIM

unread,
Nov 16, 2020, 3:36:42 AM11/16/20
to cobalt-dev
I specified SbDecodeTargetFormat as kSbDecodeTargetFormat2PlaneYUVNV12 

my decode_target code is attached file.


2020년 11월 16일 월요일 오후 5시 12분 39초 UTC+9에 Toan Pham님이 작성:
decode_target_internal.cc

RYUNHYEON KIM

unread,
Nov 16, 2020, 4:27:38 AM11/16/20
to cobalt-dev
In addition, if NV12 format video frame data is organized like below, 

is the SbDecodeTargetInfoPlane's height value Height/2?? 


2020년 11월 16일 월요일 오후 5시 36분 42초 UTC+9에 RYUNHYEON KIM님이 작성:

RYUNHYEON KIM

unread,
Nov 16, 2020, 4:30:59 AM11/16/20
to cobalt-dev
Oh, Sorry I missed attaching picture 

Here is NV12 format 
NV12Format.png
2020년 11월 16일 월요일 오후 6시 27분 38초 UTC+9에 RYUNHYEON KIM님이 작성:

Toan Pham

unread,
Nov 16, 2020, 6:39:42 AM11/16/20
to RYUNHYEON KIM, cobalt-dev
You should be setting your decode target's UV plane info to half the frame height. Could you verify that your UV texture has appropriate information? It looks like your code is creating a full frame texture for UV, but it's unclear whether your decoder generated enough data for that (as opposed to a half-height texture).

RYUNHYEON KIM

unread,
Nov 18, 2020, 11:18:51 PM11/18/20
to cobalt-dev
1. I dumped decoding data and checked it using raw image viewer 
-> decoded data is correct(NV12). NV12 frame is likes below
nv12구조.png

2. According to your advice, I set UV plane height info to half the frame height. ( target->data->info.planes[kSbDecodeTargetPlaneUV].height = params->frame->_height/2; )
-> Image is flipped upside down  

3. While trying to attempt various things, i found that U/V attribute setting is wrong.
So, i fixed that and got result like below (right picture is original frame)
test1.jpg    image-2020-11-03-11-47-55-881.png
-> red & blue is displayed correctly, but white and yellow is wrong

Could you advise on the above result?

Regards,
Ryan

2020년 11월 16일 월요일 오후 8시 39분 42초 UTC+9에 Toan Pham님이 작성:

Toan Pham

unread,
Nov 19, 2020, 5:36:23 PM11/19/20
to RYUNHYEON KIM, cobalt-dev
It looks like your Y channel is being sampled as 0. In order to reproduce the white, yellow, and green colors, you need that channel. However, you can produce red, blue, and magenta without the Y channel.

Vinho Xie

unread,
Nov 14, 2023, 1:52:40 AM11/14/23
to cobalt-dev
  If you want to change the video format for digital files, you can check this post for help, where you will find several ways to change video formats on desktop, mobile, and online.
https://www.leawo.org/entips/change-video-format-1410.html?group=1410  
Reply all
Reply to author
Forward
0 new messages