Changeset 3335 for trunk/packages/vizservers/nanovis/RpAVTranslate.cpp
- Timestamp:
- Feb 24, 2013, 5:46:58 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/RpAVTranslate.cpp
r3177 r3335 59 59 #endif /*HAVE_AVIO_CLOSE*/ 60 60 61 #ifndef AVIO_FLAG_WRITE 62 #define AVIO_FLAG_WRITE URL_WRONLY 63 #endif 64 65 #ifndef HAVE_AVFORMAT_NEW_STREAM 66 #define avformat_new_stream av_new_stream 67 #endif 68 69 #ifndef HAVE_AVCODEC_OPEN2 70 #define avcodec_open(context, codec, options) avcodec_open2(contex, codec, NULL) 71 #endif 72 61 73 #ifndef M_PI 62 74 #define M_PI 3.14159265358979323846 … … 120 132 status.addContext("Rappture::AVTranslate::init()"); 121 133 /* Initialize libavcodec, and register all codecs and formats */ 134 #ifdef HAVE_AVCODEC_REGISTER_ALL 135 avcodec_register_all(); 136 #else 122 137 avcodec_init(); 123 avcodec_register_all(); 138 #endif 124 139 av_register_all(); 125 140 … … 179 194 /* Open the output file, if needed. */ 180 195 if (!(_fmtPtr->flags & AVFMT_NOFILE)) { 181 if (avio_open(&_ocPtr->pb, filename, URL_WRONLY) < 0) {196 if (avio_open(&_ocPtr->pb, filename, AVIO_FLAG_WRITE) < 0) { 182 197 status.addError("Could not open '%s'", filename); 183 198 return false; … … 277 292 278 293 AVStream *streamPtr; 279 streamPtr = av _new_stream(_ocPtr, 0);294 streamPtr = avformat_new_stream(_ocPtr, 0); 280 295 if (streamPtr == NULL) { 281 296 status.addError("Could not alloc stream"); … … 359 374 AVCodec *codec; 360 375 AVCodecContext *c; 376 int result; 361 377 362 378 status.addContext("Rappture::AVTranslate::openVideo()"); … … 369 385 return false; 370 386 } 371 387 #ifdef HAVE_AVCODEC_OPEN2 388 result = avcodec_open2(c, codec, NULL); 389 #else 390 result = avcodec_open2(c, codec); 391 #endif 372 392 /* open the codec */ 373 if ( avcodec_open(c, codec)< 0) {393 if (result < 0) { 374 394 status.addError("can't open codec %d", c->codec->id); 375 395 return false; … … 400 420 AVTranslate::writeVideoFrame(Outcome &status) 401 421 { 402 AVCodecContext *co decPtr;422 AVCodecContext *contextPtr; 403 423 404 424 status.addContext("Rappture::AVTranslate::writeVideoframe()"); 405 co decPtr = _avStreamPtr->codec;425 contextPtr = _avStreamPtr->codec; 406 426 407 427 /* encode the image */ 408 428 int size; 409 size = avcodec_encode_video(co decPtr, _videoOutbuf, _videoOutbufSize,429 size = avcodec_encode_video(contextPtr, _videoOutbuf, _videoOutbufSize, 410 430 _pictPtr); 411 431 if (size < 0) { … … 419 439 av_init_packet(&pkt); 420 440 421 pkt.pts = av_rescale_q(co decPtr->coded_frame->pts, codecPtr->time_base,441 pkt.pts = av_rescale_q(contextPtr->coded_frame->pts, contextPtr->time_base, 422 442 _avStreamPtr->time_base); 423 if (co decPtr->coded_frame->key_frame) {443 if (contextPtr->coded_frame->key_frame) { 424 444 pkt.flags |= AV_PKT_FLAG_KEY; 425 445 }
Note: See TracChangeset
for help on using the changeset viewer.