Changeset 2893 for trunk/video


Ignore:
Timestamp:
Mar 28, 2012, 12:22:32 PM (12 years ago)
Author:
gah
Message:

updates to video package

Location:
trunk/video
Files:
1 deleted
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/video/RpVideo.c

    r2892 r2893  
    177177}
    178178
    179 int
    180 VideoOpenFile(vidPtr, fileName, mode)
    181     VideoObj *vidPtr;
    182     const char *fileName;
    183     const char *mode;
    184 {
    185     int fnlen = 0;
    186     int err = 0;
    187     int lastframe = 0;
    188 
    189     if (fileName == NULL) {
    190         // missing value for fileName
    191         // return TCL_ERROR;
    192         return -1;
    193     }
    194     if (fileName == '\0') {
    195         /* no file name set -- do nothing */
    196         return 0;
    197     }
    198 
    199     fnlen = strlen(fileName);
    200     if (vidPtr->fileName != NULL) {
    201         free(vidPtr->fileName);
    202     }
    203     vidPtr->fileName = (char *) malloc((fnlen+1)*sizeof(char));
    204     if (vidPtr->fileName == NULL) {
    205         // trouble mallocing space
    206         return -1;
    207     }
    208     strncpy(vidPtr->fileName,fileName,fnlen);
    209     vidPtr->fileName[fnlen] = '\0';
    210 
    211     // FIXME: remove this constraint when we support
    212     // the modes: r, r+, w, w+, a, a+, b and combinations
    213     if (strlen(mode) > 1) {
    214         return -1;
    215     }
    216 
    217     if (*mode == 'r') {
    218         /* we're now in "input" mode */
    219         err = VideoModeRead(vidPtr);
    220         if (err) {
    221             return err;
    222         }
    223 
    224         VideoFindLastFrame(vidPtr,&lastframe);
    225         vidPtr->lastframe = lastframe;
    226     } else if (*mode == 'w') {
    227         /* we're now in "input" mode */
    228         // VideoModeWrite(vidPtr);
    229     } else {
    230         // unrecognized mode
    231         return -1;
    232     }
    233 
    234     return 0;
    235 }
    236 
    237179/*
    238180 * ------------------------------------------------------------------------
     
    280222    *lastframe = nframe;
    281223    VideoGoToN(vidPtr,f);
     224
     225    return 0;
     226}
     227
     228
     229int
     230VideoOpenFile(vidPtr, fileName, mode)
     231    VideoObj *vidPtr;
     232    const char *fileName;
     233    const char *mode;
     234{
     235    int fnlen = 0;
     236    int err = 0;
     237    int lastframe = 0;
     238
     239    if (fileName == NULL) {
     240        // missing value for fileName
     241        // return TCL_ERROR;
     242        return -1;
     243    }
     244    if (fileName == '\0') {
     245        /* no file name set -- do nothing */
     246        return 0;
     247    }
     248
     249    fnlen = strlen(fileName);
     250    if (vidPtr->fileName != NULL) {
     251        free(vidPtr->fileName);
     252    }
     253    vidPtr->fileName = (char *) malloc((fnlen+1)*sizeof(char));
     254    if (vidPtr->fileName == NULL) {
     255        // trouble mallocing space
     256        return -1;
     257    }
     258    strncpy(vidPtr->fileName,fileName,fnlen);
     259    vidPtr->fileName[fnlen] = '\0';
     260
     261    // FIXME: remove this constraint when we support
     262    // the modes: r, r+, w, w+, a, a+, b and combinations
     263    if (strlen(mode) > 1) {
     264        return -1;
     265    }
     266
     267    if (*mode == 'r') {
     268        /* we're now in "input" mode */
     269        err = VideoModeRead(vidPtr);
     270        if (err) {
     271            return err;
     272        }
     273
     274        VideoFindLastFrame(vidPtr,&lastframe);
     275        vidPtr->lastframe = lastframe;
     276    } else if (*mode == 'w') {
     277        /* we're now in "input" mode */
     278        // VideoModeWrite(vidPtr);
     279    } else {
     280        // unrecognized mode
     281        return -1;
     282    }
    282283
    283284    return 0;
     
    315316    VideoObj *vidPtr;
    316317{
    317     char c, buffer[64]; int i;
     318    int i;
    318319    const char *fmt;
    319320    AVCodecContext *vcodecCtx;
     
    358359    }
    359360#endif
     361#ifdef HAVE_AVFORMAT_FIND_STREAM_INFO
     362    if (avformat_find_stream_info(vidPtr->pFormatCtx, NULL) < 0) {
     363#else
    360364    if (av_find_stream_info(vidPtr->pFormatCtx) < 0) {
     365#endif
    361366        // Tcl_AppendResult(interp, "couldn't find streams in file \"",
    362367        //     fileName, "\"", (char*)NULL);
     
    397402        return -6;
    398403    }
     404#ifdef HAVE_AVCODEC_OPEN2
     405    if (avcodec_open2(vcodecCtx, vcodec, NULL) < 0) {
     406#else
    399407    if (avcodec_open(vcodecCtx, vcodec) < 0) {
     408#endif
    400409        // Tcl_AppendResult(interp, "couldn't open codec for file \"",
    401410        //     fileName, "\"", (char*)NULL);
     
    925934    int n;
    926935{
    927     int nrel, nabs, seekFlags, gotframe, t;
     936    int nrel, nabs, seekFlags, gotframe;
    928937    int64_t nseek;
    929938    AVCodecContext *vcodecCtx;
     
    10311040{
    10321041
    1033     int nframe, numBytes;
    1034     char c, buffer[64];
     1042    int numBytes;
    10351043    AVCodecContext *vcodecCtx;
    1036     AVStream *vstreamPtr;
    10371044
    10381045    if (vidPtr == NULL) {
     
    11171124*/
    11181125
    1119         int bufsize = 0;
    11201126        if (vidPtr->img == NULL) {
    11211127            VideoAllocImgBuffer(vidPtr,iw,ih);
     
    11761182    const char **fname;
    11771183{
    1178     AVStream *vstreamPtr;
    1179 
    11801184    if (vidPtr == NULL) {
    11811185        return -1;
     
    12311235    int *den;
    12321236{
    1233     AVCodecContext *vcodecCtx;
    12341237    int width = 0;
    12351238    int height = 0;
    12361239    int64_t gcd = 0;
    1237     int64_t gcd2 = 0;
    12381240
    12391241    if (vidPtr == NULL) {
     
    13151317{
    13161318    int fnum = -1;
    1317     AVStream *vstreamPtr;
    13181319
    13191320    if (vidPtr == NULL) {
     
    13421343    int *pos;
    13431344{
    1344     AVStream *vstreamPtr;
    1345 
    13461345    if (vidPtr == NULL) {
    13471346        return -1;
     
    16581657    }
    16591658    if (vidPtr->pFormatCtx) {
     1659#ifdef HAVE_AVFORMAT_CLOSE_INPUT
     1660        avformat_close_input(&vidPtr->pFormatCtx);
     1661#else
    16601662        av_close_input_file(vidPtr->pFormatCtx);
     1663#endif
    16611664        vidPtr->pFormatCtx = NULL;
    16621665    }
  • trunk/video/RpVideoTclInterface.cc

    r2892 r2893  
    1717#include "RpVideo.h"
    1818
    19 extern "C" Tcl_AppInitProc RpVideo_Init;
     19extern "C" Tcl_AppInitProc Rpvideo_Init;
    2020
    2121#include "RpOp.h"
     
    5454 */
    5555int
    56 RpVideo_Init(Tcl_Interp *interp)
     56Rpvideo_Init(Tcl_Interp *interp)
    5757{
    5858
     
    521521    return TCL_OK;
    522522}
     523
Note: See TracChangeset for help on using the changeset viewer.