-
diff --git a/mythtv/configure b/mythtv/configure
index 2e5c49e..7c743eb 100755
a
|
b
|
wtv_muxer_select="mpegts_muxer riffenc" |
3306 | 3306 | xmv_demuxer_select="riffdec" |
3307 | 3307 | xwma_demuxer_select="riffdec" |
3308 | 3308 | |
| 3309 | # ffmpeg setting - value for image utils - 32 recommended, 1 used to now |
| 3310 | image_align=1 |
| 3311 | |
3309 | 3312 | # indevs / outdevs |
3310 | 3313 | alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp" |
3311 | 3314 | alsa_outdev_deps="alsa_asoundlib_h" |
… |
… |
cat > $TMPH <<EOF |
8593 | 8596 | #define SIZEOF_LONG $_sizeof_long |
8594 | 8597 | #define JDK_HOME "$JDK_HOME" |
8595 | 8598 | #define JAVA_ARCH "$java_arch" |
| 8599 | #define IMAGE_ALIGN $image_align |
8596 | 8600 | EOF |
8597 | 8601 | |
8598 | 8602 | # Code only checks whether HAVE_BDJ_J2ME is defined, not what value |
-
diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
index f7fd572..d0ec724 100644
a
|
b
|
extern "C" { |
73 | 73 | #include "libswscale/swscale.h" |
74 | 74 | #include "libavformat/isom.h" |
75 | 75 | #include "ivtv_myth.h" |
| 76 | #include "libavutil/imgutils.h" |
76 | 77 | } |
77 | 78 | |
78 | 79 | #ifdef _MSC_VER |
… |
… |
bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) |
3711 | 3712 | } |
3712 | 3713 | else if (!directrendering) |
3713 | 3714 | { |
3714 | | AVPicture tmppicture; |
| 3715 | AVFrame tmppicture; |
3715 | 3716 | |
3716 | 3717 | VideoFrame *xf = picframe; |
3717 | 3718 | picframe = m_parent->GetNextVideoFrame(); |
3718 | 3719 | |
3719 | 3720 | 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); |
3722 | 3724 | tmppicture.data[0] = buf + picframe->offsets[0]; |
3723 | 3725 | tmppicture.data[1] = buf + picframe->offsets[1]; |
3724 | 3726 | tmppicture.data[2] = buf + picframe->offsets[2]; |
-
diff --git a/mythtv/libs/libmythtv/avformatwriter.cpp b/mythtv/libs/libmythtv/avformatwriter.cpp
index e34dc2d..37efe12 100644
a
|
b
|
extern "C" { |
31 | 31 | #endif |
32 | 32 | #include "libavutil/opt.h" |
33 | 33 | #include "libavutil/samplefmt.h" |
| 34 | #include "libavutil/imgutils.h" |
34 | 35 | } |
35 | 36 | |
36 | 37 | #define LOC QString("AVFW(%1): ").arg(m_filename) |
… |
… |
int AVFormatWriter::WriteVideoFrame(VideoFrame *frame) |
237 | 238 | int framesEncoded = m_framesWritten + m_bufferedVideoFrameTimes.size(); |
238 | 239 | |
239 | 240 | av_frame_unref(m_picture); |
240 | | AVPictureFill(reinterpret_cast<AVPicture*>(m_picture), frame); |
| 241 | AVPictureFill(reinterpret_cast<AVFrame*>(m_picture), frame); |
241 | 242 | m_picture->pts = framesEncoded + 1; |
242 | 243 | |
243 | 244 | if ((framesEncoded % m_keyFrameDist) == 0) |
… |
… |
AVFrame* AVFormatWriter::AllocPicture(enum AVPixelFormat pix_fmt) |
721 | 722 | av_frame_free(&picture); |
722 | 723 | return NULL; |
723 | 724 | } |
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); |
726 | 727 | return picture; |
727 | 728 | } |
728 | 729 | |
-
diff --git a/mythtv/libs/libmythtv/mhi.cpp b/mythtv/libs/libmythtv/mhi.cpp
index 3d9a7e4..3d5c446 100644
a
|
b
|
|
38 | 38 | #include "mythuiactions.h" // for ACTION_0, ACTION_1, etc |
39 | 39 | #include "tv_actions.h" // for ACTION_MENUTEXT, etc |
40 | 40 | |
| 41 | extern "C" { |
| 42 | #include "libavutil/imgutils.h" |
| 43 | } |
| 44 | |
41 | 45 | static bool ft_loaded = false; |
42 | 46 | static FT_Library ft_library; |
43 | 47 | |
… |
… |
void MHIBitmap::CreateFromMPEG(const unsigned char *data, int length) |
1920 | 1924 | m_image = QImage(nContentWidth, nContentHeight, QImage::Format_ARGB32); |
1921 | 1925 | m_opaque = true; // MPEG images are always opaque. |
1922 | 1926 | |
1923 | | AVPicture retbuf; |
1924 | | memset(&retbuf, 0, sizeof(AVPicture)); |
| 1927 | AVFrame retbuf; |
| 1928 | memset(&retbuf, 0, sizeof(AVFrame)); |
1925 | 1929 | |
1926 | 1930 | int bufflen = nContentWidth * nContentHeight * 3; |
1927 | 1931 | unsigned char *outputbuf = (unsigned char*)av_malloc(bufflen); |
1928 | 1932 | |
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); |
1931 | 1936 | |
1932 | 1937 | 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, |
1934 | 1939 | nContentWidth, nContentHeight); |
1935 | 1940 | |
1936 | 1941 | uint8_t * buf = outputbuf; |
-
diff --git a/mythtv/libs/libmythtv/mythavutil.cpp b/mythtv/libs/libmythtv/mythavutil.cpp
index 8fc8875..80a1777 100644
a
|
b
|
extern "C" { |
16 | 16 | #include "libavcodec/avcodec.h" |
17 | 17 | #include "libavfilter/buffersrc.h" |
18 | 18 | #include "libavfilter/buffersink.h" |
| 19 | #include "libavutil/imgutils.h" |
19 | 20 | } |
20 | 21 | |
21 | 22 | AVPixelFormat FrameTypeToPixelFormat(VideoFrameType type) |
… |
… |
VideoFrameType PixelFormatToFrameType(AVPixelFormat fmt) |
58 | 59 | } |
59 | 60 | } |
60 | 61 | |
61 | | int AVPictureFill(AVPicture *pic, const VideoFrame *frame, AVPixelFormat fmt) |
| 62 | int AVPictureFill(AVFrame *pic, const VideoFrame *frame, AVPixelFormat fmt) |
62 | 63 | { |
63 | 64 | if (fmt == AV_PIX_FMT_NONE) |
64 | 65 | { |
65 | 66 | fmt = FrameTypeToPixelFormat(frame->codec); |
66 | 67 | } |
67 | 68 | |
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); |
69 | 71 | pic->data[1] = frame->buf + frame->offsets[1]; |
70 | 72 | pic->data[2] = frame->buf + frame->offsets[2]; |
71 | 73 | pic->linesize[0] = frame->pitches[0]; |
… |
… |
public: |
98 | 100 | { |
99 | 101 | return size; |
100 | 102 | } |
101 | | size = avpicture_get_size(_fmt, _width, _height); |
| 103 | size = av_image_get_buffer_size(_fmt, _width, _height, IMAGE_ALIGN); |
102 | 104 | width = _width; |
103 | 105 | height = _height; |
104 | 106 | format = _fmt; |
… |
… |
MythAVCopy::~MythAVCopy() |
120 | 122 | delete d; |
121 | 123 | } |
122 | 124 | |
123 | | void MythAVCopy::FillFrame(VideoFrame *frame, const AVPicture *pic, int pitch, |
| 125 | void MythAVCopy::FillFrame(VideoFrame *frame, const AVFrame *pic, int pitch, |
124 | 126 | int width, int height, AVPixelFormat pix_fmt) |
125 | 127 | { |
126 | | int size = avpicture_get_size(pix_fmt, width, height); |
| 128 | int size = av_image_get_buffer_size(pix_fmt, width, height, IMAGE_ALIGN); |
127 | 129 | |
128 | 130 | if (pix_fmt == AV_PIX_FMT_YUV420P) |
129 | 131 | { |
… |
… |
void MythAVCopy::FillFrame(VideoFrame *frame, const AVPicture *pic, int pitch, |
146 | 148 | } |
147 | 149 | } |
148 | 150 | |
149 | | int MythAVCopy::Copy(AVPicture *dst, AVPixelFormat dst_pix_fmt, |
150 | | const AVPicture *src, AVPixelFormat pix_fmt, |
| 151 | int MythAVCopy::Copy(AVFrame *dst, AVPixelFormat dst_pix_fmt, |
| 152 | const AVFrame *src, AVPixelFormat pix_fmt, |
151 | 153 | int width, int height) |
152 | 154 | { |
153 | 155 | if ((pix_fmt == AV_PIX_FMT_YUV420P || pix_fmt == AV_PIX_FMT_NV12) && |
… |
… |
int MythAVCopy::Copy(VideoFrame *dst, const VideoFrame *src) |
197 | 199 | return dst->size; |
198 | 200 | } |
199 | 201 | |
200 | | AVPicture srcpic, dstpic; |
| 202 | AVFrame srcpic, dstpic; |
201 | 203 | |
202 | 204 | AVPictureFill(&srcpic, src); |
203 | 205 | AVPictureFill(&dstpic, dst); |
… |
… |
int MythAVCopy::Copy(VideoFrame *dst, const VideoFrame *src) |
207 | 209 | src->width, src->height); |
208 | 210 | } |
209 | 211 | |
210 | | int MythAVCopy::Copy(AVPicture *pic, const VideoFrame *frame, |
| 212 | int MythAVCopy::Copy(AVFrame *pic, const VideoFrame *frame, |
211 | 213 | unsigned char *buffer, AVPixelFormat fmt) |
212 | 214 | { |
213 | 215 | VideoFrameType type = PixelFormatToFrameType(fmt); |
… |
… |
int MythAVCopy::Copy(AVPicture *pic, const VideoFrame *frame, |
219 | 221 | return 0; |
220 | 222 | } |
221 | 223 | |
222 | | AVPicture pic_in; |
| 224 | AVFrame pic_in; |
223 | 225 | AVPixelFormat fmt_in = FrameTypeToPixelFormat(frame->codec); |
224 | 226 | |
225 | 227 | 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); |
227 | 229 | return Copy(pic, fmt, &pic_in, fmt_in, frame->width, frame->height); |
228 | 230 | } |
229 | 231 | |
230 | | int MythAVCopy::Copy(VideoFrame *frame, const AVPicture *pic, AVPixelFormat fmt) |
| 232 | int MythAVCopy::Copy(VideoFrame *frame, const AVFrame *pic, AVPixelFormat fmt) |
231 | 233 | { |
232 | 234 | if (fmt == AV_PIX_FMT_NV12 || AV_PIX_FMT_YUV420P) |
233 | 235 | { |
… |
… |
int MythAVCopy::Copy(VideoFrame *frame, const AVPicture *pic, AVPixelFormat fmt) |
236 | 238 | return Copy(frame, &framein); |
237 | 239 | } |
238 | 240 | |
239 | | AVPicture frame_out; |
| 241 | AVFrame frame_out; |
240 | 242 | AVPixelFormat fmt_out = FrameTypeToPixelFormat(frame->codec); |
241 | 243 | |
242 | 244 | AVPictureFill(&frame_out, frame, fmt_out); |
… |
… |
MythPictureDeinterlacer::MythPictureDeinterlacer(AVPixelFormat pixfmt, |
260 | 262 | } |
261 | 263 | } |
262 | 264 | |
263 | | int MythPictureDeinterlacer::Deinterlace(AVPicture *dst, const AVPicture *src) |
| 265 | int MythPictureDeinterlacer::Deinterlace(AVFrame *dst, const AVFrame *src) |
264 | 266 | { |
265 | 267 | if (m_errored) |
266 | 268 | { |
… |
… |
int MythPictureDeinterlacer::Deinterlace(AVPicture *dst, const AVPicture *src) |
284 | 286 | { |
285 | 287 | return res; |
286 | 288 | } |
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 | |
288 | 295 | av_frame_unref(m_filter_frame); |
289 | 296 | |
290 | 297 | return 0; |
291 | 298 | } |
292 | 299 | |
293 | | int MythPictureDeinterlacer::DeinterlaceSingle(AVPicture *dst, const AVPicture *src) |
| 300 | int MythPictureDeinterlacer::DeinterlaceSingle(AVFrame *dst, const AVFrame *src) |
294 | 301 | { |
295 | 302 | if (m_errored) |
296 | 303 | { |
-
diff --git a/mythtv/libs/libmythtv/mythavutil.h b/mythtv/libs/libmythtv/mythavutil.h
index cbe169f..a59c246 100644
a
|
b
|
public: |
66 | 66 | { |
67 | 67 | return m_frame; |
68 | 68 | } |
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 | | } |
77 | 69 | |
78 | 70 | private: |
79 | 71 | AVFrame *m_frame; |
… |
… |
class MythAVCopyPrivate; |
83 | 75 | |
84 | 76 | /** |
85 | 77 | * MythAVCopy |
86 | | * Copy AVPicture<->frame, performing the required conversion if any |
| 78 | * Copy AVFrame<->frame, performing the required conversion if any |
87 | 79 | */ |
88 | 80 | class MTV_PUBLIC MythAVCopy |
89 | 81 | { |
… |
… |
public: |
94 | 86 | int Copy(VideoFrame *dst, const VideoFrame *src); |
95 | 87 | /** |
96 | 88 | * 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 |
98 | 90 | * VideoFrame frame into it, performing the required conversion if any |
99 | 91 | * Returns size of buffer allocated |
100 | 92 | * Data would have to be deleted once finished with object with: |
101 | 93 | * av_freep(pic->data[0]) |
102 | 94 | */ |
103 | | int Copy(AVPicture *pic, const VideoFrame *frame, |
| 95 | int Copy(AVFrame *pic, const VideoFrame *frame, |
104 | 96 | unsigned char *buffer = NULL, |
105 | 97 | AVPixelFormat fmt = AV_PIX_FMT_YUV420P); |
106 | 98 | /** |
107 | 99 | * Copy |
108 | | * Copy AVPicture pic into VideoFrame frame, performing the required conversion |
| 100 | * Copy AVFrame pic into VideoFrame frame, performing the required conversion |
109 | 101 | * Returns size of frame data |
110 | 102 | */ |
111 | | int Copy(VideoFrame *frame, const AVPicture *pic, |
| 103 | int Copy(VideoFrame *frame, const AVFrame *pic, |
112 | 104 | 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, |
115 | 107 | int width, int height); |
116 | 108 | |
117 | 109 | private: |
118 | | void FillFrame(VideoFrame *frame, const AVPicture *pic, int pitch, |
| 110 | void FillFrame(VideoFrame *frame, const AVFrame *pic, int pitch, |
119 | 111 | int width, int height, AVPixelFormat pix_fmt); |
120 | 112 | MythAVCopyPrivate *d; |
121 | 113 | }; |
122 | 114 | |
123 | 115 | /** |
124 | 116 | * AVPictureFill |
125 | | * Initialise AVPicture pic with content from VideoFrame frame |
| 117 | * Initialise AVFrame pic with content from VideoFrame frame |
126 | 118 | */ |
127 | | int MTV_PUBLIC AVPictureFill(AVPicture *pic, const VideoFrame *frame, |
| 119 | int MTV_PUBLIC AVPictureFill(AVFrame *pic, const VideoFrame *frame, |
128 | 120 | AVPixelFormat fmt = AV_PIX_FMT_NONE); |
129 | 121 | |
130 | 122 | /** |
… |
… |
public: |
149 | 141 | // To drain the deinterlacer, call Deinterlace with src = NULL until you |
150 | 142 | // get no more frames. Once drained, you must call Flush() to start |
151 | 143 | // 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); |
154 | 146 | // Flush and reset the deinterlacer. |
155 | 147 | int Flush(); |
156 | 148 | private: |
-
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, |
4509 | 4509 | unsigned char *data = NULL; |
4510 | 4510 | unsigned char *outputbuf = NULL; |
4511 | 4511 | VideoFrame *frame = NULL; |
4512 | | AVPicture orig; |
4513 | | AVPicture retbuf; |
| 4512 | AVFrame orig; |
| 4513 | AVFrame retbuf; |
4514 | 4514 | 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)); |
4517 | 4517 | |
4518 | 4518 | bufflen = 0; |
4519 | 4519 | vw = vh = 0; |
-
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, |
963 | 963 | return true; |
964 | 964 | |
965 | 965 | AVFrame *tmp = mpa_pic; |
966 | | copyFrame.Copy(frame, (AVPicture*)tmp, mpa_vidctx->pix_fmt); |
| 966 | copyFrame.Copy(frame, (AVFrame*)tmp, mpa_vidctx->pix_fmt); |
967 | 967 | } |
968 | 968 | |
969 | 969 | return true; |
-
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) |
872 | 872 | MYTHTV_UYVY == videoTextureType) |
873 | 873 | { |
874 | 874 | // software conversion |
875 | | AVPicture img_out; |
| 875 | AVFrame img_out; |
876 | 876 | AVPixelFormat out_fmt = AV_PIX_FMT_BGRA; |
877 | 877 | if ((GL_YCBCR_MESA == videoTextureType) || |
878 | 878 | (GL_YCBCR_422_APPLE == videoTextureType) || |
-
diff --git a/mythtv/libs/libmythtv/privatedecoder_crystalhd.cpp b/mythtv/libs/libmythtv/privatedecoder_crystalhd.cpp
index a59b5da..6c8841d 100644
a
|
b
|
|
3 | 3 | #include "fourcc.h" |
4 | 4 | #include "unistd.h" |
5 | 5 | |
| 6 | extern "C" { |
| 7 | #include "libavutil/imgutils.h" |
| 8 | } |
| 9 | |
6 | 10 | #define LOC QString("CrystalHD: ") |
7 | 11 | #define ERR QString("CrystalHD Err: ") |
8 | 12 | #define WARN QString("CrystalHD Warn: ") |
… |
… |
void PrivateDecoderCrystalHD::FillFrame(BC_DTS_PROC_OUT *out) |
664 | 668 | |
665 | 669 | AVPixelFormat out_fmt = AV_PIX_FMT_YUV420P; |
666 | 670 | AVPixelFormat in_fmt = bcmpixfmt_to_pixfmt(m_pix_fmt); |
667 | | AVPicture img_in; |
| 671 | AVFrame img_in; |
668 | 672 | |
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); |
670 | 675 | |
671 | 676 | if (!(out->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC)) |
672 | 677 | { |
… |
… |
void PrivateDecoderCrystalHD::FillFrame(BC_DTS_PROC_OUT *out) |
676 | 681 | } |
677 | 682 | else |
678 | 683 | { |
679 | | AVPicture img_out; |
| 684 | AVFrame img_out; |
680 | 685 | |
681 | 686 | AVPictureFill(&img_out, m_frame); |
682 | 687 | img_out.linesize[0] *= 2; |
-
diff --git a/mythtv/libs/libmythtv/privatedecoder_omx.cpp b/mythtv/libs/libmythtv/privatedecoder_omx.cpp
index 585687c..7c4fbf7 100644
a
|
b
|
|
14 | 14 | extern "C" { |
15 | 15 | #include "libavutil/pixdesc.h" |
16 | 16 | #include "libavcodec/avcodec.h" |
| 17 | #include "libavutil/imgutils.h" |
17 | 18 | } |
18 | 19 | |
19 | 20 | #include "avformatdecoder.h" |
… |
… |
int PrivateDecoderOMX::GetBufferedFrame(AVStream *stream, AVFrame *picture) |
1031 | 1032 | buf = (unsigned char*)av_malloc(size); |
1032 | 1033 | init(&vf, frametype, buf, out_width, out_height, size); |
1033 | 1034 | |
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); |
1038 | 1041 | |
1039 | 1042 | LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Converting %1 to %2") |
1040 | 1043 | .arg(av_pix_fmt_desc_get(in_fmt)->name) |
-
diff --git a/mythtv/libs/libmythtv/privatedecoder_vda.cpp b/mythtv/libs/libmythtv/privatedecoder_vda.cpp
index dbb9976..f98a2d5 100644
a
|
b
|
|
16 | 16 | |
17 | 17 | extern "C" { |
18 | 18 | #include "libavformat/avformat.h" |
| 19 | #include "libavutil/imgutils.h" |
19 | 20 | } |
20 | 21 | VDALibrary *gVDALib = NULL; |
21 | 22 | |
… |
… |
int PrivateDecoderVDA::GetFrame(AVStream *stream, |
657 | 658 | { |
658 | 659 | CVPixelBufferLockBaseAddress(vdaframe.buffer, 0); |
659 | 660 | 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); |
662 | 664 | m_copyCtx.Copy(frame, &img_in, in_fmt); |
663 | 665 | CVPixelBufferUnlockBaseAddress(vdaframe.buffer, 0); |
664 | 666 | } |
-
diff --git a/mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp
index 04c6d01..c8b2e80 100644
a
|
b
|
extern "C" { |
43 | 43 | |
44 | 44 | extern "C" { |
45 | 45 | #include "libswscale/swscale.h" |
| 46 | #include "libavutil/imgutils.h" |
46 | 47 | } |
47 | 48 | |
48 | 49 | #ifdef USING_V4L2 |
… |
… |
void NuppelVideoRecorder::DoV4L2(void) |
1613 | 1614 | // setup pixel format conversions for YUYV and UYVY |
1614 | 1615 | uint8_t *output_buffer = NULL; |
1615 | 1616 | struct SwsContext *convert_ctx = NULL; |
1616 | | AVPicture img_out; |
| 1617 | AVFrame img_out; |
1617 | 1618 | if (v4l2_pixelformat == V4L2_PIX_FMT_YUYV || |
1618 | 1619 | v4l2_pixelformat == V4L2_PIX_FMT_UYVY) |
1619 | 1620 | { |
… |
… |
void NuppelVideoRecorder::DoV4L2(void) |
1640 | 1641 | return; |
1641 | 1642 | } |
1642 | 1643 | |
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); |
1644 | 1646 | } |
1645 | 1647 | |
1646 | 1648 | while (IsRecordingRequested() && !IsErrored()) |
… |
… |
again: |
1743 | 1745 | { |
1744 | 1746 | if (v4l2_pixelformat == V4L2_PIX_FMT_YUYV) |
1745 | 1747 | { |
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); |
1748 | 1752 | sws_scale(convert_ctx, img_in.data, img_in.linesize, |
1749 | 1753 | 0, height, img_out.data, img_out.linesize); |
1750 | 1754 | BufferIt(output_buffer, video_buffer_size); |
1751 | 1755 | } |
1752 | 1756 | else if (v4l2_pixelformat == V4L2_PIX_FMT_UYVY) |
1753 | 1757 | { |
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); |
1756 | 1762 | sws_scale(convert_ctx, img_in.data, img_in.linesize, |
1757 | 1763 | 0, height, img_out.data, img_out.linesize); |
1758 | 1764 | BufferIt(output_buffer, video_buffer_size); |
-
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; |
18 | 18 | #include "mmsystem.h" |
19 | 19 | #include "tv.h" |
20 | 20 | |
| 21 | extern "C" { |
| 22 | #include "libavutil/imgutils.h" |
| 23 | } |
| 24 | |
21 | 25 | #undef UNICODE |
22 | 26 | |
23 | 27 | const int kNumBuffers = 31; |
… |
… |
void VideoOutputD3D::UpdateFrame(VideoFrame *frame, D3D9Image *img) |
473 | 477 | } |
474 | 478 | else if (buf && !hardware_conv) |
475 | 479 | { |
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); |
479 | 484 | image_out.linesize[0] = pitch; |
480 | 485 | m_copyFrame.Copy(&image_out, frame,(uint8_t*)buf, AV_PIX_FMT_RGB32); |
481 | 486 | } |
-
diff --git a/mythtv/libs/libmythtv/videoout_xv.cpp b/mythtv/libs/libmythtv/videoout_xv.cpp
index 17736e3..0dd52ed 100644
a
|
b
|
extern "C" { |
58 | 58 | #endif // silences warning when these are already defined |
59 | 59 | |
60 | 60 | #include "libswscale/swscale.h" |
| 61 | #include "libavutil/imgutils.h" |
61 | 62 | } |
62 | 63 | |
63 | 64 | #if ! HAVE_ROUND |
… |
… |
void VideoOutputXv::PrepareFrameMem(VideoFrame *buffer, FrameScanType /*scan*/) |
1435 | 1436 | |
1436 | 1437 | int out_width = display_visible_rect.width() & ~0x1; |
1437 | 1438 | int out_height = display_visible_rect.height() & ~0x1; |
1438 | | AVPicture image_in, image_out; |
| 1439 | AVFrame image_in, image_out; |
1439 | 1440 | |
1440 | 1441 | if ((out_width == width) && |
1441 | 1442 | (out_height == height)) |
… |
… |
void VideoOutputXv::PrepareFrameMem(VideoFrame *buffer, FrameScanType /*scan*/) |
1449 | 1450 | int size = buffersize(FMT_YV12, out_width, out_height); |
1450 | 1451 | unsigned char *sbuf = (unsigned char*)av_malloc(size); |
1451 | 1452 | |
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); |
1454 | 1456 | AVPictureFill(&image_in, buffer); |
1455 | 1457 | QMutexLocker locker(&lock); |
1456 | 1458 | scontext = sws_getCachedContext(scontext, width, height, |
… |
… |
void VideoOutputXv::PrepareFrameMem(VideoFrame *buffer, FrameScanType /*scan*/) |
1462 | 1464 | image_out.data, image_out.linesize); |
1463 | 1465 | } |
1464 | 1466 | |
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); |
1467 | 1470 | |
1468 | 1471 | m_copyFrame.Copy(&image_in, non_xv_av_format, &image_out, AV_PIX_FMT_YUV420P, |
1469 | 1472 | out_width, out_height); |
-
diff --git a/mythtv/libs/libmythtv/videooutbase.cpp b/mythtv/libs/libmythtv/videooutbase.cpp
index d0bc6b4..9f8e3a5 100644
a
|
b
|
|
53 | 53 | extern "C" { |
54 | 54 | #include "libavcodec/avcodec.h" |
55 | 55 | #include "libswscale/swscale.h" |
| 56 | #include "libavutil/imgutils.h" |
56 | 57 | } |
57 | 58 | |
58 | 59 | #include "filtermanager.h" |
… |
… |
void VideoOutput::ShowPIP(VideoFrame *frame, |
1120 | 1121 | |
1121 | 1122 | if (pip_tmp_buf && pip_scaling_context) |
1122 | 1123 | { |
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); |
1127 | 1130 | |
1128 | 1131 | AVPictureFill(&img_in, pipimage); |
1129 | 1132 | |
… |
… |
void VideoOutput::ShowPIP(VideoFrame *frame, |
1135 | 1138 | |
1136 | 1139 | if (pipActive) |
1137 | 1140 | { |
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); |
1141 | 1145 | |
1142 | 1146 | 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, |
1144 | 1149 | AV_PIX_FMT_YUV420P, 4, 4, 4, 4, color); |
1145 | 1150 | |
1146 | 1151 | int offsets[3] = {0, int(img_padded.data[1] - img_padded.data[0]), |
… |
… |
void VideoOutput::ResizeVideo(VideoFrame *frame) |
1247 | 1252 | |
1248 | 1253 | if (vsz_tmp_buf && vsz_scale_context) |
1249 | 1254 | { |
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); |
1256 | 1263 | img_in.data[0] = frame->buf + frame->offsets[0]; |
1257 | 1264 | img_in.data[1] = frame->buf + frame->offsets[1]; |
1258 | 1265 | img_in.data[2] = frame->buf + frame->offsets[2]; |
-
diff --git a/mythtv/programs/mythcommflag/BlankFrameDetector.h b/mythtv/programs/mythcommflag/BlankFrameDetector.h
index a6d96ef..0d00164 100644
a
|
b
|
|
9 | 9 | |
10 | 10 | #include "FrameAnalyzer.h" |
11 | 11 | |
12 | | typedef struct AVPicture AVPicture; |
13 | 12 | class HistogramAnalyzer; |
14 | 13 | class TemplateMatcher; |
15 | 14 | |
-
diff --git a/mythtv/programs/mythcommflag/BorderDetector.cpp b/mythtv/programs/mythcommflag/BorderDetector.cpp
index 165a4df..b9ce0b5 100644
a
|
b
|
|
3 | 3 | #include "mythconfig.h" |
4 | 4 | |
5 | 5 | extern "C" { |
6 | | #include "libavcodec/avcodec.h" /* AVPicture */ |
| 6 | #include "libavcodec/avcodec.h" /* AVFrame */ |
7 | 7 | } |
8 | 8 | #include "mythcorecontext.h" /* gContext */ |
9 | 9 | #include "compat.h" |
… |
… |
BorderDetector::setLogoState(TemplateFinder *finder) |
62 | 62 | } |
63 | 63 | |
64 | 64 | int |
65 | | BorderDetector::getDimensions(const AVPicture *pgm, int pgmheight, |
| 65 | BorderDetector::getDimensions(const AVFrame *pgm, int pgmheight, |
66 | 66 | long long _frameno, int *prow, int *pcol, int *pwidth, int *pheight) |
67 | 67 | { |
68 | 68 | /* |
-
diff --git a/mythtv/programs/mythcommflag/BorderDetector.h b/mythtv/programs/mythcommflag/BorderDetector.h
index ae0541d..eb0e858 100644
a
|
b
|
|
12 | 12 | #ifndef __BORDERDETECTOR_H__ |
13 | 13 | #define __BORDERDETECTOR_H__ |
14 | 14 | |
15 | | typedef struct AVPicture AVPicture; |
| 15 | typedef struct AVFrame AVFrame; |
16 | 16 | class MythPlayer; |
17 | 17 | class TemplateFinder; |
18 | 18 | |
… |
… |
public: |
26 | 26 | void setLogoState(TemplateFinder *finder); |
27 | 27 | |
28 | 28 | 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, |
30 | 30 | int *prow, int *pcol, int *pwidth, int *pheight); |
31 | 31 | |
32 | 32 | int reportTime(void); |
33 | 33 | |
34 | 34 | private: |
35 | 35 | TemplateFinder *logoFinder; |
36 | | const struct AVPicture *logo; |
| 36 | const struct AVFrame *logo; |
37 | 37 | int logorow, logocol; |
38 | 38 | int logowidth, logoheight; |
39 | 39 | |
-
diff --git a/mythtv/programs/mythcommflag/CannyEdgeDetector.cpp b/mythtv/programs/mythcommflag/CannyEdgeDetector.cpp
index bfd7683..411c4ec 100644
a
|
b
|
|
10 | 10 | #include "pgm.h" |
11 | 11 | #include "CannyEdgeDetector.h" |
12 | 12 | |
| 13 | extern "C" { |
| 14 | #include "libavutil/imgutils.h" |
| 15 | } |
| 16 | |
13 | 17 | using namespace edgeDetector; |
14 | 18 | |
15 | 19 | CannyEdgeDetector::CannyEdgeDetector(void) |
… |
… |
CannyEdgeDetector::CannyEdgeDetector(void) |
59 | 63 | |
60 | 64 | CannyEdgeDetector::~CannyEdgeDetector(void) |
61 | 65 | { |
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]); |
66 | 70 | if (sgmsorted) |
67 | 71 | delete []sgmsorted; |
68 | 72 | if (sgm) |
… |
… |
CannyEdgeDetector::resetBuffers(int newwidth, int newheight) |
82 | 86 | * Sentinel value to determine whether or not stuff has already been |
83 | 87 | * allocated. |
84 | 88 | */ |
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]); |
89 | 93 | delete []sgm; |
90 | 94 | delete []sgmsorted; |
91 | 95 | sgm = NULL; |
… |
… |
CannyEdgeDetector::resetBuffers(int newwidth, int newheight) |
94 | 98 | const int padded_width = newwidth + 2 * mask_radius; |
95 | 99 | const int padded_height = newheight + 2 * mask_radius; |
96 | 100 | |
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)) |
98 | 103 | { |
99 | 104 | LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers " |
100 | | "avpicture_alloc s1 failed"); |
| 105 | "av_image_alloc s1 failed"); |
101 | 106 | return -1; |
102 | 107 | } |
103 | 108 | |
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)) |
105 | 111 | { |
106 | 112 | LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers " |
107 | | "avpicture_alloc s2 failed"); |
| 113 | "av_image_alloc s2 failed"); |
108 | 114 | goto free_s1; |
109 | 115 | } |
110 | 116 | |
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)) |
112 | 119 | { |
113 | 120 | LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers " |
114 | | "avpicture_alloc convolved failed"); |
| 121 | "av_image_alloc convolved failed"); |
115 | 122 | goto free_s2; |
116 | 123 | } |
117 | 124 | |
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)) |
119 | 127 | { |
120 | 128 | LOG(VB_COMMFLAG, LOG_ERR, "CannyEdgeDetector::resetBuffers " |
121 | | "avpicture_alloc edges failed"); |
| 129 | "av_image_alloc edges failed"); |
122 | 130 | goto free_convolved; |
123 | 131 | } |
124 | 132 | |
… |
… |
CannyEdgeDetector::resetBuffers(int newwidth, int newheight) |
131 | 139 | return 0; |
132 | 140 | |
133 | 141 | free_convolved: |
134 | | avpicture_free(&convolved); |
| 142 | av_freep(&convolved.data[0]); |
135 | 143 | free_s2: |
136 | | avpicture_free(&s2); |
| 144 | av_freep(&s2.data[0]); |
137 | 145 | free_s1: |
138 | | avpicture_free(&s1); |
| 146 | av_freep(&s1.data[0]); |
139 | 147 | return -1; |
140 | 148 | } |
141 | 149 | |
… |
… |
CannyEdgeDetector::setExcludeArea(int row, int col, int width, int height) |
149 | 157 | return 0; |
150 | 158 | } |
151 | 159 | |
152 | | const AVPicture * |
153 | | CannyEdgeDetector::detectEdges(const AVPicture *pgm, int pgmheight, |
| 160 | const AVFrame * |
| 161 | CannyEdgeDetector::detectEdges(const AVFrame *pgm, int pgmheight, |
154 | 162 | int percentile) |
155 | 163 | { |
156 | 164 | /* |
-
diff --git a/mythtv/programs/mythcommflag/CannyEdgeDetector.h b/mythtv/programs/mythcommflag/CannyEdgeDetector.h
index eef6a5c..f482ae9 100644
a
|
b
|
|
8 | 8 | #define __CANNYEDGEDETECTOR_H__ |
9 | 9 | |
10 | 10 | extern "C" { |
11 | | #include "libavcodec/avcodec.h" /* AVPicture */ |
| 11 | #include "libavcodec/avcodec.h" /* AVFrame */ |
12 | 12 | } |
13 | 13 | #include "EdgeDetector.h" |
14 | 14 | |
… |
… |
public: |
22 | 22 | ~CannyEdgeDetector(void); |
23 | 23 | int MythPlayerInited(const MythPlayer *player, int width, int height); |
24 | 24 | 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, |
26 | 26 | int percentile); |
27 | 27 | |
28 | 28 | private: |
… |
… |
private: |
32 | 32 | int mask_radius; /* radius of mask */ |
33 | 33 | |
34 | 34 | unsigned int *sgm, *sgmsorted; /* squared-gradient magnitude */ |
35 | | AVPicture s1, s2, convolved; /* smoothed grayscale frame */ |
| 35 | AVFrame s1, s2, convolved; /* smoothed grayscale frame */ |
36 | 36 | int ewidth, eheight; /* dimensions */ |
37 | | AVPicture edges; /* detected edges */ |
| 37 | AVFrame edges; /* detected edges */ |
38 | 38 | |
39 | 39 | struct { |
40 | 40 | int row, col, width, height; |
-
diff --git a/mythtv/programs/mythcommflag/EdgeDetector.cpp b/mythtv/programs/mythcommflag/EdgeDetector.cpp
index a0be23f..cd9d590 100644
a
|
b
|
using namespace std; |
9 | 9 | |
10 | 10 | // avlib/ffmpeg headers |
11 | 11 | extern "C" { |
12 | | #include "libavcodec/avcodec.h" // AVPicture |
| 12 | #include "libavcodec/avcodec.h" // AVFrame |
13 | 13 | } |
14 | 14 | |
15 | 15 | // MythTV headers |
… |
… |
namespace edgeDetector { |
25 | 25 | using namespace frameAnalyzer; |
26 | 26 | |
27 | 27 | unsigned int * |
28 | | sgm_init_exclude(unsigned int *sgm, const AVPicture *src, int srcheight, |
| 28 | sgm_init_exclude(unsigned int *sgm, const AVFrame *src, int srcheight, |
29 | 29 | int excluderow, int excludecol, int excludewidth, int excludeheight) |
30 | 30 | { |
31 | 31 | /* |
… |
… |
sgm_init_exclude(unsigned int *sgm, const AVPicture *src, int srcheight, |
62 | 62 | |
63 | 63 | #ifdef LATER |
64 | 64 | unsigned int * |
65 | | sgm_init(unsigned int *sgm, const AVPicture *src, int srcheight) |
| 65 | sgm_init(unsigned int *sgm, const AVFrame *src, int srcheight) |
66 | 66 | { |
67 | 67 | return sgm_init_exclude(sgm, src, srcheight, 0, 0, 0, 0); |
68 | 68 | } |
… |
… |
static int sort_ascending(const void *aa, const void *bb) |
74 | 74 | } |
75 | 75 | |
76 | 76 | static int |
77 | | edge_mark(AVPicture *dst, int dstheight, |
| 77 | edge_mark(AVFrame *dst, int dstheight, |
78 | 78 | int extratop, int extraright, int extrabottom, int extraleft, |
79 | 79 | const unsigned int *sgm, unsigned int *sgmsorted, int percentile, |
80 | 80 | int excluderow, int excludecol, int excludewidth, int excludeheight) |
… |
… |
edge_mark(AVPicture *dst, int dstheight, |
180 | 180 | } |
181 | 181 | |
182 | 182 | #ifdef LATER |
183 | | int edge_mark_uniform(AVPicture *dst, int dstheight, int extramargin, |
| 183 | int edge_mark_uniform(AVFrame *dst, int dstheight, int extramargin, |
184 | 184 | const unsigned int *sgm, unsigned int *sgmsorted, |
185 | 185 | int percentile) |
186 | 186 | { |
… |
… |
int edge_mark_uniform(AVPicture *dst, int dstheight, int extramargin, |
190 | 190 | } |
191 | 191 | #endif /* LATER */ |
192 | 192 | |
193 | | int edge_mark_uniform_exclude(AVPicture *dst, int dstheight, int extramargin, |
| 193 | int edge_mark_uniform_exclude(AVFrame *dst, int dstheight, int extramargin, |
194 | 194 | const unsigned int *sgm, unsigned int *sgmsorted, int percentile, |
195 | 195 | int excluderow, int excludecol, int excludewidth, int excludeheight) |
196 | 196 | { |
-
diff --git a/mythtv/programs/mythcommflag/EdgeDetector.h b/mythtv/programs/mythcommflag/EdgeDetector.h
index 60cf767..ea61845 100644
a
|
b
|
|
8 | 8 | #ifndef __EDGEDETECTOR_H__ |
9 | 9 | #define __EDGEDETECTOR_H__ |
10 | 10 | |
11 | | typedef struct AVPicture AVPicture; |
| 11 | typedef struct AVFrame AVFrame; |
12 | 12 | |
13 | 13 | namespace edgeDetector { |
14 | 14 | |
15 | 15 | /* Pass all zeroes to not exclude any areas from examination. */ |
16 | 16 | |
17 | 17 | unsigned int *sgm_init_exclude(unsigned int *sgm, |
18 | | const AVPicture *src, int srcheight, |
| 18 | const AVFrame *src, int srcheight, |
19 | 19 | int excluderow, int excludecol, int excludewidth, int excludeheight); |
20 | 20 | |
21 | | int edge_mark_uniform_exclude(AVPicture *dst, int dstheight, int extramargin, |
| 21 | int edge_mark_uniform_exclude(AVFrame *dst, int dstheight, int extramargin, |
22 | 22 | const unsigned int *sgm, unsigned int *sgmsorted, int percentile, |
23 | 23 | int excluderow, int excludecol, int excludewidth, int excludeheight); |
24 | 24 | |
… |
… |
public: |
33 | 33 | virtual int setExcludeArea(int row, int col, int width, int height); |
34 | 34 | |
35 | 35 | /* 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, |
37 | 37 | int percentile) = 0; |
38 | 38 | }; |
39 | 39 | |
-
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) |
308 | 308 | static const int CINC = 4; |
309 | 309 | #define ROUNDUP(a,b) (((a) + (b) - 1) / (b) * (b)) |
310 | 310 | |
311 | | const AVPicture *pgm; |
| 311 | const AVFrame *pgm; |
312 | 312 | int pgmwidth, pgmheight; |
313 | 313 | bool ismonochromatic; |
314 | 314 | int croprow, cropcol, cropwidth, cropheight; |
-
diff --git a/mythtv/programs/mythcommflag/HistogramAnalyzer.h b/mythtv/programs/mythcommflag/HistogramAnalyzer.h
index dbb1945..2da903b 100644
a
|
b
|
|
9 | 9 | |
10 | 10 | #include "FrameAnalyzer.h" |
11 | 11 | |
12 | | typedef struct AVPicture AVPicture; |
| 12 | typedef struct AVFrame AVFrame; |
13 | 13 | class PGMConverter; |
14 | 14 | class BorderDetector; |
15 | 15 | class TemplateFinder; |
… |
… |
private: |
45 | 45 | BorderDetector *borderDetector; |
46 | 46 | |
47 | 47 | TemplateFinder *logoFinder; |
48 | | const struct AVPicture *logo; |
| 48 | const struct AVFrame *logo; |
49 | 49 | int logowidth, logoheight; |
50 | 50 | int logorr1, logocc1, logorr2, logocc2; |
51 | 51 | |
-
diff --git a/mythtv/programs/mythcommflag/PGMConverter.cpp b/mythtv/programs/mythcommflag/PGMConverter.cpp
index 320ba39..83a9646 100644
a
|
b
|
|
15 | 15 | #include "pgm.h" |
16 | 16 | #include "PGMConverter.h" |
17 | 17 | |
| 18 | extern "C" { |
| 19 | #include "libavutil/imgutils.h" |
| 20 | } |
| 21 | |
18 | 22 | using namespace commDetector2; |
19 | 23 | |
20 | 24 | PGMConverter::PGMConverter(void) |
… |
… |
PGMConverter::~PGMConverter(void) |
34 | 38 | { |
35 | 39 | width = -1; |
36 | 40 | #ifdef PGM_CONVERT_GREYSCALE |
37 | | avpicture_free(&pgm); |
| 41 | av_freep(&pgm.data[0]); |
38 | 42 | memset(&pgm, 0, sizeof(pgm)); |
39 | 43 | delete m_copy; |
40 | 44 | #endif /* PGM_CONVERT_GREYSCALE */ |
… |
… |
PGMConverter::MythPlayerInited(const MythPlayer *player) |
56 | 60 | height = buf_dim.height(); |
57 | 61 | |
58 | 62 | #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)) |
60 | 65 | { |
61 | 66 | LOG(VB_COMMFLAG, LOG_ERR, QString("PGMConverter::MythPlayerInited " |
62 | | "avpicture_alloc pgm (%1x%2) failed") |
| 67 | "av_image_alloc pgm (%1x%2) failed") |
63 | 68 | .arg(width).arg(height)); |
64 | 69 | return -1; |
65 | 70 | } |
… |
… |
PGMConverter::MythPlayerInited(const MythPlayer *player) |
78 | 83 | return 0; |
79 | 84 | } |
80 | 85 | |
81 | | const AVPicture * |
| 86 | const AVFrame * |
82 | 87 | PGMConverter::getImage(const VideoFrame *frame, long long _frameno, |
83 | 88 | int *pwidth, int *pheight) |
84 | 89 | { |
… |
… |
PGMConverter::getImage(const VideoFrame *frame, long long _frameno, |
103 | 108 | timersub(&end, &start, &elapsed); |
104 | 109 | timeradd(&convert_time, &elapsed, &convert_time); |
105 | 110 | #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) |
107 | 113 | { |
108 | 114 | LOG(VB_COMMFLAG, LOG_ERR, |
109 | 115 | QString("PGMConverter::getImage error at frame %1 (%2x%3)") |
-
diff --git a/mythtv/programs/mythcommflag/PGMConverter.h b/mythtv/programs/mythcommflag/PGMConverter.h
index 2fc5184..c30f1e2 100644
a
|
b
|
|
8 | 8 | #define __PGMCONVERTER_H__ |
9 | 9 | |
10 | 10 | extern "C" { |
11 | | #include "libavcodec/avcodec.h" /* AVPicture */ |
| 11 | #include "libavcodec/avcodec.h" /* AVFrame */ |
12 | 12 | } |
13 | 13 | |
14 | 14 | typedef struct VideoFrame_ VideoFrame; |
… |
… |
public: |
35 | 35 | ~PGMConverter(void); |
36 | 36 | |
37 | 37 | 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, |
39 | 39 | int *pwidth, int *pheight); |
40 | 40 | int reportTime(void); |
41 | 41 | |
42 | 42 | private: |
43 | 43 | long long frameno; /* frame number */ |
44 | 44 | int width, height; /* frame dimensions */ |
45 | | AVPicture pgm; /* grayscale frame */ |
| 45 | AVFrame pgm; /* grayscale frame */ |
46 | 46 | #ifdef PGM_CONVERT_GREYSCALE |
47 | 47 | struct timeval convert_time; |
48 | 48 | bool time_reported; |
-
diff --git a/mythtv/programs/mythcommflag/SceneChangeDetector.h b/mythtv/programs/mythcommflag/SceneChangeDetector.h
index ec25911..c35432e 100644
a
|
b
|
|
11 | 11 | |
12 | 12 | #include "FrameAnalyzer.h" |
13 | 13 | |
14 | | typedef struct AVPicture AVPicture; |
| 14 | typedef struct AVFrame AVFrame; |
15 | 15 | class HistogramAnalyzer; |
16 | 16 | |
17 | 17 | class SceneChangeDetector : public FrameAnalyzer |
-
diff --git a/mythtv/programs/mythcommflag/TemplateFinder.cpp b/mythtv/programs/mythcommflag/TemplateFinder.cpp
index a82a7a5..bdff156 100644
a
|
b
|
|
26 | 26 | #include "EdgeDetector.h" |
27 | 27 | #include "TemplateFinder.h" |
28 | 28 | |
| 29 | extern "C" { |
| 30 | #include "libavutil/imgutils.h" |
| 31 | } |
| 32 | |
29 | 33 | using namespace commDetector2; |
30 | 34 | |
31 | 35 | namespace { |
32 | 36 | |
33 | | int writeJPG(QString prefix, const AVPicture *img, int imgheight) |
| 37 | int writeJPG(QString prefix, const AVFrame *img, int imgheight) |
34 | 38 | { |
35 | 39 | const int imgwidth = img->linesize[0]; |
36 | 40 | QFileInfo jpgfi(prefix + ".jpg"); |
… |
… |
int writeJPG(QString prefix, const AVPicture *img, int imgheight) |
65 | 69 | |
66 | 70 | int |
67 | 71 | pgm_scorepixels(unsigned int *scores, int width, int row, int col, |
68 | | const AVPicture *src, int srcheight) |
| 72 | const AVFrame *src, int srcheight) |
69 | 73 | { |
70 | 74 | /* Every time a pixel is an edge, give it a point. */ |
71 | 75 | const int srcwidth = src->linesize[0]; |
… |
… |
sort_ascending(const void *aa, const void *bb) |
90 | 94 | } |
91 | 95 | |
92 | 96 | float |
93 | | bounding_score(const AVPicture *img, int row, int col, int width, int height) |
| 97 | bounding_score(const AVFrame *img, int row, int col, int width, int height) |
94 | 98 | { |
95 | 99 | /* Return a value between [0..1] */ |
96 | 100 | const int imgwidth = img->linesize[0]; |
… |
… |
bounding_score(const AVPicture *img, int row, int col, int width, int height) |
112 | 116 | } |
113 | 117 | |
114 | 118 | bool |
115 | | rowisempty(const AVPicture *img, int row, int col, int width) |
| 119 | rowisempty(const AVFrame *img, int row, int col, int width) |
116 | 120 | { |
117 | 121 | const int imgwidth = img->linesize[0]; |
118 | 122 | for (int cc = col; cc < col + width; cc++) |
… |
… |
rowisempty(const AVPicture *img, int row, int col, int width) |
122 | 126 | } |
123 | 127 | |
124 | 128 | bool |
125 | | colisempty(const AVPicture *img, int col, int row, int height) |
| 129 | colisempty(const AVFrame *img, int col, int row, int height) |
126 | 130 | { |
127 | 131 | const int imgwidth = img->linesize[0]; |
128 | 132 | for (int rr = row; rr < row + height; rr++) |
… |
… |
colisempty(const AVPicture *img, int col, int row, int height) |
132 | 136 | } |
133 | 137 | |
134 | 138 | int |
135 | | bounding_box(const AVPicture *img, int imgheight, |
| 139 | bounding_box(const AVFrame *img, int imgheight, |
136 | 140 | int minrow, int mincol, int maxrow1, int maxcol1, |
137 | 141 | int *prow, int *pcol, int *pwidth, int *pheight) |
138 | 142 | { |
… |
… |
bounding_box(const AVPicture *img, int imgheight, |
440 | 444 | |
441 | 445 | int |
442 | 446 | template_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, |
444 | 448 | int *ptmplrow, int *ptmplcol, int *ptmplwidth, int *ptmplheight, |
445 | 449 | bool debug_edgecounts, QString debugdir) |
446 | 450 | { |
… |
… |
template_alloc(const unsigned int *scores, int width, int height, |
458 | 462 | const int nn = width * height; |
459 | 463 | int ii, first, last; |
460 | 464 | unsigned int *sortedscores, threshscore; |
461 | | AVPicture thresh; |
| 465 | AVFrame thresh; |
462 | 466 | |
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)) |
464 | 469 | { |
465 | 470 | 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") |
467 | 472 | .arg(width).arg(height)); |
468 | 473 | return -1; |
469 | 474 | } |
… |
… |
template_alloc(const unsigned int *scores, int width, int height, |
505 | 510 | if (debug_edgecounts) |
506 | 511 | { |
507 | 512 | /* 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)) |
510 | 516 | { |
511 | 517 | 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") |
513 | 519 | .arg(width).arg(height)); |
514 | 520 | goto free_thresh; |
515 | 521 | } |
… |
… |
template_alloc(const unsigned int *scores, int width, int height, |
518 | 524 | scored.data[0][ii] = scores[ii] * UCHAR_MAX / maxscore; |
519 | 525 | int error = writeJPG(debugdir + "/TemplateFinder-scores", &scored, |
520 | 526 | height); |
521 | | avpicture_free(&scored); |
| 527 | av_freep(&scored.data[0]); |
522 | 528 | if (error) |
523 | 529 | goto free_thresh; |
524 | 530 | |
… |
… |
template_alloc(const unsigned int *scores, int width, int height, |
542 | 548 | goto free_thresh; |
543 | 549 | } |
544 | 550 | |
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)) |
546 | 553 | { |
547 | 554 | 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") |
549 | 556 | .arg(*ptmplwidth).arg(*ptmplheight)); |
550 | 557 | goto free_thresh; |
551 | 558 | } |
… |
… |
template_alloc(const unsigned int *scores, int width, int height, |
555 | 562 | goto free_thresh; |
556 | 563 | |
557 | 564 | delete []sortedscores; |
558 | | avpicture_free(&thresh); |
| 565 | av_freep(&thresh.data[0]); |
| 566 | |
559 | 567 | return 0; |
560 | 568 | |
561 | 569 | free_thresh: |
562 | 570 | delete []sortedscores; |
563 | | avpicture_free(&thresh); |
| 571 | av_freep(&thresh.data[0]); |
564 | 572 | return -1; |
565 | 573 | } |
566 | 574 | |
567 | 575 | int |
568 | | analyzeFrameDebug(long long frameno, const AVPicture *pgm, int pgmheight, |
569 | | const AVPicture *cropped, const AVPicture *edges, int cropheight, |
| 576 | analyzeFrameDebug(long long frameno, const AVFrame *pgm, int pgmheight, |
| 577 | const AVFrame *cropped, const AVFrame *edges, int cropheight, |
570 | 578 | int croprow, int cropcol, bool debug_frames, QString debugdir) |
571 | 579 | { |
572 | 580 | static const int delta = 24; |
… |
… |
error: |
619 | 627 | |
620 | 628 | bool |
621 | 629 | readTemplate(QString datafile, int *prow, int *pcol, int *pwidth, int *pheight, |
622 | | QString tmplfile, AVPicture *tmpl, bool *pvalid) |
| 630 | QString tmplfile, AVFrame *tmpl, bool *pvalid) |
623 | 631 | { |
624 | 632 | QFile dfile(datafile); |
625 | 633 | QFileInfo dfileinfo(dfile); |
… |
… |
readTemplate(QString datafile, int *prow, int *pcol, int *pwidth, int *pheight, |
638 | 646 | stream >> *prow >> *pcol >> *pwidth >> *pheight; |
639 | 647 | dfile.close(); |
640 | 648 | |
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)) |
642 | 651 | { |
643 | 652 | LOG(VB_COMMFLAG, LOG_ERR, |
644 | | QString("readTemplate avpicture_alloc %1 (%2x%3) failed") |
| 653 | QString("readTemplate av_image_alloc %1 (%2x%3) failed") |
645 | 654 | .arg(tmplfile).arg(*pwidth).arg(*pheight)); |
646 | 655 | return false; |
647 | 656 | } |
… |
… |
readTemplate(QString datafile, int *prow, int *pcol, int *pwidth, int *pheight, |
649 | 658 | QByteArray tmfile = tmplfile.toLatin1(); |
650 | 659 | if (pgm_read(tmpl->data[0], *pwidth, *pheight, tmfile.constData())) |
651 | 660 | { |
652 | | avpicture_free(tmpl); |
| 661 | av_freep(&tmpl->data[0]); |
653 | 662 | return false; |
654 | 663 | } |
655 | 664 | |
… |
… |
writeDummyTemplate(QString datafile) |
669 | 678 | } |
670 | 679 | |
671 | 680 | bool |
672 | | writeTemplate(QString tmplfile, const AVPicture *tmpl, QString datafile, |
| 681 | writeTemplate(QString tmplfile, const AVFrame *tmpl, QString datafile, |
673 | 682 | int row, int col, int width, int height) |
674 | 683 | { |
675 | 684 | QFile tfile(tmplfile); |
… |
… |
TemplateFinder::~TemplateFinder(void) |
782 | 791 | { |
783 | 792 | if (scores) |
784 | 793 | delete []scores; |
785 | | avpicture_free(&tmpl); |
786 | | avpicture_free(&cropped); |
| 794 | av_freep(&tmpl.data[0]); |
| 795 | av_freep(&cropped.data[0]); |
787 | 796 | } |
788 | 797 | |
789 | 798 | enum FrameAnalyzer::analyzeFrameResult |
… |
… |
TemplateFinder::MythPlayerInited(MythPlayer *player, long long nframes) |
848 | 857 | return ANALYZE_OK; |
849 | 858 | |
850 | 859 | free_tmpl: |
851 | | avpicture_free(&tmpl); |
| 860 | av_freep(&tmpl.data[0]); |
852 | 861 | return ANALYZE_FATAL; |
853 | 862 | } |
854 | 863 | |
… |
… |
TemplateFinder::resetBuffers(int newwidth, int newheight) |
858 | 867 | if (cwidth == newwidth && cheight == newheight) |
859 | 868 | return 0; |
860 | 869 | |
861 | | avpicture_free(&cropped); |
| 870 | av_freep(&cropped.data[0]); |
862 | 871 | |
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)) |
864 | 874 | { |
865 | 875 | LOG(VB_COMMFLAG, LOG_ERR, |
866 | 876 | QString("TemplateFinder::resetBuffers " |
867 | | "avpicture_alloc cropped (%1x%2) failed") |
| 877 | "av_image_alloc cropped (%1x%2) failed") |
868 | 878 | .arg(newwidth).arg(newheight)); |
869 | 879 | return -1; |
870 | 880 | } |
… |
… |
TemplateFinder::analyzeFrame(const VideoFrame *frame, long long frameno, |
908 | 918 | static const float EXCLUDEWIDTH = 0.5; |
909 | 919 | static const float EXCLUDEHEIGHT = 0.5; |
910 | 920 | |
911 | | const AVPicture *pgm, *edges; |
| 921 | const AVFrame *pgm, *edges; |
912 | 922 | int pgmwidth, pgmheight; |
913 | 923 | int croprow, cropcol, cropwidth, cropheight; |
914 | 924 | int excluderow, excludecol, excludewidth, excludeheight; |
… |
… |
TemplateFinder::finished(long long nframes, bool final) |
1037 | 1047 | return 0; |
1038 | 1048 | |
1039 | 1049 | free_tmpl: |
1040 | | avpicture_free(&tmpl); |
| 1050 | av_freep(&tmpl.data[0]); |
1041 | 1051 | return -1; |
1042 | 1052 | } |
1043 | 1053 | |
… |
… |
TemplateFinder::reportTime(void) const |
1055 | 1065 | return 0; |
1056 | 1066 | } |
1057 | 1067 | |
1058 | | const struct AVPicture * |
| 1068 | const struct AVFrame * |
1059 | 1069 | TemplateFinder::getTemplate(int *prow, int *pcol, int *pwidth, int *pheight) |
1060 | 1070 | const |
1061 | 1071 | { |
-
diff --git a/mythtv/programs/mythcommflag/TemplateFinder.h b/mythtv/programs/mythcommflag/TemplateFinder.h
index 3b83c2a..c8f7ed1 100644
a
|
b
|
|
19 | 19 | #define __TEMPLATEFINDER_H__ |
20 | 20 | |
21 | 21 | extern "C" { |
22 | | #include "libavcodec/avcodec.h" /* AVPicture */ |
| 22 | #include "libavcodec/avcodec.h" /* AVFrame */ |
23 | 23 | } |
24 | 24 | #include "FrameAnalyzer.h" |
25 | 25 | |
… |
… |
public: |
46 | 46 | FrameMap GetMap(unsigned int) const { FrameMap map; return map; } |
47 | 47 | |
48 | 48 | /* TemplateFinder implementation. */ |
49 | | const struct AVPicture *getTemplate(int *prow, int *pcol, |
| 49 | const struct AVFrame *getTemplate(int *prow, int *pcol, |
50 | 50 | int *pwidth, int *pheight) const; |
51 | 51 | |
52 | 52 | private: |
… |
… |
private: |
69 | 69 | int maxcontentrow1; /* minrow + height ("maxrow + 1") */ |
70 | 70 | int maxcontentcol1; /* mincol + width ("maxcol + 1") */ |
71 | 71 | |
72 | | AVPicture tmpl; /* logo-matching template */ |
| 72 | AVFrame tmpl; /* logo-matching template */ |
73 | 73 | int tmplrow, tmplcol; |
74 | 74 | int tmplwidth, tmplheight; |
75 | 75 | |
76 | | AVPicture cropped; /* cropped version of frame */ |
| 76 | AVFrame cropped; /* cropped version of frame */ |
77 | 77 | int cwidth, cheight; /* cropped height */ |
78 | 78 | |
79 | 79 | /* Debugging. */ |
-
diff --git a/mythtv/programs/mythcommflag/TemplateMatcher.cpp b/mythtv/programs/mythcommflag/TemplateMatcher.cpp
index 059edcd..a587629 100644
a
|
b
|
using namespace std; |
28 | 28 | #include "TemplateFinder.h" |
29 | 29 | #include "TemplateMatcher.h" |
30 | 30 | |
| 31 | extern "C" { |
| 32 | #include "libavutil/imgutils.h" |
| 33 | } |
| 34 | |
31 | 35 | using namespace commDetector2; |
32 | 36 | using namespace frameAnalyzer; |
33 | 37 | |
34 | 38 | namespace { |
35 | 39 | |
36 | | int pgm_set(const AVPicture *pict, int height) |
| 40 | int pgm_set(const AVFrame *pict, int height) |
37 | 41 | { |
38 | 42 | const int width = pict->linesize[0]; |
39 | 43 | const int size = height * width; |
… |
… |
int pgm_set(const AVPicture *pict, int height) |
46 | 50 | return score; |
47 | 51 | } |
48 | 52 | |
49 | | int pgm_match(const AVPicture *tmpl, const AVPicture *test, int height, |
| 53 | int pgm_match(const AVFrame *tmpl, const AVFrame *test, int height, |
50 | 54 | int radius, unsigned short *pscore) |
51 | 55 | { |
52 | 56 | /* Return the number of matching "edge" and non-edge pixels. */ |
… |
… |
TemplateMatcher::~TemplateMatcher(void) |
370 | 374 | delete []matches; |
371 | 375 | if (match) |
372 | 376 | delete []match; |
373 | | avpicture_free(&cropped); |
| 377 | av_freep(&cropped.data[0]); |
374 | 378 | } |
375 | 379 | |
376 | 380 | enum FrameAnalyzer::analyzeFrameResult |
… |
… |
TemplateMatcher::MythPlayerInited(MythPlayer *_player, |
388 | 392 | return ANALYZE_FATAL; |
389 | 393 | } |
390 | 394 | |
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)) |
392 | 397 | { |
393 | 398 | LOG(VB_COMMFLAG, LOG_ERR, |
394 | 399 | QString("TemplateMatcher::MythPlayerInited " |
395 | | "avpicture_alloc cropped (%1x%2) failed") |
| 400 | "av_image_alloc cropped (%1x%2) failed") |
396 | 401 | .arg(tmplwidth).arg(tmplheight)); |
397 | 402 | return ANALYZE_FATAL; |
398 | 403 | } |
… |
… |
TemplateMatcher::MythPlayerInited(MythPlayer *_player, |
422 | 427 | return ANALYZE_OK; |
423 | 428 | |
424 | 429 | free_cropped: |
425 | | avpicture_free(&cropped); |
| 430 | av_freep(&cropped.data[0]); |
426 | 431 | return ANALYZE_FATAL; |
427 | 432 | } |
428 | 433 | |
… |
… |
TemplateMatcher::analyzeFrame(const VideoFrame *frame, long long frameno, |
465 | 470 | */ |
466 | 471 | const int JITTER_RADIUS = 0; |
467 | 472 | |
468 | | const AVPicture *pgm; |
469 | | const AVPicture *edges; |
| 473 | const AVFrame *pgm; |
| 474 | const AVFrame *edges; |
470 | 475 | int pgmwidth, pgmheight; |
471 | 476 | struct timeval start, end, elapsed; |
472 | 477 | |
-
diff --git a/mythtv/programs/mythcommflag/TemplateMatcher.h b/mythtv/programs/mythcommflag/TemplateMatcher.h
index e3fd9b6..8c03941 100644
a
|
b
|
|
19 | 19 | #define __TEMPLATEMATCHER_H__ |
20 | 20 | |
21 | 21 | extern "C" { |
22 | | #include "libavcodec/avcodec.h" /* AVPicture */ |
| 22 | #include "libavcodec/avcodec.h" /* AVFrame */ |
23 | 23 | } |
24 | 24 | #include "FrameAnalyzer.h" |
25 | 25 | |
26 | | typedef struct AVPicture AVPicture; |
| 26 | typedef struct AVFrame AVFrame; |
27 | 27 | class PGMConverter; |
28 | 28 | class EdgeDetector; |
29 | 29 | class TemplateFinder; |
… |
… |
private: |
56 | 56 | PGMConverter *pgmConverter; |
57 | 57 | EdgeDetector *edgeDetector; |
58 | 58 | TemplateFinder *templateFinder; |
59 | | const struct AVPicture *tmpl; /* template image */ |
| 59 | const struct AVFrame *tmpl; /* template image */ |
60 | 60 | int tmplrow, tmplcol; /* template location */ |
61 | 61 | int tmplwidth, tmplheight; /* template dimensions */ |
62 | 62 | |
… |
… |
private: |
65 | 65 | unsigned char *match; /* boolean result: 1/0 */ |
66 | 66 | |
67 | 67 | float fps; |
68 | | AVPicture cropped; /* pre-allocated buffer */ |
| 68 | AVFrame cropped; /* pre-allocated buffer */ |
69 | 69 | FrameAnalyzer::FrameMap breakMap; /* frameno => nframes */ |
70 | 70 | |
71 | 71 | /* Debugging */ |
-
diff --git a/mythtv/programs/mythcommflag/pgm.cpp b/mythtv/programs/mythcommflag/pgm.cpp
index 2523eb7..751c2e1 100644
a
|
b
|
|
4 | 4 | |
5 | 5 | extern "C" { |
6 | 6 | #include "libavcodec/avcodec.h" |
| 7 | #include "libavutil/imgutils.h" |
7 | 8 | } |
8 | 9 | #include "mythframe.h" |
9 | 10 | #include "mythlogging.h" |
… |
… |
error: |
108 | 109 | return -1; |
109 | 110 | } |
110 | 111 | |
111 | | static int pgm_expand(AVPicture *dst, const AVPicture *src, int srcheight, |
| 112 | static int pgm_expand(AVFrame *dst, const AVFrame *src, int srcheight, |
112 | 113 | int extratop, int extraright, int extrabottom, |
113 | 114 | int extraleft) |
114 | 115 | { |
… |
… |
static int pgm_expand(AVPicture *dst, const AVPicture *src, int srcheight, |
150 | 151 | return 0; |
151 | 152 | } |
152 | 153 | |
153 | | static int pgm_expand_uniform(AVPicture *dst, const AVPicture *src, |
| 154 | static int pgm_expand_uniform(AVFrame *dst, const AVFrame *src, |
154 | 155 | int srcheight, int extramargin) |
155 | 156 | { |
156 | 157 | return pgm_expand(dst, src, srcheight, |
157 | 158 | extramargin, extramargin, extramargin, extramargin); |
158 | 159 | } |
159 | 160 | |
160 | | int pgm_crop(AVPicture *dst, const AVPicture *src, int srcheight, |
| 161 | int pgm_crop(AVFrame *dst, const AVFrame *src, int srcheight, |
161 | 162 | int srcrow, int srccol, int cropwidth, int cropheight) |
162 | 163 | { |
163 | 164 | const int srcwidth = src->linesize[0]; |
… |
… |
int pgm_crop(AVPicture *dst, const AVPicture *src, int srcheight, |
179 | 180 | return 0; |
180 | 181 | } |
181 | 182 | |
182 | | int pgm_overlay(AVPicture *dst, const AVPicture *s1, int s1height, |
183 | | int s1row, int s1col, const AVPicture *s2, int s2height) |
| 183 | int pgm_overlay(AVFrame *dst, const AVFrame *s1, int s1height, |
| 184 | int s1row, int s1col, const AVFrame *s2, int s2height) |
184 | 185 | { |
185 | 186 | const int dstwidth = dst->linesize[0]; |
186 | 187 | const int s1width = s1->linesize[0]; |
… |
… |
int pgm_overlay(AVPicture *dst, const AVPicture *s1, int s1height, |
194 | 195 | return -1; |
195 | 196 | } |
196 | 197 | |
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); |
198 | 205 | |
199 | 206 | /* Overwrite overlay area of "dst" with "s2". */ |
200 | 207 | for (rr = 0; rr < s2height; rr++) |
… |
… |
int pgm_overlay(AVPicture *dst, const AVPicture *s1, int s1height, |
205 | 212 | return 0; |
206 | 213 | } |
207 | 214 | |
208 | | int pgm_convolve_radial(AVPicture *dst, AVPicture *s1, AVPicture *s2, |
209 | | const AVPicture *src, int srcheight, |
| 215 | int pgm_convolve_radial(AVFrame *dst, AVFrame *s1, AVFrame *s2, |
| 216 | const AVFrame *src, int srcheight, |
210 | 217 | const double *mask, int mask_radius) |
211 | 218 | { |
212 | 219 | /* |
… |
… |
int pgm_convolve_radial(AVPicture *dst, AVPicture *s1, AVPicture *s2, |
233 | 240 | return -1; |
234 | 241 | |
235 | 242 | /* 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); |
238 | 253 | |
239 | 254 | /* "s1" convolve with column vector => "s2" */ |
240 | 255 | rr2 = mask_radius + srcheight; |
-
diff --git a/mythtv/programs/mythcommflag/pgm.h b/mythtv/programs/mythcommflag/pgm.h
index 8cb2053..f1873e2 100644
a
|
b
|
|
8 | 8 | #define __PGM_H__ |
9 | 9 | |
10 | 10 | struct VideoFrame_; |
11 | | struct AVPicture; |
| 11 | struct AVFrame; |
12 | 12 | |
13 | 13 | int pgm_read(unsigned char *buf, int width, int height, const char *filename); |
14 | 14 | int pgm_write(const unsigned char *buf, int width, int height, |
15 | 15 | const char *filename); |
16 | | int pgm_crop(struct AVPicture *dst, const struct AVPicture *src, int srcheight, |
| 16 | int pgm_crop(struct AVFrame *dst, const struct AVFrame *src, int srcheight, |
17 | 17 | 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, |
| 18 | int pgm_overlay(struct AVFrame *dst, |
| 19 | const struct AVFrame *s1, int s1height, int s1row, int s1col, |
| 20 | const struct AVFrame *s2, int s2height); |
| 21 | int pgm_convolve_radial(struct AVFrame *dst, struct AVFrame *s1, |
| 22 | struct AVFrame *s2, const struct AVFrame *src, int srcheight, |
23 | 23 | const double *mask, int mask_radius); |
24 | 24 | |
25 | 25 | #endif /* !__PGM_H__ */ |
-
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, |
1075 | 1075 | VideoOutput *videoOutput = GetPlayer()->GetVideoOutput(); |
1076 | 1076 | bool is_key = 0; |
1077 | 1077 | bool first_loop = true; |
1078 | | AVPicture imageIn, imageOut; |
| 1078 | AVFrame imageIn, imageOut; |
1079 | 1079 | struct SwsContext *scontext = NULL; |
1080 | 1080 | |
1081 | 1081 | if (fifow) |