xpra icon
Bug tracker and wiki

Ticket #2828: hack-r210.patch

File hack-r210.patch, 1.8 KB (added by Antoine Martin, 2 months ago)

more correct handling of 10-bit data (hacked: free memleak included)

  • xpra/codecs/dec_avcodec2/decoder.pyx

     
    965965
    966966        cs = self.get_actual_colorspace()
    967967        log("actual_colorspace(%s)=%s", self.actual_pix_fmt, cs)
     968        #log("size: %s, actual size: %s", (self.width, self.height), (self.codec_ctx.width, self.codec_ctx.height))
     969        cdef const unsigned short* shortbuf = NULL
    968970        if cs.find("P")>0:  #ie: GBRP, YUV420P, YUV422P10LE etc
    969971            divs = get_subsampling_divs(cs)
    970972            nplanes = 3
     
    980982                    raise Exception("invalid height divisor %s" % dy)
    981983                stride = av_frame.linesize[i]
    982984                size = height * stride
     985                log.warn("width=%s, height=%s, stride(%s)=%s", self.width, self.height, cs, stride)
    983986                outsize += size
    984987
    985                 out.append(memory_as_pybuffer(<void *>av_frame.data[i], size, True))
     988                if cs=="GBRP10":
     989                    shortbuf = <unsigned short*> av_frame.data[i]
     990                    rotated_buf = <unsigned short*> memalign(size+1024)
     991                    for z in range(size//2):
     992                        rotated_buf[z] = shortbuf[z]<<6
     993                    obuf = memory_as_pybuffer(<void *>rotated_buf, size, True)
     994                else:
     995                    obuf = memory_as_pybuffer(<void *>av_frame.data[i], size, True)
     996                out.append(obuf)
     997                #out.append(memory_as_pybuffer(<void *>av_frame.data[i], size, True))
    986998                strides.append(stride)
    987999                log("decompress_image() read back '%s' plane: %s bytes", cs[i:i+1], size)
    9881000        else: