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