Exemple #1
0
# Texture compression. Kakadu decides the slopes, automatically.

# {{{ Imports

import os
import sys
import display
import math
from GOP import GOP
from arguments_parser import arguments_parser
import io
from shell import Shell as shell
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger(
    "texture_compress__automatic"))  # remove __automatic (some day)
log.setLevel('INFO')
shell.setLogger(log)

# }}}

# {{{ Logging

#logging.basicConfig()
#log = logging.getLogger("texture_compress__automatic")
#log.setLevel('INFO')

# }}}

# {{{ Arguments parsing
Exemple #2
0
#!/bin/sh
''''exec python3 -O -- "$0" ${1+"$@"} # '''
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# {{{ Imports

from shell import Shell as shell
from arguments_parser import arguments_parser
# from defaults import Defaults
import os
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("subband_texture_compress__j2k"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing

parser = arguments_parser(description="Compress texture data using JPEG 2000.")
parser.add_argument("--file",
                    help="File that contains the texture data.",
                    default="")
parser.add_argument("--pictures",
                    help="Number of pictures to compress.",
                    default=3)
parser.pixels_in_x()
parser.pixels_in_y()
Exemple #3
0
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Decompress a temporal subband of texture.

# {{{ Imports

import sys
import os
from GOP import GOP
from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("texture_expand"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

MCTF_TEXTURE_CODEC = os.environ["MCTF_TEXTURE_CODEC"]
LOW = "L"
HIGH = "H"

# {{{ Arguments parsing
parser = arguments_parser(description="Expands the texture.")
parser.GOPs()
parser.pixels_in_x()
parser.pixels_in_y()
parser.SRLs()
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Performs the temporal analysis of a picture sequence. Generates a
# series of files that will later be encoded.

import os
import sys
from GOP import GOP
from arguments_parser import arguments_parser
from shell import Shell as shell
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("analyze"))
log.setLevel('ERROR')
shell.setLogger(log)

MAX_SEARCH_RANGE = 128

parser = arguments_parser(description="Temporal analysis of a picture sequence.")
parser.always_B()
parser.block_overlaping()
parser.block_size()
parser.min_block_size()
parser.border_size()
parser.GOPs()
parser.pixels_in_x()
parser.pixels_in_y()
parser.search_range()
parser.subpixel_accuracy()
Exemple #5
0
#!/bin/sh
''''exec python3 -O -- "$0" ${1+"$@"} # '''
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Decompression of the motin vector fields using J2K.

# {{{ Imports

from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("subband_motion_expand__j2k"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Defs

COMPONENTS = 4
BYTES_PER_COMPONENT = 2
BITS_PER_COMPONENT = BYTES_PER_COMPONENT * 8
spatial_dwt_levels = 0  # 1 # SRLs - 1

# }}}

# {{{ Arguments parsing
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# The MCTF project has been supported by the Junta de Andalucía through
# the Proyecto Motriz "Codificación de Vídeo Escalable y su Streaming
# sobre Internet" (P10-TIC-6548).

#  Iteration of the temporal transform.

from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("analyze_step"))
log.setLevel('ERROR')
shell.setLogger(log)

parser = arguments_parser(description="Performs a temporal analysis step.")
parser.add_argument("--pictures",
                    help="number of pictures to analyze",
                    default=33)
parser.search_range()
parser.subpixel_accuracy()
parser.update_factor()
parser.pixels_in_x()
parser.pixels_in_y()
parser.add_argument("--temporal_subband",
                    help="number of the temporal subband.",
                    default=0)
parser.always_B()
import sys
from GOP import GOP
from arguments_parser import arguments_parser
import io
import operator
from shell import Shell as shell
from colorlog import ColorLog
import logging

import os
import math
import subprocess as sub
from subprocess import check_call
from subprocess import CalledProcessError

log = ColorLog(logging.getLogger("transcode_quality"))
log.setLevel('DEBUG')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing

parser = arguments_parser(
    description="Transcodes in quality a MCJ2K sequence.")
parser.GOPs()
parser.add_argument("--keep_layers",
                    help="Number of quality layers to output",
                    default=16)
parser.TRLs()
parser.layers()
#!/bin/sh
''''exec python3 -O -- "$0" ${1+"$@"} # '''
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Compression of the motion vector fields using J2K.

# {{{ imports

from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("subband_motion_compress__j2k"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Defs

COMPONENTS = 4
BYTES_PER_COMPONENT = 2
BITS_PER_COMPONENT = BYTES_PER_COMPONENT * 8
spatial_dwt_levels = 0  # 1 # SRLs - 1

# }}}

# {{{ Arguments parsing
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

#
#  Compresses motion data.
#

import os
import sys
from GOP import GOP
from shell import Shell as shell
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("motion_compress"))
log.setLevel('ERROR')
shell.setLogger(log)

# {{{ Logging

import logging

logging.basicConfig()
log = logging.getLogger("motion_compress")
log.setLevel('ERROR')

# }}}

MCTF_MOTION_CODEC = os.environ["MCTF_MOTION_CODEC"]

# {{{ Arguments parsing
Exemple #10
0
#  information, to produce the Output.

# }}}

# {{{ Importing

import sys
from GOP import GOP
from arguments_parser import arguments_parser
import io
import operator
from shell import Shell as shell
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("transcode_quality"))
log.setLevel('DEBUG')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing
parser = arguments_parser(
    description="Transcodes in quality a MCJ2K sequence.")
