Ticket #13186: 002_avpicture.patch

File 002_avpicture.patch, 62.1 KB (added by Peter Bennett, 3 years ago)

Patch 002 AVPicture

  • mythtv/configure

    diff --git a/mythtv/configure b/mythtv/configure
    index 2e5c49e..7c743eb 100755
    a b wtv_muxer_select="mpegts_muxer riffenc" 
    33063306xmv_demuxer_select="riffdec"
    33073307xwma_demuxer_select="riffdec"
    33083308
     3309# ffmpeg setting - value for image utils - 32 recommended, 1 used to now
     3310image_align=1
     3311
    33093312# indevs / outdevs
    33103313alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
    33113314alsa_outdev_deps="alsa_asoundlib_h"
    cat > $TMPH <<EOF 
    85938596#define SIZEOF_LONG $_sizeof_long
    85948597#define JDK_HOME "$JDK_HOME"
    85958598#define JAVA_ARCH "$java_arch"
     8599#define IMAGE_ALIGN $image_align
    85968600EOF
    85978601
    85988602# Code only checks whether HAVE_BDJ_J2ME is defined, not what value
  • mythtv/libs/libmythtv/avformatdecoder.cpp

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index f7fd572..d0ec724 100644
    a b extern "C" { 
    7373#include "libswscale/swscale.h"
    7474#include "libavformat/isom.h"
    7575#include "ivtv_myth.h"
     76#include "libavutil/imgutils.h"
    7677}
    7778
    7879#ifdef _MSC_VER
    bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 
    37113712    }
    37123713    else if (!directrendering)
    37133714    {
    3714         AVPicture tmppicture;
     3715        AVFrame tmppicture;
    37153716
    37163717        VideoFrame *xf = picframe;
    37173718        picframe = m_parent->GetNextVideoFrame();
    37183719
    37193720        unsigned char *buf = picframe->buf;
    3720         avpicture_fill(&tmppicture, buf, AV_PIX_FMT_YUV420P, context->width,
    3721                        context->height);
     3721        av_image_fill_arrays(tmppicture.data, tmppicture.linesize,
     3722            buf, AV_PIX_FMT_YUV420P, context->width,
     3723                       context->height, IMAGE_ALIGN);
    37223724        tmppicture.data[0] = buf + picframe->offsets[0];
    37233725        tmppicture.data[1] = buf + picframe->offsets[1];
    37243726        tmppicture.data[2] = buf + picframe->offsets[2];
  • mythtv/libs/libmythtv/avformatwriter.cpp

    diff --git a/mythtv/libs/libmythtv/avformatwriter.cpp b/mythtv/libs/libmythtv/avformatwriter.cpp
    index e34dc2d..37efe12 100644
    a b extern "C" { 
    3131#endif
    3232#include "libavutil/opt.h"
    3333#include "libavutil/samplefmt.h"
     34#include "libavutil/imgutils.h"
    3435}
    3536
    3637#define LOC QString("AVFW(%1): ").arg(m_filename)
    int AVFormatWriter::WriteVideoFrame(VideoFrame *frame) 
    237238    int framesEncoded = m_framesWritten + m_bufferedVideoFrameTimes.size();
    238239
    239240    av_frame_unref(m_picture);
    240     AVPictureFill(reinterpret_cast<AVPicture*>(m_picture), frame);
     241    AVPictureFill(reinterpret_cast<AVFrame*>(m_picture), frame);
    241242    m_picture->pts = framesEncoded + 1;
    242243
    243244    if ((framesEncoded % m_keyFrameDist) == 0)
    AVFrame* AVFormatWriter::AllocPicture(enum AVPixelFormat pix_fmt) 
    721722        av_frame_free(&picture);
    722723        return NULL;
    723724    }
    724     avpicture_fill((AVPicture *)picture, picture_buf,
    725                    pix_fmt, m_width, m_height);
     725    av_image_fill_arrays(picture->data, picture->linesize,
     726        picture_buf, pix_fmt, m_width, m_height, IMAGE_ALIGN);
    726727    return picture;
    727728}
    728729
  • mythtv/libs/libmythtv/mhi.cpp

    diff --git a/mythtv/libs/libmythtv/mhi.cpp b/mythtv/libs/libmythtv/mhi.cpp
    index 3d9a7e4..3d5c446 100644
    a b  
    3838#include "mythuiactions.h"              // for ACTION_0, ACTION_1, etc
    3939#include "tv_actions.h"                 // for ACTION_MENUTEXT, etc
    4040
     41extern "C" {
     42#include "libavutil/imgutils.h"
     43}
     44
    4145static bool       ft_loaded = false;
    4246static FT_Library ft_library;
    4347
    void MHIBitmap::CreateFromMPEG(const unsigned char *data, int length) 
    19201924        m_image = QImage(nContentWidth, nContentHeight, QImage::Format_ARGB32);
    19211925        m_opaque = true; // MPEG images are always opaque.
    19221926
    1923         AVPicture retbuf;
    1924         memset(&retbuf, 0, sizeof(AVPicture));
     1927        AVFrame retbuf;
     1928        memset(&retbuf, 0, sizeof(AVFrame));
    19251929
    19261930        int bufflen = nContentWidth * nContentHeight * 3;
    19271931        unsigned char *outputbuf = (unsigned char*)av_malloc(bufflen);
    19281932
    1929         avpicture_fill(&retbuf, outputbuf, AV_PIX_FMT_RGB24,
    1930                        nContentWidth, nContentHeight);
     1933        av_image_fill_arrays(retbuf.data, retbuf.linesize,
     1934            outputbuf, AV_PIX_FMT_RGB24,
     1935            nContentWidth, nContentHeight,IMAGE_ALIGN);
    19311936
    19321937        AVFrame *tmp = picture;
    1933         m_copyCtx->Copy(&retbuf, AV_PIX_FMT_RGB24, (AVPicture*)tmp, c->pix_fmt,
     1938        m_copyCtx->Copy(&retbuf, AV_PIX_FMT_RGB24, (AVFrame*)tmp, c->pix_fmt,
    19341939                     nContentWidth, nContentHeight);
    19351940
    19361941        uint8_t * buf = outputbuf;
  • mythtv/libs/libmythtv/mythavutil.cpp

    diff --git a/mythtv/libs/libmythtv/mythavutil.cpp b/mythtv/libs/libmythtv/mythavutil.cpp
    index 8fc8875..80a1777 100644
    a b extern "C" { 
    1616#include "libavcodec/avcodec.h"
    1717#include "libavfilter/buffersrc.h"
    1818#include "libavfilter/buffersink.h"
     19#include "libavutil/imgutils.h"
    1920}
    2021
    2122AVPixelFormat FrameTypeToPixelFormat(VideoFrameType type)
    VideoFrameType PixelFormatToFrameType(AVPixelFormat fmt) 
    5859    }
    5960}
    6061
    61 int AVPictureFill(AVPicture *pic, const VideoFrame *frame, AVPixelFormat fmt)
     62int AVPictureFill(AVFrame *pic, const VideoFrame *frame, AVPixelFormat fmt)
    6263{
    6364    if (fmt == AV_PIX_FMT_NONE)
    6465    {
    6566        fmt = FrameTypeToPixelFormat(frame->codec);
    6667    }
    6768
    68     avpicture_fill(pic, frame->buf, fmt, frame->width, frame->height);
     69    av_image_fill_arrays(pic->data, pic->linesize, frame->buf,
     70        fmt, frame->width, frame->height, IMAGE_ALIGN);
    6971    pic->data[1] = frame->buf + frame->offsets[1];
    7072    pic->data[2] = frame->buf + frame->offsets[2];
    7173    pic->linesize[0] = frame->pitches[0];
    public: 
    98100        {
    99101            return size;
    100102        }
    101         size    = avpicture_get_size(_fmt, _width, _height);
     103        size    = av_image_get_buffer_size(_fmt, _width, _height, IMAGE_ALIGN);
    102104        width   = _width;
    103105        height  = _height;
    104106        format  = _fmt;
    MythAVCopy::~MythAVCopy() 
    120122    delete d;
    121123}
    122124
    123 void MythAVCopy::FillFrame(VideoFrame *frame, const AVPicture *pic, int pitch,
     125void MythAVCopy::FillFrame(VideoFrame *frame, const AVFrame *pic, int pitch,
    124126                           int width, int height, AVPixelFormat pix_fmt)
    125127{
    126     int size = avpicture_get_size(pix_fmt, width, height);
     128    int size = av_image_get_buffer_size(pix_fmt, width, height, IMAGE_ALIGN);
    127129
    128130    if (pix_fmt == AV_PIX_FMT_YUV420P)
    129131    {
    void MythAVCopy::FillFrame(VideoFrame *frame, const AVPicture *pic, int pitch, 
    146148    }
    147149}
    148150
    149 int MythAVCopy::Copy(AVPicture *dst, AVPixelFormat dst_pix_fmt,
    150                  const AVPicture *src, AVPixelFormat pix_fmt,
     151int MythAVCopy::Copy(AVFrame *dst, AVPixelFormat dst_pix_fmt,
     152                 const AVFrame *src, AVPixelFormat pix_fmt,
    151153                 int width, int height)
    152154{
    153155    if ((pix_fmt == AV_PIX_FMT_YUV420P || pix_fmt == AV_PIX_FMT_NV12) &&
    int MythAVCopy::Copy(VideoFrame *dst, const VideoFrame *src) 
    197199        return dst->size;
    198200    }
    199201
    200     AVPicture srcpic, dstpic;
     202    AVFrame srcpic, dstpic;
    201203
    202204    AVPictureFill(&srcpic, src);
    203205    AVPictureFill(&dstpic, dst);
    int MythAVCopy::Copy(VideoFrame *dst, const VideoFrame *src) 
    207209                src->width, src->height);
    208210}
    209211
    210 int MythAVCopy::Copy(AVPicture *pic, const VideoFrame *frame,
     212int MythAVCopy::Copy(AVFrame *pic, const VideoFrame *frame,
    211213                 unsigned char *buffer, AVPixelFormat fmt)
    212214{
    213215    VideoFrameType type = PixelFormatToFrameType(fmt);
    int MythAVCopy::Copy(AVPicture *pic, const VideoFrame *frame, 
    219221        return 0;
    220222    }
    221223
    222     AVPicture pic_in;
     224    AVFrame pic_in;
    223225    AVPixelFormat fmt_in = FrameTypeToPixelFormat(frame->codec);
    224226
    225227    AVPictureFill(&pic_in, frame, fmt_in);
    226     avpicture_fill(pic, sbuf, fmt, frame->width, frame->height);
     228    av_image_fill_arrays(pic->data, pic->linesize, sbuf, fmt, frame->width, frame->height, IMAGE_ALIGN);
    227229    return Copy(pic, fmt, &pic_in, fmt_in, frame->width, frame->height);
    228230}
    229231
    230 int MythAVCopy::Copy(VideoFrame *frame, const AVPicture *pic, AVPixelFormat fmt)
     232int MythAVCopy::Copy(VideoFrame *frame, const AVFrame *pic, AVPixelFormat fmt)
    231233{
    232234    if (fmt == AV_PIX_FMT_NV12 || AV_PIX_FMT_YUV420P)
    233235    {
    int MythAVCopy::Copy(VideoFrame *frame, const AVPicture *pic, AVPixelFormat fmt) 
    236238        return Copy(frame, &framein);
    237239    }
    238240
    239     AVPicture frame_out;
     241    AVFrame frame_out;
    240242    AVPixelFormat fmt_out = FrameTypeToPixelFormat(frame->codec);
    241243
    242244    AVPictureFill(&frame_out, frame, fmt_out);
    MythPictureDeinterlacer::MythPictureDeinterlacer(AVPixelFormat pixfmt, 
    260262    }
    261263}
    262264
    263 int MythPictureDeinterlacer::Deinterlace(AVPicture *dst, const AVPicture *src)
     265int MythPictureDeinterlacer::Deinterlace(AVFrame *dst, const AVFrame *src)
    264266{
    265267    if (m_errored)
    266268    {
    int MythPictureDeinterlacer::Deinterlace(AVPicture *dst, const AVPicture *src) 
    284286    {
    285287        return res;
    286288    }
    287     av_picture_copy(dst, (const AVPicture*)m_filter_frame, m_pixfmt, m_width, m_height);
     289
     290    av_image_copy(dst->data, dst->linesize,
     291        (const uint8_t **)((AVFrame*)m_filter_frame)->data,
     292        (const int*)((AVFrame*)m_filter_frame)->linesize,
     293        m_pixfmt, m_width, m_height);
     294
    288295    av_frame_unref(m_filter_frame);
    289296
    290297    return 0;
    291298}
    292299
    293 int MythPictureDeinterlacer::DeinterlaceSingle(AVPicture *dst, const AVPicture *src)
     300int MythPictureDeinterlacer::DeinterlaceSingle(AVFrame *dst, const AVFrame *src)
    294301{
    295302    if (m_errored)
    296303    {
  • mythtv/libs/libmythtv/mythavutil.h

    diff --git a/mythtv/libs/libmythtv/mythavutil.h b/mythtv/libs/libmythtv/mythavutil.h
    index cbe169f..a59c246 100644
    a b public: 
    6666    {
    6767        return m_frame;
    6868    }
    69     operator AVPicture*() const
    70     {
    71         return reinterpret_cast<AVPicture*>(m_frame);
    72     }
    73     operator const AVPicture*() const
    74     {
    75         return reinterpret_cast<AVPicture*>(m_frame);
    76     }
    7769
    7870private:
    7971    AVFrame *m_frame;
    class MythAVCopyPrivate; 
    8375
    8476/**
    8577 * MythAVCopy
    86  * Copy AVPicture<->frame, performing the required conversion if any
     78 * Copy AVFrame<->frame, performing the required conversion if any
    8779 */
    8880class MTV_PUBLIC MythAVCopy
    8981{
    public: 
    9486    int Copy(VideoFrame *dst, const VideoFrame *src);
    9587    /**
    9688     * Copy
    97      * Initialise AVPicture pic, create buffer if required and copy content of
     89     * Initialise AVFrame pic, create buffer if required and copy content of
    9890     * VideoFrame frame into it, performing the required conversion if any
    9991     * Returns size of buffer allocated
    10092     * Data would have to be deleted once finished with object with:
    10193     * av_freep(pic->data[0])
    10294     */
    103     int Copy(AVPicture *pic, const VideoFrame *frame,
     95    int Copy(AVFrame *pic, const VideoFrame *frame,
    10496             unsigned char *buffer = NULL,
    10597             AVPixelFormat fmt = AV_PIX_FMT_YUV420P);
    10698    /**
    10799     * Copy
    108      * Copy AVPicture pic into VideoFrame frame, performing the required conversion
     100     * Copy AVFrame pic into VideoFrame frame, performing the required conversion
    109101     * Returns size of frame data
    110102     */
    111     int Copy(VideoFrame *frame, const AVPicture *pic,
     103    int Copy(VideoFrame *frame, const AVFrame *pic,
    112104             AVPixelFormat fmt = AV_PIX_FMT_YUV420P);
    113     int Copy(AVPicture *dst, AVPixelFormat dst_pix_fmt,
    114              const AVPicture *src, AVPixelFormat pix_fmt,
     105    int Copy(AVFrame *dst, AVPixelFormat dst_pix_fmt,
     106             const AVFrame *src, AVPixelFormat pix_fmt,
    115107             int width, int height);
    116108
    117109private:
    118     void FillFrame(VideoFrame *frame, const AVPicture *pic, int pitch,
     110    void FillFrame(VideoFrame *frame, const AVFrame *pic, int pitch,
    119111                   int width, int height, AVPixelFormat pix_fmt);
    120112    MythAVCopyPrivate *d;
    121113};
    122114
    123115/**
    124116 * AVPictureFill
    125  * Initialise AVPicture pic with content from VideoFrame frame
     117 * Initialise AVFrame pic with content from VideoFrame frame
    126118 */
    127 int MTV_PUBLIC AVPictureFill(AVPicture *pic, const VideoFrame *frame,
     119int MTV_PUBLIC AVPictureFill(AVFrame *pic, const VideoFrame *frame,
    128120                             AVPixelFormat fmt = AV_PIX_FMT_NONE);
    129121
    130122/**
    public: 
    149141    // To drain the deinterlacer, call Deinterlace with src = NULL until you
    150142    // get no more frames. Once drained, you must call Flush() to start
    151143    // deinterlacing again.
    152     int Deinterlace(AVPicture *dst, const AVPicture *src);
    153     int DeinterlaceSingle(AVPicture *dst, const AVPicture *src);
     144    int Deinterlace(AVFrame *dst, const AVFrame *src);
     145    int DeinterlaceSingle(AVFrame *dst, const AVFrame *src);
    154146    // Flush and reset the deinterlacer.
    155147    int Flush();
    156148private:
  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 3320553..2f9dbf9 100644
    a b char *MythPlayer::GetScreenGrabAtFrame(uint64_t frameNum, bool absolute, 
    45094509    unsigned char *data      = NULL;
    45104510    unsigned char *outputbuf = NULL;
    45114511    VideoFrame    *frame     = NULL;
    4512     AVPicture      orig;
    4513     AVPicture      retbuf;
     4512    AVFrame      orig;
     4513    AVFrame      retbuf;
    45144514    MythAVCopy     copyCtx;
    4515     memset(&orig,   0, sizeof(AVPicture));
    4516     memset(&retbuf, 0, sizeof(AVPicture));
     4515    memset(&orig,   0, sizeof(AVFrame));
     4516    memset(&retbuf, 0, sizeof(AVFrame));
    45174517
    45184518    bufflen = 0;
    45194519    vw = vh = 0;
  • mythtv/libs/libmythtv/nuppeldecoder.cpp

    diff --git a/mythtv/libs/libmythtv/nuppeldecoder.cpp b/mythtv/libs/libmythtv/nuppeldecoder.cpp
    index 9079c17..ff9e581 100644
    a b bool NuppelDecoder::DecodeFrame(struct rtframeheader *frameheader, 
    963963            return true;
    964964
    965965        AVFrame *tmp = mpa_pic;
    966         copyFrame.Copy(frame, (AVPicture*)tmp, mpa_vidctx->pix_fmt);
     966        copyFrame.Copy(frame, (AVFrame*)tmp, mpa_vidctx->pix_fmt);
    967967    }
    968968
    969969    return true;
  • mythtv/libs/libmythtv/openglvideo.cpp

    diff --git a/mythtv/libs/libmythtv/openglvideo.cpp b/mythtv/libs/libmythtv/openglvideo.cpp
    index f4d2c04..75d5fa7 100644
    a b void OpenGLVideo::UpdateInputFrame(const VideoFrame *frame, bool soft_bob) 
    872872        MYTHTV_UYVY == videoTextureType)
    873873    {
    874874        // software conversion
    875         AVPicture img_out;
     875        AVFrame img_out;
    876876        AVPixelFormat out_fmt = AV_PIX_FMT_BGRA;
    877877        if ((GL_YCBCR_MESA == videoTextureType) ||
    878878            (GL_YCBCR_422_APPLE == videoTextureType) ||
  • mythtv/libs/libmythtv/privatedecoder_crystalhd.cpp

    diff --git a/mythtv/libs/libmythtv/privatedecoder_crystalhd.cpp b/mythtv/libs/libmythtv/privatedecoder_crystalhd.cpp
    index a59b5da..6c8841d 100644
    a b  
    33#include "fourcc.h"
    44#include "unistd.h"
    55
     6extern "C" {
     7#include "libavutil/imgutils.h"
     8}
     9
    610#define LOC  QString("CrystalHD: ")
    711#define ERR  QString("CrystalHD Err: ")
    812#define WARN QString("CrystalHD Warn: ")
    void PrivateDecoderCrystalHD::FillFrame(BC_DTS_PROC_OUT *out) 
    664668
    665669    AVPixelFormat out_fmt = AV_PIX_FMT_YUV420P;
    666670    AVPixelFormat in_fmt  = bcmpixfmt_to_pixfmt(m_pix_fmt);
    667     AVPicture img_in;
     671    AVFrame img_in;
    668672
    669     avpicture_fill(&img_in, src, in_fmt, in_width, in_height);
     673    av_image_fill_arrays(img_in.data, img_in.linesize,
     674        src, in_fmt, in_width, in_height, IMAGE_ALIGN);
    670675
    671676    if (!(out->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC))
    672677    {
    void PrivateDecoderCrystalHD::FillFrame(BC_DTS_PROC_OUT *out) 
    676681    }
    677682    else
    678683    {
    679         AVPicture img_out;
     684        AVFrame img_out;
    680685
    681686        AVPictureFill(&img_out, m_frame);
    682687        img_out.linesize[0] *= 2;
  • mythtv/libs/libmythtv/privatedecoder_omx.cpp

    diff --git a/mythtv/libs/libmythtv/privatedecoder_omx.cpp b/mythtv/libs/libmythtv/privatedecoder_omx.cpp
    index 585687c..7c4fbf7 100644
    a b  
    1414extern "C" {
    1515#include "libavutil/pixdesc.h"
    1616#include "libavcodec/avcodec.h"
     17#include "libavutil/imgutils.h"
    1718}
    1819
    1920#include "avformatdecoder.h"
    int PrivateDecoderOMX::GetBufferedFrame(AVStream *stream, AVFrame *picture) 
    10311032            buf = (unsigned char*)av_malloc(size);
    10321033            init(&vf, frametype, buf, out_width, out_height, size);
    10331034
    1034             AVPicture img_in, img_out;
    1035             avpicture_fill(&img_out, (uint8_t *)vf.buf, out_fmt, out_width,
    1036                 out_height);
    1037             avpicture_fill(&img_in, src, in_fmt, in_width, in_height);
     1035            AVFrame img_in, img_out;
     1036            av_image_fill_arrays(img_out.data, img_out.linesize,
     1037                (uint8_t *)vf.buf, out_fmt, out_width,
     1038                out_height, IMAGE_ALIGN);
     1039            av_image_fill_arrays(img_in.data, img_in.linesize,
     1040                src, in_fmt, in_width, in_height, IMAGE_ALIGN);
    10381041
    10391042            LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Converting %1 to %2")
    10401043                .arg(av_pix_fmt_desc_get(in_fmt)->name)
  • mythtv/libs/libmythtv/privatedecoder_vda.cpp

    diff --git a/mythtv/libs/libmythtv/privatedecoder_vda.cpp b/mythtv/libs/libmythtv/privatedecoder_vda.cpp
    index dbb9976..f98a2d5 100644
    a b  
    1616
    1717extern "C" {
    1818#include "libavformat/avformat.h"
     19#include "libavutil/imgutils.h"
    1920}
    2021VDALibrary *gVDALib = NULL;
    2122
    int PrivateDecoderVDA::GetFrame(AVStream *stream, 
    657658    {
    658659        CVPixelBufferLockBaseAddress(vdaframe.buffer, 0);
    659660        uint8_t* base = (uint8_t*)CVPixelBufferGetBaseAddressOfPlane(vdaframe.buffer, 0);
    660         AVPicture img_in;
    661         avpicture_fill(&img_in, base, in_fmt, frame->width, frame->height);
     661        AVFrame img_in;
     662        av_image_fill_arrays(img_in.data, img_in.linesize,
     663            base, in_fmt, frame->width, frame->height, IMAGE_ALIGN);
    662664        m_copyCtx.Copy(frame, &img_in, in_fmt);
    663665        CVPixelBufferUnlockBaseAddress(vdaframe.buffer, 0);
    664666    }
  • mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp

    diff --git a/mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp
    index 04c6d01..c8b2e80 100644
    a b extern "C" { 
    4343
    4444extern "C" {
    4545#include "libswscale/swscale.h"
     46#include "libavutil/imgutils.h"
    4647}
    4748
    4849#ifdef USING_V4L2
    void NuppelVideoRecorder::DoV4L2(void) 
    16131614    // setup pixel format conversions for YUYV and UYVY
    16141615    uint8_t *output_buffer = NULL;
    16151616    struct SwsContext *convert_ctx = NULL;
    1616     AVPicture img_out;
     1617    AVFrame img_out;
    16171618    if (v4l2_pixelformat == V4L2_PIX_FMT_YUYV ||
    16181619        v4l2_pixelformat == V4L2_PIX_FMT_UYVY)
    16191620    {
    void NuppelVideoRecorder::DoV4L2(void) 
    16401641            return;
    16411642        }
    16421643
    1643         avpicture_fill(&img_out, output_buffer, AV_PIX_FMT_YUV420P, width, height);
     1644        av_image_fill_arrays(img_out.data, img_out.linesize,
     1645            output_buffer, AV_PIX_FMT_YUV420P, width, height, IMAGE_ALIGN);
    16441646    }
    16451647
    16461648    while (IsRecordingRequested() && !IsErrored())
    again: 
    17431745        {
    17441746            if (v4l2_pixelformat == V4L2_PIX_FMT_YUYV)
    17451747            {
    1746                 AVPicture img_in;
    1747                 avpicture_fill(&img_in, buffers[frame], AV_PIX_FMT_YUYV422, width, height);
     1748                AVFrame img_in;
     1749                av_image_fill_arrays(img_in.data, img_in.linesize,
     1750                    buffers[frame], AV_PIX_FMT_YUYV422, width, height,
     1751                    IMAGE_ALIGN);
    17481752                sws_scale(convert_ctx, img_in.data, img_in.linesize,
    17491753                          0, height, img_out.data, img_out.linesize);
    17501754                BufferIt(output_buffer, video_buffer_size);
    17511755            }
    17521756            else if (v4l2_pixelformat == V4L2_PIX_FMT_UYVY)
    17531757            {
    1754                 AVPicture img_in;
    1755                 avpicture_fill(&img_in, buffers[frame], AV_PIX_FMT_UYVY422, width, height);
     1758                AVFrame img_in;
     1759                av_image_fill_arrays(img_in.data, img_in.linesize,
     1760                    buffers[frame], AV_PIX_FMT_UYVY422, width, height,
     1761                    IMAGE_ALIGN);
    17561762                sws_scale(convert_ctx, img_in.data, img_in.linesize,
    17571763                          0, height, img_out.data, img_out.linesize);
    17581764                BufferIt(output_buffer, video_buffer_size);
  • mythtv/libs/libmythtv/videoout_d3d.cpp

    diff --git a/mythtv/libs/libmythtv/videoout_d3d.cpp b/mythtv/libs/libmythtv/videoout_d3d.cpp
    index afff5b8..095f48f 100644
    a b using namespace std; 
    1818#include "mmsystem.h"
    1919#include "tv.h"
    2020
     21extern "C" {
     22#include "libavutil/imgutils.h"
     23}
     24
    2125#undef UNICODE
    2226
    2327const int kNumBuffers = 31;
    void VideoOutputD3D::UpdateFrame(VideoFrame *frame, D3D9Image *img) 
    473477    }
    474478    else if (buf && !hardware_conv)
    475479    {
    476         AVPicture image_out;
    477         avpicture_fill(&image_out, (uint8_t*)buf,
    478                        AV_PIX_FMT_RGB32, frame->width, frame->height);
     480        AVFrame image_out;
     481        av_image_fill_arrays(image_out.data, image_out.linesize,
     482            (uint8_t*)buf,
     483            AV_PIX_FMT_RGB32, frame->width, frame->height, IMAGE_ALIGN);
    479484        image_out.linesize[0] = pitch;
    480485        m_copyFrame.Copy(&image_out, frame,(uint8_t*)buf, AV_PIX_FMT_RGB32);
    481486    }
  • mythtv/libs/libmythtv/videoout_xv.cpp

    diff --git a/mythtv/libs/libmythtv/videoout_xv.cpp b/mythtv/libs/libmythtv/videoout_xv.cpp
    index 17736e3..0dd52ed 100644
    a b extern "C" { 
    5858#endif // silences warning when these are already defined
    5959
    6060#include "libswscale/swscale.h"
     61#include "libavutil/imgutils.h"
    6162}
    6263
    6364#if ! HAVE_ROUND
    void VideoOutputXv::PrepareFrameMem(VideoFrame *buffer, FrameScanType /*scan*/) 
    14351436
    14361437    int out_width  = display_visible_rect.width()  & ~0x1;
    14371438    int out_height = display_visible_rect.height() & ~0x1;
    1438     AVPicture image_in, image_out;
     1439    AVFrame image_in, image_out;
    14391440
    14401441    if ((out_width  == width) &&
    14411442        (out_height == height))
    void VideoOutputXv::PrepareFrameMem(VideoFrame *buffer, FrameScanType /*scan*/) 
    14491450        int size = buffersize(FMT_YV12, out_width, out_height);
    14501451        unsigned char *sbuf = (unsigned char*)av_malloc(size);
    14511452
    1452         avpicture_fill(&image_out, (uint8_t *)sbuf, AV_PIX_FMT_YUV420P,
    1453                        out_width, out_height);
     1453        av_image_fill_arrays(image_out.data, image_out.linesize,
     1454            (uint8_t *)sbuf, AV_PIX_FMT_YUV420P,
     1455            out_width, out_height, IMAGE_ALIGN);
    14541456        AVPictureFill(&image_in, buffer);
    14551457        QMutexLocker locker(&lock);
    14561458        scontext = sws_getCachedContext(scontext, width, height,
    void VideoOutputXv::PrepareFrameMem(VideoFrame *buffer, FrameScanType /*scan*/) 
    14621464                  image_out.data, image_out.linesize);
    14631465    }
    14641466
    1465     avpicture_fill(&image_in, (uint8_t *)XJ_non_xv_image->data,
    1466                    non_xv_av_format, out_width, out_height);
     1467    av_image_fill_arrays(image_in.data, image_in.linesize,
     1468        (uint8_t *)XJ_non_xv_image->data,
     1469        non_xv_av_format, out_width, out_height, IMAGE_ALIGN);
    14671470
    14681471    m_copyFrame.Copy(&image_in, non_xv_av_format, &image_out, AV_PIX_FMT_YUV420P,
    14691472                out_width, out_height);
  • mythtv/libs/libmythtv/videooutbase.cpp

    diff --git a/mythtv/libs/libmythtv/videooutbase.cpp b/mythtv/libs/libmythtv/videooutbase.cpp
    index d0bc6b4..9f8e3a5 100644
    a b  
    5353extern "C" {
    5454#include "libavcodec/avcodec.h"
    5555#include "libswscale/swscale.h"
     56#include "libavutil/imgutils.h"
    5657}
    5758
    5859#include "filtermanager.h"
    void VideoOutput::ShowPIP(VideoFrame *frame, 
    11201121
    11211122        if (pip_tmp_buf && pip_scaling_context)
    11221123        {
    1123             AVPicture img_in, img_out;
    1124             avpicture_fill(
    1125                 &img_out, (uint8_t *)pip_tmp_buf, AV_PIX_FMT_YUV420P,
    1126                 pip_display_size.width(), pip_display_size.height());
     1124            AVFrame img_in, img_out;
     1125            av_image_fill_arrays(
     1126                img_out.data, img_out.linesize,
     1127                (uint8_t *)pip_tmp_buf, AV_PIX_FMT_YUV420P,
     1128                pip_display_size.width(), pip_display_size.height(),
     1129                IMAGE_ALIGN);
    11271130
    11281131            AVPictureFill(&img_in, pipimage);
    11291132
    void VideoOutput::ShowPIP(VideoFrame *frame, 
    11351138
    11361139            if (pipActive)
    11371140            {
    1138                 AVPicture img_padded;
    1139                 avpicture_fill( &img_padded, (uint8_t *)pip_tmp_buf2,
    1140                     AV_PIX_FMT_YUV420P, pipw, piph);
     1141                AVFrame img_padded;
     1142                av_image_fill_arrays(img_padded.data, img_padded.linesize,
     1143                    (uint8_t *)pip_tmp_buf2,
     1144                    AV_PIX_FMT_YUV420P, pipw, piph, IMAGE_ALIGN);
    11411145
    11421146                int color[3] = { 20, 0, 200 }; //deep red YUV format
    1143                 av_picture_pad(&img_padded, &img_out, piph, pipw,
     1147                av_picture_pad((AVPicture*)(&img_padded),
     1148                    (AVPicture*)(&img_out), piph, pipw,
    11441149                               AV_PIX_FMT_YUV420P, 4, 4, 4, 4, color);
    11451150
    11461151                int offsets[3] = {0, int(img_padded.data[1] - img_padded.data[0]),
    void VideoOutput::ResizeVideo(VideoFrame *frame) 
    12471252
    12481253    if (vsz_tmp_buf && vsz_scale_context)
    12491254    {
    1250         AVPicture img_in, img_out;
    1251 
    1252         avpicture_fill(&img_out, (uint8_t *)vsz_tmp_buf, AV_PIX_FMT_YUV420P,
    1253                        resize.width(), resize.height());
    1254         avpicture_fill(&img_in, (uint8_t *)frame->buf, AV_PIX_FMT_YUV420P,
    1255                        frame->width, frame->height);
     1255        AVFrame img_in, img_out;
     1256
     1257        av_image_fill_arrays(img_out.data, img_out.linesize,
     1258            (uint8_t *)vsz_tmp_buf, AV_PIX_FMT_YUV420P,
     1259            resize.width(), resize.height(),IMAGE_ALIGN);
     1260        av_image_fill_arrays(img_in.data, img_in.linesize,
     1261            (uint8_t *)frame->buf, AV_PIX_FMT_YUV420P,
     1262            frame->width, frame->height,IMAGE_ALIGN);
    12561263        img_in.data[0] = frame->buf + frame->offsets[0];
    12571264        img_in.data[1] = frame->buf + frame->offsets[1];
    12581265        img_in.data[2] = frame->buf + frame->offsets[2];
  • mythtv/programs/mythcommflag/BlankFrameDetector.h

    diff --git a/mythtv/programs/mythcommflag/BlankFrameDetector.h b/mythtv/programs/mythcommflag/BlankFrameDetector.h
    index a6d96ef..0d00164 100644
    a b  
    99
    1010#include "FrameAnalyzer.h"
    1111
    12 typedef struct AVPicture AVPicture;
    1312class HistogramAnalyzer;
    1413class TemplateMatcher;
    1514
  • mythtv/programs/mythcommflag/BorderDetector.cpp

    diff --git a/mythtv/programs/mythcommflag/BorderDetector.cpp b/mythtv/programs/mythcommflag/BorderDetector.cpp
    index 165a4df..b9ce0b5 100644
    a b  
    33#include "mythconfig.h"
    44
    55extern "C" {
    6 #include "libavcodec/avcodec.h"        /* AVPicture */
     6#include "libavcodec/avcodec.h"        /* AVFrame */
    77}
    88#include "mythcorecontext.h"    /* gContext */
    99#include "compat.h"
    BorderDetector::setLogoState(TemplateFinder *finder) 
    6262}
    6363
    6464int
    65 BorderDetector::getDimensions(const AVPicture *pgm, int pgmheight,
     65BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight,
    6666        long long _frameno, int *prow, int *pcol, int *pwidth, int *pheight)
    6767{
    6868    /*
  • mythtv/programs/mythcommflag/BorderDetector.h

    diff --git a/mythtv/programs/mythcommflag/BorderDetector.h b/mythtv/programs/mythcommflag/BorderDetector.h
    index ae0541d..eb0e858 100644
    a b  
    1212#ifndef __BORDERDETECTOR_H__
    1313#define __BORDERDETECTOR_H__
    1414
    15 typedef struct AVPicture AVPicture;
     15typedef struct AVFrame AVFrame;
    1616class MythPlayer;
    1717class TemplateFinder;
    1818
    public: 
    2626    void setLogoState(TemplateFinder *finder);
    2727
    2828    static const long long UNCACHED = -1;
    29     int getDimensions(const AVPicture *pgm, int pgmheight, long long frameno,
     29    int getDimensions(const AVFrame *pgm, int pgmheight, long long frameno,
    3030            int *prow, int *pcol, int *pwidth, int *pheight);
    3131
    3232    int reportTime(void);
    3333
    3434private:
    3535    TemplateFinder          *logoFinder;
    36     const struct AVPicture  *logo;
     36    const struct AVFrame  *logo;
    3737    int                     logorow, logocol;
    3838    int                     logowidth, logoheight;
    3939
  • mythtv/programs/mythcommflag/CannyEdgeDetector.cpp

    diff --git a/mythtv/programs/mythcommflag/CannyEdgeDetector.cpp b/mythtv/programs/mythcommflag/CannyEdgeDetector.cpp
    index bfd7683..411c4ec 100644
    a b  
    1010#include "pgm.h"
    1111#include "CannyEdgeDetector.h"
    1212
     13extern "C" {
     14#include "libavutil/imgutils.h"
     15}
     16
    1317using namespace edgeDetector;
    1418
    1519CannyEdgeDetector::CannyEdgeDetector(void)
    CannyEdgeDetector::CannyEdgeDetector(void) 
    5963
    6064CannyEdgeDetector::~CannyEdgeDetector(void)
    6165{
    62     avpicture_free(&edges);
    63     avpicture_free(&convolved);
    64     avpicture_free(&s2);
    65     avpicture_free(&s1);
     66    av_freep(&edges.data[0]);
     67    av_freep(&convolved.data[0]);
     68    av_freep(&s2.data[0]);
     69    av_freep(&s1.data[0]);
    6670    if (sgmsorted)
    6771        delete []sgmsorted;
    6872    if (sgm)
    CannyEdgeDetector::resetBuffers(int newwidth, int newheight) 
    8286         * Sentinel value to determine whether or not stuff has already been
    8387         * allocated.
    8488         */
    85         avpicture_free(&s1);
    86         avpicture_free(&s2);
    87         avpicture_free(&convolved);
    88         avpicture_free(&edges);
     89        av_freep(&s1.data[0]);
     90        av_freep(&s2.data[0]);
     91        av_freep(&convolved.data[0]);
     92        av_freep(&edges.data[0]);
    8993        delete []sgm;
    9094        delete []sgmsorted;
    9195        sgm = NULL;
    CannyEdgeDetector::resetBuffers(int newwidth, int newheight) 
    9498    const int   padded_width = newwidth + 2 * mask_radius;
    9599    const int   padded_height = newheight + 2 * mask_radius;
    96100
    97     if (avpicture_alloc(&s1, AV_PIX_FMT_GRAY8, padded_width, padded_height))
     101    if (av_image_alloc(s1.data, s1.linesize,
     102        padded_width, padded_height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    98103    {
    99104        LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers "
    100                                   "avpicture_alloc s1 failed");
     105                                  "av_image_alloc s1 failed");
    101106        return -1;
    102107    }
    103108
    104     if (avpicture_alloc(&s2, AV_PIX_FMT_GRAY8, padded_width, padded_height))
     109    if (av_image_alloc(s2.data, s2.linesize,
     110        padded_width, padded_height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    105111    {
    106112        LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers "
    107                                   "avpicture_alloc s2 failed");
     113                                  "av_image_alloc s2 failed");
    108114        goto free_s1;
    109115    }
    110116
    111     if (avpicture_alloc(&convolved, AV_PIX_FMT_GRAY8, padded_width, padded_height))
     117    if (av_image_alloc(convolved.data, convolved.linesize,
     118        padded_width, padded_height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    112119    {
    113120        LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers "
    114                                   "avpicture_alloc convolved failed");
     121                                  "av_image_alloc convolved failed");
    115122        goto free_s2;
    116123    }
    117124
    118     if (avpicture_alloc(&edges, AV_PIX_FMT_GRAY8, newwidth, newheight))
     125    if (av_image_alloc(edges.data, edges.linesize,
     126        newwidth, newheight, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    119127    {
    120128        LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers "
    121                                   "avpicture_alloc edges failed");
     129                                  "av_image_alloc edges failed");
    122130        goto free_convolved;
    123131    }
    124132
    CannyEdgeDetector::resetBuffers(int newwidth, int newheight) 
    131139    return 0;
    132140
    133141free_convolved:
    134     avpicture_free(&convolved);
     142    av_freep(&convolved.data[0]);
    135143free_s2:
    136     avpicture_free(&s2);
     144    av_freep(&s2.data[0]);
    137145free_s1:
    138     avpicture_free(&s1);
     146    av_freep(&s1.data[0]);
    139147    return -1;
    140148}
    141149
    CannyEdgeDetector::setExcludeArea(int row, int col, int width, int height) 
    149157    return 0;
    150158}
    151159
    152 const AVPicture *
    153 CannyEdgeDetector::detectEdges(const AVPicture *pgm, int pgmheight,
     160const AVFrame *
     161CannyEdgeDetector::detectEdges(const AVFrame *pgm, int pgmheight,
    154162        int percentile)
    155163{
    156164    /*
  • mythtv/programs/mythcommflag/CannyEdgeDetector.h

    diff --git a/mythtv/programs/mythcommflag/CannyEdgeDetector.h b/mythtv/programs/mythcommflag/CannyEdgeDetector.h
    index eef6a5c..f482ae9 100644
    a b  
    88#define __CANNYEDGEDETECTOR_H__
    99
    1010extern "C" {
    11 #include "libavcodec/avcodec.h"    /* AVPicture */
     11#include "libavcodec/avcodec.h"    /* AVFrame */
    1212}
    1313#include "EdgeDetector.h"
    1414
    public: 
    2222    ~CannyEdgeDetector(void);
    2323    int MythPlayerInited(const MythPlayer *player, int width, int height);
    2424    virtual int setExcludeArea(int row, int col, int width, int height);
    25     virtual const AVPicture *detectEdges(const AVPicture *pgm, int pgmheight,
     25    virtual const AVFrame *detectEdges(const AVFrame *pgm, int pgmheight,
    2626            int percentile);
    2727
    2828private:
    private: 
    3232    int             mask_radius;            /* radius of mask */
    3333
    3434    unsigned int    *sgm, *sgmsorted;       /* squared-gradient magnitude */
    35     AVPicture       s1, s2, convolved;      /* smoothed grayscale frame */
     35    AVFrame       s1, s2, convolved;      /* smoothed grayscale frame */
    3636    int             ewidth, eheight;        /* dimensions */
    37     AVPicture       edges;                  /* detected edges */
     37    AVFrame       edges;                  /* detected edges */
    3838
    3939    struct {
    4040        int         row, col, width, height;
  • mythtv/programs/mythcommflag/EdgeDetector.cpp

    diff --git a/mythtv/programs/mythcommflag/EdgeDetector.cpp b/mythtv/programs/mythcommflag/EdgeDetector.cpp
    index a0be23f..cd9d590 100644
    a b using namespace std; 
    99
    1010// avlib/ffmpeg headers
    1111extern "C" {
    12 #include "libavcodec/avcodec.h"        // AVPicture
     12#include "libavcodec/avcodec.h"        // AVFrame
    1313}
    1414
    1515// MythTV headers
    namespace edgeDetector { 
    2525using namespace frameAnalyzer;
    2626
    2727unsigned int *
    28 sgm_init_exclude(unsigned int *sgm, const AVPicture *src, int srcheight,
     28sgm_init_exclude(unsigned int *sgm, const AVFrame *src, int srcheight,
    2929        int excluderow, int excludecol, int excludewidth, int excludeheight)
    3030{
    3131    /*
    sgm_init_exclude(unsigned int *sgm, const AVPicture *src, int srcheight, 
    6262
    6363#ifdef LATER
    6464unsigned int *
    65 sgm_init(unsigned int *sgm, const AVPicture *src, int srcheight)
     65sgm_init(unsigned int *sgm, const AVFrame *src, int srcheight)
    6666{
    6767    return sgm_init_exclude(sgm, src, srcheight, 0, 0, 0, 0);
    6868}
    static int sort_ascending(const void *aa, const void *bb) 
    7474}
    7575
    7676static int
    77 edge_mark(AVPicture *dst, int dstheight,
     77edge_mark(AVFrame *dst, int dstheight,
    7878        int extratop, int extraright, int extrabottom, int extraleft,
    7979        const unsigned int *sgm, unsigned int *sgmsorted, int percentile,
    8080        int excluderow, int excludecol, int excludewidth, int excludeheight)
    edge_mark(AVPicture *dst, int dstheight, 
    180180}
    181181
    182182#ifdef LATER
    183 int edge_mark_uniform(AVPicture *dst, int dstheight, int extramargin,
     183int edge_mark_uniform(AVFrame *dst, int dstheight, int extramargin,
    184184        const unsigned int *sgm, unsigned int *sgmsorted,
    185185        int percentile)
    186186{
    int edge_mark_uniform(AVPicture *dst, int dstheight, int extramargin, 
    190190}
    191191#endif /* LATER */
    192192
    193 int edge_mark_uniform_exclude(AVPicture *dst, int dstheight, int extramargin,
     193int edge_mark_uniform_exclude(AVFrame *dst, int dstheight, int extramargin,
    194194        const unsigned int *sgm, unsigned int *sgmsorted, int percentile,
    195195        int excluderow, int excludecol, int excludewidth, int excludeheight)
    196196{
  • mythtv/programs/mythcommflag/EdgeDetector.h

    diff --git a/mythtv/programs/mythcommflag/EdgeDetector.h b/mythtv/programs/mythcommflag/EdgeDetector.h
    index 60cf767..ea61845 100644
    a b  
    88#ifndef __EDGEDETECTOR_H__
    99#define __EDGEDETECTOR_H__
    1010
    11 typedef struct AVPicture AVPicture;
     11typedef struct AVFrame AVFrame;
    1212
    1313namespace edgeDetector {
    1414
    1515/* Pass all zeroes to not exclude any areas from examination. */
    1616
    1717unsigned int *sgm_init_exclude(unsigned int *sgm,
    18         const AVPicture *src, int srcheight,
     18        const AVFrame *src, int srcheight,
    1919        int excluderow, int excludecol, int excludewidth, int excludeheight);
    2020
    21 int edge_mark_uniform_exclude(AVPicture *dst, int dstheight, int extramargin,
     21int edge_mark_uniform_exclude(AVFrame *dst, int dstheight, int extramargin,
    2222        const unsigned int *sgm, unsigned int *sgmsorted, int percentile,
    2323        int excluderow, int excludecol, int excludewidth, int excludeheight);
    2424
    public: 
    3333    virtual int setExcludeArea(int row, int col, int width, int height);
    3434
    3535    /* Detect edges in "pgm" image. */
    36     virtual const AVPicture *detectEdges(const AVPicture *pgm, int pgmheight,
     36    virtual const AVFrame *detectEdges(const AVFrame *pgm, int pgmheight,
    3737            int percentile) = 0;
    3838};
    3939
  • mythtv/programs/mythcommflag/HistogramAnalyzer.cpp

    diff --git a/mythtv/programs/mythcommflag/HistogramAnalyzer.cpp b/mythtv/programs/mythcommflag/HistogramAnalyzer.cpp
    index 43b911a..957af73 100644
    a b HistogramAnalyzer::analyzeFrame(const VideoFrame *frame, long long frameno) 
    308308    static const int    CINC = 4;
    309309#define ROUNDUP(a,b)    (((a) + (b) - 1) / (b) * (b))
    310310
    311     const AVPicture     *pgm;
     311    const AVFrame     *pgm;
    312312    int                 pgmwidth, pgmheight;
    313313    bool                ismonochromatic;
    314314    int                 croprow, cropcol, cropwidth, cropheight;
  • mythtv/programs/mythcommflag/HistogramAnalyzer.h

    diff --git a/mythtv/programs/mythcommflag/HistogramAnalyzer.h b/mythtv/programs/mythcommflag/HistogramAnalyzer.h
    index dbb1945..2da903b 100644
    a b  
    99
    1010#include "FrameAnalyzer.h"
    1111
    12 typedef struct AVPicture AVPicture;
     12typedef struct AVFrame AVFrame;
    1313class PGMConverter;
    1414class BorderDetector;
    1515class TemplateFinder;
    private: 
    4545    BorderDetector          *borderDetector;
    4646
    4747    TemplateFinder          *logoFinder;
    48     const struct AVPicture  *logo;
     48    const struct AVFrame  *logo;
    4949    int                     logowidth, logoheight;
    5050    int                     logorr1, logocc1, logorr2, logocc2;
    5151
  • mythtv/programs/mythcommflag/PGMConverter.cpp

    diff --git a/mythtv/programs/mythcommflag/PGMConverter.cpp b/mythtv/programs/mythcommflag/PGMConverter.cpp
    index 320ba39..83a9646 100644
    a b  
    1515#include "pgm.h"
    1616#include "PGMConverter.h"
    1717
     18extern "C" {
     19#include "libavutil/imgutils.h"
     20}
     21
    1822using namespace commDetector2;
    1923
    2024PGMConverter::PGMConverter(void)
    PGMConverter::~PGMConverter(void) 
    3438{
    3539    width = -1;
    3640#ifdef PGM_CONVERT_GREYSCALE
    37     avpicture_free(&pgm);
     41    av_freep(&pgm.data[0]);
    3842    memset(&pgm, 0, sizeof(pgm));
    3943    delete m_copy;
    4044#endif /* PGM_CONVERT_GREYSCALE */
    PGMConverter::MythPlayerInited(const MythPlayer *player) 
    5660    height = buf_dim.height();
    5761
    5862#ifdef PGM_CONVERT_GREYSCALE
    59     if (avpicture_alloc(&pgm, AV_PIX_FMT_GRAY8, width, height))
     63    if (av_image_alloc(pgm.data, pgm.linesize,
     64        width, height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    6065    {
    6166        LOG(VB_COMMFLAG, LOG_ERR, QString("PGMConverter::MythPlayerInited "
    62                                           "avpicture_alloc pgm (%1x%2) failed")
     67                                          "av_image_alloc pgm (%1x%2) failed")
    6368                .arg(width).arg(height));
    6469        return -1;
    6570    }
    PGMConverter::MythPlayerInited(const MythPlayer *player) 
    7883    return 0;
    7984}
    8085
    81 const AVPicture *
     86const AVFrame *
    8287PGMConverter::getImage(const VideoFrame *frame, long long _frameno,
    8388        int *pwidth, int *pheight)
    8489{
    PGMConverter::getImage(const VideoFrame *frame, long long _frameno, 
    103108    timersub(&end, &start, &elapsed);
    104109    timeradd(&convert_time, &elapsed, &convert_time);
    105110#else  /* !PGM_CONVERT_GREYSCALE */
    106     if (avpicture_fill(&pgm, frame->buf, AV_PIX_FMT_GRAY8, width, height) == -1)
     111    if (av_image_fill_arrays(pgm.data, pgm.linesize,
     112        frame->buf, AV_PIX_FMT_GRAY8, width, height,IMAGE_ALIGN) < 0)
    107113    {
    108114        LOG(VB_COMMFLAG, LOG_ERR,
    109115            QString("PGMConverter::getImage error at frame %1 (%2x%3)")
  • mythtv/programs/mythcommflag/PGMConverter.h

    diff --git a/mythtv/programs/mythcommflag/PGMConverter.h b/mythtv/programs/mythcommflag/PGMConverter.h
    index 2fc5184..c30f1e2 100644
    a b  
    88#define __PGMCONVERTER_H__
    99
    1010extern "C" {
    11 #include "libavcodec/avcodec.h"    /* AVPicture */
     11#include "libavcodec/avcodec.h"    /* AVFrame */
    1212}
    1313
    1414typedef struct VideoFrame_ VideoFrame;
    public: 
    3535    ~PGMConverter(void);
    3636
    3737    int MythPlayerInited(const MythPlayer *player);
    38     const AVPicture *getImage(const VideoFrame *frame, long long frameno,
     38    const AVFrame *getImage(const VideoFrame *frame, long long frameno,
    3939            int *pwidth, int *pheight);
    4040    int reportTime(void);
    4141
    4242private:
    4343    long long       frameno;            /* frame number */
    4444    int             width, height;      /* frame dimensions */
    45     AVPicture       pgm;                /* grayscale frame */
     45    AVFrame       pgm;                /* grayscale frame */
    4646#ifdef PGM_CONVERT_GREYSCALE
    4747    struct timeval  convert_time;
    4848    bool            time_reported;
  • mythtv/programs/mythcommflag/SceneChangeDetector.h

    diff --git a/mythtv/programs/mythcommflag/SceneChangeDetector.h b/mythtv/programs/mythcommflag/SceneChangeDetector.h
    index ec25911..c35432e 100644
    a b  
    1111
    1212#include "FrameAnalyzer.h"
    1313
    14 typedef struct AVPicture AVPicture;
     14typedef struct AVFrame AVFrame;
    1515class HistogramAnalyzer;
    1616
    1717class SceneChangeDetector : public FrameAnalyzer
  • mythtv/programs/mythcommflag/TemplateFinder.cpp

    diff --git a/mythtv/programs/mythcommflag/TemplateFinder.cpp b/mythtv/programs/mythcommflag/TemplateFinder.cpp
    index a82a7a5..bdff156 100644
    a b  
    2626#include "EdgeDetector.h"
    2727#include "TemplateFinder.h"
    2828
     29extern "C" {
     30    #include "libavutil/imgutils.h"
     31    }
     32
    2933using namespace commDetector2;
    3034
    3135namespace {
    3236
    33 int writeJPG(QString prefix, const AVPicture *img, int imgheight)
     37int writeJPG(QString prefix, const AVFrame *img, int imgheight)
    3438{
    3539    const int imgwidth = img->linesize[0];
    3640    QFileInfo jpgfi(prefix + ".jpg");
    int writeJPG(QString prefix, const AVPicture *img, int imgheight) 
    6569
    6670int
    6771pgm_scorepixels(unsigned int *scores, int width, int row, int col,
    68         const AVPicture *src, int srcheight)
     72        const AVFrame *src, int srcheight)
    6973{
    7074    /* Every time a pixel is an edge, give it a point. */
    7175    const int   srcwidth = src->linesize[0];
    sort_ascending(const void *aa, const void *bb) 
    9094}
    9195
    9296float
    93 bounding_score(const AVPicture *img, int row, int col, int width, int height)
     97bounding_score(const AVFrame *img, int row, int col, int width, int height)
    9498{
    9599    /* Return a value between [0..1] */
    96100    const int       imgwidth = img->linesize[0];
    bounding_score(const AVPicture *img, int row, int col, int width, int height) 
    112116}
    113117
    114118bool
    115 rowisempty(const AVPicture *img, int row, int col, int width)
     119rowisempty(const AVFrame *img, int row, int col, int width)
    116120{
    117121    const int   imgwidth = img->linesize[0];
    118122    for (int cc = col; cc < col + width; cc++)
    rowisempty(const AVPicture *img, int row, int col, int width) 
    122126}
    123127
    124128bool
    125 colisempty(const AVPicture *img, int col, int row, int height)
     129colisempty(const AVFrame *img, int col, int row, int height)
    126130{
    127131    const int   imgwidth = img->linesize[0];
    128132    for (int rr = row; rr < row + height; rr++)
    colisempty(const AVPicture *img, int col, int row, int height) 
    132136}
    133137
    134138int
    135 bounding_box(const AVPicture *img, int imgheight,
     139bounding_box(const AVFrame *img, int imgheight,
    136140        int minrow, int mincol, int maxrow1, int maxcol1,
    137141        int *prow, int *pcol, int *pwidth, int *pheight)
    138142{
    bounding_box(const AVPicture *img, int imgheight, 
    440444
    441445int
    442446template_alloc(const unsigned int *scores, int width, int height,
    443         int minrow, int mincol, int maxrow1, int maxcol1, AVPicture *tmpl,
     447        int minrow, int mincol, int maxrow1, int maxcol1, AVFrame *tmpl,
    444448        int *ptmplrow, int *ptmplcol, int *ptmplwidth, int *ptmplheight,
    445449        bool debug_edgecounts, QString debugdir)
    446450{
    template_alloc(const unsigned int *scores, int width, int height, 
    458462    const int               nn = width * height;
    459463    int                     ii, first, last;
    460464    unsigned int            *sortedscores, threshscore;
    461     AVPicture               thresh;
     465    AVFrame               thresh;
    462466
    463     if (avpicture_alloc(&thresh, AV_PIX_FMT_GRAY8, width, height))
     467    if (av_image_alloc(thresh.data, thresh.linesize,
     468        width, height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    464469    {
    465470        LOG(VB_COMMFLAG, LOG_ERR,
    466             QString("template_alloc avpicture_alloc thresh (%1x%2) failed")
     471            QString("template_alloc av_image_alloc thresh (%1x%2) failed")
    467472                .arg(width).arg(height));
    468473        return -1;
    469474    }
    template_alloc(const unsigned int *scores, int width, int height, 
    505510    if (debug_edgecounts)
    506511    {
    507512        /* Scores, rescaled to [0..UCHAR_MAX]. */
    508         AVPicture scored;
    509         if (avpicture_alloc(&scored, AV_PIX_FMT_GRAY8, width, height))
     513        AVFrame scored;
     514        if (av_image_alloc(scored.data, scored.linesize,
     515            width, height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    510516        {
    511517            LOG(VB_COMMFLAG, LOG_ERR,
    512                 QString("template_alloc avpicture_alloc scored (%1x%2) failed")
     518                QString("template_alloc av_image_alloc scored (%1x%2) failed")
    513519                    .arg(width).arg(height));
    514520            goto free_thresh;
    515521        }
    template_alloc(const unsigned int *scores, int width, int height, 
    518524            scored.data[0][ii] = scores[ii] * UCHAR_MAX / maxscore;
    519525        int error = writeJPG(debugdir + "/TemplateFinder-scores", &scored,
    520526                height);
    521         avpicture_free(&scored);
     527        av_freep(&scored.data[0]);
    522528        if (error)
    523529            goto free_thresh;
    524530
    template_alloc(const unsigned int *scores, int width, int height, 
    542548        goto free_thresh;
    543549    }
    544550
    545     if (avpicture_alloc(tmpl, AV_PIX_FMT_GRAY8, *ptmplwidth, *ptmplheight))
     551    if (av_image_alloc(tmpl->data, tmpl->linesize,
     552        *ptmplwidth, *ptmplheight, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    546553    {
    547554        LOG(VB_COMMFLAG, LOG_ERR,
    548             QString("template_alloc avpicture_alloc tmpl (%1x%2) failed")
     555            QString("template_alloc av_image_alloc tmpl (%1x%2) failed")
    549556                .arg(*ptmplwidth).arg(*ptmplheight));
    550557        goto free_thresh;
    551558    }
    template_alloc(const unsigned int *scores, int width, int height, 
    555562        goto free_thresh;
    556563
    557564    delete []sortedscores;
    558     avpicture_free(&thresh);
     565    av_freep(&thresh.data[0]);
     566
    559567    return 0;
    560568
    561569free_thresh:
    562570    delete []sortedscores;
    563     avpicture_free(&thresh);
     571    av_freep(&thresh.data[0]);
    564572    return -1;
    565573}
    566574
    567575int
    568 analyzeFrameDebug(long long frameno, const AVPicture *pgm, int pgmheight,
    569         const AVPicture *cropped, const AVPicture *edges, int cropheight,
     576analyzeFrameDebug(long long frameno, const AVFrame *pgm, int pgmheight,
     577        const AVFrame *cropped, const AVFrame *edges, int cropheight,
    570578        int croprow, int cropcol, bool debug_frames, QString debugdir)
    571579{
    572580    static const int    delta = 24;
    error: 
    619627
    620628bool
    621629readTemplate(QString datafile, int *prow, int *pcol, int *pwidth, int *pheight,
    622         QString tmplfile, AVPicture *tmpl, bool *pvalid)
     630        QString tmplfile, AVFrame *tmpl, bool *pvalid)
    623631{
    624632    QFile dfile(datafile);
    625633    QFileInfo dfileinfo(dfile);
    readTemplate(QString datafile, int *prow, int *pcol, int *pwidth, int *pheight, 
    638646    stream >> *prow >> *pcol >> *pwidth >> *pheight;
    639647    dfile.close();
    640648
    641     if (avpicture_alloc(tmpl, AV_PIX_FMT_GRAY8, *pwidth, *pheight))
     649    if (av_image_alloc(tmpl->data, tmpl->linesize,
     650        *pwidth, *pheight, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    642651    {
    643652        LOG(VB_COMMFLAG, LOG_ERR,
    644             QString("readTemplate avpicture_alloc %1 (%2x%3) failed")
     653            QString("readTemplate av_image_alloc %1 (%2x%3) failed")
    645654                .arg(tmplfile).arg(*pwidth).arg(*pheight));
    646655        return false;
    647656    }
    readTemplate(QString datafile, int *prow, int *pcol, int *pwidth, int *pheight, 
    649658    QByteArray tmfile = tmplfile.toLatin1();
    650659    if (pgm_read(tmpl->data[0], *pwidth, *pheight, tmfile.constData()))
    651660    {
    652         avpicture_free(tmpl);
     661        av_freep(&tmpl->data[0]);
    653662        return false;
    654663    }
    655664
    writeDummyTemplate(QString datafile) 
    669678}
    670679
    671680bool
    672 writeTemplate(QString tmplfile, const AVPicture *tmpl, QString datafile,
     681writeTemplate(QString tmplfile, const AVFrame *tmpl, QString datafile,
    673682        int row, int col, int width, int height)
    674683{
    675684    QFile tfile(tmplfile);
    TemplateFinder::~TemplateFinder(void) 
    782791{
    783792    if (scores)
    784793        delete []scores;
    785     avpicture_free(&tmpl);
    786     avpicture_free(&cropped);
     794    av_freep(&tmpl.data[0]);
     795    av_freep(&cropped.data[0]);
    787796}
    788797
    789798enum FrameAnalyzer::analyzeFrameResult
    TemplateFinder::MythPlayerInited(MythPlayer *player, long long nframes) 
    848857    return ANALYZE_OK;
    849858
    850859free_tmpl:
    851     avpicture_free(&tmpl);
     860    av_freep(&tmpl.data[0]);
    852861    return ANALYZE_FATAL;
    853862}
    854863
    TemplateFinder::resetBuffers(int newwidth, int newheight) 
    858867    if (cwidth == newwidth && cheight == newheight)
    859868        return 0;
    860869
    861     avpicture_free(&cropped);
     870        av_freep(&cropped.data[0]);
    862871
    863     if (avpicture_alloc(&cropped, AV_PIX_FMT_GRAY8, newwidth, newheight))
     872    if (av_image_alloc(cropped.data, cropped.linesize,
     873        newwidth, newheight, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    864874    {
    865875        LOG(VB_COMMFLAG, LOG_ERR,
    866876            QString("TemplateFinder::resetBuffers "
    867                     "avpicture_alloc cropped (%1x%2) failed")
     877                    "av_image_alloc cropped (%1x%2) failed")
    868878                .arg(newwidth).arg(newheight));
    869879        return -1;
    870880    }
    TemplateFinder::analyzeFrame(const VideoFrame *frame, long long frameno, 
    908918    static const float  EXCLUDEWIDTH = 0.5;
    909919    static const float  EXCLUDEHEIGHT = 0.5;
    910920
    911     const AVPicture     *pgm, *edges;
     921    const AVFrame     *pgm, *edges;
    912922    int                 pgmwidth, pgmheight;
    913923    int                 croprow, cropcol, cropwidth, cropheight;
    914924    int                 excluderow, excludecol, excludewidth, excludeheight;
    TemplateFinder::finished(long long nframes, bool final) 
    10371047    return 0;
    10381048
    10391049free_tmpl:
    1040     avpicture_free(&tmpl);
     1050    av_freep(&tmpl.data[0]);
    10411051    return -1;
    10421052}
    10431053
    TemplateFinder::reportTime(void) const 
    10551065    return 0;
    10561066}
    10571067
    1058 const struct AVPicture *
     1068const struct AVFrame *
    10591069TemplateFinder::getTemplate(int *prow, int *pcol, int *pwidth, int *pheight)
    10601070    const
    10611071{
  • mythtv/programs/mythcommflag/TemplateFinder.h

    diff --git a/mythtv/programs/mythcommflag/TemplateFinder.h b/mythtv/programs/mythcommflag/TemplateFinder.h
    index 3b83c2a..c8f7ed1 100644
    a b  
    1919#define __TEMPLATEFINDER_H__
    2020
    2121extern "C" {
    22 #include "libavcodec/avcodec.h"    /* AVPicture */
     22#include "libavcodec/avcodec.h"    /* AVFrame */
    2323}
    2424#include "FrameAnalyzer.h"
    2525
    public: 
    4646    FrameMap GetMap(unsigned int) const { FrameMap map; return map; }
    4747
    4848    /* TemplateFinder implementation. */
    49     const struct AVPicture *getTemplate(int *prow, int *pcol,
     49    const struct AVFrame *getTemplate(int *prow, int *pcol,
    5050            int *pwidth, int *pheight) const;
    5151
    5252private:
    private: 
    6969    int             maxcontentrow1;     /* minrow + height ("maxrow + 1") */
    7070    int             maxcontentcol1;     /* mincol + width ("maxcol + 1") */
    7171
    72     AVPicture       tmpl;               /* logo-matching template */
     72    AVFrame       tmpl;               /* logo-matching template */
    7373    int             tmplrow, tmplcol;
    7474    int             tmplwidth, tmplheight;
    7575
    76     AVPicture       cropped;            /* cropped version of frame */
     76    AVFrame       cropped;            /* cropped version of frame */
    7777    int             cwidth, cheight;    /* cropped height */
    7878
    7979    /* Debugging. */
  • mythtv/programs/mythcommflag/TemplateMatcher.cpp

    diff --git a/mythtv/programs/mythcommflag/TemplateMatcher.cpp b/mythtv/programs/mythcommflag/TemplateMatcher.cpp
    index 059edcd..a587629 100644
    a b using namespace std; 
    2828#include "TemplateFinder.h"
    2929#include "TemplateMatcher.h"
    3030
     31extern "C" {
     32#include "libavutil/imgutils.h"
     33}
     34
    3135using namespace commDetector2;
    3236using namespace frameAnalyzer;
    3337
    3438namespace {
    3539
    36 int pgm_set(const AVPicture *pict, int height)
     40int pgm_set(const AVFrame *pict, int height)
    3741{
    3842    const int   width = pict->linesize[0];
    3943    const int   size = height * width;
    int pgm_set(const AVPicture *pict, int height) 
    4650    return score;
    4751}
    4852
    49 int pgm_match(const AVPicture *tmpl, const AVPicture *test, int height,
     53int pgm_match(const AVFrame *tmpl, const AVFrame *test, int height,
    5054              int radius, unsigned short *pscore)
    5155{
    5256    /* Return the number of matching "edge" and non-edge pixels. */
    TemplateMatcher::~TemplateMatcher(void) 
    370374        delete []matches;
    371375    if (match)
    372376        delete []match;
    373     avpicture_free(&cropped);
     377    av_freep(&cropped.data[0]);
    374378}
    375379
    376380enum FrameAnalyzer::analyzeFrameResult
    TemplateMatcher::MythPlayerInited(MythPlayer *_player, 
    388392        return ANALYZE_FATAL;
    389393    }
    390394
    391     if (avpicture_alloc(&cropped, AV_PIX_FMT_GRAY8, tmplwidth, tmplheight))
     395    if (av_image_alloc(cropped.data, cropped.linesize,
     396        tmplwidth, tmplheight, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
    392397    {
    393398        LOG(VB_COMMFLAG, LOG_ERR,
    394399            QString("TemplateMatcher::MythPlayerInited "
    395                     "avpicture_alloc cropped (%1x%2) failed")
     400                    "av_image_alloc cropped (%1x%2) failed")
    396401                .arg(tmplwidth).arg(tmplheight));
    397402        return ANALYZE_FATAL;
    398403    }
    TemplateMatcher::MythPlayerInited(MythPlayer *_player, 
    422427    return ANALYZE_OK;
    423428
    424429free_cropped:
    425     avpicture_free(&cropped);
     430    av_freep(&cropped.data[0]);
    426431    return ANALYZE_FATAL;
    427432}
    428433
    TemplateMatcher::analyzeFrame(const VideoFrame *frame, long long frameno, 
    465470     */
    466471    const int           JITTER_RADIUS = 0;
    467472
    468     const AVPicture     *pgm;
    469     const AVPicture     *edges;
     473    const AVFrame     *pgm;
     474    const AVFrame     *edges;
    470475    int                 pgmwidth, pgmheight;
    471476    struct timeval      start, end, elapsed;
    472477
  • mythtv/programs/mythcommflag/TemplateMatcher.h

    diff --git a/mythtv/programs/mythcommflag/TemplateMatcher.h b/mythtv/programs/mythcommflag/TemplateMatcher.h
    index e3fd9b6..8c03941 100644
    a b  
    1919#define __TEMPLATEMATCHER_H__
    2020
    2121extern "C" {
    22 #include "libavcodec/avcodec.h"    /* AVPicture */
     22#include "libavcodec/avcodec.h"    /* AVFrame */
    2323}
    2424#include "FrameAnalyzer.h"
    2525
    26 typedef struct AVPicture AVPicture;
     26typedef struct AVFrame AVFrame;
    2727class PGMConverter;
    2828class EdgeDetector;
    2929class TemplateFinder;
    private: 
    5656    PGMConverter            *pgmConverter;
    5757    EdgeDetector            *edgeDetector;
    5858    TemplateFinder          *templateFinder;
    59     const struct AVPicture  *tmpl;                  /* template image */
     59    const struct AVFrame  *tmpl;                  /* template image */
    6060    int                     tmplrow, tmplcol;       /* template location */
    6161    int                     tmplwidth, tmplheight;  /* template dimensions */
    6262
    private: 
    6565    unsigned char           *match;                 /* boolean result: 1/0 */
    6666
    6767    float                   fps;
    68     AVPicture               cropped;                /* pre-allocated buffer */
     68    AVFrame               cropped;                /* pre-allocated buffer */
    6969    FrameAnalyzer::FrameMap breakMap;               /* frameno => nframes */
    7070
    7171    /* Debugging */
  • mythtv/programs/mythcommflag/pgm.cpp

    diff --git a/mythtv/programs/mythcommflag/pgm.cpp b/mythtv/programs/mythcommflag/pgm.cpp
    index 2523eb7..751c2e1 100644
    a b  
    44
    55extern "C" {
    66#include "libavcodec/avcodec.h"
     7#include "libavutil/imgutils.h"
    78}
    89#include "mythframe.h"
    910#include "mythlogging.h"
    error: 
    108109    return -1;
    109110}
    110111
    111 static int pgm_expand(AVPicture *dst, const AVPicture *src, int srcheight,
     112static int pgm_expand(AVFrame *dst, const AVFrame *src, int srcheight,
    112113                      int extratop, int extraright, int extrabottom,
    113114                      int extraleft)
    114115{
    static int pgm_expand(AVPicture *dst, const AVPicture *src, int srcheight, 
    150151    return 0;
    151152}
    152153
    153 static int pgm_expand_uniform(AVPicture *dst, const AVPicture *src,
     154static int pgm_expand_uniform(AVFrame *dst, const AVFrame *src,
    154155                              int srcheight, int extramargin)
    155156{
    156157    return pgm_expand(dst, src, srcheight,
    157158            extramargin, extramargin, extramargin, extramargin);
    158159}
    159160
    160 int pgm_crop(AVPicture *dst, const AVPicture *src, int srcheight,
     161int pgm_crop(AVFrame *dst, const AVFrame *src, int srcheight,
    161162             int srcrow, int srccol, int cropwidth, int cropheight)
    162163{
    163164    const int   srcwidth = src->linesize[0];
    int pgm_crop(AVPicture *dst, const AVPicture *src, int srcheight, 
    179180    return 0;
    180181}
    181182
    182 int pgm_overlay(AVPicture *dst, const AVPicture *s1, int s1height,
    183                 int s1row, int s1col, const AVPicture *s2, int s2height)
     183int pgm_overlay(AVFrame *dst, const AVFrame *s1, int s1height,
     184                int s1row, int s1col, const AVFrame *s2, int s2height)
    184185{
    185186    const int   dstwidth = dst->linesize[0];
    186187    const int   s1width = s1->linesize[0];
    int pgm_overlay(AVPicture *dst, const AVPicture *s1, int s1height, 
    194195        return -1;
    195196    }
    196197
    197     av_picture_copy(dst, s1, AV_PIX_FMT_GRAY8, s1width, s1height);
     198    // av_image_copy is badly designed to require writeable
     199    // pointers to the read-only data, so copy the pointers here
     200    const uint8_t *src_data[4]
     201      =  {s1->data[0], s1->data[1], s1->data[2], s1->data[3]};
     202
     203    av_image_copy(dst->data, dst->linesize, src_data, s1->linesize,
     204        AV_PIX_FMT_GRAY8, s1width, s1height);
    198205
    199206    /* Overwrite overlay area of "dst" with "s2". */
    200207    for (rr = 0; rr < s2height; rr++)
    int pgm_overlay(AVPicture *dst, const AVPicture *s1, int s1height, 
    205212    return 0;
    206213}
    207214
    208 int pgm_convolve_radial(AVPicture *dst, AVPicture *s1, AVPicture *s2,
    209                         const AVPicture *src, int srcheight,
     215int pgm_convolve_radial(AVFrame *dst, AVFrame *s1, AVFrame *s2,
     216                        const AVFrame *src, int srcheight,
    210217                        const double *mask, int mask_radius)
    211218{
    212219    /*
    int pgm_convolve_radial(AVPicture *dst, AVPicture *s1, AVPicture *s2, 
    233240        return -1;
    234241
    235242    /* copy s1 to s2 and dst */
    236     av_picture_copy(s2, s1, AV_PIX_FMT_GRAY8, newwidth, newheight);
    237     av_picture_copy(dst, s1, AV_PIX_FMT_GRAY8, newwidth, newheight);
     243
     244    // av_image_copy is badly designed to require writeable
     245    // pointers to the read-only data, so copy the pointers here
     246    const uint8_t *src_data[4]
     247    =  {s1->data[0], s1->data[1], s1->data[2], s1->data[3]};
     248
     249    av_image_copy(s2->data, s2->linesize, src_data, s1->linesize,
     250        AV_PIX_FMT_GRAY8, newwidth, newheight);
     251    av_image_copy(dst->data, dst->linesize, src_data, s1->linesize,
     252        AV_PIX_FMT_GRAY8, newwidth, newheight);
    238253
    239254    /* "s1" convolve with column vector => "s2" */
    240255    rr2 = mask_radius + srcheight;
  • mythtv/programs/mythcommflag/pgm.h

    diff --git a/mythtv/programs/mythcommflag/pgm.h b/mythtv/programs/mythcommflag/pgm.h
    index 8cb2053..f1873e2 100644
    a b  
    88#define __PGM_H__
    99
    1010struct VideoFrame_;
    11 struct AVPicture;
     11struct AVFrame;
    1212
    1313int pgm_read(unsigned char *buf, int width, int height, const char *filename);
    1414int pgm_write(const unsigned char *buf, int width, int height,
    1515        const char *filename);
    16 int pgm_crop(struct AVPicture *dst, const struct AVPicture *src, int srcheight,
     16int pgm_crop(struct AVFrame *dst, const struct AVFrame *src, int srcheight,
    1717        int srcrow, int srccol, int cropwidth, int cropheight);
    18 int pgm_overlay(struct AVPicture *dst,
    19         const struct AVPicture *s1, int s1height, int s1row, int s1col,
    20         const struct AVPicture *s2, int s2height);
    21 int pgm_convolve_radial(struct AVPicture *dst, struct AVPicture *s1,
    22         struct AVPicture *s2, const struct AVPicture *src, int srcheight,
     18int pgm_overlay(struct AVFrame *dst,
     19        const struct AVFrame *s1, int s1height, int s1row, int s1col,
     20        const struct AVFrame *s2, int s2height);
     21int pgm_convolve_radial(struct AVFrame *dst, struct AVFrame *s1,
     22        struct AVFrame *s2, const struct AVFrame *src, int srcheight,
    2323        const double *mask, int mask_radius);
    2424
    2525#endif  /* !__PGM_H__ */
  • mythtv/programs/mythtranscode/transcode.cpp

    diff --git a/mythtv/programs/mythtranscode/transcode.cpp b/mythtv/programs/mythtranscode/transcode.cpp
    index 8d16ddb..f9c73aa 100644
    a b int Transcode::TranscodeFile(const QString &inputname, 
    10751075    VideoOutput *videoOutput = GetPlayer()->GetVideoOutput();
    10761076    bool is_key = 0;
    10771077    bool first_loop = true;
    1078     AVPicture imageIn, imageOut;
     1078    AVFrame imageIn, imageOut;
    10791079    struct SwsContext  *scontext = NULL;
    10801080
    10811081    if (fifow)