16 #include "libavutil/imgutils.h"
24 #ifdef PGM_CONVERT_GREYSCALE
25 av_freep(
reinterpret_cast<void*
>(&m_pgm.data[0]));
26 memset(&m_pgm, 0,
sizeof(m_pgm));
34 #ifdef PGM_CONVERT_GREYSCALE
35 m_timeReported =
false;
36 memset(&m_convertTime, 0,
sizeof(m_convertTime));
43 m_width = buf_dim.width();
44 m_height = buf_dim.height();
46 #ifdef PGM_CONVERT_GREYSCALE
47 if (av_image_alloc(m_pgm.data, m_pgm.linesize,
48 m_width, m_height, AV_PIX_FMT_GRAY8, IMAGE_ALIGN))
50 LOG(VB_COMMFLAG, LOG_ERR, QString(
"PGMConverter::MythPlayerInited "
51 "av_image_alloc m_pgm (%1x%2) failed")
52 .arg(m_width).arg(m_height));
58 LOG(VB_COMMFLAG, LOG_INFO, QString(
"PGMConverter::MythPlayerInited "
59 "using true greyscale conversion"));
61 LOG(VB_COMMFLAG, LOG_INFO, QString(
"PGMConverter::MythPlayerInited "
70 int *pwidth,
int *pheight)
72 #ifdef PGM_CONVERT_GREYSCALE
73 std::chrono::microseconds start {0us};
74 std::chrono::microseconds end {0us};
76 if (m_frameNo == _frameno)
81 LOG(VB_COMMFLAG, LOG_ERR,
"PGMConverter::getImage no buf");
85 #ifdef PGM_CONVERT_GREYSCALE
86 start = nowAsDuration<std::chrono::microseconds>();
87 if (m_copy->Copy(&m_pgm, frame, m_pgm.data[0], AV_PIX_FMT_GRAY8) < 0)
89 end = nowAsDuration<std::chrono::microseconds>();
90 m_convertTime += (end - start);
92 if (av_image_fill_arrays(m_pgm.data, m_pgm.linesize,
93 frame->buf, AV_PIX_FMT_GRAY8, m_width, m_height,IMAGE_ALIGN) < 0)
95 LOG(VB_COMMFLAG, LOG_ERR,
96 QString(
"PGMConverter::getImage error at frame %1 (%2x%3)")
97 .arg(_frameno).arg(m_width).arg(m_height));
102 m_frameNo = _frameno;
116 #ifdef PGM_CONVERT_GREYSCALE
119 LOG(VB_COMMFLAG, LOG_INFO, QString(
"PGM Time: convert=%1s")
121 m_timeReported =
true;