Skip to content

Commit

Permalink
#2061: remove ugly info method, replace it with more details about th…
Browse files Browse the repository at this point in the history
…e csc / encoder - makes debug output much easier to parse

git-svn-id: https://xpra.org/svn/Xpra/trunk@21112 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 27, 2018
1 parent 0c5ca1b commit 8187200
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 50 deletions.
45 changes: 13 additions & 32 deletions src/xpra/codecs/codec_constants.py
Expand Up @@ -137,51 +137,32 @@ def get_runtime_factor(self):
return max(0, 1.0 - (1.0*ic/mi)**2)
return 1.0

def info(self):
try:
s = str(self.codec_class)
#regexp it?
p = s.find("xpra.codecs.")
if p>=0:
s = s[p+len("xpra.codecs."):]
p = s.find(".encoder.")
if p<0:
p = s.find(".colorspace_converter.")
if p>0:
s = s[:p]
if s=="csc_%s" % self.codec_type:
return self.codec_type
if s=="enc_%s" % self.codec_type:
return self.codec_type
if self.codec_type==s:
return self.codec_type
if s.startswith(self.codec_type):
return s
return "%s:%s" % (self.codec_type, s)
except:
return "%s" % (self.codec_type or self.codec_class)


class video_spec(_codec_spec):

def __init__(self, encoding=None, output_colorspaces=None, has_lossless_mode=False, **kwargs):
_codec_spec.__init__(self, **kwargs)
def __init__(self, encoding, input_colorspace, output_colorspaces, has_lossless_mode,
codec_class, codec_type, **kwargs):
self.encoding = encoding #ie: "h264"
self.input_colorspace = input_colorspace
self.output_colorspaces = output_colorspaces #ie: ["YUV420P" : "YUV420P", ...]
self.has_lossless_mode = has_lossless_mode
self._exported_fields += ["encoding", "output_colorspaces"]

def info(self):
return "%s:%s" % (_codec_spec.info(self), self.encoding)
_codec_spec.__init__(self, codec_class, codec_type, **kwargs)
self._exported_fields += ["encoding", "input_colorspace", "output_colorspaces", "has_lossless_mode"]

def __repr__(self):
return self.info()
return "%s(%s to %s)" % (self.codec_type, self.input_colorspace, self.encoding)


class csc_spec(_codec_spec):

def __init__(self, input_colorspace, output_colorspace, codec_class, codec_type, **kwargs):
self.input_colorspace = input_colorspace
self.output_colorspace = output_colorspace
_codec_spec.__init__(self, codec_class, codec_type, **kwargs)
self._exported_fields += ["input_colorspace", "output_colorspace"]

def __repr__(self):
return "csc:%s" % self.info()
return "%s(%s to %s)" % (self.codec_type, self.input_colorspace, self.output_colorspace)


