Ticket #13530: yuva.diff

File yuva.diff, 22.6 KB (added by Mark Kendall, 20 months ago)

YUVA Patch

  • mythtv/libs/libmythtv/DetectLetterbox.cpp

    diff --git a/mythtv/libs/libmythtv/DetectLetterbox.cpp b/mythtv/libs/libmythtv/DetectLetterbox.cpp
    index e17683f183..bb649fc6ff 100644
    a b void DetectLetterbox::Detect(VideoFrame *Frame) 
    6060        case FMT_YUV420P12:
    6161        case FMT_YUV420P14:
    6262        case FMT_YUV420P16:
     63        case FMT_YUVA420P:
    6364        case FMT_NV12:
    6465        case FMT_P010:
    6566        case FMT_P016:
  • mythtv/libs/libmythtv/decoders/avformatdecoder.cpp

    diff --git a/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp b/mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
    index a802e8f75c..b89955d74e 100644
    a b int get_avf_buffer(struct AVCodecContext *c, AVFrame *pic, int flags) 
    26962696
    26972697    frame->colorshifted = 0;
    26982698    uint max = planes(frame->codec);
    2699     for (uint i = 0; i < 3; i++)
     2699    for (uint i = 0; i < MYTH_MAX_VIDEO_PLANES; i++)
    27002700    {
    27012701        pic->data[i]     = (i < max) ? (frame->buf + frame->offsets[i]) : nullptr;
    27022702        pic->linesize[i] = frame->pitches[i];
    bool AvFormatDecoder::ProcessVideoFrame(AVStream *Stream, AVFrame *AvFrame) 
    35443544            av_image_fill_arrays(tmppicture.data, tmppicture.linesize,
    35453545                                 frame->buf, AV_PIX_FMT_YUV420P, AvFrame->width,
    35463546                                 AvFrame->height, IMAGE_ALIGN);
    3547             tmppicture.data[0] = frame->buf + frame->offsets[0];
    3548             tmppicture.data[1] = frame->buf + frame->offsets[1];
    3549             tmppicture.data[2] = frame->buf + frame->offsets[2];
    3550             tmppicture.linesize[0] = frame->pitches[0];
    3551             tmppicture.linesize[1] = frame->pitches[1];
    3552             tmppicture.linesize[2] = frame->pitches[2];
     3547            for (int i = 0; i < MYTH_MAX_VIDEO_PLANES; ++i)
     3548            {
     3549                tmppicture.data[i] = frame->buf + frame->offsets[i];
     3550                tmppicture.linesize[i] = frame->pitches[i];
     3551            }
    35533552
    35543553            QSize dim = get_video_dim(*context);
    35553554            m_sws_ctx = sws_getCachedContext(m_sws_ctx, AvFrame->width,
  • mythtv/libs/libmythtv/decoders/mythcodeccontext.cpp

    diff --git a/mythtv/libs/libmythtv/decoders/mythcodeccontext.cpp b/mythtv/libs/libmythtv/decoders/mythcodeccontext.cpp
    index 4b41452637..085f49be42 100644
    a b bool MythCodecContext::RetrieveHWFrame(VideoFrame *Frame, AVFrame *AvFrame) 
    560560                // Retrieve the picture directly into the VideoFrame Buffer
    561561                temp->format = best;
    562562                uint max = planes(Frame->codec);
    563                 for (uint i = 0; i < 3; i++)
     563                for (uint i = 0; i < MYTH_MAX_VIDEO_PLANES; i++)
    564564                {
    565565                    temp->data[i]     = (i < max) ? (Frame->buf + Frame->offsets[i]) : nullptr;
    566566                    temp->linesize[i] = Frame->pitches[i];
  • mythtv/libs/libmythtv/decoders/mythnvdeccontext.cpp

    diff --git a/mythtv/libs/libmythtv/decoders/mythnvdeccontext.cpp b/mythtv/libs/libmythtv/decoders/mythnvdeccontext.cpp
    index bc5222640f..eaaa17c922 100644
    a b bool MythNVDECContext::GetBuffer(struct AVCodecContext *Context, VideoFrame *Fra 
    405405
    406406    auto *decoder = static_cast<AvFormatDecoder*>(Context->opaque);
    407407
    408     for (int i = 0; i < 3; i++)
     408    for (int i = 0; i < MYTH_MAX_VIDEO_PLANES; i++)
    409409    {
    410410        Frame->pitches[i] = AvFrame->linesize[i];
    411411        Frame->offsets[i] = AvFrame->data[i] ? (static_cast<int>(AvFrame->data[i] - AvFrame->data[0])) : 0;
  • mythtv/libs/libmythtv/mythavutil.cpp

    diff --git a/mythtv/libs/libmythtv/mythavutil.cpp b/mythtv/libs/libmythtv/mythavutil.cpp
    index 9248f824db..676f28933a 100644
    a b AVPixelFormat FrameTypeToPixelFormat(VideoFrameType type) 
    6060        case FMT_DXVA2:      return AV_PIX_FMT_DXVA2_VLD;
    6161        case FMT_MMAL:       return AV_PIX_FMT_MMAL;
    6262        case FMT_DRMPRIME:   return AV_PIX_FMT_DRM_PRIME;
     63        case FMT_YUVA420P:   return AV_PIX_FMT_YUVA420P;
    6364        case FMT_NONE: break;
    6465    }
    6566    return AV_PIX_FMT_NONE;
    VideoFrameType PixelFormatToFrameType(AVPixelFormat fmt) 
    106107        case AV_PIX_FMT_DXVA2_VLD: return FMT_DXVA2;
    107108        case AV_PIX_FMT_MEDIACODEC: return FMT_MEDIACODEC;
    108109        case AV_PIX_FMT_DRM_PRIME: return FMT_DRMPRIME;
     110        case AV_PIX_FMT_YUVA420P:  return FMT_YUVA420P;
    109111        default: break;
    110112    }
    111113    return FMT_NONE;
    QString DeinterlacerPref(MythDeintType Deint) 
    195197int AVPictureFill(AVFrame *pic, const VideoFrame *frame, AVPixelFormat fmt)
    196198{
    197199    if (fmt == AV_PIX_FMT_NONE)
    198     {
    199200        fmt = FrameTypeToPixelFormat(frame->codec);
    200     }
    201201
    202202    av_image_fill_arrays(pic->data, pic->linesize, frame->buf,
    203203        fmt, frame->width, frame->height, IMAGE_ALIGN);
    204     pic->data[1] = frame->buf + frame->offsets[1];
    205     pic->data[2] = frame->buf + frame->offsets[2];
    206     pic->linesize[0] = frame->pitches[0];
    207     pic->linesize[1] = frame->pitches[1];
    208     pic->linesize[2] = frame->pitches[2];
     204    for (int i = 0; i < MYTH_MAX_VIDEO_PLANES; ++i)
     205    {
     206        pic->data[i] = frame->buf + frame->offsets[i];
     207        pic->linesize[i] = frame->pitches[i];
     208    }
    209209    return static_cast<int>(GetBufferSize(frame->codec, frame->width, frame->height));
    210210}
    211211
    void MythAVCopy::FillFrame(VideoFrame *frame, const AVFrame *pic, int pitch, 
    269269    {
    270270        int chroma_pitch  = pitch >> 1;
    271271        int chroma_height = height >> 1;
    272         int offsets[3] =
     272        int offsets[MYTH_MAX_VIDEO_PLANES] =
    273273            { 0,
    274274              pitch * height,
    275               pitch * height + chroma_pitch * chroma_height };
    276         int pitches[3] = { pitch, chroma_pitch, chroma_pitch };
     275              pitch * height + chroma_pitch * chroma_height, 0 };
     276        int pitches[MYTH_MAX_VIDEO_PLANES] = { pitch, chroma_pitch, chroma_pitch, 0 };
    277277
    278278        init(frame, FMT_YV12, pic->data[0], width, height, size, pitches, offsets);
    279279    }
    280280    else if (pix_fmt == AV_PIX_FMT_NV12)
    281281    {
    282         int offsets[3] = { 0, pitch * height, 0 };
    283         int pitches[3] = { pitch, pitch, 0 };
    284 
     282        int offsets[MYTH_MAX_VIDEO_PLANES] = { 0, pitch * height, 0, 0 };
     283        int pitches[MYTH_MAX_VIDEO_PLANES] = { pitch, pitch, 0, 0 };
    285284        init(frame, FMT_NV12, pic->data[0], width, height, size, pitches, offsets);
    286285    }
    287286}
  • mythtv/libs/libmythtv/mythframe.cpp

    diff --git a/mythtv/libs/libmythtv/mythframe.cpp b/mythtv/libs/libmythtv/mythframe.cpp
    index dd0764fd4c..20ac175f55 100644
    a b const char* format_description(VideoFrameType Type) 
    7070        case FMT_VTB:        return "VideoToolBox";
    7171        case FMT_NVDEC:      return "NVDec";
    7272        case FMT_DRMPRIME:   return "DRM-PRIME";
     73        case FMT_YUVA420P:   return "YUVA420P";
    7374    }
    7475    return "?";
    7576}
  • mythtv/libs/libmythtv/mythframe.h

    diff --git a/mythtv/libs/libmythtv/mythframe.h b/mythtv/libs/libmythtv/mythframe.h
    index 31a4cb38b3..54cb765e75 100644
    a b extern "C" { 
    2020
    2121#define MYTH_WIDTH_ALIGNMENT 64
    2222#define MYTH_HEIGHT_ALIGNMENT 16
     23#define MYTH_MAX_VIDEO_PLANES 4
     24
    2325enum VideoFrameType
    2426{
    2527    FMT_NONE = -1,
    enum VideoFrameType 
    6466    FMT_MEDIACODEC,
    6567    FMT_VTB,
    6668    FMT_NVDEC,
    67     FMT_DRMPRIME
     69    FMT_DRMPRIME,
     70    // YUVA formats - alpha plane is last and same size as Y
     71    FMT_YUVA420P
    6872};
    6973
    7074const char* format_description(VideoFrameType Type);
    static inline int format_is_nv12(VideoFrameType Type) 
    106110    return (Type == FMT_NV12) || (Type == FMT_P010) || (Type == FMT_P016);
    107111}
    108112
     113static inline int format_is_yuva(VideoFrameType Type)
     114{
     115    return (Type == FMT_YUVA420P);
     116}
     117
    109118static inline int format_is_packed(VideoFrameType Type)
    110119{
    111120    return Type == FMT_YUY2;
    static inline int format_is_packed(VideoFrameType Type) 
    114123static inline int format_is_yuv(VideoFrameType Type)
    115124{
    116125    return format_is_420(Type)  || format_is_422(Type) || format_is_444(Type) ||
    117            format_is_nv12(Type) || format_is_packed(Type);
     126           format_is_nv12(Type) || format_is_packed(Type) || format_is_yuva(Type);
    118127}
    119128
    120129enum MythDeintType
    struct VideoFrame 
    148157    long long frameCounter; ///< raw frame counter/ticker for discontinuity checks
    149158    long long timecode;
    150159    int64_t   disp_timecode;
    151     unsigned char *priv[4]; ///< random empty storage
     160    unsigned char *priv[MYTH_MAX_VIDEO_PLANES]; ///< random empty storage
    152161    int interlaced_frame; ///< 1 if interlaced.
    153162    int top_field_first; ///< 1 if top field is first.
    154163    int interlaced_reversed; /// 1 for user override of scan
    struct VideoFrame 
    156165    int forcekey; ///< hardware encoded .nuv
    157166    int dummy;
    158167    int pause_frame;
    159     int pitches[3]; ///< Y, U, & V pitches
    160     int offsets[3]; ///< Y, U, & V offsets
     168    int pitches[MYTH_MAX_VIDEO_PLANES]; ///< Y, U, & V pitches
     169    int offsets[MYTH_MAX_VIDEO_PLANES]; ///< Y, U, & V offsets
    161170    int pix_fmt;
    162171    int sw_pix_fmt;
    163172    int directrendering; ///< 1 if managed by FFmpeg
    static inline void init(VideoFrame *vf, VideoFrameType _codec, 
    266275    vf->deinterlace_allowed = DEINT_NONE;
    267276    vf->deinterlace_inuse = DEINT_NONE;
    268277    vf->deinterlace_inuse2x = 0;
    269     memset(vf->priv, 0, 4 * sizeof(unsigned char *));
     278    memset(vf->priv, 0, MYTH_MAX_VIDEO_PLANES * sizeof(unsigned char *));
    270279
    271280    int width_aligned;
    272281    int height_aligned = (_height + MYTH_HEIGHT_ALIGNMENT - 1) & ~(MYTH_HEIGHT_ALIGNMENT -1);
    static inline void init(VideoFrame *vf, VideoFrameType _codec, 
    277286
    278287    if (p)
    279288    {
    280         memcpy(vf->pitches, p, 3 * sizeof(int));
     289        memcpy(vf->pitches, p, MYTH_MAX_VIDEO_PLANES * sizeof(int));
    281290    }
    282291    else
    283292    {
    284         for (uint i = 0; i < 3; ++i)
     293        for (uint i = 0; i < MYTH_MAX_VIDEO_PLANES; ++i)
    285294            vf->pitches[i] = pitch_for_plane(_codec, width_aligned, i);
    286295    }
    287296
    288297    if (o)
    289298    {
    290         memcpy(vf->offsets, o, 3 * sizeof(int));
     299        memcpy(vf->offsets, o, MYTH_MAX_VIDEO_PLANES * sizeof(int));
    291300    }
    292301    else
    293302    {
    294303        vf->offsets[0] = 0;
    295         if (FMT_YV12 == _codec)
     304        if (FMT_YV12 == _codec || FMT_YUVA420P == _codec)
    296305        {
     306            int uvsize = ((width_aligned + 1) >> 1) * ((height_aligned+1) >> 1);
    297307            vf->offsets[1] = width_aligned * height_aligned;
    298             vf->offsets[2] = vf->offsets[1] + ((width_aligned + 1) >> 1) * ((height_aligned+1) >> 1);
     308            vf->offsets[2] = vf->offsets[1] + uvsize;
     309            if (FMT_YUVA420P == _codec)
     310                vf->offsets[3] = vf->offsets[2] + uvsize;
    299311        }
    300312        else if (format_is_420(_codec))
    301313        {
    static inline int pitch_for_plane(VideoFrameType Type, int Width, uint Plane) 
    343355{
    344356    switch (Type)
    345357    {
     358        case FMT_YUVA420P:
     359            if (Plane == 3) return Width;
     360            Q_FALLTHROUGH();
    346361        case FMT_YV12:
    347362        case FMT_YUV422P:
    348363            if (Plane == 0) return Width;
    static inline int width_for_plane(VideoFrameType Type, int Width, uint Plane) 
    393408{
    394409    switch (Type)
    395410    {
     411        case FMT_YUVA420P:
     412            if (Plane == 3) return Width;
     413            Q_FALLTHROUGH();
    396414        case FMT_YV12:
    397415        case FMT_YUV420P9:
    398416        case FMT_YUV420P10:
    static inline int height_for_plane(VideoFrameType Type, int Height, uint Plane) 
    438456{
    439457    switch (Type)
    440458    {
     459        case FMT_YUVA420P:
     460            if (Plane == 3) return Height;
     461            Q_FALLTHROUGH();
    441462        case FMT_YV12:
    442463        case FMT_YUV420P9:
    443464        case FMT_YUV420P10:
    static inline void clear(VideoFrame *vf) 
    487508    // luma (or RGBA)
    488509    int uv_height = height_for_plane(vf->codec, vf->height, 1);
    489510    int uv = (1 << (ColorDepth(vf->codec) - 1)) - 1;
    490     if (FMT_YV12 == vf->codec || FMT_YUV422P == vf->codec || FMT_YUV444P == vf->codec)
     511    if (FMT_YV12 == vf->codec || FMT_YUV422P == vf->codec || FMT_YUV444P == vf->codec || FMT_YUVA420P == vf->codec)
    491512    {
    492513        memset(vf->buf + vf->offsets[0], 0, static_cast<size_t>(vf->pitches[0] * vf->height));
    493514        memset(vf->buf + vf->offsets[1], uv & 0xff, static_cast<size_t>(vf->pitches[1] * uv_height));
    494515        memset(vf->buf + vf->offsets[2], uv & 0xff, static_cast<size_t>(vf->pitches[2] * uv_height));
     516        if (FMT_YUVA420P == vf->codec)
     517            memset(vf->buf + vf->offsets[3], 0xff, static_cast<size_t>(vf->pitches[3] * vf->height));
    495518    }
    496519    else if ((format_is_420(vf->codec) || format_is_422(vf->codec) || format_is_444(vf->codec)) && (vf->pitches[1] == vf->pitches[2]))
    497520    {
    static inline uint planes(VideoFrameType Type) 
    604627        case FMT_MMAL:
    605628        case FMT_DRMPRIME:
    606629        case FMT_VTB:       return 0;
     630        case FMT_YUVA420P:  return 4;
    607631    }
    608632    return 0;
    609633}
    static inline int bitsperpixel(VideoFrameType Type) 
    626650        case FMT_YUY2:      return 16;
    627651        case FMT_YV12:
    628652        case FMT_NV12:      return 12;
     653        case FMT_YUVA420P:  return 20;
    629654        case FMT_YUV444P:
    630655        case FMT_P010:
    631656        case FMT_P016:
    static inline void copybuffer(VideoFrame *dst, uint8_t *buffer, 
    703728        VideoFrame framein;
    704729        int chroma_pitch  = pitch >> 1;
    705730        int chroma_height = dst->height >> 1;
    706         int offsets[3] =
     731        int offsets[MYTH_MAX_VIDEO_PLANES] =
    707732            { 0,
    708733              pitch * dst->height,
    709               pitch * dst->height + chroma_pitch * chroma_height };
    710         int pitches[3] = { pitch, chroma_pitch, chroma_pitch };
     734              pitch * dst->height + chroma_pitch * chroma_height, 0 };
     735        int pitches[MYTH_MAX_VIDEO_PLANES] = { pitch, chroma_pitch, chroma_pitch, 0 };
    711736
    712737        init(&framein, type, buffer, dst->width, dst->height, dst->size,
    713738             pitches, offsets);
    static inline void copybuffer(VideoFrame *dst, uint8_t *buffer, 
    716741    else if (type == FMT_NV12)
    717742    {
    718743        VideoFrame framein;
    719         int offsets[3] = { 0, pitch * dst->height, 0 };
    720         int pitches[3] = { pitch, pitch, 0 };
     744        int offsets[MYTH_MAX_VIDEO_PLANES] = { 0, pitch * dst->height, 0, 0 };
     745        int pitches[MYTH_MAX_VIDEO_PLANES] = { pitch, pitch, 0, 0 };
    721746
    722747        init(&framein, type, buffer, dst->width, dst->height, dst->size,
    723748             pitches, offsets);
    static inline void copybuffer(uint8_t *dstbuffer, const VideoFrame *src, 
    736761        VideoFrame frameout;
    737762        int chroma_pitch  = pitch >> 1;
    738763        int chroma_height = src->height >> 1;
    739         int offsets[3] =
     764        int offsets[MYTH_MAX_VIDEO_PLANES] =
    740765            { 0,
    741766              pitch * src->height,
    742               pitch * src->height + chroma_pitch * chroma_height };
    743         int pitches[3] = { pitch, chroma_pitch, chroma_pitch };
     767              pitch * src->height + chroma_pitch * chroma_height, 0 };
     768        int pitches[MYTH_MAX_VIDEO_PLANES] = { pitch, chroma_pitch, chroma_pitch, 0 };
    744769
    745770        init(&frameout, type, dstbuffer, src->width, src->height, src->size,
    746771             pitches, offsets);
    static inline void copybuffer(uint8_t *dstbuffer, const VideoFrame *src, 
    749774    else if (type == FMT_NV12)
    750775    {
    751776        VideoFrame frameout;
    752         int offsets[3] = { 0, pitch * src->height, 0 };
    753         int pitches[3] = { pitch, pitch, 0 };
     777        int offsets[MYTH_MAX_VIDEO_PLANES] = { 0, pitch * src->height, 0, 0 };
     778        int pitches[MYTH_MAX_VIDEO_PLANES] = { pitch, pitch, 0, 0 };
    754779
    755780        init(&frameout, type, dstbuffer, src->width, src->height, src->size,
    756781             pitches, offsets);
  • mythtv/libs/libmythtv/opengl/mythopenglvideo.cpp

    diff --git a/mythtv/libs/libmythtv/opengl/mythopenglvideo.cpp b/mythtv/libs/libmythtv/opengl/mythopenglvideo.cpp
    index 491f3bd0da..7a8cc5910c 100644
    a b bool MythOpenGLVideo::CreateVideoShader(VideoShaderType Type, MythDeintType Dein 
    295295        bool kernel = false;
    296296        bool topfield = InterlacedTop == Type;
    297297        bool progressive = (Progressive == Type) || (Deint == DEINT_NONE);
    298         if (format_is_420(m_outputType) || format_is_422(m_outputType) || format_is_444(m_outputType))
     298        if (format_is_420(m_outputType) || format_is_422(m_outputType) || format_is_444(m_outputType) || format_is_yuva(m_outputType))
    299299        {
    300300            defines << "YV12";
    301301            cost = 3;
    bool MythOpenGLVideo::CreateVideoShader(VideoShaderType Type, MythDeintType Dein 
    346346        // 'expand' calls to sampleYUV for multiple planes
    347347        // do this before we add the samplers
    348348        int count = static_cast<int>(planes(m_outputType));
     349        // HACK - ignore Alpha channel
     350        if (count > 3)
     351            count = 3;
    349352        for (int i = (kernel ? 2 : 0); (i >= 0) && count; i--)
    350353        {
    351354            QString find = QString("s_texture%1").arg(i);
  • mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp

    diff --git a/mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp b/mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp
    index 25a60593a9..14dcd5249d 100644
    a b VideoFrameType* MythVideoOutputOpenGL::DirectRenderFormats(void) 
    718718          FMT_YUV422P9, FMT_YUV422P10, FMT_YUV422P12, FMT_YUV422P14, FMT_YUV422P16,
    719719          FMT_YUV444P9, FMT_YUV444P10, FMT_YUV444P12, FMT_YUV444P14, FMT_YUV444P16,
    720720          FMT_P010, FMT_P016,
     721          FMT_YUVA420P,
    721722          FMT_NONE };
    722723    // OpenGLES2 only allows luminance textures - no RG etc
    723724    static VideoFrameType s_opengles2Formats[] =
    724         { FMT_YV12, FMT_YUY2, FMT_YUV422P, FMT_YUV444P, FMT_NONE };
     725        { FMT_YV12, FMT_YUY2, FMT_YUV422P, FMT_YUV444P, FMT_YUVA420P, FMT_NONE };
    725726    return m_isGLES2 ? &s_opengles2Formats[0] : &s_openglFormats[0];
    726727}
    727728
  • mythtv/libs/libmythtv/opengl/mythvideotexture.cpp

    diff --git a/mythtv/libs/libmythtv/opengl/mythvideotexture.cpp b/mythtv/libs/libmythtv/opengl/mythvideotexture.cpp
    index 3abb162f4f..238e95b812 100644
    a b vector<MythVideoTexture*> MythVideoTexture::CreateSoftwareTextures(MythRenderOpe 
    139139    vector<MythVideoTexture*> result;
    140140
    141141    uint count = planes(Format);
     142    // HACK - ignore Alpha plane
     143    if (count > 3)
     144        count = 3;
    142145    if (count < 1)
    143146    {
    144147        LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame format");
    vector<MythVideoTexture*> MythVideoTexture::CreateSoftwareTextures(MythRenderOpe 
    158161        switch (Format)
    159162        {
    160163            case FMT_YV12:
     164            case FMT_YUVA420P:
    161165                if (plane > 0)
    162166                    size = QSize(size.width() >> 1, size.height() >> 1);
    163167                texture = CreateTexture(Context, size, Target,
    void MythVideoTexture::UpdateTextures(MythRenderOpenGL *Context, 
    269273    }
    270274
    271275    uint count = planes(Textures[0]->m_frameFormat);
     276    // HACK - ignore alpha channel
     277    if (count > 3)
     278        count = 3;
    272279    if (!count || (count != Textures.size()))
    273280    {
    274281        LOG(VB_GENERAL, LOG_ERR, LOC + "Invalid software frame type");
    void MythVideoTexture::UpdateTextures(MythRenderOpenGL *Context, 
    294301        switch (texture->m_frameType)
    295302        {
    296303            case FMT_YV12:
     304            case FMT_YUVA420P:
    297305            {
    298306                switch (texture->m_frameFormat)
    299307                {
    300                     case FMT_YV12:   YV12ToYV12(Context, Frame, texture, i); break;
    301                     case FMT_YUY2:   YV12ToYUYV(Frame, texture);    break;
     308                    case FMT_YUVA420P:
     309                    case FMT_YV12: YV12ToYV12(Context, Frame, texture, i); break;
     310                    case FMT_YUY2: YV12ToYUYV(Frame, texture);    break;
    302311                    default: break;
    303312                }
    304313                break;
    inline void MythVideoTexture::YV12ToYV12(MythRenderOpenGL *Context, const VideoF 
    460469{
    461470    if (Context->GetExtraFeatures() & kGLExtSubimage)
    462471    {
    463         int pitch = (Frame->codec == FMT_YV12 || Frame->codec == FMT_YUV422P || Frame->codec == FMT_YUV444P) ?
     472        int pitch = (Frame->codec == FMT_YV12 || Frame->codec == FMT_YUVA420P ||
     473                     Frame->codec == FMT_YUV422P || Frame->codec == FMT_YUV444P) ?
    464474                     Frame->pitches[Plane] : Frame->pitches[Plane] >> 1;
    465475        Context->glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch);
    466476        Texture->m_texture->setData(Texture->m_pixelFormat, Texture->m_pixelType,
    inline void MythVideoTexture::YV12ToYV12(MythRenderOpenGL *Context, const VideoF 
    472482        if (!Texture->m_data)
    473483            if (!CreateBuffer(Texture, Texture->m_bufferSize))
    474484                return;
    475         int pitch = (Frame->codec == FMT_YV12 || Frame->codec == FMT_YUV422P || Frame->codec == FMT_YUV444P) ?
     485        int pitch = (Frame->codec == FMT_YV12 || Frame->codec == FMT_YUVA420P ||
     486                     Frame->codec == FMT_YUV422P || Frame->codec == FMT_YUV444P) ?
    476487                     Texture->m_size.width() : Texture->m_size.width() << 1;
    477488        copyplane(Texture->m_data, pitch, Frame->buf + Frame->offsets[Plane],
    478489                  Frame->pitches[Plane], pitch, Texture->m_size.height());
  • mythtv/libs/libmythtv/videobuffers.cpp

    diff --git a/mythtv/libs/libmythtv/videobuffers.cpp b/mythtv/libs/libmythtv/videobuffers.cpp
    index 13d7f31f59..01e571f212 100644
    a b YUVInfo::YUVInfo(uint Width, uint Height, uint Size, const int *Pitches, 
    4343
    4444    if (Pitches)
    4545    {
    46         memcpy(m_pitches, Pitches, 3 * sizeof(int));
     46        memcpy(m_pitches, Pitches, MYTH_MAX_VIDEO_PLANES * sizeof(int));
    4747    }
    4848    else
    4949    {
    5050        m_pitches[0] = alignedwidth;
    5151        m_pitches[1] = m_pitches[2] = (alignedwidth+1) >> 1;
     52        m_pitches[3] = 0;
    5253    }
    5354
    5455    if (Offsets)
    5556    {
    56         memcpy(m_offsets, Offsets, 3 * sizeof(int));
     57        memcpy(m_offsets, Offsets, MYTH_MAX_VIDEO_PLANES * sizeof(int));
    5758    }
    5859    else
    5960    {
    6061        m_offsets[0] = 0;
    6162        m_offsets[1] = alignedwidth * m_height;
    6263        m_offsets[2] = m_offsets[1] + ((alignedwidth+1) >> 1) * ((m_height+1) >> 1);
     64        m_offsets[3] = 0;
    6365    }
    6466}
    6567
  • mythtv/libs/libmythtv/videobuffers.h

    diff --git a/mythtv/libs/libmythtv/videobuffers.h b/mythtv/libs/libmythtv/videobuffers.h
    index 083ef6bc42..c195ed1915 100644
    a b class YUVInfo 
    4646    uint m_width;
    4747    uint m_height;
    4848    uint m_size;
    49     uint m_pitches[3];
    50     uint m_offsets[3];
     49    uint m_pitches[MYTH_MAX_VIDEO_PLANES];
     50    uint m_offsets[MYTH_MAX_VIDEO_PLANES];
    5151};
    5252
    5353class MTV_PUBLIC VideoBuffers