Skip to content

Commit

Permalink
#4345 handle padded frames
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Sep 4, 2024
1 parent 124baa8 commit 9cb2a66
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xpra/codecs/ffmpeg/decoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,9 @@ cdef class Decoder:
for i in range(3):
_, dy = divs[i]
if dy==1:
plane_height = self.codec_ctx.height
plane_height = height
elif dy==2:
plane_height = (self.codec_ctx.height+1)>>1
plane_height = (height+1)>>1
else:
av_frame_unref(av_frame)
av_frame_free(&av_frame)
Expand All @@ -1006,20 +1006,20 @@ cdef class Decoder:
av_frame_free(&av_frame)
raise RuntimeError("output size is zero!")
# ignore rounding:
if abs(width-self.width)>1 or abs(height-self.height)>1:
if width < self.width or height < self.height:
log.warn(f"Error: {self.encoding} context size mismatch")
log.warn(f" on {self.frames+1} with colorspace {self.colorspace} (actual: {self.get_actual_colorspace()})")
log.warn(f" {self.get_type()} decoder object is configured for {self.width}x{self.height}")
log.warn(f" but AVCodecContext is set to {width}x{height}")
av_frame_unref(av_frame)
av_frame_free(&av_frame)
raise RuntimeError("%s context dimension %ix%i is smaller than the codec's expected size of %ix%i for frame %i" % (
raise RuntimeError("%s frame dimension %ix%i is smaller than the codec context expected size of %ix%i for frame %i" % (
self.encoding, width, height, self.width, self.height, self.frames+1))

bpp = BYTES_PER_PIXEL.get(self.actual_pix_fmt, 0)
cdef AVFrameWrapper framewrapper = AVFrameWrapper()
framewrapper.set_context(self.codec_ctx, av_frame)
cdef object img = AVImageWrapper(0, 0, width, height, out, cs, 24, strides, bpp, nplanes, thread_safe=False)
cdef object img = AVImageWrapper(0, 0, self.width, self.height, out, cs, 24, strides, bpp, nplanes, thread_safe=False)
img.av_frame = framewrapper
self.frames += 1
self.weakref_images.add(img)
Expand Down

0 comments on commit 9cb2a66

Please sign in to comment.