def main():
Expand Down
3 changes: 2 additions & 1 deletion src/xpra/codecs/csc_libyuv/colorspace_converter.pyx
Expand Up @@ -114,7 +114,8 @@ def get_output_colorspaces(input_colorspace):
def get_spec(in_colorspace, out_colorspace):
assert in_colorspace in IN_COLORSPACES, "invalid input colorspace: %s (must be one of %s)" % (in_colorspace, IN_COLORSPACES)
assert out_colorspace in OUT_COLORSPACES, "invalid output colorspace: %s (must be one of %s)" % (out_colorspace, OUT_COLORSPACES)
return csc_spec(ColorspaceConverter, codec_type=get_type(),
return csc_spec(in_colorspace, out_colorspace,
ColorspaceConverter, codec_type=get_type(),
quality=100, speed=100,
setup_cost=0, min_w=8, min_h=2, can_scale=True,
max_w=MAX_WIDTH, max_h=MAX_HEIGHT)
Expand Down
3 changes: 2 additions & 1 deletion src/xpra/codecs/csc_swscale/colorspace_converter.pyx
Expand Up @@ -245,7 +245,8 @@ def get_spec(in_colorspace, out_colorspace):
#setup cost is very low (usually less than 1ms!)
#there are restrictions on dimensions (8x2 minimum!)
#swscale can be used to scale (obviously)
return csc_spec(ColorspaceConverter, codec_type=get_type(),
return csc_spec(in_colorspace, out_colorspace,
ColorspaceConverter, codec_type=get_type(),
quality=100, speed=60,
setup_cost=20, min_w=8, min_h=2, can_scale=True,
max_w=MAX_WIDTH, max_h=MAX_HEIGHT)
Expand Down
9 changes: 5 additions & 4 deletions src/xpra/codecs/enc_ffmpeg/encoder.pyx
Expand Up @@ -729,10 +729,11 @@ MAX_WIDTH, MAX_HEIGHT = 4096, 4096
def get_spec(encoding, colorspace):
assert encoding in get_encodings(), "invalid encoding: %s (must be one of %s" % (encoding, get_encodings())
assert colorspace in get_input_colorspaces(encoding), "invalid colorspace: %s (must be one of %s)" % (colorspace, get_input_colorspaces(encoding))
return video_spec(encoding=encoding, output_colorspaces=get_output_colorspaces(encoding, colorspace), has_lossless_mode=False,
codec_class=Encoder, codec_type=get_type(),
quality=40, speed=40,
setup_cost=90, width_mask=0xFFFE, height_mask=0xFFFE, max_w=MAX_WIDTH, max_h=MAX_HEIGHT)
return video_spec(encoding=encoding, input_colorspace=colorspace,
output_colorspaces=get_output_colorspaces(encoding, colorspace), has_lossless_mode=False,
codec_class=Encoder, codec_type=get_type(),
quality=40, speed=40,
setup_cost=90, width_mask=0xFFFE, height_mask=0xFFFE, max_w=MAX_WIDTH, max_h=MAX_HEIGHT)


cdef class Encoder(object):
Expand Down
11 changes: 6 additions & 5 deletions src/xpra/codecs/enc_x264/encoder.pyx
Expand Up @@ -418,11 +418,12 @@ def get_spec(encoding, colorspace):
#we can handle high quality and any speed
#setup cost is moderate (about 10ms)
has_lossless_mode = colorspace in ("YUV444P", "BGR", "BGRA", "BGRX", "RGB")
return video_spec(encoding=encoding, output_colorspaces=COLORSPACES[colorspace], has_lossless_mode=has_lossless_mode,
codec_class=Encoder, codec_type=get_type(),
quality=60+40*int(has_lossless_mode), speed=60,
size_efficiency=60,
setup_cost=20, width_mask=0xFFFE, height_mask=0xFFFE, max_w=MAX_WIDTH, max_h=MAX_HEIGHT)
return video_spec(encoding=encoding, input_colorspace=colorspace, output_colorspaces=COLORSPACES[colorspace],
has_lossless_mode=has_lossless_mode,
codec_class=Encoder, codec_type=get_type(),
quality=60+40*int(has_lossless_mode), speed=60,
size_efficiency=60,
setup_cost=20, width_mask=0xFFFE, height_mask=0xFFFE, max_w=MAX_WIDTH, max_h=MAX_HEIGHT)


#maps a log level to one of our logger functions:
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/codecs/enc_x265/encoder.pyx
Expand Up @@ -304,7 +304,7 @@ def get_spec(encoding, colorspace):
#ratings: quality, speed, setup cost, cpu cost, gpu cost, latency, max_w, max_h, max_pixels
#we can handle high quality and any speed
#setup cost is moderate (about 10ms)
return video_spec(encoding=encoding, output_colorspaces=[colorspace],
return video_spec(encoding=encoding, input_colorspace=colorspace, output_colorspaces=[colorspace], has_lossless_mode=False,
codec_class=Encoder, codec_type=get_type(),
min_w=64, min_h=64,
setup_cost=70, width_mask=0xFFFE, height_mask=0xFFFE)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/codecs/nvenc/encoder.pyx
Expand Up @@ -1346,7 +1346,7 @@ def get_spec(encoding, colorspace):
global MAX_SIZE
max_w, max_h = MAX_SIZE.get(encoding, (4096, 4096))
has_lossless_mode = colorspace in ("XRGB", "ARGB", "BGRX", "BGRA" ) and encoding=="h264"
cs = video_spec(encoding=encoding, output_colorspaces=get_COLORSPACES(encoding)[colorspace], has_lossless_mode=LOSSLESS_CODEC_SUPPORT.get(encoding, LOSSLESS_ENABLED),
cs = video_spec(encoding=encoding, input_colorspace=colorspace, output_colorspaces=get_COLORSPACES(encoding)[colorspace], has_lossless_mode=LOSSLESS_CODEC_SUPPORT.get(encoding, LOSSLESS_ENABLED),
codec_class=Encoder, codec_type=get_type(),
quality=60+has_lossless_mode*40, speed=100, setup_cost=80, cpu_cost=10, gpu_cost=100,
#using a hardware encoder for something this small is silly:
Expand Down
11 changes: 6 additions & 5 deletions src/xpra/codecs/vpx/encoder.pyx
Expand Up @@ -315,11 +315,12 @@ def get_spec(encoding, colorspace):
if VPX_ENCODER_ABI_VERSION>=11:
#libvpx 1.5 made some significant performance improvements with vp9:
speed = 40
return video_spec(encoding=encoding, output_colorspaces=[colorspace], has_lossless_mode=has_lossless_mode,
codec_class=Encoder, codec_type=get_type(),
quality=quality, speed=speed,
size_efficiency=60,
setup_cost=20, max_w=max_w, max_h=max_h)
return video_spec(encoding=encoding, input_colorspace=colorspace, output_colorspaces=[colorspace],
has_lossless_mode=has_lossless_mode,
codec_class=Encoder, codec_type=get_type(),
quality=quality, speed=speed,
size_efficiency=60,
setup_cost=20, max_w=max_w, max_h=max_h)


cdef vpx_img_fmt_t get_vpx_colorspace(colorspace) except -1:
Expand Down

0 comments on commit 8187200

Please sign in to comment.