Skip to content

Commit

Permalink
src:Fix YUV to RGB color conversion in NV12 and NV21 formats (NV12、NV…
Browse files Browse the repository at this point in the history
…21 显示问题 #21)

Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Nov 7, 2023
1 parent f5e3a07 commit 9cb8c46
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
16 changes: 13 additions & 3 deletions lang/yuvviewer_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</message>
<message>
<location filename="../src/UI_YUVviewer.ui" line="467"/>
<location filename="../src/YUVviewer.cpp" line="746"/>
<location filename="../src/YUVviewer.cpp" line="760"/>
<source>About</source>
<translation></translation>
</message>
Expand All @@ -96,7 +96,17 @@
<translation></translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="732"/>
<location filename="../src/YUVviewer.cpp" line="712"/>
<source>Open File</source>
<translation></translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="728"/>
<source>Open Folder</source>
<translation></translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="746"/>
<source>1.Select parameters on the main interface.
2.Click Open File or Folder to parse the image data and display the image.
3.Used in the image display interface
Expand All @@ -109,7 +119,7 @@
<translation></translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="747"/>
<location filename="../src/YUVviewer.cpp" line="761"/>
<source>&lt;p&gt;Version&lt;/p&gt;&lt;p&gt;&amp;nbsp;%1&lt;/p&gt;&lt;p&gt;Commit&lt;/p&gt;&lt;p&gt;&amp;nbsp;%2&lt;/p&gt;&lt;p&gt;Author&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;Website&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://github.com/QQxiaoming/YUVviewer&apos;&gt;https://github.com/QQxiaoming&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://gitee.com/QQxiaoming/YUVviewer&apos;&gt;https://gitee.com/QQxiaoming&lt;/a&gt;&lt;/p&gt;</source>
<translation></translation>
</message>
Expand Down
16 changes: 13 additions & 3 deletions lang/yuvviewer_ja_JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</message>
<message>
<location filename="../src/UI_YUVviewer.ui" line="467"/>
<location filename="../src/YUVviewer.cpp" line="746"/>
<location filename="../src/YUVviewer.cpp" line="760"/>
<source>About</source>
<translation>について</translation>
</message>
Expand All @@ -96,7 +96,17 @@
<translation>Qtについて</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="732"/>
<location filename="../src/YUVviewer.cpp" line="712"/>
<source>Open File</source>
<translation>ファイルを開く</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="728"/>
<source>Open Folder</source>
<translation>開いたフォルダ</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="746"/>
<source>1.Select parameters on the main interface.
2.Click Open File or Folder to parse the image data and display the image.
3.Used in the image display interface
Expand All @@ -117,7 +127,7 @@
- 中クリックすると、画像の元のサイズが表示されます。</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="747"/>
<location filename="../src/YUVviewer.cpp" line="761"/>
<source>&lt;p&gt;Version&lt;/p&gt;&lt;p&gt;&amp;nbsp;%1&lt;/p&gt;&lt;p&gt;Commit&lt;/p&gt;&lt;p&gt;&amp;nbsp;%2&lt;/p&gt;&lt;p&gt;Author&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;Website&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://github.com/QQxiaoming/YUVviewer&apos;&gt;https://github.com/QQxiaoming&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://gitee.com/QQxiaoming/YUVviewer&apos;&gt;https://gitee.com/QQxiaoming&lt;/a&gt;&lt;/p&gt;</source>
<translation>&lt;p&gt;バージョン&lt;/p&gt;&lt;p&gt;&amp;nbsp;%1&lt;/p&gt;&lt;p&gt;コミット&lt;/p&gt;&lt;p&gt;&amp;nbsp;%2&lt;/p&gt;&lt;p&gt;開発者&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;ウェブサイト&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://github.com/QQxiaoming/YUVviewer&apos;&gt;https://github.com/QQxiaoming&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://gitee.com/QQxiaoming/YUVviewer&apos;&gt;https://gitee.com/QQxiaoming&lt;/a&gt;&lt;/p&gt;</translation>
</message>
Expand Down
16 changes: 13 additions & 3 deletions lang/yuvviewer_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</message>
<message>
<location filename="../src/UI_YUVviewer.ui" line="467"/>
<location filename="../src/YUVviewer.cpp" line="746"/>
<location filename="../src/YUVviewer.cpp" line="760"/>
<source>About</source>
<translation>关于</translation>
</message>
Expand All @@ -96,7 +96,17 @@
<translation>关于Qt</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="732"/>
<location filename="../src/YUVviewer.cpp" line="712"/>
<source>Open File</source>
<translation>打开文件</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="728"/>
<source>Open Folder</source>
<translation>打开文件夹</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="746"/>
<source>1.Select parameters on the main interface.
2.Click Open File or Folder to parse the image data and display the image.
3.Used in the image display interface
Expand All @@ -117,7 +127,7 @@
- 单击鼠标中键可显示图像的原始尺寸。</translation>
</message>
<message>
<location filename="../src/YUVviewer.cpp" line="747"/>
<location filename="../src/YUVviewer.cpp" line="761"/>
<source>&lt;p&gt;Version&lt;/p&gt;&lt;p&gt;&amp;nbsp;%1&lt;/p&gt;&lt;p&gt;Commit&lt;/p&gt;&lt;p&gt;&amp;nbsp;%2&lt;/p&gt;&lt;p&gt;Author&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;Website&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://github.com/QQxiaoming/YUVviewer&apos;&gt;https://github.com/QQxiaoming&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://gitee.com/QQxiaoming/YUVviewer&apos;&gt;https://gitee.com/QQxiaoming&lt;/a&gt;&lt;/p&gt;</source>
<translation>&lt;p&gt;版本&lt;/p&gt;&lt;p&gt;&amp;nbsp;%1&lt;/p&gt;&lt;p&gt;提交&lt;/p&gt;&lt;p&gt;&amp;nbsp;%2&lt;/p&gt;&lt;p&gt;作者&lt;/p&gt;&lt;p&gt;&amp;nbsp;[email protected]&lt;/p&gt;&lt;p&gt;主页&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://github.com/QQxiaoming/YUVviewer&apos;&gt;https://github.com/QQxiaoming&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;a href=&apos;https://gitee.com/QQxiaoming/YUVviewer&apos;&gt;https://gitee.com/QQxiaoming&lt;/a&gt;&lt;/p&gt;</translation>
</message>
Expand Down
4 changes: 2 additions & 2 deletions src/YUVdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ QList<cv::Mat*> ImageDecoder::nv21(const QString &yuvfilename,int W, int H, int
cv::Mat *rgbImg = new cv::Mat;
yuvImg.create(H*3/2, W, CV_8UC1);
out.readRawData((char *)yuvImg.data,W*H*3/2);
cvtColor(yuvImg, *rgbImg, cv::COLOR_YUV2RGB_NV21);
cvtColor(yuvImg, *rgbImg, cv::COLOR_YUV2RGB_NV12); // NV21
totalframe--;
rgbImglist.insert(rgbImglist.constEnd(), rgbImg);
}
Expand All @@ -143,7 +143,7 @@ QList<cv::Mat*> ImageDecoder::nv12(const QString &yuvfilename,int W, int H, int
cv::Mat *rgbImg = new cv::Mat;
yuvImg.create(H*3/2, W, CV_8UC1);
out.readRawData((char *)yuvImg.data,W*H*3/2);
cvtColor(yuvImg, *rgbImg, cv::COLOR_YUV2RGB_NV12);
cvtColor(yuvImg, *rgbImg, cv::COLOR_YUV2RGB_NV21); // NV12
totalframe--;
rgbImglist.insert(rgbImglist.constEnd(), rgbImg);
}
Expand Down
4 changes: 2 additions & 2 deletions src/YUVviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ void YUVviewer::openFile() {
if(lastPath.isDir()) {
openDir = YUVviewerConfigFile->config_dict.lastPath;
}
QStringList openfile_list = FileDialog::getOpenFileNames(this, "选择文件", openDir, "files(*.yuv *.data *.raw *.png)");
QStringList openfile_list = FileDialog::getOpenFileNames(this, tr("Open File"), openDir, "files(*.yuv *.data *.raw *.png)");
if(openfile_list.size() != 0) {
QFileInfo file(openfile_list[0]);
YUVviewerConfigFile->config_dict.lastPath = file.absolutePath();
Expand All @@ -725,7 +725,7 @@ void YUVviewer::openFolder() {
if(lastPath.isDir()) {
openDir = YUVviewerConfigFile->config_dict.lastPath;
}
QString openfolder_name = FileDialog::getExistingDirectory(this, "选择文件夹", openDir);
QString openfolder_name = FileDialog::getExistingDirectory(this, tr("Open Folder"), openDir);
if (!openfolder_name.isEmpty()) {
YUVviewerConfigFile->config_dict.lastPath = openfolder_name;
QDir dir(openfolder_name);
Expand Down
2 changes: 1 addition & 1 deletion test/640x480_NV12.yuv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/640x480_NV21.yuv

Large diffs are not rendered by default.

0 comments on commit 9cb8c46

Please sign in to comment.