Ticket #2171: 2171-nvr.patch

File 2171-nvr.patch, 6.4 KB (added by danielk, 18 years ago)

Possible fix for problem reported by "Gnome42" (untested)

  • libs/libmythtv/NuppelVideoRecorder.cpp

     
    27522752            case ACTION_VIDEO:
    27532753            {
    27542754                VideoFrame frame;
    2755                 frame.codec = FMT_YV12;
    2756                 frame.width = w;
    2757                 frame.height = h;
    2758                 frame.buf = videobuffer[act_video_encode]->buffer;
    2759                 frame.size = videobuffer[act_video_encode]->bufferlen;
     2755                init(&frame,
     2756                     FMT_YV12, videobuffer[act_video_encode]->buffer,
     2757                     w, h, 12, videobuffer[act_video_encode]->bufferlen);
     2758
    27602759                frame.frameNumber = videobuffer[act_video_encode]->sample;
    27612760                frame.timecode = videobuffer[act_video_encode]->timecode;
    27622761                frame.forcekey = videobuffer[act_video_encode]->forcekey; 
  • libs/libmythtv/frame.h

     
    11#ifndef _FRAME_H
    22#define _FRAME_H
    33
     4#include <string.h>
     5
     6#ifdef __cplusplus
     7extern "C" {
     8#endif
     9
    410typedef enum FrameType_
    511{
    612    FMT_NONE = -1,
     
    2026    VideoFrameType codec;
    2127    unsigned char *buf;
    2228
     29    int width;
    2330    int height;
    24     int width;
    2531    int bpp;
    2632    int size;
    2733
     
    4248    int offsets[3]; // Y, U, & V offsets
    4349} VideoFrame;
    4450
     51#ifdef __cplusplus
     52}
    4553#endif
    4654
     55#ifdef __cplusplus
     56static inline void init(
     57    VideoFrame *vf,
     58    VideoFrameType _codec, unsigned char *_buf,
     59    int _width, int _height, int _bpp, int _size,
     60    const int *p = 0, const int *o = 0) __attribute__ ((unused));
     61
     62static inline void init(
     63    VideoFrame *vf,
     64    VideoFrameType _codec, unsigned char *_buf,
     65    int _width, int _height, int _bpp, int _size,
     66    const int *p, const int *o)
     67{
     68    vf->codec  = _codec;
     69    vf->buf    = _buf;
     70    vf->width  = _width;
     71    vf->height = _height;
     72
     73    vf->bpp          = _bpp;
     74    vf->size         = _size;
     75    vf->frameNumber  = 0;
     76    vf->timecode     = 0;
     77
     78    vf->qscale_table = 0;
     79    vf->qstride      = 0;
     80
     81    vf->interlaced_frame = 1;
     82    vf->top_field_first  = 1;
     83    vf->repeat_pict      = 0;
     84    vf->forcekey         = 0;
     85
     86    bzero(vf->priv, 4 * sizeof(unsigned char *));
     87
     88    if (p)
     89    {
     90        memcpy(vf->pitches, p, 3 * sizeof(int));
     91    }
     92    else
     93    {
     94        if (FMT_YV12 == _codec || FMT_YUV422P == _codec)
     95        {
     96            vf->pitches[0] = _width;
     97            vf->pitches[1] = vf->pitches[2] = _width >> 1;
     98        }
     99        else
     100        {
     101            vf->pitches[0] = (_width * _bpp) >> 3;
     102            vf->pitches[1] = vf->pitches[2] = 0;
     103        }
     104    }
     105       
     106    if (o)
     107    {
     108        memcpy(vf->offsets, o, 3 * sizeof(int));
     109    }
     110    else
     111    {
     112        if (FMT_YV12 == _codec)
     113        {
     114            vf->offsets[0] = 0;
     115            vf->offsets[1] = _width * _height;
     116            vf->offsets[2] = vf->offsets[1] + (vf->offsets[1] >> 2);
     117        }
     118        else if (FMT_YUV422P == _codec)
     119        {
     120            vf->offsets[0] = 0;
     121            vf->offsets[1] = _width * _height;
     122            vf->offsets[2] = vf->offsets[1] + (vf->offsets[1] >> 1);
     123        }
     124        else
     125        {
     126            vf->offsets[0] = vf->offsets[1] = vf->offsets[2] = 0;
     127        }
     128    }
     129}
     130
     131#endif /* __cplusplus */
     132
     133#endif
     134
  • libs/libmythtv/videoout_ivtv.cpp

     
    443443        return;
    444444
    445445    VideoFrame tmpframe;
    446     tmpframe.codec = FMT_ARGB32;
    447     tmpframe.buf = (unsigned char *)osdbuf_aligned;
    448     tmpframe.width = stride;
    449     tmpframe.height = video_dim.height();
     446    init(&tmpframe, FMT_ARGB32, (unsigned char *)osdbuf_aligned,
     447         stride, video_dim.height(), 32, 4 * stride * video_dim.height());
    450448
    451449    OSDSurface *surface = NULL;
    452450    if (osd)
  • libs/libmythtv/videobuffers.cpp

     
    11351135
    11361136    for (uint i = 0; i < allocSize(); i++)
    11371137    {
    1138         buffers[i].width  = yuvinfo[i].width;
    1139         buffers[i].height = yuvinfo[i].height;
    1140         memcpy(buffers[i].pitches, yuvinfo[i].pitches, 3 * sizeof(int));
    1141         memcpy(buffers[i].offsets, yuvinfo[i].offsets, 3 * sizeof(int));
    1142         buffers[i].bpp = 12;
    1143         buffers[i].size = max(buf_size, yuvinfo[i].size);
    1144         buffers[i].codec = FMT_YV12;
    1145         buffers[i].qscale_table = NULL;
    1146         buffers[i].qstride = 0;
    1147         buffers[i].buf = bufs[i];
     1138        init(&buffers[i],
     1139             FMT_YV12, bufs[i], yuvinfo[i].width, yuvinfo[i].height,
     1140             12, max(buf_size, yuvinfo[i].size),
     1141             (const int*) yuvinfo[i].pitches, (const int*) yuvinfo[i].offsets);
     1142
    11481143        ok &= (bufs[i] != NULL);
    11491144    }
    11501145
     
    11871182        xvmc_render_state_t *render = new xvmc_render_state_t;
    11881183        allocated_structs.push_back((unsigned char*)render);
    11891184        memset(render, 0, sizeof(xvmc_render_state_t));
    1190         buffers[i].buf          = (unsigned char*) render;
    11911185
    11921186        // constants
    11931187        render->magic           = MP_XVMC_RENDER_MAGIC;
    11941188        render->state           = 0;
    1195         buffers[i].bpp          = -1;
    1196         buffers[i].codec        = FMT_XVMC_IDCT_MPEG2;
    1197         buffers[i].size         = sizeof(XvMCSurface);
    11981189
    11991190        // from videoout_xv
    12001191        render->disp            = disp;
    12011192        render->ctx             = &xvmc_ctx;
    12021193
    1203         // from width, height, and xvmv block and surface arrays
     1194        // from xvmv block and surface arrays
    12041195        render->p_surface       = &surf->surface;
    1205         buffers[i].height       = height;
    1206         buffers[i].width        = width;
    12071196
    12081197        render->total_number_of_data_blocks = surf->blocks.num_blocks;
    12091198        render->total_number_of_mv_blocks   = surf->macro_blocks.num_blocks;
     1199
     1200        init(&buffers[i],
     1201             FMT_XVMC_IDCT_MPEG2, (unsigned char*) render,
     1202             width, height, -1, sizeof(XvMCSurface));
     1203
    12101204        buffers[i].priv[0]      = ffmpeg_vld_hack;
    12111205        buffers[i].priv[1]      = ffmpeg_vld_hack;
    12121206