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