MythTV  master
mythcodeccontext.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017-19 MythTV Developers <mythtv-dev@mythtv.org>
3 //
4 // This is part of MythTV (https://www.mythtv.org)
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 //
24 
25 #include "mythcorecontext.h"
26 #include "mythlogging.h"
27 #include "mythmainwindow.h"
28 #include "mythinteropgpu.h"
29 #include "avformatdecoder.h"
30 #include "mythplayerui.h"
31 
32 #ifdef USING_VAAPI
33 #include "mythvaapicontext.h"
34 #endif
35 #ifdef USING_VDPAU
36 #include "mythvdpauhelper.h"
37 #include "mythvdpaucontext.h"
38 #endif
39 #ifdef USING_NVDEC
40 #include "mythnvdeccontext.h"
41 #endif
42 #ifdef USING_VTB
43 #include "mythvtbcontext.h"
44 #endif
45 #ifdef USING_MEDIACODEC
46 #include "mythmediacodeccontext.h"
47 #endif
48 #ifdef USING_V4L2
49 #include "mythv4l2m2mcontext.h"
50 #endif
51 #ifdef USING_MMAL
52 #include "mythmmalcontext.h"
53 #endif
54 #ifdef USING_EGL
55 #include "mythdrmprimecontext.h"
56 #endif
57 #include "mythcodeccontext.h"
58 
59 extern "C" {
60 #include "libavutil/pixdesc.h"
61 }
62 
63 #define LOC QString("MythCodecContext: ")
64 
66 
68  : m_parent(Parent),
69  m_codecID(CodecID)
70 {
71 }
72 
74 {
75  MythCodecContext *mctx = nullptr;
76 #ifdef USING_VAAPI
77  if (codec_is_vaapi(Codec) || codec_is_vaapi_dec(Codec))
78  mctx = new MythVAAPIContext(Parent, Codec);
79 #endif
80 #ifdef USING_VDPAU
81  if (codec_is_vdpau_hw(Codec) || codec_is_vdpau_dechw(Codec))
82  mctx = new MythVDPAUContext(Parent, Codec);
83 #endif
84 #ifdef USING_NVDEC
85  if (codec_is_nvdec_dec(Codec) || codec_is_nvdec(Codec))
86  mctx = new MythNVDECContext(Parent, Codec);
87 #endif
88 #ifdef USING_VTB
89  if (codec_is_vtb_dec(Codec) || codec_is_vtb(Codec))
90  mctx = new MythVTBContext(Parent, Codec);
91 #endif
92 #ifdef USING_MEDIACODEC
93  if (codec_is_mediacodec(Codec) || codec_is_mediacodec_dec(Codec))
94  mctx = new MythMediaCodecContext(Parent, Codec);
95 #endif
96 #ifdef USING_V4L2
97  if (codec_is_v4l2_dec(Codec) || codec_is_v4l2(Codec))
98  mctx = new MythV4L2M2MContext(Parent, Codec);
99 #endif
100 #ifdef USING_MMAL
101  if (codec_is_mmal_dec(Codec) || codec_is_mmal(Codec))
102  mctx = new MythMMALContext(Parent, Codec);
103 #endif
104 #ifdef USING_EGL
105  if (codec_is_drmprime(Codec))
106  mctx = new MythDRMPRIMEContext(Parent, Codec);
107 #endif
108  Q_UNUSED(Codec);
109 
110  if (!mctx)
111  mctx = new MythCodecContext(Parent, Codec);
112  return mctx;
113 }
114 
116 {
117  QStringList decoders;
118 
119 #ifdef USING_VDPAU
121 #endif
122 #ifdef USING_VAAPI
124 #endif
125 #ifdef USING_MEDIACODEC
127 #endif
128 #ifdef USING_NVDEC
130 #endif
131 #ifdef USING_MMAL
133 #endif
134 #ifdef USING_V4L2
136 #endif
137 #ifdef USING_VTB
139 #endif
140  return decoders;
141 }
142 
143 void MythCodecContext::GetDecoders(RenderOptions &Opts, bool Reinit /*=false*/)
144 {
145  if (!gCoreContext->IsUIThread())
146  {
147  LOG(VB_GENERAL, LOG_ERR, LOC + "Must be called from UI thread");
148  return;
149  }
150 
151  if (!HasMythMainWindow())
152  {
153  LOG(VB_GENERAL, LOG_INFO, LOC + "No window: Ignoring hardware decoders");
154  return;
155  }
156 
157  Opts.decoders->append("ffmpeg");
158  (*Opts.equiv_decoders)["ffmpeg"].append("dummy");
159 
160 #ifdef USING_VDPAU
161  // Only enable VDPAU support if it is actually present
162  if (MythVDPAUHelper::HaveVDPAU(Reinit))
163  {
164  Opts.decoders->append("vdpau");
165  (*Opts.equiv_decoders)["vdpau"].append("dummy");
166  Opts.decoders->append("vdpau-dec");
167  (*Opts.equiv_decoders)["vdpau-dec"].append("dummy");
168  }
169 #endif
170 #ifdef USING_DXVA2
171  Opts.decoders->append("dxva2");
172  (*Opts.equiv_decoders)["dxva2"].append("dummy");
173 #endif
174 
175 #ifdef USING_VAAPI
176  // Only enable VAAPI if it is actually present and isn't actually VDPAU
177  if (!MythVAAPIContext::HaveVAAPI(Reinit).isEmpty())
178  {
179  Opts.decoders->append("vaapi");
180  (*Opts.equiv_decoders)["vaapi"].append("dummy");
181  Opts.decoders->append("vaapi-dec");
182  (*Opts.equiv_decoders)["vaapi-dec"].append("dummy");
183  }
184 #endif
185 #ifdef USING_NVDEC
186  // Only enable NVDec support if it is actually present
187  if (MythNVDECContext::HaveNVDEC(Reinit))
188  {
189  Opts.decoders->append("nvdec");
190  (*Opts.equiv_decoders)["nvdec"].append("dummy");
191  Opts.decoders->append("nvdec-dec");
192  (*Opts.equiv_decoders)["nvdec-dec"].append("dummy");
193  }
194 #endif
195 #ifdef USING_MEDIACODEC
197  {
198  Opts.decoders->append("mediacodec");
199  (*Opts.equiv_decoders)["mediacodec"].append("dummy");
200  Opts.decoders->append("mediacodec-dec");
201  (*Opts.equiv_decoders)["mediacodec-dec"].append("dummy");
202  }
203 #endif
204 #ifdef USING_VTB
205  if (MythVTBContext::HaveVTB(Reinit))
206  {
207  Opts.decoders->append("vtb");
208  Opts.decoders->append("vtb-dec");
209  (*Opts.equiv_decoders)["vtb"].append("dummy");
210  (*Opts.equiv_decoders)["vtb-dec"].append("dummy");
211  }
212 #endif
213 #ifdef USING_V4L2
215  {
216 #ifdef USING_V4L2PRIME
217  Opts.decoders->append("v4l2");
218  (*Opts.equiv_decoders)["v4l2"].append("dummy");
219 #endif
220  Opts.decoders->append("v4l2-dec");
221  (*Opts.equiv_decoders)["v4l2-dec"].append("dummy");
222  }
223 #endif
224 #ifdef USING_EGL
226  {
227  Opts.decoders->append("drmprime");
228  (*Opts.equiv_decoders)["drmprime"].append("dummy");
229  }
230 #endif
231 #ifdef USING_MMAL
232  if (MythMMALContext::HaveMMAL(Reinit))
233  {
234  Opts.decoders->append("mmal-dec");
235  (*Opts.equiv_decoders)["mmal-dec"].append("dummy");
237  if (auto mmal = types.find(FMT_MMAL); (mmal != types.end()) && !mmal->second.empty())
238  {
239  Opts.decoders->append("mmal");
240  (*Opts.equiv_decoders)["mmal"].append("dummy");
241  }
242  }
243 #endif
244 }
245 
246 MythCodecID MythCodecContext::FindDecoder(const QString &Decoder, AVStream *Stream,
247  AVCodecContext **Context, AVCodec **Codec)
248 {
249  MythCodecID result = kCodec_NONE;
250  uint streamtype = mpeg_version((*Context)->codec_id);
251 
252 #ifdef USING_VDPAU
253  result = MythVDPAUContext::GetSupportedCodec(Context, Codec, Decoder, streamtype);
254  if (codec_is_vdpau_hw(result) || codec_is_vdpau_dechw(result))
255  return result;
256 #endif
257 #ifdef USING_VAAPI
258  result = MythVAAPIContext::GetSupportedCodec(Context, Codec, Decoder, streamtype);
259  if (codec_is_vaapi(result) || codec_is_vaapi_dec(result))
260  return result;
261 #endif
262 #ifdef USING_VTB
263  (void)Stream;
264  result = MythVTBContext::GetSupportedCodec(Context, Codec, Decoder, streamtype);
265  if (codec_is_vtb(result) || codec_is_vtb_dec(result))
266  return result;
267 #endif
268 #ifdef USING_DXVA2
269  result = VideoOutputD3D::GetBestSupportedCodec(width, height, Decoder, streamtype, false);
270  if (codec_is_dxva2(result))
271  return result;
272 #endif
273 #ifdef USING_MEDIACODEC
274  result = MythMediaCodecContext::GetBestSupportedCodec(Context, Codec, Decoder, Stream, streamtype);
275  if (codec_is_mediacodec(result) || codec_is_mediacodec_dec(result))
276  return result;
277 #endif
278 #ifdef USING_NVDEC
279  result = MythNVDECContext::GetSupportedCodec(Context, Codec, Decoder, Stream, streamtype);
280  if (codec_is_nvdec(result) || codec_is_nvdec_dec(result))
281  return result;
282 #endif
283 #ifdef USING_V4L2
284  result = MythV4L2M2MContext::GetSupportedCodec(Context, Codec, Decoder, Stream, streamtype);
285  if (codec_is_v4l2_dec(result) || codec_is_v4l2(result))
286  return result;
287 #endif
288 #ifdef USING_MMAL
289  result = MythMMALContext::GetSupportedCodec(Context, Codec, Decoder, Stream, streamtype);
290  if (codec_is_mmal_dec(result) || codec_is_mmal(result))
291  return result;
292 #endif
293 #ifdef USING_EGL
294  result = MythDRMPRIMEContext::GetSupportedCodec(Context, Codec, Decoder, Stream, streamtype);
295  if (codec_is_drmprime(result))
296  return result;
297 #endif
298 
299  return kCodec_NONE;
300 }
301 
302 void MythCodecContext::InitVideoCodec(AVCodecContext *Context,
303  bool SelectedStream, bool &DirectRendering)
304 {
305  const AVCodec *codec1 = Context->codec;
306  if (codec1 && codec1->capabilities & AV_CODEC_CAP_DR1)
307  {
308  // Context->flags |= CODEC_FLAG_EMU_EDGE;
309  }
310  else
311  {
312  if (SelectedStream)
313  DirectRendering = false;
314  LOG(VB_PLAYBACK, LOG_INFO, LOC +
315  QString("Using software scaling to convert pixel format %1 for "
316  "codec %2").arg(av_get_pix_fmt_name(Context->pix_fmt))
317  .arg(ff_codec_id_string(Context->codec_id)));
318  }
319 }
320 
322 int MythCodecContext::GetBuffer(struct AVCodecContext *Context, AVFrame *Frame, int Flags)
323 {
324  auto *avfd = static_cast<AvFormatDecoder*>(Context->opaque);
325  MythVideoFrame *videoframe = avfd->GetPlayer()->GetNextVideoFrame();
326 
327  // set fields required for directrendering
328  for (int i = 0; i < 4; i++)
329  {
330  Frame->data[i] = nullptr;
331  Frame->linesize[i] = 0;
332  }
333  Frame->opaque = videoframe;
334  videoframe->m_pixFmt = Context->pix_fmt;
335  Frame->reordered_opaque = Context->reordered_opaque;
336 
337  int ret = avcodec_default_get_buffer2(Context, Frame, Flags);
338  if (ret < 0)
339  return ret;
340 
341  // set the underlying pixel format. Set here rather than guessing later.
342  if (Frame->hw_frames_ctx)
343  {
344  auto *context = reinterpret_cast<AVHWFramesContext*>(Frame->hw_frames_ctx->data);
345  if (context)
346  videoframe->m_swPixFmt = context->sw_format;
347  }
348 
349  // VAAPI 'fixes' 10/12/16bit colour values. Irrelevant for VDPAU.
350  videoframe->m_colorshifted = true;
351 
352  // avcodec_default_get_buffer2 will retrieve an AVBufferRef from the pool of
353  // hardware surfaces stored within AVHWFramesContext. The pointer to the surface is stored
354  // in Frame->data[3]. Store this in VideoFrame::buf for the interop class to use.
355  videoframe->m_buffer = Frame->data[3];
356  // Frame->buf(0) also contains a reference to the buffer. Take an additional reference to this
357  // buffer to retain the surface until it has been displayed (otherwise it is
358  // reused once the decoder is finished with it).
359  videoframe->m_priv[0] = reinterpret_cast<unsigned char*>(av_buffer_ref(Frame->buf[0]));
360  // frame->hw_frames_ctx contains a reference to the AVHWFramesContext. Take an additional
361  // reference to ensure AVHWFramesContext is not released until we are finished with it.
362  // This also contains the underlying MythInteropGPU class reference.
363  videoframe->m_priv[1] = reinterpret_cast<unsigned char*>(av_buffer_ref(Frame->hw_frames_ctx));
364 
365  // Set release method
366  Frame->buf[1] = av_buffer_create(reinterpret_cast<uint8_t*>(videoframe), 0,
368  return ret;
369 }
370 
371 
373 bool MythCodecContext::GetBuffer2(struct AVCodecContext *Context, MythVideoFrame* Frame,
374  AVFrame *AvFrame, int /*Flags*/)
375 {
376  if (!AvFrame || !Context || !Frame)
377  return false;
378 
379  auto *avfd = static_cast<AvFormatDecoder*>(Context->opaque);
380 
381  Frame->m_pixFmt = Context->pix_fmt;
382  Frame->m_directRendering = true;
383  Frame->m_colorshifted = true;
384 
385  AvFrame->reordered_opaque = Context->reordered_opaque;
386  AvFrame->opaque = Frame;
387 
388  // retrieve the software format
389  if (AvFrame->hw_frames_ctx)
390  {
391  auto *context = reinterpret_cast<AVHWFramesContext*>(AvFrame->hw_frames_ctx->data);
392  if (context)
393  Frame->m_swPixFmt = context->sw_format;
394  }
395 
396  // the hardware surface is stored in Frame->data[3]
397  Frame->m_buffer = AvFrame->data[3];
398 
399  // Frame->buf[0] contains the release method. Take another reference to
400  // ensure the frame is not released before it is displayed.
401  Frame->m_priv[0] = reinterpret_cast<unsigned char*>(av_buffer_ref(AvFrame->buf[0]));
402 
403  // Retrieve and set the interop class
404  auto *devicectx = reinterpret_cast<AVHWDeviceContext*>(Context->hw_device_ctx->data);
405  Frame->m_priv[1] = reinterpret_cast<unsigned char*>(devicectx->user_opaque);
406 
407  // Set release method
408  AvFrame->buf[1] = av_buffer_create(reinterpret_cast<uint8_t*>(Frame), 0,
410  return true;
411 }
412 
413 void MythCodecContext::ReleaseBuffer(void *Opaque, uint8_t *Data)
414 {
415  auto *decoder = static_cast<AvFormatDecoder*>(Opaque);
416  auto *frame = reinterpret_cast<MythVideoFrame*>(Data);
417  if (decoder && decoder->GetPlayer())
418  decoder->GetPlayer()->DeLimboFrame(frame);
419 }
420 
429 {
430  int count = ++s_hwFramesContextCount;
431  if (count != 1)
432  LOG(VB_GENERAL, LOG_WARNING, LOC + QString("Error: %1 concurrent hardware frames contexts").arg(count));
433 }
434 
435 void MythCodecContext::FramesContextFinished(AVHWFramesContext *Context)
436 {
438  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("%1 frames context finished")
439  .arg(av_hwdevice_get_type_name(Context->device_ctx->type)));
440  auto * interop = reinterpret_cast<MythInteropGPU*>(Context->user_opaque);
441  if (interop)
442  DestroyInterop(interop);
443 }
444 
445 void MythCodecContext::DeviceContextFinished(AVHWDeviceContext* Context)
446 {
447  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("%1 device context finished")
448  .arg(av_hwdevice_get_type_name(Context->type)));
449  auto * interop = reinterpret_cast<MythInteropGPU*>(Context->user_opaque);
450  if (interop)
451  {
452  DestroyInterop(interop);
453  FreeAVHWDeviceContext free = interop->GetDefaultFree();
454  if (free)
455  {
456  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Calling default device context free");
457  Context->user_opaque = interop->GetDefaultUserOpaque();
458  free(Context);
459  }
460  }
461 }
462 
464 {
465  if (gCoreContext->IsUIThread())
466  {
467  Interop->DecrRef();
468  return;
469  }
470 
471  auto destroy = [](void *Wait, void *Interop2, void* /*unused*/)
472  {
473  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Destroy interop callback");
474  auto *wait = reinterpret_cast<QWaitCondition*>(Wait);
475  auto *interop = reinterpret_cast<MythInteropGPU*>(Interop2);
476  if (interop)
477  interop->DecrRef();
478  if (wait)
479  wait->wakeAll();
480  };
481 
482  if (!Interop->GetPlayer())
483  {
484  LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot destroy interop - no player");
485  return;
486  }
487  Interop->GetPlayer()->HandleDecoderCallback("Destroy OpenGL interop",
488  destroy, Interop, nullptr);
489 }
490 
491 void MythCodecContext::CreateDecoderCallback(void *Wait, void *Context, void *Callback)
492 {
493  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Create decoder callback");
494  auto *wait = reinterpret_cast<QWaitCondition*>(Wait);
495  auto *context = reinterpret_cast<AVCodecContext*>(Context);
496  auto callback = reinterpret_cast<CreateHWDecoder>(Callback);
497  if (context && callback)
498  (void)callback(context);
499  if (wait)
500  wait->wakeAll();
501 }
502 
504 {
505  MythPlayerUI* result = nullptr;
506  auto* decoder = reinterpret_cast<AvFormatDecoder*>(Context->opaque);
507  if (decoder)
508  result = dynamic_cast<MythPlayerUI*>(decoder->GetPlayer());
509  return result;
510 }
511 
513 {
514  if (auto * player = GetPlayerUI(Context); player != nullptr)
515  {
516  const auto & supported = player->GetInteropTypes();
517  return supported.find(Format) != supported.cend();
518  }
519  return false;
520 }
521 
523 int MythCodecContext::InitialiseDecoder(AVCodecContext *Context, CreateHWDecoder Callback,
524  const QString &Debug)
525 {
526  if (!Context || !Callback)
527  return -1;
528  if (gCoreContext->IsUIThread())
529  return Callback(Context);
530 
531  // Callback to MythPlayer (which will fail without a MythPlayer instance)
532  MythPlayerUI* player = GetPlayerUI(Context);
533  if (player)
535  Context, reinterpret_cast<void*>(Callback));
536  return Context->hw_frames_ctx ? 0 : -1;
537 }
538 
540 int MythCodecContext::InitialiseDecoder2(AVCodecContext *Context, CreateHWDecoder Callback,
541  const QString &Debug)
542 {
543  if (!Context || !Callback)
544  return -1;
545  if (gCoreContext->IsUIThread())
546  return Callback(Context);
547 
548  // Callback to MythPlayer (which will fail without a MythPlayer instance)
549  MythPlayerUI* player = GetPlayerUI(Context);
550  if (player)
552  Context, reinterpret_cast<void*>(Callback));
553  return Context->hw_device_ctx ? 0 : -1;
554 }
555 
556 AVBufferRef* MythCodecContext::CreateDevice(AVHWDeviceType Type, MythInteropGPU* Interop, const QString& Device)
557 {
558  AVBufferRef* result = nullptr;
559  int res = av_hwdevice_ctx_create(&result, Type, Device.isEmpty() ? nullptr :
560  Device.toLocal8Bit().constData(), nullptr, 0);
561  if (res == 0)
562  {
563  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created hardware device '%1'%2")
564  .arg(av_hwdevice_get_type_name(Type))
565  .arg(Device == nullptr ? "" : QString(" (%1)").arg(Device)));
566  auto *context = reinterpret_cast<AVHWDeviceContext*>(result->data);
567 
568  if ((context->free || context->user_opaque) && !Interop)
569  {
570  LOG(VB_PLAYBACK, LOG_INFO, "Creating dummy interop");
571  Interop = MythInteropGPU::CreateDummy();
572  }
573 
574  if (Interop)
575  {
576  Interop->SetDefaultFree(context->free);
577  Interop->SetDefaultUserOpaque(context->user_opaque);
578  Interop->IncrRef();
579  }
580 
582  context->user_opaque = Interop;
583  return result;
584  }
585 
586  std::string error;
587  LOG(VB_PLAYBACK, LOG_ERR, LOC + QString("Failed to create hardware device '%1'%2 Error '%3'")
588  .arg(av_hwdevice_get_type_name(Type))
589  .arg(Device == nullptr ? "" : QString(" (%1)").arg(Device))
590  .arg(av_make_error_stdstring(error, res)));
591  return nullptr;
592 }
593 
595 bool MythCodecContext::IsUnsupportedProfile(AVCodecContext *Context)
596 {
597  switch (Context->codec_id)
598  {
599  case AV_CODEC_ID_H264:
600  switch (Context->profile)
601  {
602  case FF_PROFILE_H264_HIGH_10:
603  case FF_PROFILE_H264_HIGH_10_INTRA:
604  case FF_PROFILE_H264_HIGH_422:
605  case FF_PROFILE_H264_HIGH_422_INTRA:
606  case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
607  case FF_PROFILE_H264_HIGH_444_INTRA:
608  case FF_PROFILE_H264_CAVLC_444: return true;
609  default: break;
610  }
611  break;
612  default: break;
613  }
614  return false;
615 }
616 
621 {
622  return avcodec_receive_frame(Context, Frame);
623 }
624 
626 {
627  if (!Frame || !AvFrame)
628  return false;
629 
630  AVFrame *temp = av_frame_alloc();
631  if (!temp)
632  return false;
633 
634  AVPixelFormat *pixelformats = nullptr;
635  int ret = av_hwframe_transfer_get_formats(AvFrame->hw_frames_ctx,
636  AV_HWFRAME_TRANSFER_DIRECTION_FROM,
637  &pixelformats, 0);
638  if (ret == 0)
639  {
640  AVPixelFormat best = DecoderBase::GetBestVideoFormat(pixelformats, Frame->m_renderFormats);
641  if (best != AV_PIX_FMT_NONE)
642  {
644  bool valid = Frame->m_type == type;
645  if (!valid || (Frame->m_width != AvFrame->width) || (Frame->m_height != AvFrame->height))
647  AvFrame->width, AvFrame->height);
648 
649  if (valid)
650  {
651  // Retrieve the picture directly into the VideoFrame Buffer
652  temp->format = best;
653  uint max = MythVideoFrame::GetNumPlanes(Frame->m_type);
654  for (uint i = 0; i < 3; i++)
655  {
656  temp->data[i] = (i < max) ? (Frame->m_buffer + Frame->m_offsets[i]) : nullptr;
657  temp->linesize[i] = Frame->m_pitches[i];
658  }
659 
660  // Dummy release method - we do not want to free the buffer
661  temp->buf[0] = av_buffer_create(reinterpret_cast<uint8_t*>(Frame), 0,
662  [](void* /*unused*/, uint8_t* /*unused*/){}, this, 0);
663  temp->width = AvFrame->width;
664  temp->height = AvFrame->height;
665  }
666  }
667  }
668  av_freep(&pixelformats);
669 
670  // retrieve data from GPU to CPU
671  if (ret >= 0)
672  if ((ret = av_hwframe_transfer_data(temp, AvFrame, 0)) < 0)
673  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Error %1 transferring the data to system memory").arg(ret));
674 
675  Frame->m_colorshifted = true;
676  av_frame_free(&temp);
677  return ret >= 0;
678 }
679 
681 {
682  switch (CodecID)
683  {
684  case AV_CODEC_ID_MPEG1VIDEO: return MPEG1;
685  case AV_CODEC_ID_MPEG2VIDEO:
686  switch (Profile)
687  {
688  case FF_PROFILE_MPEG2_422: return MPEG2422;
689  case FF_PROFILE_MPEG2_HIGH: return MPEG2High;
690  case FF_PROFILE_MPEG2_SS: return MPEG2Spatial;
691  case FF_PROFILE_MPEG2_SNR_SCALABLE: return MPEG2SNR;
692  case FF_PROFILE_MPEG2_SIMPLE: return MPEG2Simple;
693  case FF_PROFILE_MPEG2_MAIN: return MPEG2Main;
694  default: break;
695  }
696  break;
697  case AV_CODEC_ID_MPEG4:
698  switch (Profile)
699  {
700  case FF_PROFILE_MPEG4_SIMPLE: return MPEG4Simple;
701  case FF_PROFILE_MPEG4_SIMPLE_SCALABLE: return MPEG4SimpleScaleable;
702  case FF_PROFILE_MPEG4_CORE: return MPEG4Core;
703  case FF_PROFILE_MPEG4_MAIN: return MPEG4Main;
704  case FF_PROFILE_MPEG4_N_BIT: return MPEG4NBit;
705  case FF_PROFILE_MPEG4_SCALABLE_TEXTURE: return MPEG4ScaleableTexture;
706  case FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION: return MPEG4SimpleFace;
707  case FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE: return MPEG4BasicAnimated;
708  case FF_PROFILE_MPEG4_HYBRID: return MPEG4Hybrid;
709  case FF_PROFILE_MPEG4_ADVANCED_REAL_TIME: return MPEG4AdvancedRT;
710  case FF_PROFILE_MPEG4_CORE_SCALABLE: return MPEG4CoreScaleable;
711  case FF_PROFILE_MPEG4_ADVANCED_CODING: return MPEG4AdvancedCoding;
712  case FF_PROFILE_MPEG4_ADVANCED_CORE: return MPEG4AdvancedCore;
713  case FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE: return MPEG4AdvancedScaleableTexture;
714  case FF_PROFILE_MPEG4_SIMPLE_STUDIO: return MPEG4SimpleStudio;
715  case FF_PROFILE_MPEG4_ADVANCED_SIMPLE: return MPEG4AdvancedSimple;
716  }
717  break;
718  case AV_CODEC_ID_H263: return H263;
719  case AV_CODEC_ID_H264:
720  switch (Profile)
721  {
722  // Mapping of H264MainExtended, H264ConstrainedHigh?
723  case FF_PROFILE_H264_BASELINE: return H264Baseline;
724  case FF_PROFILE_H264_CONSTRAINED_BASELINE: return H264ConstrainedBaseline;
725  case FF_PROFILE_H264_MAIN: return H264Main;
726  case FF_PROFILE_H264_EXTENDED: return H264Extended;
727  case FF_PROFILE_H264_HIGH: return H264High;
728  case FF_PROFILE_H264_HIGH_10: return H264High10;
729  //case FF_PROFILE_H264_HIGH_10_INTRA:
730  //case FF_PROFILE_H264_MULTIVIEW_HIGH:
731  case FF_PROFILE_H264_HIGH_422: return H264High422;
732  //case FF_PROFILE_H264_HIGH_422_INTRA:
733  //case FF_PROFILE_H264_STEREO_HIGH:
734  case FF_PROFILE_H264_HIGH_444: return H264High444;
735  //case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
736  //case FF_PROFILE_H264_HIGH_444_INTRA:
737  //case FF_PROFILE_H264_CAVLC_444:
738  }
739  break;
740  case AV_CODEC_ID_HEVC:
741  switch (Profile)
742  {
743  case FF_PROFILE_HEVC_MAIN: return HEVCMain;
744  case FF_PROFILE_HEVC_MAIN_10: return HEVCMain10;
745  case FF_PROFILE_HEVC_MAIN_STILL_PICTURE: return HEVCMainStill;
746  case FF_PROFILE_HEVC_REXT: return HEVCRext;
747  }
748  break;
749  case AV_CODEC_ID_VC1:
750  switch (Profile)
751  {
752  case FF_PROFILE_VC1_SIMPLE: return VC1Simple;
753  case FF_PROFILE_VC1_MAIN: return VC1Main;
754  case FF_PROFILE_VC1_COMPLEX: return VC1Complex;
755  case FF_PROFILE_VC1_ADVANCED: return VC1Advanced;
756  }
757  break;
758  case AV_CODEC_ID_VP8: return VP8;
759  case AV_CODEC_ID_VP9:
760  switch (Profile)
761  {
762  case FF_PROFILE_VP9_0: return VP9_0;
763  case FF_PROFILE_VP9_1: return VP9_1;
764  case FF_PROFILE_VP9_2: return VP9_2;
765  case FF_PROFILE_VP9_3: return VP9_3;
766  }
767  break;
768  case AV_CODEC_ID_AV1:
769  switch (Profile)
770  {
771  case FF_PROFILE_AV1_MAIN: return AV1Main;
772  case FF_PROFILE_AV1_HIGH: return AV1High;
773  case FF_PROFILE_AV1_PROFESSIONAL: return AV1Professional;
774  }
775  break;
776  case AV_CODEC_ID_MJPEG: return MJPEG;
777  default: break;
778  }
779 
780  return NoProfile;
781 }
782 
784  VideoFrameType Format, uint ColorDepth)
785 {
786  QString profile;
787  switch (Profile)
788  {
789  case NoProfile: profile = QObject::tr("Unknown/Unsupported"); break;
790  case MPEG1: profile = "MPEG1"; break;
791  case MPEG2: profile = "MPEG2"; break;
792  case MPEG2Simple: profile = "MPEG2 Simple"; break;
793  case MPEG2Main: profile = "MPEG2 Main"; break;
794  case MPEG2422: profile = "MPEG2 422"; break;
795  case MPEG2High: profile = "MPEG2 High"; break;
796  case MPEG2Spatial: profile = "MPEG2 Spatial"; break;
797  case MPEG2SNR: profile = "MPEG2 SNR"; break;
798  case MPEG4: profile = "MPEG4"; break;
799  case MPEG4Simple: profile = "MPEG4 Simple"; break;
800  case MPEG4SimpleScaleable: profile = "MPEG4 Simple Scaleable"; break;
801  case MPEG4Core: profile = "MPEG4 Core"; break;
802  case MPEG4Main: profile = "MPEG4 Main"; break;
803  case MPEG4NBit: profile = "MPEG4 NBit"; break;
804  case MPEG4ScaleableTexture: profile = "MPEG4 Scaleable Texture"; break;
805  case MPEG4SimpleFace: profile = "MPEG4 Simple Face"; break;
806  case MPEG4BasicAnimated: profile = "MPEG4 Basic Animated"; break;
807  case MPEG4Hybrid: profile = "MPEG4 Hybrid"; break;
808  case MPEG4AdvancedRT: profile = "MPEG4 Advanced RT"; break;
809  case MPEG4CoreScaleable: profile = "MPEG4 Core Scaleable"; break;
810  case MPEG4AdvancedCoding: profile = "MPEG4 Advanced Coding"; break;
811  case MPEG4AdvancedCore: profile = "MPEG4 Advanced Core"; break;
812  case MPEG4AdvancedScaleableTexture: profile = "MPEG4 Advanced Scaleable Texture"; break;
813  case MPEG4SimpleStudio: profile = "MPEG4 Simple Studio"; break;
814  case MPEG4AdvancedSimple: profile = "MPEG4 Advanced Simple"; break;
815  case H263: profile = "H263"; break;
816  case H264: profile = "H264"; break;
817  case H264Baseline: profile = "H264 Baseline"; break;
818  case H264ConstrainedBaseline: profile = "H264 Constrained"; break;
819  case H264Main: profile = "H264 Main"; break;
820  case H264MainExtended: profile = "H264 Main Extended"; break;
821  case H264High: profile = "H264 High"; break;
822  case H264High10: profile = "H264 High10"; break;
823  case H264Extended: profile = "H264 Extended"; break;
824  case H264High422: profile = "H264 High 422"; break;
825  case H264High444: profile = "H264 High 444"; break;
826  case H264ConstrainedHigh: profile = "H264 Constrained High"; break;
827  case HEVC: profile = "HEVC"; break;
828  case HEVCMain: profile = "HEVC Main"; break;
829  case HEVCMain10: profile = "HEVC Main10"; break;
830  case HEVCMainStill: profile = "HEVC Main Still"; break;
831  case HEVCRext: profile = "HEVC Rext"; break;
832  case HEVCMain10HDR: profile = "HEVC Main10HDR"; break;
833  case HEVCMain10HDRPlus: profile = "HEVC Main10HDRPlus"; break;
834  case VC1: profile = "VC1"; break;
835  case VC1Simple: profile = "VC1 Simple"; break;
836  case VC1Main: profile = "VC1 Main"; break;
837  case VC1Complex: profile = "VC1 Complex"; break;
838  case VC1Advanced: profile = "VC1 Advanced"; break;
839  case VP8: profile = "VP8"; break;
840  case VP9: profile = "VP9"; break;
841  case VP9_0: profile = "VP9 Level 0"; break;
842  case VP9_1: profile = "VP9 Level 1"; break;
843  case VP9_2: profile = "VP9 Level 2"; break;
844  case VP9_2HDR: profile = "VP9 Level 2 HDR"; break;
845  case VP9_2HDRPlus: profile = "VP9 Level 2 HDRPlus"; break;
846  case VP9_3: profile = "VP9 Level 3"; break;
847  case VP9_3HDR: profile = "VP9 Level 3 HDR"; break;
848  case VP9_3HDRPlus: profile = "VP9 Level 3 HDRPlus"; break;
849  case AV1: profile = "AV1"; break;
850  case AV1Main: profile = "AV1 Main"; break;
851  case AV1High: profile = "AV1 High"; break;
852  case AV1Professional: profile = "AV1 Professional"; break;
853  case MJPEG: profile = "MJPEG";
854  }
855 
856  if (Size.isEmpty())
857  return profile;
858 
859  return QObject::tr("%1%2%3 (Max size: %4x%5)")
860  .arg(profile).arg(Format != FMT_NONE ? QString(" %1").arg(MythVideoFrame::FormatDescription(Format)) : "")
861  .arg(ColorDepth > 8 ? QString(" %1Bit").arg(ColorDepth) : "")
862  .arg(Size.width()).arg(Size.height());
863 }
MythDRMPRIMEContext::HavePrimeDecoders
static bool HavePrimeDecoders(bool Reinit=false, AVCodecID Codec=AV_CODEC_ID_NONE)
Definition: mythdrmprimecontext.cpp:192
mythvtbcontext.h
MythCodecContext::VP9_3
@ VP9_3
Definition: mythcodeccontext.h:113
RenderOptions::equiv_decoders
QMap< QString, QStringList > * equiv_decoders
Definition: mythvideoprofile.h:52
MythCodecContext::VC1Simple
@ VC1Simple
Definition: mythcodeccontext.h:104
MythCodecContext::MPEG4Simple
@ MPEG4Simple
Definition: mythcodeccontext.h:68
MythCodecContext::H264Baseline
@ H264Baseline
Definition: mythcodeccontext.h:86
MythCodecContext::MPEG2Simple
@ MPEG2Simple
Definition: mythcodeccontext.h:61
MythCodecContext::VC1Advanced
@ VC1Advanced
Definition: mythcodeccontext.h:107
MythCodecContext::s_hwFramesContextCount
static QAtomicInt s_hwFramesContextCount
Definition: mythcodeccontext.h:167
MythCodecContext::MythCodecContext
MythCodecContext(DecoderBase *Parent, MythCodecID CodecID)
Definition: mythcodeccontext.cpp:67
error
static void error(const char *str,...)
Definition: vbi.cpp:42
ReferenceCounter::DecrRef
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
Definition: referencecounter.cpp:125
MythCodecContext::FindDecoder
static MythCodecID FindDecoder(const QString &Decoder, AVStream *Stream, AVCodecContext **Context, AVCodec **Codec)
Definition: mythcodeccontext.cpp:246
MythCodecContext::VP9_1
@ VP9_1
Definition: mythcodeccontext.h:111
mythplayerui.h
mpeg_version
uint mpeg_version(int codec_id)
Definition: mythcodecid.cpp:455
MythCodecContext::VP9_0
@ VP9_0
Definition: mythcodeccontext.h:110
MythMMALContext::HaveMMAL
static bool HaveMMAL(bool Reinit=false)
Definition: mythmmalcontext.cpp:244
MythCodecContext::HEVCMain10
@ HEVCMain10
Definition: mythcodeccontext.h:98
kCodec_NONE
@ kCodec_NONE
Definition: mythcodecid.h:14
MythNVDECContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **CodecContext, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Determine whether NVDEC decoding is supported for this codec.
Definition: mythnvdeccontext.cpp:32
MythInteropGPU::GetPlayer
MythPlayerUI * GetPlayer()
Definition: mythinteropgpu.cpp:79
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:58
MythCodecContext::MPEG4AdvancedSimple
@ MPEG4AdvancedSimple
Definition: mythcodeccontext.h:83
CreateHWDecoder
int(*)(AVCodecContext *Context) CreateHWDecoder
Definition: mythcodeccontext.h:48
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:56
Frame
Definition: zmdefines.h:93
MythCodecContext::NewHardwareFramesContext
static void NewHardwareFramesContext(void)
Track the number of concurrent frames contexts.
Definition: mythcodeccontext.cpp:428
MythCodecContext::MPEG4ScaleableTexture
@ MPEG4ScaleableTexture
Definition: mythcodeccontext.h:73
MythCodecContext::HEVCRext
@ HEVCRext
Definition: mythcodeccontext.h:100
codec_is_nvdec
#define codec_is_nvdec(id)
Definition: mythcodecid.h:328
MythCodecContext::VC1Main
@ VC1Main
Definition: mythcodeccontext.h:105
MythCodecContext::CreateContext
static MythCodecContext * CreateContext(DecoderBase *Parent, MythCodecID Codec)
Definition: mythcodeccontext.cpp:73
MythVDPAUHelper::HaveVDPAU
static bool HaveVDPAU(bool Reinit=false)
Definition: mythvdpauhelper.cpp:53
MythMediaCodecContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythmediacodeccontext.cpp:488
MythCoreContext::IsUIThread
bool IsUIThread(void)
Definition: mythcorecontext.cpp:1361
types
static const struct wl_interface * types[]
Definition: idle_inhibit_unstable_v1.c:39
MythCodecContext::InitVideoCodec
virtual void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering)
Definition: mythcodeccontext.cpp:302
MythDate::Format
Format
Definition: mythdate.h:15
codec_is_mmal_dec
#define codec_is_mmal_dec(id)
Definition: mythcodecid.h:342
codec_is_mmal
#define codec_is_mmal(id)
Definition: mythcodecid.h:341
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythCodecContext::FramesContextFinished
static void FramesContextFinished(AVHWFramesContext *Context)
Definition: mythcodeccontext.cpp:435
MythV4L2M2MContext::HaveV4L2Codecs
static bool HaveV4L2Codecs(bool Reinit=false)
Definition: mythv4l2m2mcontext.cpp:419
MythCodecContext::AV1High
@ AV1High
Definition: mythcodeccontext.h:120
MythV4L2M2MContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythv4l2m2mcontext.cpp:397
MythCodecContext::VP9_3HDRPlus
@ VP9_3HDRPlus
Definition: mythcodeccontext.h:117
MythCodecContext::MPEG4Main
@ MPEG4Main
Definition: mythcodeccontext.h:71
Device
A device containing images (ie. USB stick, CD, storage group etc)
Definition: imagemanager.cpp:33
MythCodecContext::VP9_2
@ VP9_2
Definition: mythcodeccontext.h:112
MythCodecContext::FFmpegToMythProfile
static CodecProfile FFmpegToMythProfile(AVCodecID CodecID, int Profile)
Definition: mythcodeccontext.cpp:680
MythCodecContext::MPEG4AdvancedCore
@ MPEG4AdvancedCore
Definition: mythcodeccontext.h:80
DecoderBase::GetVideoCodecID
virtual MythCodecID GetVideoCodecID(void) const =0
HasMythMainWindow
bool HasMythMainWindow(void)
Definition: mythmainwindow.cpp:109
MythCodecContext::HEVCMainStill
@ HEVCMainStill
Definition: mythcodeccontext.h:99
MythCodecContext::H264Extended
@ H264Extended
Definition: mythcodeccontext.h:92
MythNVDECContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythnvdeccontext.cpp:553
MythCodecContext::H264ConstrainedBaseline
@ H264ConstrainedBaseline
Definition: mythcodeccontext.h:87
MythVAAPIContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, uint StreamType)
Confirm whether VAAPI support is available given Decoder and Context.
Definition: mythvaapicontext.cpp:131
MythCodecContext::VP9_2HDRPlus
@ VP9_2HDRPlus
Definition: mythcodeccontext.h:115
MythVTBContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythvtbcontext.cpp:272
MythCodecContext::VC1Complex
@ VC1Complex
Definition: mythcodeccontext.h:106
mythvaapicontext.h
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:22
MythVTBContext
Definition: mythvtbcontext.h:17
MythVAAPIContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythvaapicontext.cpp:578
MythCodecContext::MPEG4AdvancedCoding
@ MPEG4AdvancedCoding
Definition: mythcodeccontext.h:79
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
MythCodecContext::MPEG4SimpleScaleable
@ MPEG4SimpleScaleable
Definition: mythcodeccontext.h:69
MythPlayerUI
Definition: mythplayerui.h:10
mythinteropgpu.h
MythVDPAUContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **CodecContext, AVCodec **Codec, const QString &Decoder, uint StreamType)
Definition: mythvdpaucontext.cpp:118
RenderOptions::decoders
QStringList * decoders
Definition: mythvideoprofile.h:51
Decoder
Definition: decoder.h:70
MythCodecContext::MPEG2High
@ MPEG2High
Definition: mythcodeccontext.h:64
mythlogging.h
MythCodecContext::MPEG2422
@ MPEG2422
Definition: mythcodeccontext.h:63
codec_is_mediacodec
#define codec_is_mediacodec(id)
Definition: mythcodecid.h:323
RenderOptions
Definition: mythvideoprofile.h:45
MythCodecContext::DeviceContextFinished
static void DeviceContextFinished(AVHWDeviceContext *Context)
Definition: mythcodeccontext.cpp:445
MythCodecContext::MPEG4CoreScaleable
@ MPEG4CoreScaleable
Definition: mythcodeccontext.h:78
MythVDPAUHelper::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythvdpauhelper.cpp:216
hardwareprofile.scan.profile
profile
Definition: scan.py:99
mythvdpauhelper.h
MythVideoFrame::m_colorshifted
bool m_colorshifted
Definition: mythframe.h:153
MythDRMPRIMEContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Definition: mythdrmprimecontext.cpp:74
MythCodecContext::DestroyInterop
static void DestroyInterop(MythInteropGPU *Interop)
Definition: mythcodeccontext.cpp:463
MythCodecContext::ReleaseBuffer
static void ReleaseBuffer(void *Opaque, uint8_t *Data)
Definition: mythcodeccontext.cpp:413
MythVideoFrame::m_pixFmt
int m_pixFmt
Definition: mythframe.h:144
VideoOutputD3D::GetBestSupportedCodec
static MythCodecID GetBestSupportedCodec(uint width, uint height, const QString &decoder, uint stream_type, bool no_acceleration, AVPixelFormat &pix_fmt)
Definition: videoout_d3d.cpp:622
MythVAAPIContext
Definition: mythvaapicontext.h:23
MythCodecContext::H264MainExtended
@ H264MainExtended
Definition: mythcodeccontext.h:89
MythCodecContext::MPEG2SNR
@ MPEG2SNR
Definition: mythcodeccontext.h:66
MythCodecContext::MPEG4AdvancedScaleableTexture
@ MPEG4AdvancedScaleableTexture
Definition: mythcodeccontext.h:81
MythPlayerVideoUI::HandleDecoderCallback
void HandleDecoderCallback(const QString &Debug, DecoderCallback::Callback Function, void *Opaque1, void *Opaque2)
Convenience function to request and wait for a callback into the main thread.
Definition: mythplayervideoui.cpp:134
MythCodecContext::GetBuffer
static int GetBuffer(struct AVCodecContext *Context, AVFrame *Frame, int Flags)
A generic hardware buffer initialisation method when using AVHWFramesContext.
Definition: mythcodeccontext.cpp:322
MythMediaCodecContext
Definition: mythmediacodeccontext.h:16
MythNVDECContext
Definition: mythnvdeccontext.h:24
MythCodecContext::VP9
@ VP9
Definition: mythcodeccontext.h:109
MythCodecContext::H264Main
@ H264Main
Definition: mythcodeccontext.h:88
MythVAAPIContext::HaveVAAPI
static QString HaveVAAPI(bool ReCheck=false)
Check whether VAAPI is available and not emulated via VDPAU.
Definition: mythvaapicontext.cpp:418
mythvdpaucontext.h
MythCodecContext::H264High422
@ H264High422
Definition: mythcodeccontext.h:93
MythCodecContext::AV1Professional
@ AV1Professional
Definition: mythcodeccontext.h:121
MythCodecContext::MPEG4SimpleStudio
@ MPEG4SimpleStudio
Definition: mythcodeccontext.h:82
MythCodecContext::HEVCMain10HDRPlus
@ HEVCMain10HDRPlus
Definition: mythcodeccontext.h:102
MythCodecContext::MPEG4
@ MPEG4
Definition: mythcodeccontext.h:67
MythCodecContext::MPEG1
@ MPEG1
Definition: mythcodeccontext.h:59
MythCodecContext::HEVC
@ HEVC
Definition: mythcodeccontext.h:96
MythCodecContext::RetrieveHWFrame
virtual bool RetrieveHWFrame(MythVideoFrame *Frame, AVFrame *AvFrame)
Definition: mythcodeccontext.cpp:625
MythCodecContext::AV1
@ AV1
Definition: mythcodeccontext.h:118
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
codec_is_mediacodec_dec
#define codec_is_mediacodec_dec(id)
Definition: mythcodecid.h:325
MythMediaCodecContext::GetBestSupportedCodec
static MythCodecID GetBestSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Definition: mythmediacodeccontext.cpp:210
uint
unsigned int uint
Definition: compat.h:140
MythCodecContext::m_parent
DecoderBase * m_parent
Definition: mythcodeccontext.h:169
MythCodecContext::MPEG4SimpleFace
@ MPEG4SimpleFace
Definition: mythcodeccontext.h:74
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythCodecContext::MPEG2Spatial
@ MPEG2Spatial
Definition: mythcodeccontext.h:65
mythmediacodeccontext.h
MythV4L2M2MContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Definition: mythv4l2m2mcontext.cpp:52
MythCodecContext::IsUnsupportedProfile
static bool IsUnsupportedProfile(AVCodecContext *Context)
Most hardware decoders do not support these codecs/profiles.
Definition: mythcodeccontext.cpp:595
MythCodecContext::MPEG2
@ MPEG2
Definition: mythcodeccontext.h:60
MythCodecContext::VP9_3HDR
@ VP9_3HDR
Definition: mythcodeccontext.h:116
MythAVUtil::PixelFormatToFrameType
static VideoFrameType PixelFormatToFrameType(AVPixelFormat Fmt)
Definition: mythavutil.cpp:70
MythCodecContext::H264High444
@ H264High444
Definition: mythcodeccontext.h:94
MythCodecContext::FilteredReceiveFrame
virtual int FilteredReceiveFrame(AVCodecContext *Context, AVFrame *Frame)
Retrieve and process/filter AVFrame.
Definition: mythcodeccontext.cpp:620
MythCodecContext::HEVCMain10HDR
@ HEVCMain10HDR
Definition: mythcodeccontext.h:101
MythCodecContext::GetDecoderDescription
static QStringList GetDecoderDescription(void)
Definition: mythcodeccontext.cpp:115
codec_is_drmprime
#define codec_is_drmprime(id)
Definition: mythcodecid.h:296
MythInteropGPU::CreateDummy
static MythInteropGPU * CreateDummy()
Definition: mythinteropgpu.cpp:49
codec_is_dxva2
#define codec_is_dxva2(id)
Definition: mythcodecid.h:316
MythMediaCodecContext::HaveMediaCodec
static bool HaveMediaCodec(bool Reinit=false)
Definition: mythmediacodeccontext.cpp:499
MythVTBContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, uint StreamType)
Definition: mythvtbcontext.cpp:75
codec_is_vdpau_hw
#define codec_is_vdpau_hw(id)
Definition: mythcodecid.h:300
FreeAVHWDeviceContext
void(*)(struct AVHWDeviceContext *) FreeAVHWDeviceContext
Definition: mythinteropgpu.h:18
MythCodecContext::MPEG4NBit
@ MPEG4NBit
Definition: mythcodeccontext.h:72
MythVDPAUContext
Definition: mythvdpaucontext.h:7
MythCodecContext::CreateDecoderCallback
static void CreateDecoderCallback(void *Wait, void *Context, void *Callback)
Definition: mythcodeccontext.cpp:491
MythVideoFrame::FormatDescription
static QString FormatDescription(VideoFrameType Type)
Definition: mythframe.cpp:368
MythCodecContext::MPEG2Main
@ MPEG2Main
Definition: mythcodeccontext.h:62
MythCodecContext::VC1
@ VC1
Definition: mythcodeccontext.h:103
MythV4L2M2MContext
A handler for V4L2 Memory2Memory codecs.
Definition: mythv4l2m2mcontext.h:10
mythcorecontext.h
codec_is_vaapi_dec
#define codec_is_vaapi_dec(id)
Definition: mythcodecid.h:313
MythCodecContext::CreateDevice
static AVBufferRef * CreateDevice(AVHWDeviceType Type, MythInteropGPU *Interop, const QString &Device=QString())
Definition: mythcodeccontext.cpp:556
codec_is_vaapi
#define codec_is_vaapi(id)
Definition: mythcodecid.h:311
avformatdecoder.h
MythVideoFrame::m_swPixFmt
int m_swPixFmt
Definition: mythframe.h:145
MythNVDECContext::HaveNVDEC
static bool HaveNVDEC(bool Reinit=false)
Definition: mythnvdeccontext.cpp:512
codec_is_nvdec_dec
#define codec_is_nvdec_dec(id)
Definition: mythcodecid.h:330
mythnvdeccontext.h
MythCodecContext::FrameTypeIsSupported
static bool FrameTypeIsSupported(AVCodecContext *Context, VideoFrameType Format)
Definition: mythcodeccontext.cpp:512
mythmmalcontext.h
MythInteropGPU::GetTypes
static InteropMap GetTypes(MythRender *Render)
Definition: mythinteropgpu.cpp:10
MythRenderOpenGL::GetOpenGLRender
static MythRenderOpenGL * GetOpenGLRender(void)
Definition: mythrenderopengl.cpp:66
MythVideoFrame::GetNumPlanes
static uint GetNumPlanes(VideoFrameType Type)
Definition: mythframe.h:214
codec_is_v4l2
#define codec_is_v4l2(id)
Definition: mythcodecid.h:338
MythCodecContext::MPEG4BasicAnimated
@ MPEG4BasicAnimated
Definition: mythcodeccontext.h:75
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
MythCodecContext::MJPEG
@ MJPEG
Definition: mythcodeccontext.h:122
MythCodecContext::AV1Main
@ AV1Main
Definition: mythcodeccontext.h:119
DecoderBase::GetBestVideoFormat
static AVPixelFormat GetBestVideoFormat(AVPixelFormat *Formats, const VideoFrameTypes *RenderFormats)
Find a suitable frame format that is mutually acceptable to the decoder and render device.
Definition: decoderbase.cpp:1448
VideoBuffers::ReinitBuffer
static bool ReinitBuffer(MythVideoFrame *Frame, VideoFrameType Type, MythCodecID CodecID, int Width, int Height)
Definition: videobuffers.cpp:981
mythcodeccontext.h
LOC
#define LOC
Definition: mythcodeccontext.cpp:63
MythCodecContext::MPEG4Hybrid
@ MPEG4Hybrid
Definition: mythcodeccontext.h:76
FMT_MMAL
@ FMT_MMAL
Definition: mythframe.h:60
MythCodecContext
Definition: mythcodeccontext.h:53
VideoFrameType
VideoFrameType
Definition: mythframe.h:20
MythCodecContext::H264High
@ H264High
Definition: mythcodeccontext.h:90
MythCodecContext::GetProfileDescription
static QString GetProfileDescription(CodecProfile Profile, QSize Size, VideoFrameType Format=FMT_NONE, uint ColorDepth=0)
Definition: mythcodeccontext.cpp:783
codec_is_vtb
#define codec_is_vtb(id)
Definition: mythcodecid.h:333
MythCodecContext::VP9_2HDR
@ VP9_2HDR
Definition: mythcodeccontext.h:114
MythCodecContext::MPEG4AdvancedRT
@ MPEG4AdvancedRT
Definition: mythcodeccontext.h:77
MythInteropGPU::SetDefaultUserOpaque
void SetDefaultUserOpaque(void *UserOpaque)
Definition: mythinteropgpu.cpp:89
MythInteropGPU::SetDefaultFree
void SetDefaultFree(FreeAVHWDeviceContext FreeContext)
Definition: mythinteropgpu.cpp:84
MythVideoFrame
Definition: mythframe.h:88
mythdrmprimecontext.h
MythMMALContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **Context, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Definition: mythmmalcontext.cpp:40
codec_is_vdpau_dechw
#define codec_is_vdpau_dechw(id)
Definition: mythcodecid.h:306
MythCodecContext::GetDecoders
static void GetDecoders(RenderOptions &Opts, bool Reinit=false)
Definition: mythcodeccontext.cpp:143
codec_is_v4l2_dec
#define codec_is_v4l2_dec(id)
Definition: mythcodecid.h:339
ReferenceCounter::IncrRef
virtual int IncrRef(void)
Increments reference count.
Definition: referencecounter.cpp:101
mythmainwindow.h
MythMMALContext
Definition: mythmmalcontext.h:10
MythCodecContext::MPEG4Core
@ MPEG4Core
Definition: mythcodeccontext.h:70
MythCodecContext::H264ConstrainedHigh
@ H264ConstrainedHigh
Definition: mythcodeccontext.h:95
mythv4l2m2mcontext.h
MythCodecContext::HEVCMain
@ HEVCMain
Definition: mythcodeccontext.h:97
MythCodecContext::InitialiseDecoder
static int InitialiseDecoder(AVCodecContext *Context, CreateHWDecoder Callback, const QString &Debug)
Initialise a hardware decoder that is expected to use AVHWFramesContext.
Definition: mythcodeccontext.cpp:523
codec_is_vtb_dec
#define codec_is_vtb_dec(id)
Definition: mythcodecid.h:335
av_make_error_stdstring
char * av_make_error_stdstring(std::string &errbuf, int errnum)
Definition: mythaverror.cpp:41
DecoderBase
Definition: decoderbase.h:120
MythCodecContext::GetBuffer2
static bool GetBuffer2(struct AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame, int Flags)
A generic hardware buffer initialisation method when AVHWFramesContext is NOT used.
Definition: mythcodeccontext.cpp:373
MythCodecContext::GetPlayerUI
static MythPlayerUI * GetPlayerUI(AVCodecContext *Context)
Definition: mythcodeccontext.cpp:503
MythCodecContext::VP8
@ VP8
Definition: mythcodeccontext.h:108
MythMMALContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythmmalcontext.cpp:271
MythVideoFrame::m_priv
std::array< uint8_t *, 4 > m_priv
Definition: mythframe.h:133
MythVTBContext::HaveVTB
static bool HaveVTB(bool Reinit=false)
Definition: mythvtbcontext.cpp:239
MythCodecContext::H264High10
@ H264High10
Definition: mythcodeccontext.h:91
MythInteropGPU
Definition: mythinteropgpu.h:21
MythVideoFrame::m_buffer
uint8_t * m_buffer
Definition: mythframe.h:120
MythCodecContext::H264
@ H264
Definition: mythcodeccontext.h:85