hedgewars/pas2cSystem.pas
author koda
Sun, 20 Mar 2016 03:08:51 -0400
changeset 11617 b7d5d75469ee
parent 10535 428085a1be6e
child 11648 3bff941c035f
permissions -rw-r--r--
Move pixel format conversion from uVideoRec to AVWrapper This has several benefits, being in C-land allows us to better use libav API and avoid mixing memory allocated from Pascal. Also the C code for the conversion loop generated by GCC or Clang is probably more optimized than by Freepascal. Finally it will simplify code in the future if we are going to enable any other pixel format than yuv420p. Change the coefficients to improve color accuracy during conversion.

system;
{This file contains functions that are external}
type
    uinteger = uinteger;
    Integer = integer;
    LongInt = integer;
    LongWord = uinteger;
    Cardinal = uinteger;
    PtrInt = integer;
    Word = uinteger;
    Byte = integer;
    SmallInt = integer;
    ShortInt = integer;
    Int64 = integer;
    QWord = uinteger;
    GLint = integer;
    GLuint = integer;
    GLenum = integer;

    int = integer;
    size_t = integer;

    pointer = pointer;

    float = float;
    single = float;
    double = float;
    real = float;
    extended = float;
    GLfloat = float;

    boolean = boolean;
    LongBool = boolean;

    string = string;
    shortstring = string;
    ansistring = string;
    widechar = string;

    char = char;
    PChar = ^char;
    PPChar = ^Pchar;
    PWideChar = ^WideChar;

    PByte = ^Byte;
    PWord = ^Word;
    PLongInt = ^LongInt;
    PLongWord = ^LongWord;
    PInteger = ^Integer;

    Handle = integer;

    png_structp = pointer;
    png_size_t = integer;

var
    false, true: boolean;

    ord, Succ, Pred : function : integer;
    inc, dec, Low, High, Lo, Hi : function : integer;

    IOResult : integer;
    exit, break, halt, continue : procedure;

    TextFile, File : Handle;
    FileMode : integer;
    exitcode : integer;
    stdout, stderr : Handle;

    sqrt, cos, sin: function : float;
    pi : float;

    sizeof : function : integer;

    glGetString : function : pchar;

    glBegin, glBindTexture, glBlendFunc, glClear, glClearColor,
    glColor4ub, glColorMask, glColorPointer, glDeleteTextures,
    glDisable, glDisableClientState, glDrawArrays, glEnable,
    glEnableClientState, glEnd, glGenTextures, glGetIntegerv,
    glHint, glLineWidth, glLoadIdentity, glMatrixMode, glPopMatrix,
    glPushMatrix, glReadPixels, glRotatef, glScalef, glTexCoord2f,
    glTexCoordPointer, glTexImage2D, glTexParameterf,
    glTexParameteri, glTranslatef, glVertex2d, glVertexPointer,
    glViewport, glext_LoadExtension, glDeleteRenderbuffersEXT,
    glDeleteFramebuffersEXT, glGenFramebuffersEXT,
    glGenRenderbuffersEXT, glBindFramebufferEXT,
    glBindRenderbufferEXT, glRenderbufferStorageEXT,
    glFramebufferRenderbufferEXT, glFramebufferTexture2DEXT,
    glUniformMatrix4fv, glVertexAttribPointer, glCreateShader,
    glShaderSource, glCompileShader, glGetShaderiv, glGetShaderInfoLog,
    glCreateProgram, glAttachShader, glBindAttribLocation, glLinkProgram,
    glDeleteShader, glGetProgramiv, glGetProgramInfoLog, glUseProgram,
    glUniform1i, glGetUniformLocation, glEnableVertexAttribArray,
    glGetError, glDeleteProgram, glDeleteBuffers,
    glGenBuffers, glBufferData, glBindBuffer, glewInit,
    glUniform4f, glDisableVertexAttribArray, glTexEnvi,
    glLoadMatrixf, glMultMatrixf, glGetFloatv: procedure;

    GL_BGRA, GL_BLEND, GL_CLAMP_TO_EDGE, GL_COLOR_ARRAY,
    GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_DEPTH_COMPONENT,
    GL_DITHER, GL_EXTENSIONS, GL_FALSE, GL_FASTEST, GL_LINEAR,
    GL_LINE_LOOP, GL_LINES, GL_LINE_SMOOTH, GL_LINE_STRIP,
    GL_MAX_TEXTURE_SIZE, GL_MODELVIEW, GL_ONE_MINUS_SRC_ALPHA,
    GL_PERSPECTIVE_CORRECTION_HINT, GL_PROJECTION, GL_QUADS,
    GL_RENDERER, GL_RGB, GL_RGB8, GL_RGBA, GL_RGBA8, GL_SRC_ALPHA, GL_TEXTURE_2D,
    GL_TEXTURE_COORD_ARRAY, GL_TEXTURE_MAG_FILTER,
    GL_TEXTURE_MIN_FILTER, GL_TEXTURE_PRIORITY, GL_TEXTURE_WRAP_S,
    GL_TEXTURE_WRAP_T, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRUE, GL_VENDOR,
    GL_VERSION, GL_VERTEX_ARRAY, GLenum,  GL_FRAMEBUFFER_EXT,
    GL_RENDERBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    GL_COLOR_ATTACHMENT0_EXT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_COMPILE_STATUS,
    GL_INFO_LOG_LENGTH, GL_LINK_STATUS, GL_VERTEX_SHADER, GL_FRAGMENT_SHADER,
    GL_NO_ERROR, GL_ARRAY_BUFFER, GL_STATIC_DRAW, GLEW_OK,
    GL_AUX_BUFFERS, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE, GL_ADD,
    GL_MODELVIEW_MATRIX: integer;

    TThreadId : function : integer;

    _strconcat, _strappend, _strprepend, _chrconcat : function : string;
    _strcompare, _strncompare, _strcomparec, _strncompareA : function : boolean;
    _strconcatA, _strappendA : function : ansistring;

    png_structp, png_set_write_fn, png_get_io_ptr,
    png_get_libpng_ver, png_create_write_struct,
    png_create_info_struct, png_destroy_write_struct,
    png_write_row, png_set_ihdr, png_write_info,
    png_write_end : procedure;

    clear_filelist_hook, add_file_hook, idb_loader_hook, mainloop_hook, drawworld_hook : procedure;
    SDL_InitPatch : procedure;

    PHYSFS_init, PHYSFS_deinit, PHYSFS_mount, PHYSFS_readBytes, PHYSFS_read : function : LongInt;
    PHYSFSRWOPS_openRead, PHYSFSRWOPS_openWrite, PHYSFS_openRead : function : pointer;
    PHYSFS_eof, PHYSFS_close, PHYSFS_exists : function : boolean;
    PHYSFS_getLastError : function : PChar;

    hedgewarsMountPackages, physfsReaderSetBuffer, hedgewarsMountPackage : procedure;
    physfsReader : function : pointer;