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