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(), v4l2dev.GetDriverName(), QString::number(caps, 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  QSize dummy{0, 0};
338 
339  for (const auto & profile : Profiles)
340  {
341  bool found = false;
342  uint32_t v4l2pixfmt = profile.first;
343  auto mythprofile = profile.second;
344  struct v4l2_fmtdesc fdesc {};
345  memset(&fdesc, 0, sizeof(fdesc));
346 
347  // check output first
348  fdesc.type = outputtype;
349  while (!found)
350  {
351  int res = ioctl(v4l2dev.FD(), VIDIOC_ENUM_FMT, &fdesc);
352  if (res)
353  break;
354  if (fdesc.pixelformat == v4l2pixfmt)
355  found = true;
356  fdesc.index++;
357  }
358 
359  if (found)
360  {
361  QStringList pixformats;
362  bool foundfmt = false;
363  // check capture
364  memset(&fdesc, 0, sizeof(fdesc));
365  fdesc.type = capturetype;
366  while (true)
367  {
368  int res = ioctl(v4l2dev.FD(), VIDIOC_ENUM_FMT, &fdesc);
369  if (res)
370  break;
371  pixformats.append(fourcc_str(static_cast<int>(fdesc.pixelformat)));
372  if (std::find(s_formats.cbegin(), s_formats.cend(), fdesc.pixelformat) != s_formats.cend())
373  {
374  if (!result.contains(mythprofile))
375  result.append(mythprofile);
376  foundfmt = true;
377  break;
378  }
379  fdesc.index++;
380  }
381 
382  if (!foundfmt)
383  {
384  if (pixformats.isEmpty())
385  pixformats.append("None");
386  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Codec '%1' has no supported formats (Supported: %2)")
387  .arg(MythCodecContext::GetProfileDescription(mythprofile, dummy), pixformats.join((","))));
388  }
389  }
390  }
391  }
392 
393  return result;
394 }
395 
396 void MythV4L2M2MContext::GetDecoderList(QStringList &Decoders)
397 {
398  const auto & profiles = MythV4L2M2MContext::GetStandardProfiles();
399  if (!profiles.isEmpty())
400  {
401  QSize size(0, 0);
402  Decoders.append("V4L2:");
403  for (MythCodecContext::CodecProfile profile : profiles)
404  Decoders.append(MythCodecContext::GetProfileDescription(profile, size));
405  }
406 
408  if (!requests.isEmpty())
409  {
410  QSize size(0, 0);
411  Decoders.append("V4L2 Request:");
412  for (MythCodecContext::CodecProfile profile : requests)
413  Decoders.append(MythCodecContext::GetProfileDescription(profile, size));
414  }
415 
416 }
417 
418 bool MythV4L2M2MContext::HaveV4L2Codecs(bool Reinit /*=false*/)
419 {
420 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
421  static QMutex lock(QMutex::Recursive);
422 #else
423  static QRecursiveMutex lock;
424 #endif
425  QMutexLocker locker(&lock);
426  static bool s_checked = false;
427  static bool s_available = false;
428 
429  if (s_checked && !Reinit)
430  return s_available;
431  s_checked = true;
432 
433  const auto & standard = MythV4L2M2MContext::GetStandardProfiles();
434  const auto & request = MythV4L2M2MContext::GetRequestProfiles();
435  if (standard.isEmpty() && request.isEmpty())
436  {
437  LOG(VB_GENERAL, LOG_INFO, LOC + "No V4L2 decoders found");
438  return s_available;
439  }
440 
441  LOG(VB_GENERAL, LOG_INFO, LOC + "Supported/available V4L2 decoders:");
442  s_available = true;
443  QSize size {0, 0};
444  for (auto profile : qAsConst(standard))
445  LOG(VB_GENERAL, LOG_INFO, LOC + MythCodecContext::GetProfileDescription(profile, size));
446  for (auto profile : qAsConst(request))
447  LOG(VB_GENERAL, LOG_INFO, LOC + MythCodecContext::GetProfileDescription(profile, size) + "(Request)");
448  return s_available;
449 }
450 
451 #ifndef V4L2_PIX_FMT_MPEG2_SLICE
452 #define V4L2_PIX_FMT_MPEG2_SLICE v4l2_fourcc('M', 'G', '2', 'S')
453 #endif
454 
455 #ifndef V4L2_PIX_FMT_H264_SLICE
456 #define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4')
457 #endif
458 
459 #ifndef V4L2_PIX_FMT_VP8_FRAME
460 #define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F')
461 #endif
462 
463 #ifndef V4L2_PIX_FMT_VP9_FRAME
464 #define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F')
465 #endif
466 
467 #ifndef V4L2_PIX_FMT_HEVC_SLICE
468 #define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5')
469 #endif
470 
472 {
473  static const std::vector<V4L2Mapping> s_map
474  {{
480  }};
481 
482 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
483  static QMutex lock(QMutex::Recursive);
484 #else
485  static QRecursiveMutex lock;
486 #endif
487  static bool s_initialised = false;
488  static V4L2Profiles s_profiles;
489 
490  QMutexLocker locker(&lock);
491  if (!s_initialised)
492  s_profiles = GetProfiles(s_map);
493  s_initialised = true;
494  return s_profiles;
495 }
496 
497 AVPixelFormat MythV4L2M2MContext::GetV4L2RequestFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
498 {
499  while (*PixFmt != AV_PIX_FMT_NONE)
500  {
501  if (*PixFmt == AV_PIX_FMT_DRM_PRIME)
502  {
504  "V4L2 request context creation") >= 0)
505  {
506  return AV_PIX_FMT_DRM_PRIME;
507  }
508  }
509  PixFmt++;
510  }
511  return AV_PIX_FMT_NONE;
512 }
513 
515 {
516  if (!Context || !gCoreContext->IsUIThread())
517  return -1;
518 
519  // N.B. Interop support should already have been checked
520  // Allocate the device context
521  auto * hwdeviceref = MythCodecContext::CreateDevice(AV_HWDEVICE_TYPE_DRM, nullptr);
522  if (!hwdeviceref)
523  return -1;
524 
525  // Initialise device context
526  if (av_hwdevice_ctx_init(hwdeviceref) < 0)
527  {
528  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to initialise device context");
529  av_buffer_unref(&hwdeviceref);
530  return -1;
531  }
532 
533  Context->hw_device_ctx = hwdeviceref;
534  return 0;
535 }
536 
537 bool MythV4L2M2MContext::GetRequestBuffer(AVCodecContext* Context, MythVideoFrame* Frame, AVFrame* AvFrame)
538 {
539  if (!Context || !AvFrame || !Frame)
540  return false;
541 
542  if (Frame->m_type != FMT_DRMPRIME || static_cast<AVPixelFormat>(AvFrame->format) != AV_PIX_FMT_DRM_PRIME)
543  {
544  LOG(VB_GENERAL, LOG_ERR, LOC + "Not a DRM PRIME buffer");
545  return false;
546  }
547 
548  Frame->m_width = AvFrame->width;
549  Frame->m_height = AvFrame->height;
550  Frame->m_pixFmt = Context->pix_fmt;
551  Frame->m_swPixFmt = Context->sw_pix_fmt;
552  Frame->m_directRendering = true;
553  AvFrame->opaque = Frame;
554  AvFrame->reordered_opaque = Context->reordered_opaque;
555 
556  // Frame->data[0] holds V4L2RequestDescriptor which holds AVDRMFrameDescriptor
557  Frame->m_buffer = reinterpret_cast<uint8_t*>(&(reinterpret_cast<V4L2RequestDescriptor*>(AvFrame->data[0])->drm));
558  // Retain the buffer so it is not released before we display it
559  Frame->m_priv[0] = reinterpret_cast<unsigned char*>(av_buffer_ref(AvFrame->buf[0]));
560  // Set interop
561  Frame->m_priv[1] = reinterpret_cast<unsigned char*>(m_interop);
562  // Set the release method
563  AvFrame->buf[1] = av_buffer_create(reinterpret_cast<uint8_t*>(Frame), 0, MythCodecContext::ReleaseBuffer,
564  static_cast<AvFormatDecoder*>(Context->opaque), 0);
565  return true;
566 }
V4L2_PIX_FMT_VP8_FRAME
#define V4L2_PIX_FMT_VP8_FRAME
Definition: mythv4l2m2mcontext.cpp:460
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:1360
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:418
MythV4L2M2MContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythv4l2m2mcontext.cpp:396
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:537
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:471
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
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:464
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:675
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:680
MythV4L2M2MContext::GetV4L2RequestFormat
static enum AVPixelFormat GetV4L2RequestFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
Definition: mythv4l2m2mcontext.cpp:497
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:514
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:468
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:452
MythVideoFrame
Definition: mythframe.h:88
V4L2util::GetCapabilities
uint32_t GetCapabilities(void) const
Definition: v4l2util.cpp:670
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:456
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