Ticket #4851: mythphone_loopback_fix.diff

File mythphone_loopback_fix.diff, 2.3 KB (added by Shane Shrybman <gnome42@…>, 12 years ago)
  • mythphone/mythphone/h263.h

     
    6565    void H263StopDecoder();
    6666
    6767  private:
    68     AVFrame pictureOut, *pictureIn;
     68    AVFrame *pictureOut, *pictureIn;
    6969    AVCodec *h263Encoder, *h263Decoder;
    7070    AVCodecContext *h263EncContext, *h263DecContext;
    7171    int MaxPostEncodeSize, lastCompressedSize;
  • mythphone/mythphone/h263.cpp

     
    5252    }
    5353
    5454    h263EncContext = avcodec_alloc_context();
     55    pictureOut = avcodec_alloc_frame();
    5556   
    5657    h263EncContext->pix_fmt = PIX_FMT_YUV420P;
    5758    /* put sample parameters */
     
    8182    MaxPostEncodeSize = 100000;
    8283    PostEncodeFrame = (uchar *)malloc(MaxPostEncodeSize);
    8384   
    84     pictureOut.linesize[0] = h263EncContext->width;
    85     pictureOut.linesize[1] = h263EncContext->width / 2;
    86     pictureOut.linesize[2] = h263EncContext->width / 2;
     85    pictureOut->linesize[0] = h263EncContext->width;
     86    pictureOut->linesize[1] = h263EncContext->width / 2;
     87    pictureOut->linesize[2] = h263EncContext->width / 2;
    8788
    8889    return true;
    8990}
     
    117118uchar *H263Container::H263EncodeFrame(const uchar *yuvFrame, int *len)
    118119{
    119120    int size = h263EncContext->width * h263EncContext->height;
    120     pictureOut.data[0] = (uchar *)yuvFrame;
    121     pictureOut.data[1] = pictureOut.data[0] + size;
    122     pictureOut.data[2] = pictureOut.data[1] + size / 4;
     121    pictureOut->data[0] = (uchar *)yuvFrame;
     122    pictureOut->data[1] = pictureOut->data[0] + size;
     123    pictureOut->data[2] = pictureOut->data[1] + size / 4;
    123124
    124     *len = lastCompressedSize = avcodec_encode_video(h263EncContext, PostEncodeFrame, MaxPostEncodeSize, &pictureOut);
     125    *len = lastCompressedSize = avcodec_encode_video(h263EncContext, PostEncodeFrame, MaxPostEncodeSize, pictureOut);
    125126
    126127    return PostEncodeFrame;
    127128}
     
    173174        av_free(h263EncContext);
    174175        h263EncContext = 0;
    175176    }
     177
     178    if (pictureOut)
     179        av_free(pictureOut);
     180    pictureOut = 0;
    176181}
    177182
    178183void H263Container::H263StopDecoder()