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