Ignore:
Timestamp:
Feb 24, 2013, 5:46:58 PM (12 years ago)
Author:
gah
Message:

fixes for new version of ffmeg

File:
1 edited

Legend:

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

    r3177 r3335  
    5959#endif  /*HAVE_AVIO_CLOSE*/
    6060
     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
    6173#ifndef M_PI
    6274#define M_PI 3.14159265358979323846
     
    120132    status.addContext("Rappture::AVTranslate::init()");
    121133    /* Initialize libavcodec, and register all codecs and formats */
     134#ifdef HAVE_AVCODEC_REGISTER_ALL
     135    avcodec_register_all();
     136#else
    122137    avcodec_init();
    123     avcodec_register_all();
     138#endif
    124139    av_register_all();
    125140
     
    179194    /* Open the output file, if needed. */
    180195    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) {
    182197            status.addError("Could not open '%s'", filename);
    183198            return false;
     
    277292
    278293    AVStream *streamPtr;
    279     streamPtr = av_new_stream(_ocPtr, 0);
     294    streamPtr = avformat_new_stream(_ocPtr, 0);
    280295    if (streamPtr == NULL) {
    281296        status.addError("Could not alloc stream");
     
    359374    AVCodec *codec;
    360375    AVCodecContext *c;
     376    int result;
    361377
    362378    status.addContext("Rappture::AVTranslate::openVideo()");
     
    369385        return false;
    370386    }
    371 
     387#ifdef HAVE_AVCODEC_OPEN2
     388    result = avcodec_open2(c, codec, NULL);
     389#else
     390    result = avcodec_open2(c, codec);
     391#endif
    372392    /* open the codec */
    373     if (avcodec_open(c, codec) < 0) {
     393    if (result < 0) {
    374394        status.addError("can't open codec %d", c->codec->id);
    375395        return false;
     
    400420AVTranslate::writeVideoFrame(Outcome &status)
    401421{
    402     AVCodecContext *codecPtr;
     422    AVCodecContext *contextPtr;
    403423
    404424    status.addContext("Rappture::AVTranslate::writeVideoframe()");
    405     codecPtr = _avStreamPtr->codec;
     425    contextPtr = _avStreamPtr->codec;
    406426
    407427    /* encode the image */
    408428    int size;
    409     size = avcodec_encode_video(codecPtr, _videoOutbuf, _videoOutbufSize,
     429    size = avcodec_encode_video(contextPtr, _videoOutbuf, _videoOutbufSize,
    410430        _pictPtr);
    411431    if (size < 0) {
     
    419439    av_init_packet(&pkt);
    420440
    421     pkt.pts = av_rescale_q(codecPtr->coded_frame->pts, codecPtr->time_base,
     441    pkt.pts = av_rescale_q(contextPtr->coded_frame->pts, contextPtr->time_base,
    422442                           _avStreamPtr->time_base);
    423     if (codecPtr->coded_frame->key_frame) {
     443    if (contextPtr->coded_frame->key_frame) {
    424444        pkt.flags |= AV_PKT_FLAG_KEY;
    425445    }
Note: See TracChangeset for help on using the changeset viewer.