MythTV  master
mythframe.h
Go to the documentation of this file.
1 #ifndef MYTHFRAME_H
2 #define MYTHFRAME_H
3 
4 #ifdef __cplusplus
5 #include <cstdint>
6 #include <cstring>
7 #else
8 #include <stdint.h>
9 #include <string.h>
10 #endif
11 #include "mythtvexp.h" // for MTV_PUBLIC
12 #include "mythaverror.h"
13 
14 extern "C" {
15 #include "libavcodec/avcodec.h"
16 }
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #define MYTH_WIDTH_ALIGNMENT 64
23 #define MYTH_HEIGHT_ALIGNMENT 16
25 {
26  FMT_NONE = -1,
27  // YV12 and variants
28  FMT_YV12 = 0,
34  // RGB variants
40  // YUV422P and variants
47  // YUV444P and variants
54  // Packed YUV
56  // NV12 and variants
60  // hardware formats
69 };
70 
71 const char* format_description(VideoFrameType Type);
72 
73 static inline bool format_is_hw(VideoFrameType Type)
74 {
75  return (Type == FMT_VDPAU) || (Type == FMT_VAAPI) ||
76  (Type == FMT_DXVA2) || (Type == FMT_MMAL) ||
77  (Type == FMT_MEDIACODEC) || (Type == FMT_VTB) ||
78  (Type == FMT_NVDEC) || (Type == FMT_DRMPRIME);
79 }
80 
81 static inline bool format_is_hwframes(VideoFrameType Type)
82 {
83  return (Type == FMT_VDPAU) || (Type == FMT_VAAPI) || (Type == FMT_NVDEC);
84 }
85 
86 static inline bool format_is_420(VideoFrameType Type)
87 {
88  return (Type == FMT_YV12) || (Type == FMT_YUV420P9) || (Type == FMT_YUV420P10) ||
89  (Type == FMT_YUV420P12) || (Type == FMT_YUV420P14) || (Type == FMT_YUV420P16);
90 }
91 
92 static inline bool format_is_422(VideoFrameType Type)
93 {
94  return (Type == FMT_YUV422P) || (Type == FMT_YUV422P9) || (Type == FMT_YUV422P10) ||
95  (Type == FMT_YUV422P12) || (Type == FMT_YUV422P14) || (Type == FMT_YUV422P16);
96 }
97 
98 static inline bool format_is_444(VideoFrameType Type)
99 {
100  return (Type == FMT_YUV444P) || (Type == FMT_YUV444P9) || (Type == FMT_YUV444P10) ||
101  (Type == FMT_YUV444P12) || (Type == FMT_YUV444P14) || (Type == FMT_YUV444P16);
102 
103 }
104 
105 static inline bool format_is_nv12(VideoFrameType Type)
106 {
107  return (Type == FMT_NV12) || (Type == FMT_P010) || (Type == FMT_P016);
108 }
109 
110 static inline bool format_is_packed(VideoFrameType Type)
111 {
112  return Type == FMT_YUY2;
113 }
114 
115 static inline bool format_is_yuv(VideoFrameType Type)
116 {
117  return format_is_420(Type) || format_is_422(Type) || format_is_444(Type) ||
118  format_is_nv12(Type) || format_is_packed(Type);
119 }
120 
122 {
123  DEINT_NONE = 0x0000,
124  DEINT_BASIC = 0x0001,
125  DEINT_MEDIUM = 0x0002,
126  DEINT_HIGH = 0x0004,
127  DEINT_CPU = 0x0010,
128  DEINT_SHADER = 0x0020,
129  DEINT_DRIVER = 0x0040,
130  DEINT_ALL = 0x0077
131 };
132 
133 inline MythDeintType operator| (MythDeintType a, MythDeintType b) { return static_cast<MythDeintType>(static_cast<int>(a) | static_cast<int>(b)); }
134 inline MythDeintType operator& (MythDeintType a, MythDeintType b) { return static_cast<MythDeintType>(static_cast<int>(a) & static_cast<int>(b)); }
135 inline MythDeintType operator~ (MythDeintType a) { return static_cast<MythDeintType>(~(static_cast<int>(a))); }
136 
138 {
140  unsigned char *buf;
141 
142  int width;
143  int height;
144  float aspect;
145  double frame_rate;
146  int bpp;
147  int size;
148  long long frameNumber;
149  long long frameCounter;
150  long long timecode;
151  int64_t disp_timecode;
152  unsigned char *priv[4];
156  bool new_gop;
158  bool forcekey;
159  bool dummy;
161  int pitches[3];
162  int offsets[3];
163  int pix_fmt;
173  int rotation;
179 };
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 int MTV_PUBLIC ColorDepth(int Format);
186 
187 #ifdef __cplusplus
188 
192 
193 enum class uswcState {
194  Detect,
195  Use_SSE,
196  Use_SW
197 };
198 
200 {
201 public:
202  explicit MythUSWCCopy(int width, bool nocache = false);
203  virtual ~MythUSWCCopy();
204 
205  void copy(VideoFrame *dst, const VideoFrame *src);
206  void reset(int width);
207  void resetUSWCDetection(void);
208  void setUSWC(bool uswc);
209 
210 private:
211  void allocateCache(int width);
212 
213  uint8_t* m_cache {nullptr};
214  int m_size {0};
216 };
217 
218 void MTV_PUBLIC framecopy(VideoFrame *dst, const VideoFrame *src,
219  bool useSSE = true);
220 
221 static inline void init(VideoFrame *vf, VideoFrameType _codec,
222  unsigned char *_buf, int _width, int _height, int _size,
223  const int *p = nullptr,
224  const int *o = nullptr,
225  float _aspect = -1.0F, double _rate = -1.0F,
226  int _aligned = MYTH_WIDTH_ALIGNMENT);
227 static inline void clear(VideoFrame *vf);
228 static inline int bitsperpixel(VideoFrameType type);
229 static inline int pitch_for_plane(VideoFrameType Type, int Width, uint Plane);
230 static inline int height_for_plane(VideoFrameType Type, int Height, uint Plane);
231 
232 static inline void init(VideoFrame *vf, VideoFrameType _codec,
233  unsigned char *_buf, int _width, int _height,
234  int _size, const int *p, const int *o,
235  float _aspect, double _rate, int _aligned)
236 {
237  vf->bpp = bitsperpixel(_codec);
238  vf->codec = _codec;
239  vf->buf = _buf;
240  vf->width = _width;
241  vf->height = _height;
242  vf->aspect = _aspect;
243  vf->frame_rate = _rate;
244  vf->size = _size;
245  vf->frameNumber = 0;
246  vf->frameCounter = 0;
247  vf->timecode = 0;
248  vf->interlaced_frame = 1;
249  vf->interlaced_reversed = false;
250  vf->new_gop = false;
251  vf->top_field_first = true;
252  vf->repeat_pict = false;
253  vf->forcekey = false;
254  vf->dummy = false;
255  vf->pause_frame = false;
256  vf->pix_fmt = 0;
257  vf->sw_pix_fmt = -1; // AV_PIX_FMT_NONE
258  vf->directrendering = true;
259  vf->colorspace = 1; // BT.709
260  vf->colorrange = 1; // normal/mpeg
261  vf->colorprimaries = 1; // BT.709
262  vf->colortransfer = 1; // BT.709
263  vf->chromalocation = 1; // default 4:2:0
264  vf->colorshifted = false;
265  vf->already_deinterlaced = false;
266  vf->rotation = 0;
271  vf->deinterlace_inuse2x = false;
272  memset(vf->priv, 0, 4 * sizeof(unsigned char *));
273 
274  int width_aligned = 0;
275  int height_aligned = (_height + MYTH_HEIGHT_ALIGNMENT - 1) & ~(MYTH_HEIGHT_ALIGNMENT -1);
276  if (!_aligned)
277  width_aligned = _width;
278  else
279  width_aligned = (_width + _aligned - 1) & ~(_aligned - 1);
280 
281  if (p)
282  {
283  memcpy(vf->pitches, p, 3 * sizeof(int));
284  }
285  else
286  {
287  for (uint i = 0; i < 3; ++i)
288  vf->pitches[i] = pitch_for_plane(_codec, width_aligned, i);
289  }
290 
291  if (o)
292  {
293  memcpy(vf->offsets, o, 3 * sizeof(int));
294  }
295  else
296  {
297  vf->offsets[0] = 0;
298  if (FMT_YV12 == _codec)
299  {
300  vf->offsets[1] = width_aligned * height_aligned;
301  vf->offsets[2] = vf->offsets[1] + ((width_aligned + 1) >> 1) * ((height_aligned+1) >> 1);
302  }
303  else if (format_is_420(_codec))
304  {
305  vf->offsets[1] = (width_aligned << 1) * height_aligned;
306  vf->offsets[2] = vf->offsets[1] + (width_aligned * (height_aligned >> 1));
307  }
308  else if (FMT_YUV422P == _codec)
309  {
310  vf->offsets[1] = width_aligned * height_aligned;
311  vf->offsets[2] = vf->offsets[1] + ((width_aligned + 1) >> 1) * height_aligned;
312  }
313  else if (format_is_422(_codec))
314  {
315  vf->offsets[1] = (width_aligned << 1) * height_aligned;
316  vf->offsets[2] = vf->offsets[1] + (width_aligned * height_aligned);
317  }
318  else if (FMT_YUV444P == _codec)
319  {
320  vf->offsets[1] = width_aligned * height_aligned;
321  vf->offsets[2] = vf->offsets[1] + (width_aligned * height_aligned);
322  }
323  else if (format_is_444(_codec))
324  {
325  vf->offsets[1] = (width_aligned << 1) * height_aligned;
326  vf->offsets[2] = vf->offsets[1] + ((width_aligned << 1) * height_aligned);
327  }
328  else if (FMT_NV12 == _codec)
329  {
330  vf->offsets[1] = width_aligned * height_aligned;
331  vf->offsets[2] = 0;
332  }
333  else if (format_is_nv12(_codec))
334  {
335  vf->offsets[1] = (width_aligned << 1) * height_aligned;
336  vf->offsets[2] = 0;
337  }
338  else
339  {
340  vf->offsets[1] = vf->offsets[2] = 0;
341  }
342  }
343 }
344 
345 static inline int pitch_for_plane(VideoFrameType Type, int Width, uint Plane)
346 {
347  switch (Type)
348  {
349  case FMT_YV12:
350  case FMT_YUV422P:
351  if (Plane == 0) return Width;
352  if (Plane < 3) return (Width + 1) >> 1;
353  break;
354  case FMT_YUV420P9:
355  case FMT_YUV420P10:
356  case FMT_YUV420P12:
357  case FMT_YUV420P14:
358  case FMT_YUV420P16:
359  case FMT_YUV422P9:
360  case FMT_YUV422P10:
361  case FMT_YUV422P12:
362  case FMT_YUV422P14:
363  case FMT_YUV422P16:
364  if (Plane == 0) return Width << 1;
365  if (Plane < 3) return Width;
366  break;
367  case FMT_YUV444P:
368  case FMT_YUV444P9:
369  case FMT_YUV444P10:
370  case FMT_YUV444P12:
371  case FMT_YUV444P14:
372  case FMT_YUV444P16:
373  if (Plane < 3) return Width;
374  break;
375  case FMT_NV12:
376  if (Plane < 2) return Width;
377  break;
378  case FMT_P010:
379  case FMT_P016:
380  if (Plane < 2) return Width << 1;
381  break;
382  case FMT_YUY2:
383  case FMT_RGB24:
384  case FMT_ARGB32:
385  case FMT_RGBA32:
386  case FMT_BGRA:
387  case FMT_RGB32:
388  if (Plane == 0) return (bitsperpixel(Type) * Width) >> 3;
389  break;
390  default: break; // None and hardware formats
391  }
392  return 0;
393 }
394 
395 static inline int width_for_plane(VideoFrameType Type, int Width, uint Plane)
396 {
397  switch (Type)
398  {
399  case FMT_YV12:
400  case FMT_YUV420P9:
401  case FMT_YUV420P10:
402  case FMT_YUV420P12:
403  case FMT_YUV420P14:
404  case FMT_YUV420P16:
405  case FMT_YUV422P:
406  case FMT_YUV422P9:
407  case FMT_YUV422P10:
408  case FMT_YUV422P12:
409  case FMT_YUV422P14:
410  case FMT_YUV422P16:
411  if (Plane == 0) return Width;
412  if (Plane < 3) return (Width + 1) >> 1;
413  break;
414  case FMT_YUV444P:
415  case FMT_YUV444P9:
416  case FMT_YUV444P10:
417  case FMT_YUV444P12:
418  case FMT_YUV444P14:
419  case FMT_YUV444P16:
420  if (Plane < 3) return Width;
421  break;
422  case FMT_NV12:
423  case FMT_P010:
424  case FMT_P016:
425  if (Plane < 2) return Width;
426  break;
427  case FMT_YUY2:
428  case FMT_RGB24:
429  case FMT_ARGB32:
430  case FMT_RGBA32:
431  case FMT_BGRA:
432  case FMT_RGB32:
433  if (Plane == 0) return Width;
434  break;
435  default: break; // None and hardware formats
436  }
437  return 0;
438 }
439 
440 static inline int height_for_plane(VideoFrameType Type, int Height, uint Plane)
441 {
442  switch (Type)
443  {
444  case FMT_YV12:
445  case FMT_YUV420P9:
446  case FMT_YUV420P10:
447  case FMT_YUV420P12:
448  case FMT_YUV420P14:
449  case FMT_YUV420P16:
450  if (Plane == 0) return Height;
451  if (Plane < 3) return Height >> 1;
452  break;
453  case FMT_YUV422P:
454  case FMT_YUV422P9:
455  case FMT_YUV422P10:
456  case FMT_YUV422P12:
457  case FMT_YUV422P14:
458  case FMT_YUV422P16:
459  case FMT_YUV444P:
460  case FMT_YUV444P9:
461  case FMT_YUV444P10:
462  case FMT_YUV444P12:
463  case FMT_YUV444P14:
464  case FMT_YUV444P16:
465  if (Plane < 3) return Height;
466  break;
467  case FMT_NV12:
468  case FMT_P010:
469  case FMT_P016:
470  if (Plane == 0) return Height;
471  if (Plane < 2) return Height >> 1;
472  break;
473  case FMT_YUY2:
474  case FMT_RGB24:
475  case FMT_ARGB32:
476  case FMT_RGBA32:
477  case FMT_BGRA:
478  case FMT_RGB32:
479  if (Plane == 0) return Height;
480  break;
481  default: break; // None and hardware formats
482  }
483  return 0;
484 }
485 static inline void clear(VideoFrame *vf)
486 {
487  if (!vf || (vf && !vf->buf))
488  return;
489 
490  // luma (or RGBA)
491  int uv_height = height_for_plane(vf->codec, vf->height, 1);
492  int uv = (1 << (ColorDepth(vf->codec) - 1)) - 1;
493  if (FMT_YV12 == vf->codec || FMT_YUV422P == vf->codec || FMT_YUV444P == vf->codec)
494  {
495  memset(vf->buf + vf->offsets[0], 0, static_cast<size_t>(vf->pitches[0] * vf->height));
496  memset(vf->buf + vf->offsets[1], uv & 0xff, static_cast<size_t>(vf->pitches[1] * uv_height));
497  memset(vf->buf + vf->offsets[2], uv & 0xff, static_cast<size_t>(vf->pitches[2] * uv_height));
498  }
499  else if ((format_is_420(vf->codec) || format_is_422(vf->codec) || format_is_444(vf->codec)) && (vf->pitches[1] == vf->pitches[2]))
500  {
501  memset(vf->buf + vf->offsets[0], 0, static_cast<size_t>(vf->pitches[0] * vf->height));
502  unsigned char uv1 = (uv & 0xff00) >> 8;
503  unsigned char uv2 = (uv & 0x00ff);
504  unsigned char* buf1 = vf->buf + vf->offsets[1];
505  unsigned char* buf2 = vf->buf + vf->offsets[2];
506  for (int row = 0; row < uv_height; ++row)
507  {
508  for (int col = 0; col < vf->pitches[1]; col += 2)
509  {
510  buf1[col] = buf2[col] = uv1;
511  buf1[col + 1] = buf2[col + 1] = uv2;
512  }
513  buf1 += vf->pitches[1];
514  buf2 += vf->pitches[2];
515  }
516  }
517  else if (FMT_NV12 == vf->codec)
518  {
519  memset(vf->buf + vf->offsets[0], 0, static_cast<size_t>(vf->pitches[0] * vf->height));
520  memset(vf->buf + vf->offsets[1], uv & 0xff, vf->pitches[1] * uv_height);
521  }
522  else if (format_is_nv12(vf->codec))
523  {
524  memset(vf->buf + vf->offsets[0], 0, static_cast<size_t>(vf->pitches[0] * vf->height));
525  unsigned char uv1 = (uv & 0xff00) >> 8;
526  unsigned char uv2 = (uv & 0x00ff);
527  unsigned char* buf = vf->buf + vf->offsets[1];
528  for (int row = 0; row < uv_height; ++row)
529  {
530  for (int col = 0; col < vf->pitches[1]; col += 4)
531  {
532  buf[col] = buf[col + 2] = uv1;
533  buf[col + 1] = buf[col + 3] = uv2;
534  }
535  buf += vf->pitches[1];
536  }
537  }
538 }
539 
540 static inline void copyplane(uint8_t* dst, int dst_pitch,
541  const uint8_t* src, int src_pitch,
542  int width, int height)
543 {
544  if ((dst_pitch == width) && (src_pitch == width))
545  {
546  memcpy(dst, src, static_cast<size_t>(width * height));
547  return;
548  }
549 
550  for (int y = 0; y < height; y++)
551  {
552  memcpy(dst, src, static_cast<size_t>(width));
553  src += src_pitch;
554  dst += dst_pitch;
555  }
556 }
557 
565 static inline void copy(VideoFrame *dst, const VideoFrame *src)
566 {
567  framecopy(dst, src, true);
568 }
569 
570 static inline uint planes(VideoFrameType Type)
571 {
572  switch (Type)
573  {
574  case FMT_YV12:
575  case FMT_YUV420P9:
576  case FMT_YUV420P10:
577  case FMT_YUV420P12:
578  case FMT_YUV420P14:
579  case FMT_YUV420P16:
580  case FMT_YUV422P:
581  case FMT_YUV422P9:
582  case FMT_YUV422P10:
583  case FMT_YUV422P12:
584  case FMT_YUV422P14:
585  case FMT_YUV422P16:
586  case FMT_YUV444P:
587  case FMT_YUV444P9:
588  case FMT_YUV444P10:
589  case FMT_YUV444P12:
590  case FMT_YUV444P14:
591  case FMT_YUV444P16: return 3;
592  case FMT_P010:
593  case FMT_P016:
594  case FMT_NV12: return 2;
595  case FMT_YUY2:
596  case FMT_BGRA:
597  case FMT_ARGB32:
598  case FMT_RGB24:
599  case FMT_RGB32:
600  case FMT_RGBA32: return 1;
601  case FMT_NONE:
602  case FMT_VDPAU:
603  case FMT_VAAPI:
604  case FMT_DXVA2:
605  case FMT_MEDIACODEC:
606  case FMT_NVDEC:
607  case FMT_MMAL:
608  case FMT_DRMPRIME:
609  case FMT_VTB: return 0;
610  }
611  return 0;
612 }
613 
614 static inline int bitsperpixel(VideoFrameType Type)
615 {
616  switch (Type)
617  {
618  case FMT_BGRA:
619  case FMT_RGBA32:
620  case FMT_ARGB32:
621  case FMT_RGB32:
622  case FMT_YUV422P9:
623  case FMT_YUV422P10:
624  case FMT_YUV422P12:
625  case FMT_YUV422P14:
626  case FMT_YUV422P16: return 32;
627  case FMT_RGB24: return 24;
628  case FMT_YUV422P:
629  case FMT_YUY2: return 16;
630  case FMT_YV12:
631  case FMT_NV12: return 12;
632  case FMT_YUV444P:
633  case FMT_P010:
634  case FMT_P016:
635  case FMT_YUV420P9:
636  case FMT_YUV420P10:
637  case FMT_YUV420P12:
638  case FMT_YUV420P14:
639  case FMT_YUV420P16: return 24;
640  case FMT_YUV444P9:
641  case FMT_YUV444P10:
642  case FMT_YUV444P12:
643  case FMT_YUV444P14:
644  case FMT_YUV444P16: return 48;
645  case FMT_NONE:
646  case FMT_VDPAU:
647  case FMT_VAAPI:
648  case FMT_DXVA2:
649  case FMT_MMAL:
650  case FMT_MEDIACODEC:
651  case FMT_NVDEC:
652  case FMT_DRMPRIME:
653  case FMT_VTB: break;
654  }
655  return 8;
656 }
657 
658 static inline size_t GetBufferSize(VideoFrameType Type, int Width, int Height,
659  int Aligned = MYTH_WIDTH_ALIGNMENT)
660 {
661  int type_bpp = bitsperpixel(Type);
662  int bpp = type_bpp / 4; /* bits per pixel div common factor */
663  int bpb = 8 / 4; /* bits per byte div common factor */
664 
665  // make sure all our pitches are a multiple of 16 bytes
666  // as U and V channels are half the size of Y channel
667  // This allow for SSE/HW accelerated code on all planes
668  // If the buffer sizes are not 32 bytes aligned, adjust.
669  // old versions of MythTV allowed people to set invalid
670  // dimensions for MPEG-4 capture, no need to segfault..
671  int adj_w = Aligned ? ((Width + Aligned - 1) & ~(Aligned - 1)) : Width;
672  int adj_h = (Height + MYTH_HEIGHT_ALIGNMENT - 1) & ~(MYTH_HEIGHT_ALIGNMENT - 1);
673 
674  // Calculate rounding as necessary.
675  int remainder = (adj_w * adj_h * bpp) % bpb;
676  return static_cast<uint>((adj_w * adj_h * bpp) / bpb + (remainder ? 1 : 0));
677 }
678 
679 static inline unsigned char* GetAlignedBuffer(size_t Size)
680 {
681  return static_cast<unsigned char*>(av_malloc(Size + 64));
682 }
683 
684 static inline unsigned char* GetAlignedBufferZero(size_t Size)
685 {
686  return static_cast<unsigned char*>(av_mallocz(Size + 64));
687 }
688 
689 static inline unsigned char* CreateBuffer(VideoFrameType Type, int Width, int Height)
690 {
691  size_t size = GetBufferSize(Type, Width, Height);
692  return GetAlignedBuffer(size);
693 }
694 
695 static inline unsigned char* CreateBufferZero(VideoFrameType Type, int Width, int Height)
696 {
697  size_t size = GetBufferSize(Type, Width, Height);
698  return GetAlignedBufferZero(size);
699 }
700 
701 static inline void copybuffer(VideoFrame *dst, uint8_t *buffer,
702  int pitch, VideoFrameType type = FMT_YV12)
703 {
704  if (type == FMT_YV12)
705  {
706  VideoFrame framein {};
707  int chroma_pitch = pitch >> 1;
708  int chroma_height = dst->height >> 1;
709  int offsets[3] =
710  { 0,
711  pitch * dst->height,
712  pitch * dst->height + chroma_pitch * chroma_height };
713  int pitches[3] = { pitch, chroma_pitch, chroma_pitch };
714 
715  init(&framein, type, buffer, dst->width, dst->height, dst->size,
716  pitches, offsets);
717  copy(dst, &framein);
718  }
719  else if (type == FMT_NV12)
720  {
721  VideoFrame framein {};
722  int offsets[3] = { 0, pitch * dst->height, 0 };
723  int pitches[3] = { pitch, pitch, 0 };
724 
725  init(&framein, type, buffer, dst->width, dst->height, dst->size,
726  pitches, offsets);
727  copy(dst, &framein);
728  }
729 }
730 
731 static inline void copybuffer(uint8_t *dstbuffer, const VideoFrame *src,
732  int pitch = 0, VideoFrameType type = FMT_YV12)
733 {
734  if (pitch == 0)
735  pitch = src->width;
736 
737  if (type == FMT_YV12)
738  {
739  VideoFrame frameout {};
740  int chroma_pitch = pitch >> 1;
741  int chroma_height = src->height >> 1;
742  int offsets[3] =
743  { 0,
744  pitch * src->height,
745  pitch * src->height + chroma_pitch * chroma_height };
746  int pitches[3] = { pitch, chroma_pitch, chroma_pitch };
747 
748  init(&frameout, type, dstbuffer, src->width, src->height, src->size,
749  pitches, offsets);
750  copy(&frameout, src);
751  }
752  else if (type == FMT_NV12)
753  {
754  VideoFrame frameout {};
755  int offsets[3] = { 0, pitch * src->height, 0 };
756  int pitches[3] = { pitch, pitch, 0 };
757 
758  init(&frameout, type, dstbuffer, src->width, src->height, src->size,
759  pitches, offsets);
760  copy(&frameout, src);
761  }
762 }
763 #endif /* __cplusplus */
764 
765 #endif /* MYTHFRAME_H */
FMT_MEDIACODEC
@ FMT_MEDIACODEC
Definition: mythframe.h:65
copybuffer
static void copybuffer(VideoFrame *dst, uint8_t *buffer, int pitch, VideoFrameType type=FMT_YV12)
Definition: mythframe.h:701
DEINT_DRIVER
@ DEINT_DRIVER
Definition: mythframe.h:129
VideoFrame::bpp
int bpp
Definition: mythframe.h:146
CreateBufferZero
static unsigned char * CreateBufferZero(VideoFrameType Type, int Width, int Height)
Definition: mythframe.h:695
DEINT_MEDIUM
@ DEINT_MEDIUM
Definition: mythframe.h:125
VideoFrame::forcekey
bool forcekey
hardware encoded .nuv
Definition: mythframe.h:158
format_is_444
static bool format_is_444(VideoFrameType Type)
Definition: mythframe.h:98
FMT_YUV420P10
@ FMT_YUV420P10
Definition: mythframe.h:30
GetSingleRateOption
MythDeintType MTV_PUBLIC GetSingleRateOption(const VideoFrame *Frame, MythDeintType Type, MythDeintType Override=DEINT_NONE)
Definition: mythframe.cpp:834
GetBufferSize
static size_t GetBufferSize(VideoFrameType Type, int Width, int Height, int Aligned=MYTH_WIDTH_ALIGNMENT)
Definition: mythframe.h:658
FMT_YUV420P16
@ FMT_YUV420P16
Definition: mythframe.h:33
VideoFrame::pitches
int pitches[3]
Y, U, & V pitches.
Definition: mythframe.h:161
FMT_VTB
@ FMT_VTB
Definition: mythframe.h:66
DEINT_SHADER
@ DEINT_SHADER
Definition: mythframe.h:128
FMT_YUV420P14
@ FMT_YUV420P14
Definition: mythframe.h:32
FMT_DRMPRIME
@ FMT_DRMPRIME
Definition: mythframe.h:68
FMT_YUV444P10
@ FMT_YUV444P10
Definition: mythframe.h:50
format_is_420
static bool format_is_420(VideoFrameType Type)
Definition: mythframe.h:86
FMT_YUV422P14
@ FMT_YUV422P14
Definition: mythframe.h:45
framecopy
void MTV_PUBLIC framecopy(VideoFrame *dst, const VideoFrame *src, bool useSSE=true)
Definition: mythframe.cpp:322
mythtvexp.h
Frame
Definition: zmdefines.h:93
VideoFrame::timecode
long long timecode
Definition: mythframe.h:150
operator|
MythDeintType operator|(MythDeintType a, MythDeintType b)
Definition: mythframe.h:133
FMT_P010
@ FMT_P010
Definition: mythframe.h:58
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:123
operator~
MythDeintType operator~(MythDeintType a)
Definition: mythframe.h:135
MythDate::Format
Format
Definition: mythdate.h:12
FMT_YUV422P
@ FMT_YUV422P
Definition: mythframe.h:41
VideoFrame::buf
unsigned char * buf
Definition: mythframe.h:140
DEINT_ALL
@ DEINT_ALL
Definition: mythframe.h:130
VideoFrame
Definition: mythframe.h:137
VideoFrame::interlaced_reversed
bool interlaced_reversed
Definition: mythframe.h:155
VideoFrame::new_gop
bool new_gop
true for user override of scan
Definition: mythframe.h:156
VideoFrame::deinterlace_single
MythDeintType deinterlace_single
Definition: mythframe.h:174
pitch_for_plane
static int pitch_for_plane(VideoFrameType Type, int Width, uint Plane)
Definition: mythframe.h:345
MythUSWCCopy
Definition: mythframe.h:199
format_is_hwframes
static bool format_is_hwframes(VideoFrameType Type)
Definition: mythframe.h:81
MYTH_HEIGHT_ALIGNMENT
#define MYTH_HEIGHT_ALIGNMENT
Definition: mythframe.h:23
FMT_YUV444P14
@ FMT_YUV444P14
Definition: mythframe.h:52
FMT_YUV444P
@ FMT_YUV444P
Definition: mythframe.h:48
VideoFrame::codec
VideoFrameType codec
Definition: mythframe.h:139
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:26
VideoFrame::colorrange
int colorrange
Definition: mythframe.h:167
bitsperpixel
static int bitsperpixel(VideoFrameType type)
Definition: mythframe.h:614
DEINT_CPU
@ DEINT_CPU
Definition: mythframe.h:127
format_description
const char * format_description(VideoFrameType Type)
Definition: mythframe.cpp:33
VideoFrame::repeat_pict
bool repeat_pict
used to unlock the scan type
Definition: mythframe.h:157
format_is_hw
static bool format_is_hw(VideoFrameType Type)
Definition: mythframe.h:73
VideoFrame::rotation
int rotation
Definition: mythframe.h:173
copy
static void copy(VideoFrame *dst, const VideoFrame *src)
copy: copy one frame into another copy only works with the following assumptions: frames are of the s...
Definition: mythframe.h:565
VideoFrame::dummy
bool dummy
Definition: mythframe.h:159
VideoFrame::interlaced_frame
int interlaced_frame
1 if interlaced. 0 if not interlaced. -1 if unknown.
Definition: mythframe.h:153
VideoFrame::deinterlace_inuse2x
bool deinterlace_inuse2x
Definition: mythframe.h:178
format_is_packed
static bool format_is_packed(VideoFrameType Type)
Definition: mythframe.h:110
VideoFrame::deinterlace_inuse
MythDeintType deinterlace_inuse
Definition: mythframe.h:177
hardwareprofile.config.p
p
Definition: config.py:33
FMT_YUV444P9
@ FMT_YUV444P9
Definition: mythframe.h:49
FMT_YV12
@ FMT_YV12
Definition: mythframe.h:28
FMT_YUV422P10
@ FMT_YUV422P10
Definition: mythframe.h:43
FMT_YUV444P16
@ FMT_YUV444P16
Definition: mythframe.h:53
copyplane
static void copyplane(uint8_t *dst, int dst_pitch, const uint8_t *src, int src_pitch, int width, int height)
Definition: mythframe.h:540
VideoFrame::colorprimaries
int colorprimaries
Definition: mythframe.h:168
format_is_yuv
static bool format_is_yuv(VideoFrameType Type)
Definition: mythframe.h:115
FMT_BGRA
@ FMT_BGRA
Definition: mythframe.h:36
VideoFrame::pause_frame
bool pause_frame
Definition: mythframe.h:160
format_is_nv12
static bool format_is_nv12(VideoFrameType Type)
Definition: mythframe.h:105
VideoFrame::aspect
float aspect
Definition: mythframe.h:144
FMT_YUV420P12
@ FMT_YUV420P12
Definition: mythframe.h:31
MYTH_WIDTH_ALIGNMENT
#define MYTH_WIDTH_ALIGNMENT
Definition: mythframe.h:22
VideoFrame::top_field_first
bool top_field_first
true if top field is first.
Definition: mythframe.h:154
VideoFrame::deinterlace_allowed
MythDeintType deinterlace_allowed
Definition: mythframe.h:176
uswcState::Use_SSE
@ Use_SSE
VideoFrame::colortransfer
int colortransfer
Definition: mythframe.h:169
VideoFrame::sw_pix_fmt
int sw_pix_fmt
Definition: mythframe.h:164
uswcState
uswcState
Definition: mythframe.h:193
init
static void init(VideoFrame *vf, VideoFrameType _codec, unsigned char *_buf, int _width, int _height, int _size, const int *p=nullptr, const int *o=nullptr, float _aspect=-1.0F, double _rate=-1.0F, int _aligned=MYTH_WIDTH_ALIGNMENT)
Definition: mythframe.h:232
VideoFrame::priv
unsigned char * priv[4]
random empty storage
Definition: mythframe.h:152
uint
unsigned int uint
Definition: compat.h:140
VideoFrame::pix_fmt
int pix_fmt
Definition: mythframe.h:163
VideoFrame::colorshifted
bool colorshifted
false for software decoded 10/12/16bit frames. true for hardware decoders.
Definition: mythframe.h:171
operator&
MythDeintType operator&(MythDeintType a, MythDeintType b)
Definition: mythframe.h:134
VideoFrame::chromalocation
int chromalocation
Definition: mythframe.h:170
FMT_YUV444P12
@ FMT_YUV444P12
Definition: mythframe.h:51
FMT_ARGB32
@ FMT_ARGB32
Definition: mythframe.h:38
VideoFrame::disp_timecode
int64_t disp_timecode
Definition: mythframe.h:151
VideoFrame::colorspace
int colorspace
Definition: mythframe.h:166
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
FMT_NVDEC
@ FMT_NVDEC
Definition: mythframe.h:67
FMT_YUV422P9
@ FMT_YUV422P9
Definition: mythframe.h:42
MythDeintType
MythDeintType
Definition: mythframe.h:121
VideoFrame::offsets
int offsets[3]
Y, U, & V offsets.
Definition: mythframe.h:162
FMT_YUV420P9
@ FMT_YUV420P9
Definition: mythframe.h:29
planes
static uint planes(VideoFrameType Type)
Definition: mythframe.h:570
width_for_plane
static int width_for_plane(VideoFrameType Type, int Width, uint Plane)
Definition: mythframe.h:395
FMT_VDPAU
@ FMT_VDPAU
Definition: mythframe.h:61
FMT_YUV422P16
@ FMT_YUV422P16
Definition: mythframe.h:46
FMT_YUY2
@ FMT_YUY2
Definition: mythframe.h:55
clear
static void clear(VideoFrame *vf)
Definition: mythframe.h:485
VideoFrame::frame_rate
double frame_rate
Definition: mythframe.h:145
FMT_DXVA2
@ FMT_DXVA2
Definition: mythframe.h:63
FMT_RGB24
@ FMT_RGB24
Definition: mythframe.h:35
FMT_YUV422P12
@ FMT_YUV422P12
Definition: mythframe.h:44
DEINT_HIGH
@ DEINT_HIGH
Definition: mythframe.h:126
height_for_plane
static int height_for_plane(VideoFrameType Type, int Height, uint Plane)
Definition: mythframe.h:440
uswcState::Detect
@ Detect
VideoFrame::height
int height
Definition: mythframe.h:143
VideoFrame::frameNumber
long long frameNumber
Definition: mythframe.h:148
VideoFrame::already_deinterlaced
bool already_deinterlaced
temporary? TODO move scan detection/tracking into decoder
Definition: mythframe.h:172
CreateBuffer
static unsigned char * CreateBuffer(VideoFrameType Type, int Width, int Height)
Definition: mythframe.h:689
av_malloc
void * av_malloc(unsigned int size)
FMT_RGB32
@ FMT_RGB32
endian dependent format, ARGB or BGRA
Definition: mythframe.h:37
FMT_MMAL
@ FMT_MMAL
Definition: mythframe.h:64
format_is_422
static bool format_is_422(VideoFrameType Type)
Definition: mythframe.h:92
VideoFrameType
VideoFrameType
Definition: mythframe.h:24
FMT_VAAPI
@ FMT_VAAPI
Definition: mythframe.h:62
GetDoubleRateOption
MythDeintType MTV_PUBLIC GetDoubleRateOption(const VideoFrame *Frame, MythDeintType Type, MythDeintType Override=DEINT_NONE)
Definition: mythframe.cpp:847
VideoFrame::frameCounter
long long frameCounter
raw frame counter/ticker for discontinuity checks
Definition: mythframe.h:149
FMT_NV12
@ FMT_NV12
Definition: mythframe.h:57
DEINT_BASIC
@ DEINT_BASIC
Definition: mythframe.h:124
VideoFrame::size
int size
Definition: mythframe.h:147
FMT_P016
@ FMT_P016
Definition: mythframe.h:59
GetAlignedBufferZero
static unsigned char * GetAlignedBufferZero(size_t Size)
Definition: mythframe.h:684
uswcState::Use_SW
@ Use_SW
VideoFrame::deinterlace_double
MythDeintType deinterlace_double
Definition: mythframe.h:175
GetAlignedBuffer
static unsigned char * GetAlignedBuffer(size_t Size)
Definition: mythframe.h:679
ColorDepth
int MTV_PUBLIC ColorDepth(int Format)
Return the color depth for the given MythTV frame format.
Definition: mythframe.cpp:808
mythaverror.h
VideoFrame::width
int width
Definition: mythframe.h:142
VideoFrame::directrendering
bool directrendering
true if managed by FFmpeg
Definition: mythframe.h:165
FMT_RGBA32
@ FMT_RGBA32
Definition: mythframe.h:39
GetDeinterlacer
MythDeintType MTV_PUBLIC GetDeinterlacer(MythDeintType Option)
Definition: mythframe.cpp:860