MythTV  master
mythv4l2m2mcontext.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QDir>
3 
4 // MythTV
5 #include "mythlogging.h"
6 #include "v4l2util.h"
7 #include "fourcc.h"
8 #include "avformatdecoder.h"
9 #include "mythplayerui.h"
11 #ifdef USING_EGL
13 #endif
14 #include "mythv4l2m2mcontext.h"
15 
16 #ifdef USING_MMAL
17 #include "mythmmalcontext.h"
18 #endif
19 
20 // Sys
21 #include <sys/ioctl.h>
22 
23 // FFmpeg
24 extern "C" {
25 #include "libavutil/opt.h"
26 #ifdef USING_V4L2_REQUEST
27 #include "libavcodec/v4l2_request.h"
28 #else
29 struct V4L2RequestDescriptor { int drm; };
30 #endif
31 }
32 
33 #define LOC QString("V4L2_M2M: ")
34 
43  : MythDRMPRIMEContext(Parent, CodecID)
44 {
45 }
46 
48 {
49  return codec_is_v4l2(m_codecID);
50 }
51 
53  AVCodec **Codec,
54  const QString &Decoder,
55  AVStream *Stream,
56  uint StreamType)
57 {
58  bool decodeonly = Decoder == "v4l2-dec";
59  auto success = static_cast<MythCodecID>((decodeonly ? kCodec_MPEG1_V4L2_DEC : kCodec_MPEG1_V4L2) + (StreamType - 1));
60  auto failure = static_cast<MythCodecID>(kCodec_MPEG1 + (StreamType - 1));
61 
62  // not us
63  if (!Decoder.startsWith("v4l2"))
64  return failure;
65 
66  if (!decodeonly)
67  if (!FrameTypeIsSupported(*Context, FMT_DRMPRIME))
68  return failure;
69 
70  // supported by device driver?
72  switch ((*Codec)->id)
73  {
74  case AV_CODEC_ID_MPEG1VIDEO: mythprofile = MythCodecContext::MPEG1; break;
75  case AV_CODEC_ID_MPEG2VIDEO: mythprofile = MythCodecContext::MPEG2; break;
76  case AV_CODEC_ID_MPEG4: mythprofile = MythCodecContext::MPEG4; break;
77  case AV_CODEC_ID_H263: mythprofile = MythCodecContext::H263; break;
78  case AV_CODEC_ID_H264: mythprofile = MythCodecContext::H264; break;
79  case AV_CODEC_ID_VC1: mythprofile = MythCodecContext::VC1; break;
80  case AV_CODEC_ID_VP8: mythprofile = MythCodecContext::VP8; break;
81  case AV_CODEC_ID_VP9: mythprofile = MythCodecContext::VP9; break;
82  case AV_CODEC_ID_HEVC: mythprofile = MythCodecContext::HEVC; break;
83  default: break;
84  }
85 
86  if (mythprofile == MythCodecContext::NoProfile)
87  return failure;
88 
89  bool request = false;
90  const auto & standard = MythV4L2M2MContext::GetStandardProfiles();
91  if (!standard.contains(mythprofile))
92  {
94  if (!requests.contains(mythprofile))
95  return failure;
96  request = true;
97  }
98 
99 #ifdef USING_MMAL
100  // If MMAL is available, assume this is a Raspberry Pi and check the supported
101  // video sizes
102  if (!MythMMALContext::CheckCodecSize((*Context)->width, (*Context)->height, mythprofile))
103  return failure;
104  // As for MMAL, don't try and decode 10bit H264
105  if ((*Codec)->id == AV_CODEC_ID_H264)
106  {
107  if ((*Context)->profile == FF_PROFILE_H264_HIGH_10 ||
108  (*Context)->profile == FF_PROFILE_H264_HIGH_10_INTRA)
109  {
110  return failure;
111  }
112  }
113 #endif
114 
115  if (request)
116  {
117  (*Context)->pix_fmt = AV_PIX_FMT_DRM_PRIME;
118  return success;
119  }
120 
121  return MythDRMPRIMEContext::GetPrimeCodec(Context, Codec, Stream,
122  success, failure, "v4l2m2m",
123  decodeonly ? (*Context)->pix_fmt : AV_PIX_FMT_DRM_PRIME);
124 }
125 
126 int MythV4L2M2MContext::HwDecoderInit(AVCodecContext *Context)
127 {
128  if (!Context)
129  return -1;
130 
132  return 0;
133 
134  return MythDRMPRIMEContext::HwDecoderInit(Context);
135 }
136 
137 void MythV4L2M2MContext::InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering)
138 {
139  // Fairly circular check of whether our codec id is using the request API.
140  // N.B. As for other areas of this class, this assumes there is no overlap
141  // between standard and request API codec support - though both can be used
142  // but for different codecs (as is expected on the Pi 4)
144  switch (m_codecID)
145  {
146  case kCodec_MPEG2_V4L2: profile = MPEG2; break;
147  case kCodec_H264_V4L2: profile = H264; break;
148  case kCodec_VP8_V4L2: profile = VP8; break;
149  case kCodec_VP9_V4L2: profile = VP9; break;
150  case kCodec_HEVC_V4L2: profile = HEVC; break;
151  default: break;
152  }
153 
155 
157  {
158  DirectRendering = false;
159  return;
160  }
161 
163  {
164  DirectRendering = false; // Surely true ?? And then an issue for regular V4L2 as well
165  Context->get_format = MythV4L2M2MContext::GetV4L2RequestFormat;
166  return;
167  }
168 
169  MythDRMPRIMEContext::InitVideoCodec(Context, SelectedStream, DirectRendering);
170 }
171 
172 bool MythV4L2M2MContext::RetrieveFrame(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame)
173 {
175  return GetBuffer(Context, Frame, AvFrame, 0);
176 
177  if (m_request)
178  return MythV4L2M2MContext::GetRequestBuffer(Context, Frame, AvFrame);
179 
180  return MythDRMPRIMEContext::RetrieveFrame(Context, Frame, AvFrame);
181 }
182 
188 void MythV4L2M2MContext::SetDecoderOptions(AVCodecContext* Context, AVCodec* Codec)
189 {
190  if (m_request)
191  return;
192 
193  if (!(Context && Codec))
194  return;
195 
196  if (!(Codec->priv_class && Context->priv_data))
197  return;
198 
199  // best guess currently - this matches the number of capture buffers to the
200  // number of output buffers - and hence to the number of video buffers for
201  // direct rendering
202  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Setting number of capture buffers to 6");
203  av_opt_set_int(Context->priv_data, "num_capture_buffers", 6, 0);
204 }
205 
212 bool MythV4L2M2MContext::GetBuffer(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame, int /*Flags*/)
213 {
214  // Sanity checks
215  if (!Context || !AvFrame || !Frame)
216  return false;
217 
218  // Ensure we can render this format
219  auto * decoder = static_cast<AvFormatDecoder*>(Context->opaque);
220  auto type = MythAVUtil::PixelFormatToFrameType(static_cast<AVPixelFormat>(AvFrame->format));
221  const auto * supported = Frame->m_renderFormats;
222  auto found = std::find(supported->cbegin(), supported->cend(), type);
223  // No fallback currently (unlikely)
224  if (found == supported->end())
225  return false;
226 
227  // Re-allocate if necessary
228  if ((Frame->m_type != type) || (Frame->m_width != AvFrame->width) || (Frame->m_height != AvFrame->height))
229  if (!VideoBuffers::ReinitBuffer(Frame, type, decoder->GetVideoCodecID(), AvFrame->width, AvFrame->height))
230  return false;
231 
232  // Copy data
233  uint count = MythVideoFrame::GetNumPlanes(Frame->m_type);
234  for (uint plane = 0; plane < count; ++plane)
235  {
236  MythVideoFrame::CopyPlane(Frame->m_buffer + Frame->m_offsets[plane],Frame->m_pitches[plane],
237  AvFrame->data[plane], AvFrame->linesize[plane],
238  MythVideoFrame::GetPitchForPlane(Frame->m_type, AvFrame->width, plane),
239  MythVideoFrame::GetHeightForPlane(Frame->m_type, AvFrame->height, plane));
240  }
241 
242  return true;
243 }
244 
245 #ifndef V4L2_PIX_FMT_HEVC
246 #define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C')
247 #endif
248 
249 #ifndef V4L2_PIX_FMT_VP9
250 #define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')
251 #endif
252 
253 #ifndef V4L2_PIX_FMT_NV12_COL128
254 #define V4L2_PIX_FMT_NV12_COL128 v4l2_fourcc('N', 'C', '1', '2')
255 #endif
256 
257 #ifndef V4L2_PIX_FMT_NV12_10_COL128
258 #define V4L2_PIX_FMT_NV12_10_COL128 v4l2_fourcc('N', 'C', '3', '0')
259 #endif
260 
262 {
263  static const std::vector<V4L2Mapping> s_map
264  {{
265  { V4L2_PIX_FMT_MPEG1, MythCodecContext::MPEG1 },
266  { V4L2_PIX_FMT_MPEG2, MythCodecContext::MPEG2 },
267  { V4L2_PIX_FMT_MPEG4, MythCodecContext::MPEG4 },
268  { V4L2_PIX_FMT_H263, MythCodecContext::H263 },
269  { V4L2_PIX_FMT_H264, MythCodecContext::H264 },
270  { V4L2_PIX_FMT_VC1_ANNEX_G, MythCodecContext::VC1 },
271  { V4L2_PIX_FMT_VP8, MythCodecContext::VP8 },
274  }};
275 
276  static QMutex lock(QMutex::Recursive);
277  static bool s_initialised = false;
278  static V4L2Profiles s_profiles;
279 
280  QMutexLocker locker(&lock);
281  if (!s_initialised)
282  s_profiles = GetProfiles(s_map);
283  s_initialised = true;
284  return s_profiles;
285 }
286 
287 V4L2Profiles MythV4L2M2MContext::GetProfiles(const std::vector<V4L2Mapping>& Profiles)
288 {
289  static const std::vector<uint32_t> s_formats
290  {
291  V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_YVU420, V4L2_PIX_FMT_YUV420M,
292  V4L2_PIX_FMT_YVU420M, V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12M,
293  V4L2_PIX_FMT_NV21, V4L2_PIX_FMT_NV21M, V4L2_PIX_FMT_NV12_COL128,
295  };
296 
297  V4L2Profiles result;
298 
299  const QString root("/dev/");
300  QDir dir(root);
301  QStringList namefilters;
302  namefilters.append("video*");
303  auto devices = dir.entryList(namefilters, QDir::Files |QDir::System);
304  for (const QString& device : qAsConst(devices))
305  {
306  V4L2util v4l2dev(root + device);
307  uint32_t caps = v4l2dev.GetCapabilities();
308  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Device: %1 Driver: '%2' Capabilities: 0x%3")
309  .arg(v4l2dev.GetDeviceName()).arg(v4l2dev.GetDriverName()).arg(caps, 0, 16));
310 
311  // check capture and output support
312  // these mimic the device checks in v4l2_m2m.c
313  bool mplanar = ((caps & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE)) != 0U) &&
314  ((caps & V4L2_CAP_STREAMING) != 0U);
315  bool mplanarm2m = (caps & V4L2_CAP_VIDEO_M2M_MPLANE) != 0U;
316  bool splanar = ((caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT)) != 0U) &&
317  ((caps & V4L2_CAP_STREAMING) != 0U);
318  bool splanarm2m = (caps & V4L2_CAP_VIDEO_M2M) != 0U;
319 
320  if (!(mplanar || mplanarm2m || splanar || splanarm2m))
321  continue;
322 
323  v4l2_buf_type capturetype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
324  v4l2_buf_type outputtype = V4L2_BUF_TYPE_VIDEO_OUTPUT;
325 
326  if (mplanar || mplanarm2m)
327  {
328  capturetype = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
329  outputtype = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
330  }
331 
332  // check codec support
333  QStringList debug;
334  QSize dummy{0, 0};
335 
336  for (const auto & profile : Profiles)
337  {
338  bool found = false;
339  uint32_t v4l2pixfmt = profile.first;
340  auto mythprofile = profile.second;
341  struct v4l2_fmtdesc fdesc {};
342  memset(&fdesc, 0, sizeof(fdesc));
343 
344  // check output first
345  fdesc.type = outputtype;
346  while (!found)
347  {
348  int res = ioctl(v4l2dev.FD(), VIDIOC_ENUM_FMT, &fdesc);
349  if (res)
350  break;
351  if (fdesc.pixelformat == v4l2pixfmt)
352  found = true;
353  fdesc.index++;
354  }
355 
356  if (found)
357  {
358  QStringList pixformats;
359  bool foundfmt = false;
360  // check capture
361  memset(&fdesc, 0, sizeof(fdesc));
362  fdesc.type = capturetype;
363  while (true)
364  {
365  int res = ioctl(v4l2dev.FD(), VIDIOC_ENUM_FMT, &fdesc);
366  if (res)
367  break;
368  pixformats.append(fourcc_str(static_cast<int>(fdesc.pixelformat)));
369  if (std::find(s_formats.cbegin(), s_formats.cend(), fdesc.pixelformat) != s_formats.cend())
370  {
371  if (!result.contains(mythprofile))
372  result.append(mythprofile);
373  foundfmt = true;
374  break;
375  }
376  fdesc.index++;
377  }
378 
379  if (!foundfmt)
380  {
381  if (pixformats.isEmpty())
382  pixformats.append("None");
383  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Codec '%1' has no supported formats (Supported: %2)")
384  .arg(MythCodecContext::GetProfileDescription(mythprofile, dummy)).arg(pixformats.join((","))));
385  }
386  }
387  }
388  }
389 
390  return result;
391 }
392 
393 void MythV4L2M2MContext::GetDecoderList(QStringList &Decoders)
394 {
395  const auto & profiles = MythV4L2M2MContext::GetStandardProfiles();
396  if (!profiles.isEmpty())
397  {
398  QSize size(0, 0);
399  Decoders.append("V4L2:");
400  for (MythCodecContext::CodecProfile profile : profiles)
401  Decoders.append(MythCodecContext::GetProfileDescription(profile, size));
402  }
403 
405  if (!requests.isEmpty())
406  {
407  QSize size(0, 0);
408  Decoders.append("V4L2 Request:");
409  for (MythCodecContext::CodecProfile profile : requests)
410  Decoders.append(MythCodecContext::GetProfileDescription(profile, size));
411  }
412 
413 }
414 
415 bool MythV4L2M2MContext::HaveV4L2Codecs(bool Reinit /*=false*/)
416 {
417  static QMutex lock(QMutex::Recursive);
418  QMutexLocker locker(&lock);
419  static bool s_checked = false;
420  static bool s_available = false;
421 
422  if (s_checked && !Reinit)
423  return s_available;
424  s_checked = true;
425 
426  const auto & standard = MythV4L2M2MContext::GetStandardProfiles();
427  const auto & request = MythV4L2M2MContext::GetRequestProfiles();
428  if (standard.isEmpty() && request.isEmpty())
429  {
430  LOG(VB_GENERAL, LOG_INFO, LOC + "No V4L2 decoders found");
431  return s_available;
432  }
433 
434  LOG(VB_GENERAL, LOG_INFO, LOC + "Supported/available V4L2 decoders:");
435  s_available = true;
436  QSize size {0, 0};
437  for (auto profile : qAsConst(standard))
438  LOG(VB_GENERAL, LOG_INFO, LOC + MythCodecContext::GetProfileDescription(profile, size));
439  for (auto profile : qAsConst(request))
440  LOG(VB_GENERAL, LOG_INFO, LOC + MythCodecContext::GetProfileDescription(profile, size) + "(Request)");
441  return s_available;
442 }
443 
444 #ifndef V4L2_PIX_FMT_MPEG2_SLICE
445 #define V4L2_PIX_FMT_MPEG2_SLICE v4l2_fourcc('M', 'G', '2', 'S')
446 #endif
447 
448 #ifndef V4L2_PIX_FMT_H264_SLICE
449 #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4')
450 #endif
451 
452 #ifndef V4L2_PIX_FMT_VP8_FRAME
453 #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F')
454 #endif
455 
456 #ifndef V4L2_PIX_FMT_VP9_FRAME
457 #define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F')
458 #endif
459 
460 #ifndef V4L2_PIX_FMT_HEVC_SLICE
461 #define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5')
462 #endif
463 
465 {
466  static const std::vector<V4L2Mapping> s_map
467  {{
473  }};
474 
475  static QMutex lock(QMutex::Recursive);
476  static bool s_initialised = false;
477  static V4L2Profiles s_profiles;
478 
479  QMutexLocker locker(&lock);
480  if (!s_initialised)
481  s_profiles = GetProfiles(s_map);
482  s_initialised = true;
483  return s_profiles;
484 }
485 
486 AVPixelFormat MythV4L2M2MContext::GetV4L2RequestFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
487 {
488  while (*PixFmt != AV_PIX_FMT_NONE)
489  {
490  if (*PixFmt == AV_PIX_FMT_DRM_PRIME)
491  {
493  "V4L2 request context creation") >= 0)
494  {
495  return AV_PIX_FMT_DRM_PRIME;
496  }
497  }
498  PixFmt++;
499  }
500  return AV_PIX_FMT_NONE;
501 }
502 
504 {
505  if (!Context || !gCoreContext->IsUIThread())
506  return -1;
507 
508  // N.B. Interop support should already have been checked
509  // Allocate the device context
510  auto * hwdeviceref = MythCodecContext::CreateDevice(AV_HWDEVICE_TYPE_DRM, nullptr);
511  if (!hwdeviceref)
512  return -1;
513 
514  // Initialise device context
515  if (av_hwdevice_ctx_init(hwdeviceref) < 0)
516  {
517  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to initialise device context");
518  av_buffer_unref(&hwdeviceref);
519  return -1;
520  }
521 
522  Context->hw_device_ctx = hwdeviceref;
523  return 0;
524 }
525 
526 bool MythV4L2M2MContext::GetRequestBuffer(AVCodecContext* Context, MythVideoFrame* Frame, AVFrame* AvFrame)
527 {
528  if (!Context || !AvFrame || !Frame)
529  return false;
530 
531  if (Frame->m_type != FMT_DRMPRIME || static_cast<AVPixelFormat>(AvFrame->format) != AV_PIX_FMT_DRM_PRIME)
532  {
533  LOG(VB_GENERAL, LOG_ERR, LOC + "Not a DRM PRIME buffer");
534  return false;
535  }
536 
537  Frame->m_width = AvFrame->width;
538  Frame->m_height = AvFrame->height;
539  Frame->m_pixFmt = Context->pix_fmt;
540  Frame->m_swPixFmt = Context->sw_pix_fmt;
541  Frame->m_directRendering = true;
542  AvFrame->opaque = Frame;
543  AvFrame->reordered_opaque = Context->reordered_opaque;
544 
545  // Frame->data[0] holds V4L2RequestDescriptor which holds AVDRMFrameDescriptor
546  Frame->m_buffer = reinterpret_cast<uint8_t*>(&(reinterpret_cast<V4L2RequestDescriptor*>(AvFrame->data[0])->drm));
547  // Retain the buffer so it is not released before we display it
548  Frame->m_priv[0] = reinterpret_cast<unsigned char*>(av_buffer_ref(AvFrame->buf[0]));
549  // Set interop
550  Frame->m_priv[1] = reinterpret_cast<unsigned char*>(m_interop);
551  // Set the release method
552  AvFrame->buf[1] = av_buffer_create(reinterpret_cast<uint8_t*>(Frame), 0, MythCodecContext::ReleaseBuffer,
553  static_cast<AvFormatDecoder*>(Context->opaque), 0);
554  return true;
555 }
V4L2_PIX_FMT_VP8_FRAME
#define V4L2_PIX_FMT_VP8_FRAME
Definition: mythv4l2m2mcontext.cpp:453
V4L2_PIX_FMT_NV12_10_COL128
#define V4L2_PIX_FMT_NV12_10_COL128
Definition: mythv4l2m2mcontext.cpp:258
MythMMALContext::CheckCodecSize
static bool CheckCodecSize(int Width, int Height, MythCodecContext::CodecProfile Profile)
Definition: mythmmalcontext.cpp:24
kCodec_H264_V4L2
@ kCodec_H264_V4L2
Definition: mythcodecid.h:217
root
QDomElement root
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:656
V4L2RequestDescriptor::drm
int drm
Definition: mythv4l2m2mcontext.cpp:29
MythCodecContext::m_codecID
MythCodecID m_codecID
Definition: mythcodeccontext.h:168
MythVideoFrame::GetPitchForPlane
static int GetPitchForPlane(VideoFrameType Type, int Width, uint Plane)
Definition: mythframe.h:299
mythplayerui.h
MythV4L2M2MContext::DecoderWillResetOnFlush
bool DecoderWillResetOnFlush() override
Definition: mythv4l2m2mcontext.cpp:47
MythV4L2M2MContext::HwDecoderInit
int HwDecoderInit(AVCodecContext *Context) override
Definition: mythv4l2m2mcontext.cpp:126
MythDRMPRIMEContext::InitVideoCodec
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
Definition: mythdrmprimecontext.cpp:120
FMT_DRMPRIME
@ FMT_DRMPRIME
Definition: mythframe.h:62
V4L2RequestDescriptor
Definition: mythv4l2m2mcontext.cpp:29
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:56
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:54
Frame
Definition: zmdefines.h:93
arg
arg(title).arg(filename).arg(doDelete))
MythV4L2M2MContext::InitVideoCodec
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
Definition: mythv4l2m2mcontext.cpp:137
MythCoreContext::IsUIThread
bool IsUIThread(void)
Definition: mythcorecontext.cpp:1357
kCodec_VP9_V4L2
@ kCodec_VP9_V4L2
Definition: mythcodecid.h:221
V4L2util::FD
int FD(void) const
Definition: v4l2util.h:26
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythV4L2M2MContext::HaveV4L2Codecs
static bool HaveV4L2Codecs(bool Reinit=false)
Definition: mythv4l2m2mcontext.cpp:415
MythV4L2M2MContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythv4l2m2mcontext.cpp:393
V4L2_PIX_FMT_VP9
#define V4L2_PIX_FMT_VP9
Definition: mythv4l2m2mcontext.cpp:250
MythDRMPRIMEContext::HwDecoderInit
int HwDecoderInit(AVCodecContext *Context) override
Definition: mythdrmprimecontext.cpp:105
V4L2Profiles
QList< MythCodecContext::CodecProfile > V4L2Profiles
Definition: mythv4l2m2mcontext.h:7
MythV4L2M2MContext::GetStandardProfiles
static const V4L2Profiles & GetStandardProfiles()
Definition: mythv4l2m2mcontext.cpp:261
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
mythrenderopengl.h
MythV4L2M2MContext::SetDecoderOptions
void SetDecoderOptions(AVCodecContext *Context, AVCodec *Codec) override
Reduce the number of capture buffers.
Definition: mythv4l2m2mcontext.cpp:188
Decoder
Definition: decoder.h:65
MythV4L2M2MContext::RetrieveFrame
bool RetrieveFrame(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
Definition: mythv4l2m2mcontext.cpp:172
mythlogging.h
MythV4L2M2MContext::GetRequestBuffer
bool GetRequestBuffer(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame)
Definition: mythv4l2m2mcontext.cpp:526
hardwareprofile.scan.profile
profile
Definition: scan.py:99
MythVideoFrame::CopyPlane
static void CopyPlane(uint8_t *To, int ToPitch, const uint8_t *From, int FromPitch, int PlaneWidth, int PlaneHeight)
Definition: mythframe.cpp:187
v4l2util.h
MythCodecContext::ReleaseBuffer
static void ReleaseBuffer(void *Opaque, uint8_t *Data)
Definition: mythcodeccontext.cpp:413
MythV4L2M2MContext::GetRequestProfiles
static const V4L2Profiles & GetRequestProfiles()
Definition: mythv4l2m2mcontext.cpp:464
MythDRMPRIMEContext::RetrieveFrame
bool RetrieveFrame(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
Definition: mythdrmprimecontext.cpp:137
kCodec_MPEG1
@ kCodec_MPEG1
Definition: mythcodecid.h:21
LOC
#define LOC
Definition: mythv4l2m2mcontext.cpp:33
debug
VERBOSE_PREAMBLE Most debug(nodatabase, notimestamp, noextra)") VERBOSE_MAP(VB_GENERAL
MythCodecContext::VP9
@ VP9
Definition: mythcodeccontext.h:107
MythV4L2M2MContext::GetProfiles
static V4L2Profiles GetProfiles(const std::vector< V4L2Mapping > &Profiles)
Definition: mythv4l2m2mcontext.cpp:287
MythCodecContext::MPEG4
@ MPEG4
Definition: mythcodeccontext.h:65
V4L2_PIX_FMT_VP9_FRAME
#define V4L2_PIX_FMT_VP9_FRAME
Definition: mythv4l2m2mcontext.cpp:457
MythCodecContext::MPEG1
@ MPEG1
Definition: mythcodeccontext.h:57
MythCodecContext::HEVC
@ HEVC
Definition: mythcodeccontext.h:94
AvFormatDecoder
A decoder for media files.
Definition: avformatdecoder.h:85
MythCodecContext::H263
@ H263
Definition: mythcodeccontext.h:82
MythDRMPRIMEContext
A generic context handler for codecs that return AV_PIX_FMT_DRM_PRIME frames.
Definition: mythdrmprimecontext.h:14
V4L2_PIX_FMT_HEVC
#define V4L2_PIX_FMT_HEVC
Definition: mythv4l2m2mcontext.cpp:246
uint
unsigned int uint
Definition: compat.h:141
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
V4L2util::GetDeviceName
QString GetDeviceName(void) const
Definition: v4l2util.cpp:682
MythV4L2M2MContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Definition: mythv4l2m2mcontext.cpp:52
MythDRMPRIMEContext::m_interop
MythOpenGLInterop * m_interop
Definition: mythdrmprimecontext.h:43
MythCodecContext::MPEG2
@ MPEG2
Definition: mythcodeccontext.h:58
kCodec_MPEG2_V4L2
@ kCodec_MPEG2_V4L2
Definition: mythcodecid.h:214
MythAVUtil::PixelFormatToFrameType
static VideoFrameType PixelFormatToFrameType(AVPixelFormat Fmt)
Definition: mythavutil.cpp:70
kCodec_MPEG1_V4L2_DEC
@ kCodec_MPEG1_V4L2_DEC
Definition: mythcodecid.h:229
MythVideoFrame::GetHeightForPlane
static int GetHeightForPlane(VideoFrameType Type, int Height, uint Plane)
Definition: mythframe.h:253
V4L2util::GetDriverName
QString GetDriverName(void) const
Definition: v4l2util.cpp:687
MythV4L2M2MContext::GetV4L2RequestFormat
static enum AVPixelFormat GetV4L2RequestFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
Definition: mythv4l2m2mcontext.cpp:486
kCodec_MPEG1_V4L2
@ kCodec_MPEG1_V4L2
Definition: mythcodecid.h:213
V4L2util
Definition: v4l2util.h:16
MythCodecContext::VC1
@ VC1
Definition: mythcodeccontext.h:101
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
MythCodecContext::CreateDevice
static AVBufferRef * CreateDevice(AVHWDeviceType Type, MythInteropGPU *Interop, const QString &Device=QString())
Definition: mythcodeccontext.cpp:556
avformatdecoder.h
MythV4L2M2MContext::MythV4L2M2MContext
MythV4L2M2MContext(DecoderBase *Parent, MythCodecID CodecID)
Definition: mythv4l2m2mcontext.cpp:42
MythDRMPRIMEContext::GetPrimeCodec
static MythCodecID GetPrimeCodec(AVCodecContext **Context, AVCodec **Codec, AVStream *Stream, MythCodecID Successs, MythCodecID Failure, const QString &CodecName, AVPixelFormat Format)
Definition: mythdrmprimecontext.cpp:40
MythV4L2M2MContext::InitialiseV4L2RequestContext
static int InitialiseV4L2RequestContext(AVCodecContext *Context)
Definition: mythv4l2m2mcontext.cpp:503
MythCodecContext::FrameTypeIsSupported
static bool FrameTypeIsSupported(AVCodecContext *Context, VideoFrameType Format)
Definition: mythcodeccontext.cpp:512
mythmmalcontext.h
MythV4L2M2MContext::m_request
bool m_request
Definition: mythv4l2m2mcontext.h:40
fourcc_str
static const char * fourcc_str(int i)
Definition: fourcc.h:26
kCodec_HEVC_V4L2
@ kCodec_HEVC_V4L2
Definition: mythcodecid.h:222
MythVideoFrame::GetNumPlanes
static uint GetNumPlanes(VideoFrameType Type)
Definition: mythframe.h:209
V4L2_PIX_FMT_HEVC_SLICE
#define V4L2_PIX_FMT_HEVC_SLICE
Definition: mythv4l2m2mcontext.cpp:461
codec_is_v4l2
#define codec_is_v4l2(id)
Definition: mythcodecid.h:338
mythdrmprimeinterop.h
MythCodecContext::InitialiseDecoder2
static int InitialiseDecoder2(AVCodecContext *Context, CreateHWDecoder Callback, const QString &Debug)
Initialise a hardware decoder that is NOT expected to use AVHWFramesContext.
Definition: mythcodeccontext.cpp:540
VideoBuffers::ReinitBuffer
static bool ReinitBuffer(MythVideoFrame *Frame, VideoFrameType Type, MythCodecID CodecID, int Width, int Height)
Definition: videobuffers.cpp:981
MythV4L2M2MContext::GetBuffer
static bool GetBuffer(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame, int)
Retrieve a frame from CPU memory.
Definition: mythv4l2m2mcontext.cpp:212
MythCodecContext::GetProfileDescription
static QString GetProfileDescription(CodecProfile Profile, QSize Size, VideoFrameType Format=FMT_NONE, uint ColorDepth=0)
Definition: mythcodeccontext.cpp:783
kCodec_VP8_V4L2
@ kCodec_VP8_V4L2
Definition: mythcodecid.h:220
V4L2_PIX_FMT_MPEG2_SLICE
#define V4L2_PIX_FMT_MPEG2_SLICE
Definition: mythv4l2m2mcontext.cpp:445
MythVideoFrame
Definition: mythframe.h:85
V4L2util::GetCapabilities
uint32_t GetCapabilities(void) const
Definition: v4l2util.cpp:677
codec_is_v4l2_dec
#define codec_is_v4l2_dec(id)
Definition: mythcodecid.h:339
V4L2_PIX_FMT_NV12_COL128
#define V4L2_PIX_FMT_NV12_COL128
Definition: mythv4l2m2mcontext.cpp:254
V4L2_PIX_FMT_H264_SLICE
#define V4L2_PIX_FMT_H264_SLICE
Definition: mythv4l2m2mcontext.cpp:449
mythv4l2m2mcontext.h
DecoderBase
Definition: decoderbase.h:120
MythCodecContext::VP8
@ VP8
Definition: mythcodeccontext.h:106
find
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
Definition: dvbstreamhandler.cpp:356
fourcc.h
MythCodecContext::H264
@ H264
Definition: mythcodeccontext.h:83