parser.GOPs()
parser.add_argument("--keep_layers",
                    help="Number of quality layers to output",
                    default=16)
parser.TRLs()
parser.layers()
parser.add_argument("--destination",
# Output: truncated subband.

# {{{ Importing

import sys
from GOP import GOP
from arguments_parser import arguments_parser
import io
import operator
import math
from shell import Shell as shell
from colorlog import ColorLog
import logging
import os

log = ColorLog(logging.getLogger("transcode_quality_subband"))
log.setLevel('INFO')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing

parser = arguments_parser(description="Transcodes in quality a subband.")
parser.add_argument("--subband",
                    help="Subband prefix (for example, \"L_3\")",
                    default="")
parser.add_argument("--layers",
                    help="Number of quality layers to output",
                    default=8)
parser.add_argument("--pictures",
# -*- coding: iso-8859-15 -*-

# Decodes a subband of texture.

# {{{ Imports

import sys
import math
import struct
import os
from arguments_parser import arguments_parser
from shell import Shell as shell
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("subband_texture_expand__j2k"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing

parser = arguments_parser(description="Decodes a subband of texture.")
parser.add_argument("--file",
                    help="File that contains the LFB or HFB data.",
                    default="")
parser.add_argument("--pictures",
                    help="Number of pictures to expand.",
                    default=1)
parser.pixels_in_x()
Exemple #13
0
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# {{{ Importing

import os
from GOP import GOP
from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("motion_expand"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing
parser = arguments_parser(description="Expands the motion data.")
parser.GOPs()
parser.TRLs()
parser.block_size()
parser.pixels_in_x()
parser.pixels_in_y()

args = parser.parse_known_args()[0]

block_size = int(args.block_size)
log.info("block_size={}".format(block_size))
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Iterates temporal inverse transform.

from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("synthesize_step"))
log.setLevel('ERROR')
shell.setLogger(log)

parser = arguments_parser(
    description="Performs a step of the temporal synthesis.")
parser.block_overlaping()
parser.block_size()
parser.add_argument("--pictures",
                    help="Number of pictures to synthesize.",
                    default=1)
parser.pixels_in_x()
parser.pixels_in_y()
parser.search_range()
parser.subpixel_accuracy()
parser.add_argument("--temporal_subband",
                    help="Iteration of the temporal transform.",
                    default=0)
parser.update_factor()

args = parser.parse_known_args()[0]
def test():

    # get the name of the log (to make changes)
    log = ColorLog(root='test_colorlog')

    # show the standard levels
    print('[info]an informational message')
    print('[warn]an warning message')
    print('[alarm]an alarm')
    print('[debug]a debugging message')
    print('basic printing')

    # add a personal level
    log.add_level('mine', foreground='magenta')
    print('[mine]personal message')

    # change the formatting of an existing level
    log['info']['underline'] = True
    print('[info]a changed, informational message')

    # change the color of an existing level
    log['info']['foreground'] = 'white'
    print('[info]another changed, informational message')

    # turn off the ascii logging
    log.logging = False
    print('[warn]hide a message from the logfile, but show to terminal')
    log.logging = True  # ok turn it back on

    # turn off the STDOUT
    log.printing = False
    print('suppressed STDout')
    log.printing = True
    print("and... we're back")

    # maybe you don't like the timestamps?  turn them off:
    log.timestamp = False
    print('[info]no timestamps now')

    # you can even close, and reopen the file
    log.close()
    print('nothing gets logged, since the file is closed')
    log.reopen()
    print("and we're back after closing")

    # you can disable certain modes.
    log.disable('debug')  # turns off the debugging level
    print("[debug]nothing happened, since this is off")
    # well, there's an issue yet to be dealt with where it prints a blank line.

    # it works with tqdm, sort-of
    import tqdm
    import inspect
    import time
    inspect.builtins.print = tqdm.tqdm.write  # need to do this :(

    for i in tqdm.tqdm(range(10)):
        time.sleep(0.1)
        print('[info]{}'.format(i))
Exemple #16
0
#
# 0 1 2 3 4 5 6 7 8
# 0               8 L_3
#         4         H_3
#     2       6     H_2
#   1   3   5   7   H_1

import sys
import io
from GOP import GOP
from arguments_parser import arguments_parser
import os
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("info"))
log.setLevel('INFO')

parser = arguments_parser(description="Show information.")
parser.add_argument("--FPS", help="Frames Per Second", default=30)
parser.GOPs()
parser.TRLs()

args = parser.parse_known_args()[0]
FPS = int(args.FPS)
GOPs = int(args.GOPs)
TRLs = int(args.TRLs)

gop = GOP()
GOP_size = gop.get_size(TRLs)
pictures = GOP_size * (GOPs - 1) + 1
Exemple #17
0
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Copy MCTF structure to a different place.

import sys
import io
from GOP import GOP
from arguments_parser import arguments_parser
import traceback
from shell import Shell as shell
import os
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("copy"))
log.setLevel('INFO')
shell.setLogger(log)

parser = arguments_parser(description="Copy MCTF structure.")
parser.GOPs()
parser.TRLs()
parser.add_argument("--destination",
                    help="destination directory (must exist)",
                    default="/tmp")

args = parser.parse_known_args()[0]
GOPs = int(args.GOPs)
TRLs = int(args.TRLs)
destination = args.destination
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Create a file with texture where each pixel is 128.

import sys
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging
#import colorlog
import struct

log = ColorLog(logging.getLogger("create_zero_texture"))
log.setLevel('ERROR')

parser = arguments_parser(
    description="Creates a \"empty\" (unsigned char = 128) texture image file."
)
parser.add_argument("--file",
                    help="File that contains the texture.",
                    default="empty.pgm")
parser.pixels_in_x()
parser.pixels_in_y()

args = parser.parse_known_args()[0]

file = args.file

pixels_in_x = int(args.pixels_in_x)
log.info("pixels_in_x={}".format(pixels_in_x))
Exemple #19
0
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# Compression of a sequence of pictures.

# {{{ Importing

import os
from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("compress"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing

parser = arguments_parser(
    description="Encodes a sequence of pictures into a MCJ2K stream")
parser.always_B()
parser.block_overlaping()
parser.block_size()
parser.border_size()
parser.GOPs()
parser.min_block_size()
#parser.motion_layers()
#parser.motion_quantization()
Exemple #20
0
from colorlog import ColorLog
import logging
from shell import Shell as shell

log = ColorLog(logging.getLogger(
    "texture_compress__automatic"))  # remove __automatic (some day)
log.setLevel('INFO')
shell.setLogger(log)

for i in range(352 // 2):
    shell.run("convert -size 352x288 xc:skyblue " +
              "-fill white -stroke black -draw \"circle " + str(42 + i) +
              ",42 " + str(74 + i) + ",42\" /tmp/circle" + str('%03d' % i) +
              ".png")

shell.run("ffmpeg -i /tmp/circle%3d.png /tmp/out.avi")
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-

# {{{ Imports

import sys
from GOP import GOP
from shell import Shell as shell
from arguments_parser import arguments_parser
from colorlog import ColorLog
import logging

log = ColorLog(logging.getLogger("expand"))
log.setLevel('ERROR')
shell.setLogger(log)

# }}}

# {{{ Arguments parsing
parser = arguments_parser(
    description="Decodes a MCJ2K stream into a sequence of pictures.")
parser.block_size()
parser.block_overlaping()
parser.border_size()
parser.GOPs()
parser.min_block_size()
parser.pixels_in_x()
parser.pixels_in_y()
parser.search_range()
parser.SRLs()
#parser.add_argument("--subband_layers",