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 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
277  static QMutex lock(QMutex::Recursive);
278 #else
279  static QRecursiveMutex lock;
280 #endif
281  static bool s_initialised = false;
282  static V4L2Profiles s_profiles;
283 
284  QMutexLocker locker(&lock);
285  if (!s_initialised)
286  s_profiles = GetProfiles(s_map);
287  s_initialised = true;
288  return s_profiles;
289 }
290 
291 V4L2Profiles MythV4L2M2MContext::GetProfiles(const std::vector<V4L2Mapping>& Profiles)
292 {
293  static const std::vector<uint32_t> s_formats
294  {
295  V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_YVU420, V4L2_PIX_FMT_YUV420M,
296  V4L2_PIX_FMT_YVU420M, V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12M,
297  V4L2_PIX_FMT_NV21, V4L2_PIX_FMT_NV21M, V4L2_PIX_FMT_NV12_COL128,
299  };
300 
301  V4L2Profiles result;
302 
303  const QString root("/dev/");
304  QDir dir(root);
305  QStringList namefilters;
306  namefilters.append("video*");
307  auto devices = dir.entryList(namefilters, QDir::Files |QDir::System);
308  for (const QString& device : qAsConst(devices))
309  {
310  V4L2util v4l2dev(root + device);
311  uint32_t caps = v4l2dev.GetCapabilities();
312  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Device: %1 Driver: '%2' Capabilities: 0x%3")
313  .arg(v4l2dev.GetDeviceName()).arg(v4l2dev.GetDriverName()).arg(caps, 0, 16));
314 
315  // check capture and output support
316  // these mimic the device checks in v4l2_m2m.c
317  bool mplanar = ((caps & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE)) != 0U) &&
318  ((caps & V4L2_CAP_STREAMING) != 0U);
319  bool mplanarm2m = (caps & V4L2_CAP_VIDEO_M2M_MPLANE) != 0U;
320  bool splanar = ((caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT)) != 0U) &&
321  ((caps & V4L2_CAP_STREAMING) != 0U);
322  bool splanarm2m = (caps & V4L2_CAP_VIDEO_M2M) != 0U;
323 
324  if (!(mplanar || mplanarm2m || splanar || splanarm2m))
325  continue;
326 
327  v4l2_buf_type capturetype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
328  v4l2_buf_type outputtype = V4L2_BUF_TYPE_VIDEO_OUTPUT;
329 
330  if (mplanar || mplanarm2m)
331  {
332  capturetype = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
333  outputtype = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
334  }
335 
336  // check codec support
337  QStringList debug;
338  QSize dummy{0, 0};
339 
340  for (const auto & profile : Profiles)
341  {
342  bool found = false;
343  uint32_t v4l2pixfmt = profile.first;
344  auto mythprofile = profile.second;
345  struct v4l2_fmtdesc fdesc {};
346  memset(&fdesc, 0, sizeof(fdesc));
347 
348  // check output first
349  fdesc.type = outputtype;
350  while (!found)
351  {
352  int res = ioctl(v4l2dev.FD(), VIDIOC_ENUM_FMT, &fdesc);
353  if (res)
354  break;
355  if (fdesc.pixelformat == v4l2pixfmt)
356  found = true;
357  fdesc.index++;
358  }
359 
360  if (found)
361  {
362  QStringList pixformats;
363  bool foundfmt = false;
364  // check capture
365  memset(&fdesc, 0, sizeof(fdesc));
366  fdesc.type = capturetype;
367  while (true)
368  {
369  int res = ioctl(v4l2dev.FD(), VIDIOC_ENUM_FMT, &fdesc);
370  if (res)
371  break;
372  pixformats.append(fourcc_str(static_cast<int>(fdesc.pixelformat)));
373  if (std::find(s_formats.cbegin(), s_formats.cend(), fdesc.pixelformat) != s_formats.cend())
374  {
375  if (!result.contains(mythprofile))
376  result.append(mythprofile);
377  foundfmt = true;
378  break;
379  }
380  fdesc.index++;
381  }
382 
383  if (!foundfmt)
384  {
385  if (pixformats.isEmpty())
386  pixformats.append("None");
387  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Codec '%1' has no supported formats (Supported: %2)")
388  .arg(MythCodecContext::GetProfileDescription(mythprofile, dummy)).arg(pixformats.join((","))));
389  }
390  }
391  }
392  }
393 
394  return result;
395 }
396 
397 void MythV4L2M2MContext::GetDecoderList(QStringList &Decoders)
398 {
399  const auto & profiles = MythV4L2M2MContext::GetStandardProfiles();
400  if (!profiles.isEmpty())
401  {
402  QSize size(0, 0);
403  Decoders.append("V4L2:");
404  for (MythCodecContext::CodecProfile profile : profiles)
405  Decoders.append(MythCodecContext::GetProfileDescription(profile, size));
406  }
407 
409  if (!requests.isEmpty())
410  {
411  QSize size(0, 0);
412  Decoders.append("V4L2 Request:");
413  for (MythCodecContext::CodecProfile profile : requests)
414  Decoders.append(MythCodecContext::GetProfileDescription(profile, size));
415  }
416 
417 }
418 
419 bool MythV4L2M2MContext::HaveV4L2Codecs(bool Reinit /*=false*/)
420 {
421 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
422  static QMutex lock(QMutex::Recursive);
423 #else
424  static QRecursiveMutex lock;
425 #endif
426  QMutexLocker locker(&lock);
427  static bool s_checked = false;
428  static bool s_available = false;
429 
430  if (s_checked && !Reinit)
431  return s_available;
432  s_checked = true;
433 
434  const auto & standard = MythV4L2M2MContext::GetStandardProfiles();
435  const auto & request = MythV4L2M2MContext::GetRequestProfiles();
436  if (standard.isEmpty() && request.isEmpty())
437  {
438  LOG(VB_GENERAL, LOG_INFO, LOC + "No V4L2 decoders found");
439  return s_available;
440  }
441 
442  LOG(VB_GENERAL, LOG_INFO, LOC + "Supported/available V4L2 decoders:");
443  s_available = true;
444  QSize size {0, 0};
445  for (auto profile : qAsConst(standard))
446  LOG(VB_GENERAL, LOG_INFO, LOC + MythCodecContext::GetProfileDescription(profile, size));
447  for (auto profile : qAsConst(request))
448  LOG(VB_GENERAL, LOG_INFO, LOC + MythCodecContext::GetProfileDescription(profile, size) + "(Request)");
449  return s_available;
450 }
451 
452 #ifndef V4L2_PIX_FMT_MPEG2_SLICE
453 #define V4L2_PIX_FMT_MPEG2_SLICE v4l2_fourcc('M', 'G', '2', 'S')
454 #endif
455 
456 #ifndef V4L2_PIX_FMT_H264_SLICE
457 #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4')
458 #endif
459 
460 #ifndef V4L2_PIX_FMT_VP8_FRAME
461 #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F')
462 #endif
463 
464 #ifndef V4L2_PIX_FMT_VP9_FRAME
465 #define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F')
466 #endif
467 
468 #ifndef V4L2_PIX_FMT_HEVC_SLICE
469 #define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5')
470 #endif
471 
473 {
474  static const std::vector<V4L2Mapping> s_map
475  {{
481  }};
482 
483 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
484  static QMutex lock(QMutex::Recursive);
485 #else
486  static QRecursiveMutex lock;
487 #endif
488  static bool s_initialised = false;
489  static V4L2Profiles s_profiles;
490 
491  QMutexLocker locker(&lock);
492  if (!s_initialised)
493  s_profiles = GetProfiles(s_map);
494  s_initialised = true;
495  return s_profiles;
496 }
497 
498 AVPixelFormat MythV4L2M2MContext::GetV4L2RequestFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
499 {
500  while (*PixFmt != AV_PIX_FMT_NONE)
501  {
502  if (*PixFmt == AV_PIX_FMT_DRM_PRIME)
503  {
505  "V4L2 request context creation") >= 0)
506  {
507  return AV_PIX_FMT_DRM_PRIME;
508  }
509  }
510  PixFmt++;
511  }
512  return AV_PIX_FMT_NONE;
513 }
514 
516 {
517  if (!Context || !gCoreContext->IsUIThread())
518  return -1;
519 
520  // N.B. Interop support should already have been checked
521  // Allocate the device context
522  auto * hwdeviceref = MythCodecContext::CreateDevice(AV_HWDEVICE_TYPE_DRM, nullptr);
523  if (!hwdeviceref)
524  return -1;
525 
526  // Initialise device context
527  if (av_hwdevice_ctx_init(hwdeviceref) < 0)
528  {
529  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to initialise device context");
530  av_buffer_unref(&hwdeviceref);
531  return -1;
532  }
533 
534  Context->hw_device_ctx = hwdeviceref;
535  return 0;
536 }
537 
538 bool MythV4L2M2MContext::GetRequestBuffer(AVCodecContext* Context, MythVideoFrame* Frame, AVFrame* AvFrame)
539 {
540  if (!Context || !AvFrame || !Frame)
541  return false;
542 
543  if (Frame->m_type != FMT_DRMPRIME || static_cast<AVPixelFormat>(AvFrame->format) != AV_PIX_FMT_DRM_PRIME)
544  {
545  LOG(VB_GENERAL, LOG_ERR, LOC + "Not a DRM PRIME buffer");
546  return false;
547  }
548 
549  Frame->m_width = AvFrame->width;
550  Frame->m_height = AvFrame->height;
551  Frame->m_pixFmt = Context->pix_fmt;
552  Frame->m_swPixFmt = Context->sw_pix_fmt;
553  Frame->m_directRendering = true;
554  AvFrame->opaque = Frame;
555  AvFrame->reordered_opaque = Context->reordered_opaque;
556 
557  // Frame->data[0] holds V4L2RequestDescriptor which holds AVDRMFrameDescriptor
558  Frame->m_buffer = reinterpret_cast<uint8_t*>(&(reinterpret_cast<V4L2RequestDescriptor*>(AvFrame->data[0])->drm));
559  // Retain the buffer so it is not released before we display it
560  Frame->m_priv[0] = reinterpret_cast<unsigned char*>(av_buffer_ref(AvFrame->buf[0]));
561  // Set interop
562  Frame->m_priv[1] = reinterpret_cast<unsigned char*>(m_interop);
563  // Set the release method
564  AvFrame->buf[1] = av_buffer_create(reinterpret_cast<uint8_t*>(Frame), 0, MythCodecContext::ReleaseBuffer,
565  static_cast<AvFormatDecoder*>(Context->opaque), 0);
566  return true;
567 }
V4L2_PIX_FMT_VP8_FRAME
#define V4L2_PIX_FMT_VP8_FRAME
Definition: mythv4l2m2mcontext.cpp:461
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
V4L2RequestDescriptor::drm
int drm
Definition: mythv4l2m2mcontext.cpp:29
MythCodecContext::m_codecID
MythCodecID m_codecID
Definition: mythcodeccontext.h:170
MythVideoFrame::GetPitchForPlane
static int GetPitchForPlane(VideoFrameType Type, int Width, uint Plane)
Definition: mythframe.h:304
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:125
FMT_DRMPRIME
@ FMT_DRMPRIME
Definition: mythframe.h:64
V4L2RequestDescriptor
Definition: mythv4l2m2mcontext.cpp:29
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:58
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:56
Frame
Definition: zmdefines.h:93
MythV4L2M2MContext::InitVideoCodec
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
Definition: mythv4l2m2mcontext.cpp:137
MythCoreContext::IsUIThread
bool IsUIThread(void)
Definition: mythcorecontext.cpp:1361
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:419
MythV4L2M2MContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythv4l2m2mcontext.cpp:397
V4L2_PIX_FMT_VP9
#define V4L2_PIX_FMT_VP9
Definition: mythv4l2m2mcontext.cpp:250
MythDRMPRIMEContext::HwDecoderInit
int HwDecoderInit(AVCodecContext *Context) override
Definition: mythdrmprimecontext.cpp:110
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:70
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:538
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:188
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:472
MythDRMPRIMEContext::RetrieveFrame
bool RetrieveFrame(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
Definition: mythdrmprimecontext.cpp:142
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:109
MythV4L2M2MContext::GetProfiles
static V4L2Profiles GetProfiles(const std::vector< V4L2Mapping > &Profiles)
Definition: mythv4l2m2mcontext.cpp:291
MythCodecContext::MPEG4
@ MPEG4
Definition: mythcodeccontext.h:67
V4L2_PIX_FMT_VP9_FRAME
#define V4L2_PIX_FMT_VP9_FRAME
Definition: mythv4l2m2mcontext.cpp:465
MythCodecContext::MPEG1
@ MPEG1
Definition: mythcodeccontext.h:59
MythCodecContext::HEVC
@ HEVC
Definition: mythcodeccontext.h:96
AvFormatDecoder
A decoder for media files.
Definition: avformatdecoder.h:85
MythCodecContext::H263
@ H263
Definition: mythcodeccontext.h:84
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:140
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:47
MythCodecContext::MPEG2
@ MPEG2
Definition: mythcodeccontext.h:60
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:258
V4L2util::GetDriverName
QString GetDriverName(void) const
Definition: v4l2util.cpp:687
MythV4L2M2MContext::GetV4L2RequestFormat
static enum AVPixelFormat GetV4L2RequestFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
Definition: mythv4l2m2mcontext.cpp:498
kCodec_MPEG1_V4L2
@ kCodec_MPEG1_V4L2
Definition: mythcodecid.h:213
V4L2util
Definition: v4l2util.h:16
MythCodecContext::VC1
@ VC1
Definition: mythcodeccontext.h:103
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:45
MythV4L2M2MContext::InitialiseV4L2RequestContext
static int InitialiseV4L2RequestContext(AVCodecContext *Context)
Definition: mythv4l2m2mcontext.cpp:515
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:214
V4L2_PIX_FMT_HEVC_SLICE
#define V4L2_PIX_FMT_HEVC_SLICE
Definition: mythv4l2m2mcontext.cpp:469
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:453
MythVideoFrame
Definition: mythframe.h:88
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:457
mythv4l2m2mcontext.h
DecoderBase
Definition: decoderbase.h:120
MythCodecContext::VP8
@ VP8
Definition: mythcodeccontext.h:108
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:85