예제 #1
0
 def __init__(self, name):
     Con.Adapter.__init__(
         self,
         Con.Struct(
             name,
             Con.Embed(
                 Con.BitStruct(None, Con.Flag("signed"),
                               Con.Bits("exponent", 15))),
             Con.UBInt64("mantissa")))
def VersionLength(name):
    """A struct for 32 or 64 bit fields, depending on version field."""

    return Con.IfThenElse(name, lambda ctx: ctx["version"] == 0,
                          Con.UBInt32(None), Con.UBInt64(None))
ATOM_MVHD = Con.Struct(
    "mvhd", Con.Byte("version"), Con.String("flags", 3),
    VersionLength("created_mac_UTC_date"),
    VersionLength("modified_mac_UTC_date"), Con.UBInt32("time_scale"),
    VersionLength("duration"), Con.UBInt32("playback_speed"),
    Con.UBInt16("user_volume"), Con.Padding(10),
    Con.Struct("windows", Con.UBInt32("geometry_matrix_a"),
               Con.UBInt32("geometry_matrix_b"),
               Con.UBInt32("geometry_matrix_u"),
               Con.UBInt32("geometry_matrix_c"),
               Con.UBInt32("geometry_matrix_d"),
               Con.UBInt32("geometry_matrix_v"),
               Con.UBInt32("geometry_matrix_x"),
               Con.UBInt32("geometry_matrix_y"),
               Con.UBInt32("geometry_matrix_w")),
    Con.UBInt64("quicktime_preview"), Con.UBInt32("quicktime_still_poster"),
    Con.UBInt64("quicktime_selection_time"),
    Con.UBInt32("quicktime_current_time"), Con.UBInt32("next_track_id"))

ATOM_IODS = Con.Struct(
    "iods", Con.Byte("version"), Con.String("flags", 3), Con.Byte("type_tag"),
    Con.Switch(
        "descriptor", lambda ctx: ctx.type_tag, {
            0x10:
            Con.Struct(
                None,
                Con.StrictRepeater(3, Con.Byte("extended_descriptor_type")),
                Con.Byte("descriptor_type_length"), Con.UBInt16("OD_ID"),
                Con.Byte("OD_profile"), Con.Byte("scene_profile"),
                Con.Byte("audio_profile"), Con.Byte("video_profile"),
                Con.Byte("graphics_profile")),