Comment 5 for bug 453582

Revision history for this message
Andrew Jorgensen (ajorg) wrote :

I modified the code a bit more, moving the pixel-aspect stuff up to the owidth calculation at the top of that section. This makes things work correctly except for the mysterious green line.

I think the way to solve the green line bit is to add one pixel to the videobox instead of to the height or width when the dimensions are odd.

code snippet follows (I commented out the videobox stuff because it causes this green line thing and it's probably not appropriate for many devices (including the N800)).

            # =================================================================
            # Calculate video width/height and add black bars if necessary
            # =================================================================
            wmin, wmax = self.preset.vcodec.width
            hmin, hmax = self.preset.vcodec.height

            owidth, oheight = self.info.videowidth, self.info.videoheight

            if self.info.videocaps[0].has_key("pixel-aspect-ratio"):
                owidth = int(owidth * float(self.info.videocaps[0]["pixel-aspect-ratio"]))

            width, height = owidth, oheight

            # Scale width / height down
            if owidth > wmax:
                width = wmax
                height = int((float(wmax) / owidth) * oheight)
            if height > hmax:
                height = hmax
                width = int((float(hmax) / oheight) * owidth)

            # Add any required padding
            vbox = ""
# if width < wmin and height < hmin:
# wpx = (wmin - width) / 2
# hpx = (hmin - height) / 2
# vbox = "videobox left=%i right=%i top=%i bottom=%i ! " % \
# (-wpx, -wpx, -hpx, -hpx)
# elif width < wmin:
# px = (wmin - width) / 2
# vbox = "videobox left=%i right=%i ! " % (-px, -px)
# elif height < hmin:
# px = (hmin - height) / 2
# vbox = "videobox top=%i bottom=%i ! " % (-px, -px)

            # FIXME Odd widths / heights seem to freeze gstreamer
            if width % 2:
                width += 1
            if height % 2:
                height += 1