After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 734156 - androidmedia: doesn't calculate framesize for COLOR_FormatYUV420Planar correctly
androidmedia: doesn't calculate framesize for COLOR_FormatYUV420Planar correctly
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.4.0
Other Windows
: Normal major
: 1.4.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-08-02 01:24 UTC by Howard Wang
Modified: 2014-10-14 07:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Howard Wang 2014-08-02 01:24:08 UTC
In sys/androidmedia/gstamc.c, line 2479


Have this:

    case COLOR_FormatYUV420Planar:{
      if (stride == 0 || slice_height == 0) {
        GST_ERROR ("Stride or slice height is 0");
        return FALSE;
      }

      frame_size =
          stride * slice_height + 2 * (((stride + 1) / 2) * (slice_height +
              1) / 2);
      break;
    }


so for a width(stride)=640, height(slice_height)=480, I think that the frame_size should be 460800 bytes, but the calculation gives 461120 bytes.

bad calculation is

      frame_size = 640*480 + 2 * (((640+1)/2) * (480+1)/2) = 461120 (use integer division)

good calculation is

      frame_size = 640*480 + 2 * ((640+1)/2) * ((480+1)/2) = 460800

I think that the code is missing some parens...

      frame_size =
          stride * slice_height + 2 * ( ((stride + 1) / 2) * ((slice_height +
              1) / 2) );
Comment 1 Sebastian Dröge (slomo) 2014-10-02 07:29:06 UTC
commit 66a4572c125f63f48761d572f99de736754920da
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Thu Oct 2 10:26:43 2014 +0300

    androidmedia: Fix calculation of the frame size for COLOR_FormatYUV420Planar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734156
Comment 2 Sebastian Dröge (slomo) 2014-10-02 07:29:47 UTC
Thanks for reporting this bug and proposing a fix!