OtherCrashOverride / c2_vpcodec

Amlogic S905 hardware h264 compression library
19 stars 10 forks source link

Fixed NV21 Video Pixel Format #2

Open vice opened 7 years ago

vice commented 7 years ago

https://github.com/OtherCrashOverride/c2_vpcodec/blob/355a7f487c3989bc8ac5ccef7ef744d6dcc24a13/libvpcodec.cpp#L139

Could it be useful as a function parameter? It makes more sense to have vl_img_format_t img_format parameter in vl_video_encoder_encode instead of vl_video_encoder_init function. See issue #1.

OtherCrashOverride commented 7 years ago

The codec hardware only supports NV21. Since there is currently no other choice, the value is hardcoded by Amlogic.

vice commented 7 years ago

I have no problem with this but when I tested c2enc with NV12 as you said U and V values where swapped so I checked code and found that this value was fixed in the library.

I compiled a libvpcodec.so version with AMVENC_NV21 replaced with AMVENC_NV12 and with it c2enc encodes NV12 frames correctly. Also I found both versions perform equally.

NV12 format is more usual. I suppose hardware supports at least NV12 and NV21 pixel format.

OtherCrashOverride commented 7 years ago

The difference in NV12 and NV21 is the order of UV data: UV vs VU. My statement about "no other choice" was referring to different color formats such as YUV420 (3 planes), RGB, etc.

Exposing NV12/NV21 would be helpful in circumstances where the source data order can not be changed. Currently, data sources that I have tested offer both so there is no need for the feature.

As mentioned in #1, this library is expected to become obsolete when Amlogic mainlines codec support.