Ticket #12954: t.patch

File t.patch, 4.8 KB (added by JYA, 4 years ago)

partial revert

  • mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp

    diff --git a/mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp
    index b1598a7..919f790 100644
    a b void NuppelVideoRecorder::InitBuffers(void) 
    930930
    931931    if (!video_buffer_size)
    932932    {
    933         video_buffer_size =
    934             buffersize(picture_format == AV_PIX_FMT_YUV422P ? FMT_YUV422P : FMT_YV12,
    935                        w_out, h_out);
     933        if (picture_format == AV_PIX_FMT_YUV422P)
     934            video_buffer_size = w_out * h_out * 2;
     935        else
     936            video_buffer_size = w_out * h_out * 3 / 2;
    936937    }
    937938
    938939    if (width >= 480 || height > 288)
    void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 
    28772878    lzo_uint out_len = OUT_LEN;
    28782879    struct rtframeheader frameheader;
    28792880    int raw = 0, compressthis = compression;
    2880     uint8_t *planes[3] = {
    2881         frame->buf + frame->offsets[0],
    2882         frame->buf + frame->offsets[1],
    2883         frame->buf + frame->offsets[2] };
     2881    uint8_t *planes[3];
     2882    int len = frame->size;
    28842883    int fnum = frame->frameNumber;
    28852884    long long timecode = frame->timecode;
     2885    unsigned char *buf = frame->buf;
    28862886
    28872887    memset(&frameheader, 0, sizeof(frameheader));
    28882888
     2889    planes[0] = buf;
     2890    planes[1] = planes[0] + frame->width * frame->height;
     2891    planes[2] = planes[1] + (frame->width * frame->height) /
     2892                            (picture_format == AV_PIX_FMT_YUV422P ? 2 : 4);
     2893
    28892894    if (lf == 0)
    28902895    {   // this will be triggered every new file
    28912896        lf = fnum;
    void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 
    29442949    if (useavcodec)
    29452950    {
    29462951        MythAVFrame mpa_picture;
    2947         AVPictureFill(mpa_picture, frame);
     2952
     2953        switch (picture_format)
     2954        {
     2955            case AV_PIX_FMT_YUV420P:
     2956            case AV_PIX_FMT_YUV422P:
     2957            case AV_PIX_FMT_YUVJ420P:
     2958                mpa_picture->linesize[0] = w_out;
     2959                mpa_picture->linesize[1] = w_out / 2;
     2960                mpa_picture->linesize[2] = w_out / 2;
     2961                break;
     2962        }
     2963        mpa_picture->data[0] = planes[0];
     2964        mpa_picture->data[1] = planes[1];
     2965        mpa_picture->data[2] = planes[2];
     2966        mpa_picture->linesize[0] = frame->width;
     2967        mpa_picture->linesize[1] = frame->width / 2;
     2968        mpa_picture->linesize[2] = frame->width / 2;
    29482969
    29492970        if (wantkeyframe)
    29502971            mpa_picture->pict_type = AV_PICTURE_TYPE_I;
    void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 
    29562977            AVPacket packet;
    29572978            av_init_packet(&packet);
    29582979            packet.data = (uint8_t *)strm;
    2959             packet.size = frame->size;
     2980            packet.size = len;
    29602981
    29612982            int got_packet = 0;
    29622983
    void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 
    30003021            tmp = rtjc->Compress(strm, planes);
    30013022        }
    30023023        else
    3003             tmp = frame->size;
     3024            tmp = len;
    30043025
    30053026        // here is lzo compression afterwards
    30063027        if (compressthis)
    30073028        {
    30083029            int r = 0;
    30093030            if (raw)
    3010                 r = lzo1x_1_compress((unsigned char*)frame->buf, frame->size,
     3031                r = lzo1x_1_compress((unsigned char*)buf, len,
    30113032                                     out, &out_len, wrkmem);
    30123033            else
    30133034                r = lzo1x_1_compress((unsigned char *)strm, tmp, out,
    void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 
    30313052        if (mpa_vidcodec->id == AV_CODEC_ID_RAWVIDEO)
    30323053        {
    30333054            frameheader.comptype = '0';
    3034             frameheader.packetlength = frame->size;
     3055            frameheader.packetlength = len;
    30353056            WriteFrameheader(&frameheader);
    3036             ringBuffer->Write(frame->buf, frame->size);
     3057            ringBuffer->Write(buf, len);
    30373058        }
    30383059        else if (hardware_encode)
    30393060        {
    30403061            frameheader.comptype = '4';
    3041             frameheader.packetlength = frame->size;
     3062            frameheader.packetlength = len;
    30423063            WriteFrameheader(&frameheader);
    3043             ringBuffer->Write(frame->buf, frame->size);
     3064            ringBuffer->Write(buf, len);
    30443065        }
    30453066        else
    30463067        {
    void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, 
    30623083        else
    30633084        {
    30643085            frameheader.comptype  = '0'; // raw YUV420
    3065             frameheader.packetlength = frame->size;
     3086            frameheader.packetlength = len;
    30663087            WriteFrameheader(&frameheader);
    3067             ringBuffer->Write(frame->buf, frame->size); // we write buf directly
     3088            ringBuffer->Write(buf, len); // we write buf directly
    30683089        }
    30693090    }
    30703091    else