Changeset 2893 for trunk/video
- Timestamp:
- Mar 28, 2012, 12:22:32 PM (13 years ago)
- Location:
- trunk/video
- Files:
-
- 1 deleted
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/video/RpVideo.c
r2892 r2893 177 177 } 178 178 179 int180 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 fileName191 // 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 space206 return -1;207 }208 strncpy(vidPtr->fileName,fileName,fnlen);209 vidPtr->fileName[fnlen] = '\0';210 211 // FIXME: remove this constraint when we support212 // the modes: r, r+, w, w+, a, a+, b and combinations213 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 mode231 return -1;232 }233 234 return 0;235 }236 237 179 /* 238 180 * ------------------------------------------------------------------------ … … 280 222 *lastframe = nframe; 281 223 VideoGoToN(vidPtr,f); 224 225 return 0; 226 } 227 228 229 int 230 VideoOpenFile(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 } 282 283 283 284 return 0; … … 315 316 VideoObj *vidPtr; 316 317 { 317 char c, buffer[64];int i;318 int i; 318 319 const char *fmt; 319 320 AVCodecContext *vcodecCtx; … … 358 359 } 359 360 #endif 361 #ifdef HAVE_AVFORMAT_FIND_STREAM_INFO 362 if (avformat_find_stream_info(vidPtr->pFormatCtx, NULL) < 0) { 363 #else 360 364 if (av_find_stream_info(vidPtr->pFormatCtx) < 0) { 365 #endif 361 366 // Tcl_AppendResult(interp, "couldn't find streams in file \"", 362 367 // fileName, "\"", (char*)NULL); … … 397 402 return -6; 398 403 } 404 #ifdef HAVE_AVCODEC_OPEN2 405 if (avcodec_open2(vcodecCtx, vcodec, NULL) < 0) { 406 #else 399 407 if (avcodec_open(vcodecCtx, vcodec) < 0) { 408 #endif 400 409 // Tcl_AppendResult(interp, "couldn't open codec for file \"", 401 410 // fileName, "\"", (char*)NULL); … … 925 934 int n; 926 935 { 927 int nrel, nabs, seekFlags, gotframe , t;936 int nrel, nabs, seekFlags, gotframe; 928 937 int64_t nseek; 929 938 AVCodecContext *vcodecCtx; … … 1031 1040 { 1032 1041 1033 int nframe, numBytes; 1034 char c, buffer[64]; 1042 int numBytes; 1035 1043 AVCodecContext *vcodecCtx; 1036 AVStream *vstreamPtr;1037 1044 1038 1045 if (vidPtr == NULL) { … … 1117 1124 */ 1118 1125 1119 int bufsize = 0;1120 1126 if (vidPtr->img == NULL) { 1121 1127 VideoAllocImgBuffer(vidPtr,iw,ih); … … 1176 1182 const char **fname; 1177 1183 { 1178 AVStream *vstreamPtr;1179 1180 1184 if (vidPtr == NULL) { 1181 1185 return -1; … … 1231 1235 int *den; 1232 1236 { 1233 AVCodecContext *vcodecCtx;1234 1237 int width = 0; 1235 1238 int height = 0; 1236 1239 int64_t gcd = 0; 1237 int64_t gcd2 = 0;1238 1240 1239 1241 if (vidPtr == NULL) { … … 1315 1317 { 1316 1318 int fnum = -1; 1317 AVStream *vstreamPtr;1318 1319 1319 1320 if (vidPtr == NULL) { … … 1342 1343 int *pos; 1343 1344 { 1344 AVStream *vstreamPtr;1345 1346 1345 if (vidPtr == NULL) { 1347 1346 return -1; … … 1658 1657 } 1659 1658 if (vidPtr->pFormatCtx) { 1659 #ifdef HAVE_AVFORMAT_CLOSE_INPUT 1660 avformat_close_input(&vidPtr->pFormatCtx); 1661 #else 1660 1662 av_close_input_file(vidPtr->pFormatCtx); 1663 #endif 1661 1664 vidPtr->pFormatCtx = NULL; 1662 1665 } -
trunk/video/RpVideoTclInterface.cc
r2892 r2893 17 17 #include "RpVideo.h" 18 18 19 extern "C" Tcl_AppInitProc Rp Video_Init;19 extern "C" Tcl_AppInitProc Rpvideo_Init; 20 20 21 21 #include "RpOp.h" … … 54 54 */ 55 55 int 56 Rp Video_Init(Tcl_Interp *interp)56 Rpvideo_Init(Tcl_Interp *interp) 57 57 { 58 58 … … 521 521 return TCL_OK; 522 522 } 523
Note: See TracChangeset
for help on using the changeset viewer.