Changeset 3559


Ignore:
Timestamp:
Mar 22, 2013, 10:45:30 PM (7 years ago)
Author:
gah
Message:
  • Clean up unused variable warnings.
  • Remove use of ffmpeg libraries from nanovis. This should make it easier to maintain (don't have to keep up with all the backward incompatible changes to the ffmpeg library).
Location:
trunk/packages/vizservers/nanovis
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Command.cpp

    r3505 r3559  
    4040#include <assert.h>
    4141#include <stdlib.h>
    42 
     42#include <unistd.h>                     /* Needed for getpid, gethostname,
     43                                         * write, etc. */
    4344#include <tcl.h>
    4445
     
    5556#include "CmdProc.h"
    5657#include "Trace.h"
    57 
    5858#ifdef PLANE_CMD
    5959#include "PlaneRenderer.h"
     
    8181  0.25  0 1 1\n\
    8282  0.50  0 1 0\n\
    83   0.75  1 1 0\n\
     83   0.75  1 1 0\n\
    8484  1.00  1 0 0\n\
    8585} {\n\
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r3502 r3559  
    55 */
    66#include <assert.h>
     7#define _OPEN_SYS
     8#include <fcntl.h>
     9#define _XOPEN_SOURCE_EXTENDED 1
     10#include <sys/uio.h>
     11#include <sys/stat.h>
    712#include <stdlib.h>
    813#include <stddef.h>
    914#include <limits.h>
    1015#include <stdint.h>
     16#include <unistd.h>
    1117#include <poll.h>
    12 
    1318#include <tcl.h>
    1419
     
    2328
    2429#include "nvconf.h"
    25 
    26 #if defined(HAVE_LIBAVCODEC) || defined(HAVE_LIBAVFORMAT)
    27 #define HAVE_FFMPEG 1
    28 #endif
    29 
    30 #ifdef HAVE_FFMPEG
    31 #include "RpAVTranslate.h"
    32 #endif
    3330
    3431#include "nanovis.h"
     
    163160FlowParticles::render()
    164161{
    165     TRACE("rendering particles %s", _name);
    166     TRACE("rendering particles %s axis=%d", _name, _sv.position.axis);
    167     TRACE("rendering particles %s position=%g", _name, _sv.position.value);
    168     TRACE("rendering particles %s position=%g", _name,
    169           FlowCmd::GetRelativePosition(&_sv.position));
    170 
    171162    _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
    172163    _rendererPtr->setAxis(_sv.position.axis);
     
    243234    }
    244235
    245     TRACE("Box model bounds: (%g,%g,%g) - (%g,%g,%g)", x0, y0, z0, x1, y1, z1);
    246 
    247236    Vector3f modelMin(x0, y0, z0);
    248237    Vector3f modelMax(x1, y1, z1);
     
    267256        if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z;
    268257    }
    269 
    270     TRACE("Box world bounds: (%g,%g,%g) - (%g,%g,%g)",
    271           bboxMin.x, bboxMin.y, bboxMin.z,
    272           bboxMax.x, bboxMax.y, bboxMax.z);
    273258}
    274259
     
    276261FlowBox::Render(Volume *vol)
    277262{
    278     TRACE("Rendering box %s", _name);
    279 
    280263    glPushAttrib(GL_ENABLE_BIT);
    281264
     
    301284    max.z = vol->zAxis.max();
    302285
    303     TRACE("box is %g,%g %g,%g %g,%g",
    304           _sv.corner1.x, _sv.corner2.x,
    305           _sv.corner1.y, _sv.corner2.y,
    306           _sv.corner1.z, _sv.corner2.z);
    307     TRACE("world is %g,%g %g,%g %g,%g",
    308           min.x, max.x, min.y, max.y, min.z, max.z);
    309 
    310286    float x0, y0, z0, x1, y1, z1;
    311287    x0 = y0 = z0 = 0.0f;
     
    323299        z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
    324300    }
    325     TRACE("rendering box %g,%g %g,%g %g,%g", x0, x1, y0, y1, z0, z1);
    326 
    327301    glColor4d(_sv.color.r, _sv.color.g, _sv.color.b, _sv.color.a);
    328302    glLineWidth(_sv.lineWidth);
     
    462436        }
    463437    }
    464     TRACE("in Render before boxes %s", _name);
    465438    RenderBoxes();
    466439}
     
    612585{
    613586    if (_volPtr != NULL) {
    614         TRACE("from ScaleVectorField volId=%s", _volPtr->name());
    615587        NanoVis::removeVolume(_volPtr);
    616588        _volPtr = NULL;
     
    694666    FlowBox *boxPtr;
    695667    for (boxPtr = FirstBox(&iter); boxPtr != NULL; boxPtr = NextBox(&iter)) {
    696         TRACE("found box %s", boxPtr->name());
    697668        if (boxPtr->visible()) {
    698669            boxPtr->Render(_volPtr);
     
    748719    volPtr->zAxis.setRange(_dataPtr->zMin(), _dataPtr->zMax());
    749720
    750     TRACE("min=%g %g %g max=%g %g %g mag=%g %g",
    751           NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,
    752           NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,
    753           NanoVis::magMin, NanoVis::magMax);
    754 
    755721    volPtr->disableCutplane(0);
    756722    volPtr->disableCutplane(1);
     
    786752    const char *fileName;
    787753    fileName = Tcl_GetString(objv[3]);
    788     TRACE("Flow loading data from file %s", fileName);
    789754
    790755    int nComponents;
     
    830795        delete u2dPtr;
    831796    } else {
    832         TRACE("header is %.14s", buf.bytes());
    833797        if (!dataPtr->importDx(result, nComponents, length, bytes)) {
    834798            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     
    857821    Rappture::Outcome result;
    858822
    859     TRACE("Flow Data Loading");
    860 
    861823    int nBytes;
    862824    if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) {
     
    882844    }
    883845    Rappture::Buffer buf;
    884     TRACE("Flow Data Loading %d %d", nBytes, nComponents);
    885846    if (GetDataStream(interp, buf, nBytes) != TCL_OK) {
    886847        return TCL_ERROR;
     
    913874        delete u2dPtr;
    914875    } else {
    915         TRACE("header is %.14s", buf.bytes());
    916876        if (!dataPtr->importDx(result, nComponents, length, bytes)) {
    917877            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     
    925885        return TCL_ERROR;
    926886    }
    927     TRACE("nx = %d ny = %d nz = %d", dataPtr->xNum(), dataPtr->yNum(), dataPtr->zNum());
    928     TRACE("x0 = %lg y0 = %lg z0 = %lg", dataPtr->xMin(), dataPtr->yMin(), dataPtr->zMin());
    929     TRACE("lx = %lg ly = %lg lz = %lg",
    930           dataPtr->xMax() - dataPtr->xMin(),
    931           dataPtr->yMax() - dataPtr->yMin(),
    932           dataPtr->zMax() - dataPtr->zMin());
    933     TRACE("dx = %lg dy = %lg dz = %lg",
    934           dataPtr->xNum() > 1 ? (dataPtr->xMax() - dataPtr->xMin())/(dataPtr->xNum()-1) : 0,
    935           dataPtr->yNum() > 1 ? (dataPtr->yMax() - dataPtr->yMin())/(dataPtr->yNum()-1) : 0,
    936           dataPtr->zNum() > 1 ? (dataPtr->zMax() - dataPtr->zMin())/(dataPtr->zNum()-1) : 0);
    937     TRACE("magMin = %lg magMax = %lg",
    938           dataPtr->magMin(), dataPtr->magMax());
    939887    flowPtr->data(dataPtr);
    940888    {
     
    10931041{
    10941042    flags &= ~MAP_FLOWS;
    1095     TRACE("Enter");
    10961043
    10971044    /*
     
    11381085    }
    11391086
    1140     TRACE("MapFlows magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax);
    1141 
    11421087    /*
    11431088     * Step 2. Generate the vector field from each data set.
     
    11671112                       bool onlyVisible)
    11681113{
    1169     TRACE("Enter");
    1170 
    11711114    min.set(FLT_MAX, FLT_MAX, FLT_MAX);
    11721115    max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     
    12071150        for (box = flow->FirstBox(&iter); box != NULL;
    12081151             box = flow->NextBox(&iter)) {
    1209             TRACE("found box %s", box->name());
    12101152            if (!onlyVisible || box->visible()) {
    12111153                Vector3f fbmin, fbmax;
     
    19541896}
    19551897
    1956 #ifdef HAVE_FFMPEG
    1957 
    19581898/**
    19591899 * \brief Convert a Tcl_Obj representing the video format into its
     
    19751915                      char *record, int offset, int flags)
    19761916{
    1977     Rappture::AVTranslate::VideoFormats *formatPtr =
    1978         (Rappture::AVTranslate::VideoFormats *)(record + offset);
     1917    Tcl_Obj **formatObjPtr = (Tcl_Obj **)(record + offset);
     1918    Tcl_Obj *fmtObjPtr;
    19791919    const char *string;
    19801920    char c;
    1981 
    1982     string = Tcl_GetString(objPtr);
     1921    int length;
     1922
     1923    string = Tcl_GetStringFromObj(objPtr, &length);
    19831924    c = string[0];
    1984     if ((c == 'm') && (strcmp(string, "mpeg") == 0)) {
    1985         *formatPtr =  Rappture::AVTranslate::MPEG1;
    1986     } else if ((c == 't') && (strcmp(string, "theora") == 0)) {
    1987         *formatPtr = Rappture::AVTranslate::THEORA;
    1988     } else if ((c == 'm') && (strcmp(string, "mov") == 0)) {
    1989         *formatPtr = Rappture::AVTranslate::QUICKTIME;
     1925    if ((c == 'm') && (length > 1) &&
     1926        (strncmp(string, "mpeg", length) == 0)) {
     1927        fmtObjPtr =  Tcl_NewStringObj("mpeg1video", 10);
     1928    } else if ((c == 't') && (strncmp(string, "theora", length) == 0)) {
     1929        fmtObjPtr =  Tcl_NewStringObj("theora", 6);
     1930    } else if ((c == 'm') && (length > 1) &&
     1931               (strncmp(string, "mov", length) == 0)) {
     1932        fmtObjPtr =  Tcl_NewStringObj("mov", 3);
    19901933    } else {
    19911934        Tcl_AppendResult(interp, "bad video format \"", string,
    19921935                         "\": should be mpeg, theora, or mov", (char*)NULL);
    1993     }
    1994     return TCL_ERROR;
    1995 }
    1996 
    1997 struct FlowVideoValues {
     1936        return TCL_ERROR;
     1937    }
     1938    if (*formatObjPtr != NULL) {
     1939        Tcl_DecrRefCount(*formatObjPtr);
     1940    }
     1941    Tcl_IncrRefCount(fmtObjPtr);
     1942    *formatObjPtr = fmtObjPtr;
     1943    return TCL_OK;
     1944}
     1945
     1946struct FlowVideoSwitches {
    19981947    float frameRate;         /**< Frame rate */
    19991948    int bitRate;             /**< Video bitrate */
    20001949    int width, height;       /**< Dimensions of video frame. */
    2001     int nFrames;
    2002     Rappture::AVTranslate::VideoFormats format;
     1950    int numFrames;
     1951    Tcl_Obj *formatObjPtr;
    20031952};
    20041953
     
    20101959Rappture::SwitchSpec FlowCmd::videoSwitches[] = {
    20111960    {Rappture::SWITCH_INT, "-bitrate", "value",
    2012      offsetof(FlowVideoValues, bitRate), 0},
     1961     offsetof(FlowVideoSwitches, bitRate), 0},
    20131962    {Rappture::SWITCH_CUSTOM, "-format", "string",
    2014      offsetof(FlowVideoValues, format), 0, 0, &videoFormatSwitch},
     1963     offsetof(FlowVideoSwitches, formatObjPtr), 0, 0, &videoFormatSwitch},
    20151964    {Rappture::SWITCH_FLOAT, "-framerate", "value",
    2016      offsetof(FlowVideoValues, frameRate), 0},
     1965     offsetof(FlowVideoSwitches, frameRate), 0},
    20171966    {Rappture::SWITCH_INT, "-height", "integer",
    2018      offsetof(FlowVideoValues, height), 0},
     1967     offsetof(FlowVideoSwitches, height), 0},
    20191968    {Rappture::SWITCH_INT, "-numframes", "count",
    2020      offsetof(FlowVideoValues, nFrames), 0},
     1969     offsetof(FlowVideoSwitches, numFrames), 0},
    20211970    {Rappture::SWITCH_INT, "-width", "integer",
    2022      offsetof(FlowVideoValues, width), 0},
     1971     offsetof(FlowVideoSwitches, width), 0},
    20231972    {Rappture::SWITCH_END}
    20241973};
    20251974
    2026 static int
    2027 FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc,
    2028             Tcl_Obj *const *objv)
     1975#ifdef HAVE_FFMPEG
     1976
     1977static int
     1978ppmWriteToFile(Tcl_Interp *interp, const char *path, FlowVideoSwitches *switchesPtr)
     1979{
     1980    int f;
     1981   
     1982    /* Open the named file for writing. */
     1983    f = creat(path, 0600);
     1984    if (f < 0) {
     1985        Tcl_AppendResult(interp, "can't open temporary image file \"", path,
     1986                         "\": ", Tcl_PosixError(interp), (char *)NULL);
     1987        return TCL_ERROR;
     1988    }
     1989    // Generate the PPM binary file header
     1990    char header[200];
     1991#define PPM_MAXVAL 255
     1992    sprintf(header, "P6 %d %d %d\n", switchesPtr->width, switchesPtr->height,
     1993        PPM_MAXVAL);
     1994
     1995    size_t header_length = strlen(header);
     1996    size_t wordsPerRow = (switchesPtr->width * 24 + 31) / 32;
     1997    size_t bytesPerRow = wordsPerRow * 4;
     1998    size_t rowLength = switchesPtr->width * 3;
     1999    size_t numRecords = switchesPtr->height + 1;
     2000
     2001    struct iovec *iov;
     2002    iov = (struct iovec *)malloc(sizeof(struct iovec) * numRecords);
     2003
     2004    // Add the PPM image header.
     2005    iov[0].iov_base = header;
     2006    iov[0].iov_len = header_length;
     2007
     2008    // Now add the image data, reversing the order of the rows.
     2009    int y;
     2010    unsigned char *srcRowPtr = NanoVis::screenBuffer;
     2011    /* Reversing the pointers for the image rows.  PPM is top-to-bottom. */
     2012    for (y = switchesPtr->height; y >= 1; y--) {
     2013        iov[y].iov_base = srcRowPtr;
     2014        iov[y].iov_len = rowLength;
     2015        srcRowPtr += bytesPerRow;
     2016    }
     2017    if (writev(f, iov, numRecords) < 0) {
     2018        Tcl_AppendResult(interp, "writing image to \"", path, "\" failed: ",
     2019                         Tcl_PosixError(interp), (char *)NULL);
     2020        free(iov);
     2021        close(f);
     2022        return TCL_ERROR;
     2023    }
     2024    close(f);
     2025    free(iov);
     2026    return TCL_OK;
     2027}
     2028
     2029static int
     2030MakeImageFiles(Tcl_Interp *interp, char *tmpFileName,
     2031               FlowVideoSwitches *switchesPtr, bool *cancelPtr)
    20292032{
    20302033    struct pollfd pollResults;
    2031     int timeout;
    2032 
    20332034    pollResults.fd = fileno(NanoVis::stdin);
    20342035    pollResults.events = POLLIN;
    2035 
    20362036#define PENDING_TIMEOUT          10  /* milliseconds. */
    2037     timeout = PENDING_TIMEOUT;
    2038 
    2039     FlowVideoValues values;
    2040     const char *token;
    2041 
    2042     token = Tcl_GetString(objv[2]);
    2043     values.frameRate = 25.0f;                // Default frame rate 25 fps
    2044     values.bitRate = 6000000;                // Default video bit rate.
    2045     values.width = NanoVis::winWidth;
    2046     values.height = NanoVis::winHeight;
    2047     values.nFrames = 100;
    2048     values.format = Rappture::AVTranslate::MPEG1;
    2049     if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,
    2050                                 objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) {
    2051         return TCL_ERROR;
    2052     }
    2053     if ((values.width < 0) || (values.width > SHRT_MAX) ||
    2054         (values.height < 0) || (values.height > SHRT_MAX)) {
    2055         Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
    2056         return TCL_ERROR;
    2057     }
    2058     if ((values.frameRate < 0.0f) || (values.frameRate > 30.0f)) {
    2059         Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
    2060         return TCL_ERROR;
    2061     }
    2062     if (values.bitRate < 0) {
    2063         Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
    2064         return TCL_ERROR;
    2065     }
    2066     if (NanoVis::licRenderer == NULL) {
    2067         Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
    2068         return TCL_ERROR;
    2069     }
    2070     // Save the old dimensions of the offscreen buffer.
     2037    int timeout = PENDING_TIMEOUT;
     2038
    20712039    int oldWidth, oldHeight;
    20722040    oldWidth = NanoVis::winWidth;
    20732041    oldHeight = NanoVis::winHeight;
    20742042
    2075     TRACE("FLOW started");
    2076 
    2077     Rappture::Outcome context;
    2078 
    2079     Rappture::AVTranslate movie(values.width, values.height,
    2080                                 values.bitRate,
    2081                                 values.frameRate);
    2082     char tmpFileName[200];
    2083     sprintf(tmpFileName,"/tmp/flow%d.mpeg", getpid());
    2084     if (!movie.init(context, tmpFileName)) {
    2085         Tcl_AppendResult(interp, "can't initialized movie \"", tmpFileName,
    2086                          "\": ", context.remark(), (char *)NULL);
    2087         return TCL_ERROR;
    2088     }
    2089     if ((values.width != oldWidth) || (values.height != oldHeight)) {
     2043    if ((switchesPtr->width != oldWidth) ||
     2044        (switchesPtr->height != oldHeight)) {
    20902045        // Resize to the requested size.
    2091         NanoVis::resizeOffscreenBuffer(values.width, values.height);
    2092     }
    2093     // Now compute the line padding for the offscreen buffer.
    2094     int pad = 0;
    2095     if (( 3 * values.width) % 4 > 0) {
    2096         pad = 4 - ((3* values.width) % 4);
     2046        NanoVis::resizeOffscreenBuffer(switchesPtr->width, switchesPtr->height);
    20972047    }
    20982048    NanoVis::ResetFlows();
    2099     bool canceled = false;
    2100     for (int i = 1; i <= values.nFrames; i++) {
    2101         if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) {
     2049    *cancelPtr = false;
     2050    int result = TCL_OK;
     2051    size_t length = strlen(tmpFileName);
     2052    for (int i = 1; i <= switchesPtr->numFrames; i++) {
     2053        if (((i & 0xF) == 0) && (poll(&pollResults, 1, timeout) > 0)) {
    21022054            /* If there's another command on stdin, that means the client is
    21032055             * trying to cancel this operation. */
    2104             canceled = true;
     2056            *cancelPtr = true;
    21052057            break;
    21062058        }
     
    21192071        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
    21202072
    2121         movie.append(context, NanoVis::screenBuffer, pad);
    2122     }
    2123     movie.done(context);
    2124     TRACE("FLOW end");
    2125     if (!canceled) {
    2126         Rappture::Buffer data;
    2127 
    2128         /* FIXME: find a way to get the data from the movie object as a
    2129          * void* */
    2130         if (!data.load(context, tmpFileName)) {
    2131             Tcl_AppendResult(interp, "can't load data from temporary file \"",
    2132                              tmpFileName, "\": ", context.remark(), (char *)NULL);
     2073        sprintf(tmpFileName + length, "/image%d.ppm", i);
     2074        result = ppmWriteToFile(interp, tmpFileName, switchesPtr);
     2075        if (result != TCL_OK) {
     2076            break;
     2077        }
     2078    }
     2079    if ((switchesPtr->width != oldWidth) ||
     2080        (switchesPtr->height != oldHeight)) {
     2081        NanoVis::resizeOffscreenBuffer(oldWidth, oldHeight);
     2082    }
     2083    tmpFileName[length] = '\0';
     2084    NanoVis::ResetFlows();
     2085    return result;
     2086}
     2087
     2088static int
     2089MakeMovie(Tcl_Interp *interp, char *tmpFileName, const char *token,
     2090          FlowVideoSwitches *switchesPtr)
     2091{
     2092#ifndef FFMPEG
     2093#  define FFMPEG "/usr/bin/ffmpeg"
     2094#endif
     2095    /* Generate the movie from the frame images by exec-ing ffmpeg */
     2096    /* The ffmpeg command is
     2097     *   ffmpeg -f image2 -i /var/tmp/xxxxx/image%d.ppm                 \
     2098     *      -b bitrate -f framerate /var/tmp/xxxxx/movie.mpeg
     2099     */
     2100    char cmd[BUFSIZ];
     2101    sprintf(cmd, "%s -f image2 -i %s/image%%d.ppm -f %s -b:v %d -r %f -",
     2102            FFMPEG, tmpFileName, Tcl_GetString(switchesPtr->formatObjPtr),
     2103            switchesPtr->bitRate, switchesPtr->frameRate);
     2104    TRACE("MakeMovie %s", cmd);
     2105    FILE *f;
     2106    f = popen(cmd, "r");
     2107    if (f == NULL) {
     2108        Tcl_AppendResult(interp, "can't run ffmpeg: ",
     2109                         Tcl_PosixError(interp), (char *)NULL);
     2110        return TCL_ERROR;
     2111    }
     2112    Rappture::Buffer data;
     2113    size_t total = 0;
     2114    for (;;) {
     2115        ssize_t numRead;
     2116        char buffer[BUFSIZ];
     2117       
     2118        numRead = fread(buffer, sizeof(unsigned char), BUFSIZ, f);
     2119        total += numRead;
     2120        if (numRead == 0) {             // EOF
     2121            break;
     2122        }
     2123        if (numRead < 0) {              // Error
     2124            ERROR("MakeMovie: can't read movie data: %s",
     2125                  Tcl_PosixError(interp));
     2126            Tcl_AppendResult(interp, "can't read movie data: ",
     2127                Tcl_PosixError(interp), (char *)NULL);
    21332128            return TCL_ERROR;
    21342129        }
    2135 
    2136         char command[200];
    2137         sprintf(command,"nv>image -type movie -token \"%s\" -bytes %lu\n",
    2138                 token, (unsigned long)data.size());
    2139         NanoVis::sendDataToClient(command, data.bytes(), data.size());
    2140     }
    2141     if ((values.width != oldWidth) || (values.height != oldHeight)) {
    2142         NanoVis::resizeOffscreenBuffer(oldWidth, oldHeight);
    2143     }
    2144     NanoVis::ResetFlows();
    2145     if (unlink(tmpFileName) != 0) {
    2146         Tcl_AppendResult(interp, "can't unlink temporary movie file \"",
    2147                          tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
    2148         return TCL_ERROR;
    2149     }
    2150     return TCL_OK;
     2130        if (!data.append(buffer, numRead)) {
     2131            ERROR("MakeMovie: can't append movie data to buffer %d bytes",
     2132                  numRead);
     2133            Tcl_AppendResult(interp, "can't append movie data to buffer",
     2134                             (char *)NULL);
     2135            return TCL_ERROR;
     2136        }
     2137    }
     2138    sprintf(cmd,"nv>image -type movie -token \"%s\" -bytes %lu\n",
     2139            token, (unsigned long)data.size());
     2140    NanoVis::sendDataToClient(cmd, data.bytes(), data.size());
     2141    return TCL_OK;
     2142}
     2143
     2144static int
     2145FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2146            Tcl_Obj *const *objv)
     2147{
     2148    FlowVideoSwitches switches;
     2149    const char *token;
     2150
     2151    token = Tcl_GetString(objv[2]);
     2152    switches.frameRate = 25.0f;                // Default frame rate 25 fps
     2153    switches.bitRate = 6000000;                // Default video bit rate.
     2154    switches.width = NanoVis::winWidth;
     2155    switches.height = NanoVis::winHeight;
     2156    switches.numFrames = 100;
     2157    switches.formatObjPtr = Tcl_NewStringObj("mpeg1video", 10);
     2158    Tcl_IncrRefCount(switches.formatObjPtr);
     2159    if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,
     2160                objc - 3, objv + 3, &switches, SWITCH_DEFAULTS) < 0) {
     2161        return TCL_ERROR;
     2162    }
     2163    if ((switches.width < 0) || (switches.width > SHRT_MAX) ||
     2164        (switches.height < 0) || (switches.height > SHRT_MAX)) {
     2165        Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
     2166        return TCL_ERROR;
     2167    }
     2168    if ((switches.frameRate < 0.0f) || (switches.frameRate > 30.0f)) {
     2169        Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
     2170        return TCL_ERROR;
     2171    }
     2172    if (switches.bitRate < 0) {
     2173        Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
     2174        return TCL_ERROR;
     2175    }
     2176    if (NanoVis::licRenderer == NULL) {
     2177        Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
     2178        return TCL_ERROR;
     2179    }
     2180    TRACE("FLOW started");
     2181
     2182    char *tmpFileName;
     2183    char nameTemplate[200];
     2184    strcpy(nameTemplate,"/var/tmp/flowXXXXXX");
     2185    tmpFileName = mkdtemp(nameTemplate);
     2186    int result = TCL_OK;
     2187    if (tmpFileName == NULL) {
     2188        Tcl_AppendResult(interp, "can't create temporary directory \"",
     2189                         nameTemplate, "\" for frame image files: ",
     2190                         Tcl_PosixError(interp), (char *)NULL);
     2191        return TCL_ERROR;
     2192    }
     2193    size_t length = strlen(tmpFileName);
     2194    bool canceled = false;
     2195    result = MakeImageFiles(interp, tmpFileName, &switches, &canceled);
     2196    if ((result == TCL_OK) && (!canceled)) {
     2197        result = MakeMovie(interp, tmpFileName, token, &switches);
     2198    }
     2199    for (int i = 1; i <= switches.numFrames; i++) {
     2200        sprintf(tmpFileName + length, "/image%d.ppm", i);
     2201        unlink(tmpFileName);
     2202    }       
     2203    tmpFileName[length] = '\0';
     2204    rmdir(tmpFileName);
     2205    Rappture::FreeSwitches(FlowCmd::videoSwitches, &switches, 0);
     2206    return result;
    21512207}
    21522208#else
  • trunk/packages/vizservers/nanovis/GradientFilter.cpp

    r3522 r3559  
    161161    g_sliceDists[2] = spacing[2];
    162162
    163     int i, j, k, dir, di, vdi, idz, idy, idx;
     163    int i, j, k, dir, idz, idy, idx;
    164164    float *gp;
    165165
     
    196196    TRACE("computing gradients ... may take a while");
    197197
    198     di = 0;
    199     vdi = 0;
    200198    gp = gradients;
    201199    for (idz = 0; idz < sizes[2]; idz++) {
  • trunk/packages/vizservers/nanovis/Makefile.in

    r3502 r3559  
    137137                ReaderCommon.o \
    138138                RenderVertexArray.o \
    139                 RpAVTranslate.o \
    140139                Switch.o \
    141140                Texture1D.o \
  • trunk/packages/vizservers/nanovis/Texture1D.cpp

    r3502 r3559  
    7676    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, _interpType);
    7777
    78     GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
     78    GLuint format[5] = {
     79        (unsigned int)-1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA
     80    };
    7981
    8082    glTexImage1D(GL_TEXTURE_1D, 0, format[_numComponents], _width, 0,
  • trunk/packages/vizservers/nanovis/Texture2D.cpp

    r3502 r3559  
    7272void Texture2D::update(void *data)
    7373{
    74     static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
    75     static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    76     static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    77 
     74    static GLuint halfFloatFormats[] = {
     75        (unsigned int)-1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB,
     76        GL_RGB16F_ARB, GL_RGBA16F_ARB };
     77    static GLuint basicFormats[] = {
     78        (unsigned int)-1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA
     79    };
    7880    glBindTexture(GL_TEXTURE_2D, _id);
    7981
  • trunk/packages/vizservers/nanovis/Texture3D.cpp

    r3502 r3559  
    7676void Texture3D::update(void *data)
    7777{
    78     static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
    79     static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    80     static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    81 
     78    static GLuint halfFloatFormats[] = {
     79        (unsigned int)-1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB,
     80        GL_RGB16F_ARB, GL_RGBA16F_ARB };
     81    static GLuint basicFormats[] = {
     82        (unsigned int)-1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA
     83    };
    8284    glBindTexture(GL_TEXTURE_3D, _id);
    8385
  • trunk/packages/vizservers/nanovis/Trace.cpp

    r3492 r3559  
    5454PrintFBOStatus(GLenum status, const char *prefix)
    5555{
     56#ifdef WANT_TRACE
    5657    const char *mesg;
     58
    5759    switch(status) {
    5860    case GL_FRAMEBUFFER_COMPLETE_EXT:
     
    7880    }
    7981    TRACE("FB Status: %s: %s", prefix, mesg);
     82#endif  /*WANT_TRACE*/
    8083}
    8184
     
    8386CheckGL(const char *prefix)
    8487{
    85     const char *mesg;
    8688    GLenum status = (GLenum)glGetError();
     89    if (status == GL_NO_ERROR) {
     90        return true;
     91    }
     92#ifdef WANT_TRACE
     93    const char *mesg;                   
     94
    8795    switch(status) {
    88     case GL_NO_ERROR:
    89         return true;
    9096    case GL_INVALID_ENUM:
    9197        mesg = "GL_INVALID_ENUM";                       break;
     
    107113    }
    108114    TRACE("GL Status: %s: %s", prefix, mesg);
     115#endif
    109116    return false;
    110117}
  • trunk/packages/vizservers/nanovis/Unirect.cpp

    r3502 r3559  
    8989    int num[3], nValues;
    9090    float min[3], max[3];
    91     float *values;
    92     const char *units[4], *order;
    93 
     91    const char *units[4];
    9492
    9593    if ((objc-1) & 0x01) {
     
    106104    axis3 = 2;                  /* Z-axis */
    107105
    108     values = NULL;
    109106    num[0] = num[1] = num[2] = nValues = 0;
    110107    min[0] = min[1] = min[2] = max[0] = max[1] = max[2] = 0.0f;
    111     order = units[0] = units[1] = units[2] = units[3] = NULL;
     108    units[0] = units[1] = units[2] = units[3] = NULL;
    112109
    113110    int i;
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r3502 r3559  
    247247        TRACE("Deleting screenBuffer");
    248248        delete [] screenBuffer;
     249        screenBuffer = NULL;
    249250    }
    250251    if (perf != NULL) {
     
    13021303NanoVis::sendDataToClient(const char *command, const char *data, size_t dlen)
    13031304{
    1304     /*
    1305       char header[200];
    1306 
    1307       // Generate the PPM binary file header
    1308       sprintf(header, "P6 %d %d %d\n", winWidth, winHeight, PPM_MAXVAL);
    1309 
    1310       size_t header_length = strlen(header);
    1311       size_t data_length = winWidth * winHeight * 3;
    1312 
    1313       char command[200];
    1314       sprintf(command, "%s %lu\n", prefix,
    1315       (unsigned long)header_length + data_length);
    1316     */
    1317 
    1318     //    size_t wordsPerRow = (winWidth * 24 + 31) / 32;
    1319     //    size_t bytesPerRow = wordsPerRow * 4;
    1320     //    size_t rowLength = winWidth * 3;
    1321     size_t nRecs = 2;
    1322 
    1323     struct iovec *iov = new iovec[nRecs];
     1305    size_t numRecords = 2;
     1306
     1307    struct iovec *iov = new iovec[numRecords];
    13241308
    13251309    // Write the nanovisviewer command, then the image header and data.
     
    13321316    iov[1].iov_base = (char *)data;
    13331317    iov[1].iov_len = dlen;
    1334     if (writev(1, iov, nRecs) < 0) {
     1318    if (writev(1, iov, numRecords) < 0) {
    13351319        ERROR("write failed: %s", strerror(errno));
    13361320    }
    13371321    delete [] iov;
    1338     // stats.nFrames++;
    1339     // stats.nBytes += (bytesPerRow * winHeight);
    13401322}
    13411323
  • trunk/packages/vizservers/nanovis/nvconf.h.in

    r3502 r3559  
    1 /*
    2  * Copyright (C) 2004-2013  HUBzero Foundation, LLC
    3  *
    4  */
    51/* nanovis/nvconf.h.in.  Generated from configure.in by autoheader.  */
    62
     
    1410#undef HAVE_ARPA_INET_H
    1511
    16 /* Define to 1 if you have the `avcodec_decode_video' function. */
    17 #undef HAVE_AVCODEC_DECODE_VIDEO
    18 
    19 /* Define to 1 if you have the `avcodec_decode_video2' function. */
    20 #undef HAVE_AVCODEC_DECODE_VIDEO2
    21 
    22 /* Define to 1 if you have the `avcodec_encode_video' function. */
    23 #undef HAVE_AVCODEC_ENCODE_VIDEO
    24 
    25 /* Define to 1 if you have the `avcodec_encode_video2' function. */
    26 #undef HAVE_AVCODEC_ENCODE_VIDEO2
    27 
    28 /* Define to 1 if you have the `avcodec_init' function. */
    29 #undef HAVE_AVCODEC_INIT
    30 
    31 /* Define to 1 if you have the `avcodec_open' function. */
    32 #undef HAVE_AVCODEC_OPEN
    33 
    34 /* Define to 1 if you have the `avcodec_open2' function. */
    35 #undef HAVE_AVCODEC_OPEN2
    36 
    37 /* Define to 1 if you have the `avcodec_register_all' function. */
    38 #undef HAVE_AVCODEC_REGISTER_ALL
    39 
    40 /* Define to 1 if you have the `avformat_alloc_context' function. */
    41 #undef HAVE_AVFORMAT_ALLOC_CONTEXT
    42 
    43 /* Define to 1 if you have the `avformat_new_stream' function. */
    44 #undef HAVE_AVFORMAT_NEW_STREAM
    45 
    46 /* Define to 1 if you have the `avformat_open_input' function. */
    47 #undef HAVE_AVFORMAT_OPEN_INPUT
    48 
    49 /* Define to 1 if you have the `avformat_write_header' function. */
    50 #undef HAVE_AVFORMAT_WRITE_HEADER
    51 
    52 /* Define to 1 if you have the `avio_close' function. */
    53 #undef HAVE_AVIO_CLOSE
    54 
    55 /* Define to 1 if you have the `avio_open' function. */
    56 #undef HAVE_AVIO_OPEN
    57 
    58 /* Define if AVMEDIA_TYPE_VIDEO enum exists. */
    59 #undef HAVE_AVMEDIA_TYPE_VIDEO
    60 
    61 /* Define to 1 if you have the `av_alloc_format_context' function. */
    62 #undef HAVE_AV_ALLOC_FORMAT_CONTEXT
    63 
    64 /* Define to 1 if you have the `av_dump_format' function. */
    65 #undef HAVE_AV_DUMP_FORMAT
    66 
    67 /* Define to 1 if you have the `av_guess_format' function. */
    68 #undef HAVE_AV_GUESS_FORMAT
    69 
    70 /* Define to 1 if you have the `av_new_stream' function. */
    71 #undef HAVE_AV_NEW_STREAM
    72 
    73 /* Define to 1 if you have the `av_open_input_file' function. */
    74 #undef HAVE_AV_OPEN_INPUT_FILE
    75 
    76 /* Define to 1 if you have the `av_set_parameters' function. */
    77 #undef HAVE_AV_SET_PARAMETERS
    78 
    79 /* Define to 1 if you have the `av_write_header' function. */
    80 #undef HAVE_AV_WRITE_HEADER
    81 
    8212/* Define to 1 if you have the <Cg/cgGL.h> header file. */
    8313#undef HAVE_CG_CGGL_H
    8414
    85 /* Define to 1 if you have the `dump_format' function. */
    86 #undef HAVE_DUMP_FORMAT
    87 
    88 /* Define to 1 if you have the <dx/dx.h> header file. */
    89 #undef HAVE_DX_DX_H
    90 
    91 /* Define to 1 if you have the <ffmpeg/avcodec.h> header file. */
    92 #undef HAVE_FFMPEG_AVCODEC_H
    93 
    94 /* Define to 1 if you have the <ffmpeg/avformat.h> header file. */
    95 #undef HAVE_FFMPEG_AVFORMAT_H
    96 
    97 /* Define to 1 if you have the <ffmpeg/avutil.h> header file. */
    98 #undef HAVE_FFMPEG_AVUTIL_H
    99 
    100 /* Define to 1 if you have the `guess_format' function. */
    101 #undef HAVE_GUESS_FORMAT
    102 
    103 /* Define to 1 if you have the `img_convert' function. */
    104 #undef HAVE_IMG_CONVERT
     15/* nanovis can use ffmpeg to create videos. */
     16#undef HAVE_FFMPEG
    10517
    10618/* Define to 1 if you have the <inttypes.h> header file. */
    10719#undef HAVE_INTTYPES_H
    108 
    109 /* Define to 1 if you have the `avcodec' library (-lavcodec). */
    110 #undef HAVE_LIBAVCODEC
    111 
    112 /* Define to 1 if you have the <libavcodec/avcodec.h> header file. */
    113 #undef HAVE_LIBAVCODEC_AVCODEC_H
    114 
    115 /* Define to 1 if you have the `avformat' library (-lavformat). */
    116 #undef HAVE_LIBAVFORMAT
    117 
    118 /* Define to 1 if you have the <libavformat/avformat.h> header file. */
    119 #undef HAVE_LIBAVFORMAT_AVFORMAT_H
    120 
    121 /* Define to 1 if you have the `avutil' library (-lavutil). */
    122 #undef HAVE_LIBAVUTIL
    123 
    124 /* Define to 1 if you have the <libavutil/avutil.h> header file. */
    125 #undef HAVE_LIBAVUTIL_AVUTIL_H
    126 
    127 /* Define to 1 if you have the `swscale' library (-lswscale). */
    128 #undef HAVE_LIBSWSCALE
    12920
    13021/* Define to 1 if you have the <memory.h> header file. */
     
    15546#undef HAVE_STRING_H
    15647
    157 /* Define to 1 if you have the `sws_scale' function. */
    158 #undef HAVE_SWS_SCALE
    159 
    16048/* Define to 1 if you have the <sys/socket.h> header file. */
    16149#undef HAVE_SYS_SOCKET_H
     
    17260/* Define to 1 if you have the <unistd.h> header file. */
    17361#undef HAVE_UNISTD_H
    174 
    175 /* Define to 1 if you have the `url_fclose' function. */
    176 #undef HAVE_URL_FCLOSE
    177 
    178 /* Define to 1 if you have the `url_fopen' function. */
    179 #undef HAVE_URL_FOPEN
    18062
    18163/* Define to 1 if you have the <vtkSmartPointer.h> header file. */
  • trunk/packages/vizservers/nanovis/util/Fonts.cpp

    r3465 r3559  
    161161        if (uiFileId == (unsigned int)c_nFileMagicHeader) {
    162162            // read general font/texture dimensions
    163             unsigned int uiTextureWidth, uiTextureHeight, uiFontHeight;
    164             uiTextureWidth = uiTextureHeight = uiFontHeight = 0;
    165163            fsInput.read(reinterpret_cast<char*>(&sFont._textureWidth),
    166164                         sizeof(unsigned int));
Note: See TracChangeset for help on using the changeset viewer.