projects
/
goodguy
/
cinelerra.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lpcm with tsmuxer cleanup by Andrew
[goodguy/cinelerra.git]
/
cinelerra-5.1
/
guicast
/
bccmdl.py
diff --git
a/cinelerra-5.1/guicast/bccmdl.py
b/cinelerra-5.1/guicast/bccmdl.py
index 6b5b9363ee6adc68b03bbcf504b691441ae33fb9..92499b639f2cca8608a0aab25dc8771473168a11 100755
(executable)
--- a/
cinelerra-5.1/guicast/bccmdl.py
+++ b/
cinelerra-5.1/guicast/bccmdl.py
@@
-1,6
+1,14
@@
#!/bin/python
#!/bin/python
+# Retain python2 compatibility
+from __future__ import print_function
+
base = {
base = {
+ "clear": {
+ "i8": { "r": " uint32_t r = bg_r, g = bg_g, b = bg_b;", },
+ "i16": { "r": " uint32_t r = bg_r, g = bg_g, b = bg_b;", },
+ "fp": { "r": " float r = bg_fr, g = bg_fg, b = bg_fb;", },
+ },
"rgb8": {
"i8": {
"r": " uint32_t in = *inp; int r = ((in>>6)&3)*0x55u, g = ((in>>3)&7)*0x24u, b = (in&7)*0x24u;",
"rgb8": {
"i8": {
"r": " uint32_t in = *inp; int r = ((in>>6)&3)*0x55u, g = ((in>>3)&7)*0x24u, b = (in&7)*0x24u;",
@@
-504,7
+512,7
@@
def specialize(fr_cmdl, to_cmdl, fn):
global special
special[(fr_cmdl, to_cmdl)] = fn
global special
special[(fr_cmdl, to_cmdl)] = fn
-add_cmodel( 0, "bc_transparency")
+add_cmodel( 0, "bc_transparency"
, "clr", "clear"
)
add_cmodel( 1, "bc_compressed")
add_cmodel( 2, "bc_rgb8", "i8", "rgb8")
add_cmodel( 1, "bc_compressed")
add_cmodel( 2, "bc_rgb8", "i8", "rgb8")
@@
-558,6
+566,7
@@
add_cmodel(43, "bc_rgbx_float", "fp", "rgbfloat", "xfp")
specialize("bc_rgba8888", "bc_transparency", "XFER_rgba8888_to_transparency")
ctype = {
specialize("bc_rgba8888", "bc_transparency", "XFER_rgba8888_to_transparency")
ctype = {
+ "clr": None,
"i8": "uint8_t",
"i16": "uint16_t",
"fp": "float",
"i8": "uint8_t",
"i16": "uint16_t",
"fp": "float",
@@
-568,6
+577,11
@@
adata = {
"i16": " z_int a=0xffff;",
"fp": " z_float fa=1;",
}
"i16": " z_int a=0xffff;",
"fp": " z_float fa=1;",
}
+cdata = {
+ "i8": " z_int a = bg_a;",
+ "i16": " z_int a = bg_a;",
+ "fp": " z_float fa = bg_fa;",
+}
def has_alpha(nm):
return nm in ["bc_rgba8888", "bc_argb8888", "bc_abgr8888", \
def has_alpha(nm):
return nm in ["bc_rgba8888", "bc_argb8888", "bc_abgr8888", \
@@
-589,7
+603,8
@@
def is_rgb(nm):
"bc_argb8888", "bc_abgr8888", "bc_rgb", "bc_rgb161616", \
"bc_rgba16161616", "bc_rgb_float", "bc_rgba_float", \
"bc_rgb_floatp", "bc_rgba_floatp", "bc_gbrp", \
"bc_argb8888", "bc_abgr8888", "bc_rgb", "bc_rgb161616", \
"bc_rgba16161616", "bc_rgb_float", "bc_rgba_float", \
"bc_rgb_floatp", "bc_rgba_floatp", "bc_gbrp", \
- "bc_rgbx8888", "bc_rgbx16161616", "bc_rgbx_float", ]
+ "bc_rgbx8888", "bc_rgbx16161616", "bc_rgbx_float", \
+ "bc_transparency"]
def is_yuv(nm):
return nm in [ "bc_yuv888", "bc_yuva8888", "bc_yuv161616", \
def is_yuv(nm):
return nm in [ "bc_yuv888", "bc_yuva8888", "bc_yuv161616", \
@@
-608,19
+623,22
@@
def is_float(nm):
def gen_xfer_proto(fd, pfx, cls, fr_cmdl, to_cmdl):
global dtype, ctype
def gen_xfer_proto(fd, pfx, cls, fr_cmdl, to_cmdl):
global dtype, ctype
- print
>>fd, "%svoid %sxfer_%s_to_%s" % (pfx, cls, fr_cmdl[3:], to_cmdl[3:]),
- ityp = dtype[fr_cmdl];
fr_typ = ctype[ityp];
- otyp = dtype[to_cmdl];
to_typ = ctype[otyp];
- print
>>fd, "(unsigned y0, unsigned y1)",
+ print
("%svoid %sxfer_%s_to_%s" % (pfx, cls, fr_cmdl[3:], to_cmdl[3:]), end=' ', file=fd)
+ ityp = dtype[fr_cmdl];
+ otyp = dtype[to_cmdl];
+ print
("(unsigned y0, unsigned y1)", end=' ', file=fd)
def gen_xfer_fn(fd, fr_cmdl, to_cmdl):
def gen_xfer_fn(fd, fr_cmdl, to_cmdl):
- global layout, dtype, adata
+ global layout, dtype, adata
, cdata
ityp = dtype[fr_cmdl]; otyp = dtype[to_cmdl]
if( ityp is None or otyp is None ): return
ityp = dtype[fr_cmdl]; otyp = dtype[to_cmdl]
if( ityp is None or otyp is None ): return
+ fr_typ = ctype[ityp];
+ to_typ = ctype[otyp];
+ if( to_typ is None ): return
# xfr fn header
gen_xfer_proto(fd, "", class_qual, fr_cmdl, to_cmdl);
# xfr fn body
# xfr fn header
gen_xfer_proto(fd, "", class_qual, fr_cmdl, to_cmdl);
# xfr fn body
- print
>>fd, "{"
+ print
("{", file=fd)
# loops / pointer preload
in_xfer = "flat" if not is_planar(fr_cmdl) else \
fr_cmdl[3:] if is_yuv(fr_cmdl) else \
# loops / pointer preload
in_xfer = "flat" if not is_planar(fr_cmdl) else \
fr_cmdl[3:] if is_yuv(fr_cmdl) else \
@@
-628,52
+646,59
@@
def gen_xfer_fn(fd, fr_cmdl, to_cmdl):
out_xfer = "flat" if not is_planar(to_cmdl) else \
to_cmdl[3:] if is_yuv(to_cmdl) else \
"rgbp" if not has_alpha(to_cmdl) else "rgbap"
out_xfer = "flat" if not is_planar(to_cmdl) else \
to_cmdl[3:] if is_yuv(to_cmdl) else \
"rgbp" if not has_alpha(to_cmdl) else "rgbap"
- print >>fd, " xfer_%s_row_out(%s) xfer_%s_row_in(%s)" % \
- (out_xfer, ctype[otyp], in_xfer, ctype[ityp],)
+ print(" xfer_%s_row_out(%s)" % (out_xfer, to_typ), end=' ', file=fd)
+ if( fr_typ is None ):
+ print(" xfer_clear()", end=' ', file=fd)
+ else:
+ print(" xfer_%s_row_in(%s)" % (in_xfer, fr_typ), end=' ', file=fd)
+ print("", file=fd)
# load inp
if( is_float(to_cmdl) and is_yuv(fr_cmdl) ):
# load inp
if( is_float(to_cmdl) and is_yuv(fr_cmdl) ):
- for ic in layout[fr_cmdl]: print
>>fd, "%s" % (base[ic][ityp]['r']),
+ for ic in layout[fr_cmdl]: print
("%s" % (base[ic][ityp]['r']), end=' ', file=fd)
if( ityp == "i8" ):
if( ityp == "i8" ):
- print
>>fd, "\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);",
+ print
("\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", end=' ', file=fd)
elif( ityp == "i16" ):
elif( ityp == "i16" ):
- print
>>fd, "\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);",
+ print
("\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", end=' ', file=fd)
if( has_alpha(fr_cmdl) or has_alpha(to_cmdl) ):
if( not has_alpha(fr_cmdl) ):
if( has_alpha(fr_cmdl) or has_alpha(to_cmdl) ):
if( not has_alpha(fr_cmdl) ):
- print
>>fd, " z_float fa = 1;",
+ print
(" z_float fa = 1;", end=' ', file=fd)
elif( ityp == "i8" ):
elif( ityp == "i8" ):
- print
>>fd, " float fa = fclp(a,256);",
+ print
(" float fa = fclp(a,256);", end=' ', file=fd)
elif( ityp == "i16" ):
elif( ityp == "i16" ):
- print
>>fd, " float fa = fclp(a,65536);",
+ print
(" float fa = fclp(a,65536);", end=' ', file=fd)
else:
else:
- for ic in layout[fr_cmdl]: print
>>fd, "%s" % (base[ic][otyp]['r']),
+ for ic in layout[fr_cmdl]: print
("%s" % (base[ic][otyp]['r']), end=' ', file=fd)
if( has_alpha(to_cmdl) and not has_alpha(fr_cmdl) ):
if( has_alpha(to_cmdl) and not has_alpha(fr_cmdl) ):
- print >>fd, "%s" % (adata[otyp]),
- print >>fd, ""
+ alfa = cdata if fr_typ is None else adata
+ print("%s" % (alfa[otyp]), end=' ', file=fd)
+ print("", file=fd)
# xfer
if( is_rgb(fr_cmdl) and is_yuv(to_cmdl) ):
# xfer
if( is_rgb(fr_cmdl) and is_yuv(to_cmdl) ):
- if( otyp == "i8" ):
- print >>fd, " int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);"
+ if( ityp == "clr" ):
+ print(" int32_t y = r, u = g, v = b;", file=fd)
+ elif( otyp == "i8" ):
+ print(" int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);", file=fd)
elif( otyp == "i16" ):
elif( otyp == "i16" ):
- print
>>fd, " int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);"
+ print
(" int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);", file=fd)
elif( is_yuv(fr_cmdl) and is_rgb(to_cmdl)):
if( otyp == "i8" ):
elif( is_yuv(fr_cmdl) and is_rgb(to_cmdl)):
if( otyp == "i8" ):
- print
>>fd, " int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);"
+ print
(" int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", file=fd)
elif( otyp == "i16" ):
elif( otyp == "i16" ):
- print
>>fd, " int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);"
+ print
(" int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", file=fd)
# blend
if( has_bgcolor(fr_cmdl,to_cmdl) ):
# blend
if( has_bgcolor(fr_cmdl,to_cmdl) ):
- print
>>fd, "%s" % (base["bbg"][otyp]
)
+ print
("%s" % (base["bbg"][otyp]), file=fd
)
elif( has_alpha(fr_cmdl) and not has_alpha(to_cmdl) ):
if( is_rgb(to_cmdl) ):
elif( has_alpha(fr_cmdl) and not has_alpha(to_cmdl) ):
if( is_rgb(to_cmdl) ):
- print
>>fd, "%s" % (base["brgb"][otyp]
)
+ print
("%s" % (base["brgb"][otyp]), file=fd
)
elif( is_yuv(to_cmdl) ):
elif( is_yuv(to_cmdl) ):
- print
>>fd, "%s" % (base["byuv"][otyp]
)
+ print
("%s" % (base["byuv"][otyp]), file=fd
)
# store out
for oc in layout[to_cmdl]:
# store out
for oc in layout[to_cmdl]:
- print
>>fd, "%s" % (base[oc][otyp]['w']),
- print
>>fd, "xfer_end"
- print
>>fd, "}"
- print
>>fd, ""
+ print
("%s" % (base[oc][otyp]['w']), end=' ', file=fd)
+ print
("xfer_end", file=fd)
+ print
("}", file=fd)
+ print
("", file=fd)
# output code file
class_qual = "BC_Xfer::"
# output code file
class_qual = "BC_Xfer::"
@@
-681,9
+706,9
@@
xfn = "xfer/xfer.h"
fd = open(xfn, "w")
xid = "".join([chr(x) if chr(x).isalnum() else '_' for x in range(256)])
xid = "__" + xfn.upper()[xfn.rfind("/")+1:].translate(xid) + "__"
fd = open(xfn, "w")
xid = "".join([chr(x) if chr(x).isalnum() else '_' for x in range(256)])
xid = "__" + xfn.upper()[xfn.rfind("/")+1:].translate(xid) + "__"
-print
>>fd, "#ifndef %s" % xid
-print
>>fd, "#define %s" % xid
-print
>>fd, ""
+print
("#ifndef %s" % xid, file=fd)
+print
("#define %s" % xid, file=fd)
+print
("", file=fd)
xfd = open("bcxfer.h")
fd.write(xfd.read())
xfd.close()
xfd = open("bcxfer.h")
fd.write(xfd.read())
xfd.close()
@@
-693,57
+718,56
@@
for fr_cmdl in cmodels:
for to_cmdl in cmodels:
otyp = dtype[to_cmdl]
if( is_specialized(fr_cmdl, to_cmdl) ):
for to_cmdl in cmodels:
otyp = dtype[to_cmdl]
if( is_specialized(fr_cmdl, to_cmdl) ):
- print
>>fd, " void %s(unsigned y0, unsigned y1);" % (special[(fr_cmdl, to_cmdl)]
)
+ print
(" void %s(unsigned y0, unsigned y1);" % (special[(fr_cmdl, to_cmdl)]), file=fd
)
continue
continue
- if( ityp is None or otyp is None ): continue
+ if( ityp is None or otyp is None
or ctype[otyp] is None
): continue
gen_xfer_proto(fd, " ", "", fr_cmdl, to_cmdl);
gen_xfer_proto(fd, " ", "", fr_cmdl, to_cmdl);
- print
>>fd, ";"
+ print
(";", file=fd)
# end of class definition
# end of class definition
-print
>>fd, "};"
-print
>>fd, ""
-print
>>fd, "#endif"
+print
("};", file=fd)
+print
("", file=fd)
+print
("#endif", file=fd)
fd.close()
xfn = xfn[:xfn.rfind(".h")]
# xfer functions
for fr_cmdl in cmodels:
fd = open(xfn + "_" + fr_cmdl + ".C", "w")
fd.close()
xfn = xfn[:xfn.rfind(".h")]
# xfer functions
for fr_cmdl in cmodels:
fd = open(xfn + "_" + fr_cmdl + ".C", "w")
- print
>>fd, "#include \"xfer.h\""
- print
>>fd, ""
+ print
("#include \"xfer.h\"", file=fd)
+ print
("", file=fd)
for to_cmdl in cmodels:
gen_xfer_fn(fd, fr_cmdl, to_cmdl)
fd.close()
fd = open(xfn + ".C", "w")
# transfer switch
for to_cmdl in cmodels:
gen_xfer_fn(fd, fr_cmdl, to_cmdl)
fd.close()
fd = open(xfn + ".C", "w")
# transfer switch
-print
>>fd, "#include \"xfer.h\""
-print
>>fd, ""
-print
>>fd, "void %sxfer()" % class_qual
-print
>>fd, "{"
+print
("#include \"xfer.h\"", file=fd)
+print
("", file=fd)
+print
("int %sxfer()" % class_qual, file=fd)
+print
("{", file=fd)
mx_no = mx_bcmdl + 1
mx_no = mx_bcmdl + 1
-print
>>fd, " static xfer_fn xfns[%d][%d] = {" % (mx_no, mx_no
)
+print
(" static xfer_fn xfns[%d][%d] = {" % (mx_no, mx_no), file=fd
)
for fr_no in range(mx_no):
fr_cmdl = bcmodels.get(fr_no)
ityp = dtype[fr_cmdl]
for fr_no in range(mx_no):
fr_cmdl = bcmodels.get(fr_no)
ityp = dtype[fr_cmdl]
- print
>>fd, " { // %s" % (fr_cmdl.upper() if ityp else "None"
)
+ print
(" { // %s" % (fr_cmdl.upper() if ityp else "None"), file=fd
)
n = 0
for to_no in range(mx_no):
to_cmdl = bcmodels.get(to_no)
otyp = dtype[to_cmdl]
xfn = special[(fr_cmdl, to_cmdl)] if( is_specialized(fr_cmdl, to_cmdl) ) else \
n = 0
for to_no in range(mx_no):
to_cmdl = bcmodels.get(to_no)
otyp = dtype[to_cmdl]
xfn = special[(fr_cmdl, to_cmdl)] if( is_specialized(fr_cmdl, to_cmdl) ) else \
- "xfer_%s_to_%s" % (fr_cmdl[3:], to_cmdl[3:]) if ( ityp and otyp ) else None
- if( n > 72 ): print
>>fd, ""
; n = 0
- if( n == 0 ): print
>>fd, " ",
; n += 4
+ "xfer_%s_to_%s" % (fr_cmdl[3:], to_cmdl[3:]) if ( ityp and otyp
and ctype[otyp]
) else None
+ if( n > 72 ): print
("", file=fd)
; n = 0
+ if( n == 0 ): print
(" ", end=' ', file=fd)
; n += 4
fn = "&%s%s" % (class_qual, xfn) if( xfn ) else "0"
fn = "&%s%s" % (class_qual, xfn) if( xfn ) else "0"
- print
>>fd, "%s, " % (fn),
+ print
("%s, " % (fn), end=' ', file=fd)
n += len(fn) + 3
n += len(fn) + 3
- print
>>fd, "}, "
-print
>>fd, " }; "
-print
>>fd, " xfn = xfns[in_colormodel][out_colormodel];"
-print
>>fd, " xfer_slices(out_w*out_h/0x80000+1);"
-print
>>fd, "}"
-print
>>fd, ""
-print
>>fd, "#include \"bcxfer.C\""
-print
>>fd, ""
+ print
("}, ", file=fd)
+print
(" }; ", file=fd)
+print
(" xfn = xfns[in_colormodel][out_colormodel];", file=fd)
+print
(" return xfer_slices(out_w*out_h/0x80000+1);", file=fd)
+print
("}", file=fd)
+print
("", file=fd)
+print
("#include \"bcxfer.C\"", file=fd)
+print
("", file=fd)
fd.close()
fd.close()
-