Skip to content

Commit

Permalink
remove unecessary codec_spec.max_pixels which prevented dimensions >4…
Browse files Browse the repository at this point in the history
…k from working automatically (via scaling)

git-svn-id: https://xpra.org/svn/Xpra/trunk@4743 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 11, 2013
1 parent 47b588c commit 62f8ca5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/xpra/client/window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ def make_csc(self, src_width, src_height, src_format,
continue
for spec in specs:
if spec.min_w>src_width or spec.min_w>dst_width or \
spec.max_w<src_width or spec.max_w<dst_width or \
spec.max_pixels<max(src_width*src_height, dst_width*dst_height):
spec.max_w<src_width or spec.max_w<dst_width:
log("csc module %s cannot cope with dimensions %sx%s to %sx%s", spec.codec_class, src_width, src_height, dst_width, dst_height)
continue
if not spec.can_scale and (src_width!=dst_width or src_height!=dst_height):
Expand Down
8 changes: 1 addition & 7 deletions src/xpra/codecs/codec_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class codec_spec(object):
def __init__(self, codec_class, codec_type="", encoding=None,
quality=100, speed=100,
setup_cost=50, cpu_cost=100, gpu_cost=0,
min_w=1, min_h=1, max_w=4*1024, max_h=4*1024, max_pixels=4*1024*4*1024,
min_w=1, min_h=1, max_w=4*1024, max_h=4*1024,
can_scale=False,
width_mask=0xFFFF, height_mask=0xFFFF):
self.codec_class = codec_class #ie: xpra.codecs.enc_x264.encoder.Encoder
Expand All @@ -65,7 +65,6 @@ def __init__(self, codec_class, codec_type="", encoding=None,
self.min_h = min_h
self.max_w = max_w
self.max_h = max_h
self.max_pixels = max_pixels
self.width_mask = width_mask
self.height_mask = height_mask
self.can_scale = can_scale
Expand All @@ -76,11 +75,6 @@ def get_runtime_factor(self):
#1.0 means no change:
return 1.0

def can_handle(self, width, height):
return self.max_w>=width and self.max_h>=height \
and self.min_w<=width and self.min_h<=height \
and self.max_pixels>(width*height)

def __str__(self):
return "codec_spec(%s)" % self.__dict__

Expand Down
2 changes: 1 addition & 1 deletion src/xpra/codecs/enc_x264/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def get_colorspaces():
def get_spec(encoding, colorspace):
assert encoding in get_encodings(), "invalid encoding: %s (must be one of %s" % (encoding, get_encodings())
assert colorspace in COLORSPACES, "invalid colorspace: %s (must be one of %s)" % (colorspace, COLORSPACES.keys())
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h, max_pixels
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h
#we can handle high quality and any speed
#setup cost is moderate (about 10ms)
return codec_spec(Encoder, codec_type=get_type(), encoding=encoding, speed=0, setup_cost=50, width_mask=0xFFFE, height_mask=0xFFFE)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/codecs/nvenc/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def get_runtime_factor():
def get_spec(encoding, colorspace):
assert encoding in get_encodings(), "invalid format: %s (must be one of %s" % (format, get_encodings())
assert colorspace in COLORSPACES, "invalid colorspace: %s (must be one of %s)" % (colorspace, COLORSPACES)
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h, max_pixels
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h
cs = codec_spec(Encoder, codec_type=get_type(), encoding=encoding,
quality=80, speed=100, setup_cost=80, cpu_cost=10, gpu_cost=100,
#using a hardware encoder for something this small is silly:
Expand Down
1 change: 0 additions & 1 deletion src/xpra/codecs/vpx/decoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def get_colorspaces():

def get_spec(colorspace):
assert colorspace in COLORSPACES, "invalid colorspace: %s (must be one of %s)" % (colorspace, COLORSPACES)
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h, max_pixels
#quality: we only handle YUV420P but this is already accounted for by get_colorspaces() based score calculations
#setup cost is reasonable (usually about 5ms)
return codec_spec(Decoder, codec_type="vp8", setup_cost=40)
Expand Down
1 change: 0 additions & 1 deletion src/xpra/codecs/vpx/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def get_colorspaces():
def get_spec(encoding, colorspace):
assert encoding in get_encodings(), "invalid encoding: %s (must be one of %s" % (encoding, get_encodings())
assert colorspace in COLORSPACES, "invalid colorspace: %s (must be one of %s)" % (colorspace, COLORSPACES)
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h, max_pixels
#quality: we only handle YUV420P but this is already accounted for by get_colorspaces() based score calculations
#setup cost is reasonable (usually about 5ms)
return codec_spec(Encoder, codec_type=get_type(), encoding=encoding, setup_cost=40)
Expand Down
15 changes: 6 additions & 9 deletions src/xpra/server/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
from xpra.net.protocol import Compressed
from xpra.codecs.codec_constants import get_avutil_enum_from_colorspace, get_subsampling_divs, TransientCodecException
from xpra.codecs.video_helper import getVideoHelper
from xpra.server.window_source import WindowSource, debug, log
from xpra.server.window_source import WindowSource, log
from xpra.server.background_worker import add_work_item
from xpra.log import debug_if_env

debug = debug_if_env(log, "XPRA_VIDEO_DEBUG")


def envint(name, d):
try:
Expand Down Expand Up @@ -160,7 +164,7 @@ def set_client_properties(self, properties):
self.video_scaling = properties.get("encoding.video_scaling", self.video_scaling)
self.uses_swscale = properties.get("encoding.uses_swscale", self.uses_swscale)
WindowSource.set_client_properties(self, properties)
log("set_client_properties(%s) csc_modes=%s, video_scaling=%s, uses_swscale=%s", properties, self.csc_modes, self.video_scaling, self.uses_swscale)
debug("set_client_properties(%s) csc_modes=%s, video_scaling=%s, uses_swscale=%s", properties, self.csc_modes, self.video_scaling, self.uses_swscale)

def unmap(self):
WindowSource.cancel_damage(self)
Expand Down Expand Up @@ -408,11 +412,6 @@ def get_score(self, csc_format, csc_spec, encoder_spec, width, height):
cost" will be lower for pipelines that share components with the
current one.
"""
#first discard if we cannot handle this size:
if csc_spec and not csc_spec.can_handle(width, height):
return -1
if not encoder_spec.can_handle(width, height):
return -1
if self._video_encoder is not None and not self.video_reinit \
and self._video_encoder.get_encoding()==encoder_spec.encoding \
and self._video_encoder.get_type()!=encoder_spec.codec_type:
Expand Down Expand Up @@ -485,8 +484,6 @@ def get_encoder_dimensions(self, csc_spec, encoder_spec, width, height, scaling=
v, u = scaling
enc_width = int(width * v / u) & encoder_spec.width_mask
enc_height = int(height * v / u) & encoder_spec.height_mask
if not encoder_spec.can_handle(enc_width, enc_height):
return width, height
return enc_width, enc_height

def calculate_scaling(self, width, height, max_w=4096, max_h=4096):
Expand Down

0 comments on commit 62f8ca5

Please sign in to comment.