Coder Social home page Coder Social logo

RGB to YUV420 mistake about openh264lib.net HOT 1 CLOSED

secile avatar secile commented on July 1, 2024
RGB to YUV420 mistake

from openh264lib.net.

Comments (1)

secile avatar secile commented on July 1, 2024

Hello, thank you for your information.

I noticed this problem when I first made this library.
In line 58 of Decoder.cpp, there is a comment 'なぜかuvが逆' (in Japanese)
that means 'I don't know why, but it works if U and V are reversed.'
I thought something wrong, but it's working fine, so I left it as it is.

This time, I investigated the reason. and I found that some little problem makes this issue.

When I encoded PNG images of blue(RGB=0000FF) to h264 movie file, blue element of movie file became RGB=113EFF.
Similarly, I encoded red(RGB=FF0000), then became RGB=CD0000. It is strange. Color is almost same, but the color has changed a little.

before encode(PNG) after encode(h264)
RGB=0000FF
before
RGB=113EFF
after
RGB=FF0000
before
RGB=CD0000
after

I found some problems.

  • In C#, pixel order of Bitmap is 'BGR', but my code assumed that pixel order is 'RGB'.
  • Since element 'B' and 'R' is swapped, V plane and U plane is swapped.
  • Since B-V conversion formula is different from R-U, the color has changed.

I fixed these problems, and test again. I think color changing problem is solved.

before encode(PNG) after encode(h264)
RGB=0000FF
before
RGB=0000FC
blue_fixed
RGB=FF0000
before
RGB=FD0001
red_fixed

I'm currently working on a fix for this issue. After that, I will update my repository.
If you have any comment please let me know.

Thank you.

from openh264lib.net.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.