You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.5KB

  1. /*
  2. * Constants for DV codec
  3. * Copyright (c) 2002 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * Constants for DV codec.
  24. */
  25. #ifndef AVCODEC_DVDATA_H
  26. #define AVCODEC_DVDATA_H
  27. #include "libavutil/rational.h"
  28. #include "avcodec.h"
  29. typedef struct DVwork_chunk {
  30. uint16_t buf_offset;
  31. uint16_t mb_coordinates[5];
  32. } DVwork_chunk;
  33. /*
  34. * DVprofile is used to express the differences between various
  35. * DV flavors. For now it's primarily used for differentiating
  36. * 525/60 and 625/50, but the plans are to use it for various
  37. * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
  38. */
  39. typedef struct DVprofile {
  40. int dsf; /* value of the dsf in the DV header */
  41. int video_stype; /* stype for VAUX source pack */
  42. int frame_size; /* total size of one frame in bytes */
  43. int difseg_size; /* number of DIF segments per DIF channel */
  44. int n_difchan; /* number of DIF channels per frame */
  45. AVRational time_base; /* 1/framerate */
  46. int ltc_divisor; /* FPS from the LTS standpoint */
  47. int height; /* picture height in pixels */
  48. int width; /* picture width in pixels */
  49. AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */
  50. DVwork_chunk *work_chunks; /* each thread gets its own chunk of frame to work on */
  51. uint32_t *idct_factor; /* set of iDCT factor tables */
  52. enum PixelFormat pix_fmt; /* picture pixel format */
  53. int bpm; /* blocks per macroblock */
  54. const uint8_t *block_sizes; /* AC block sizes, in bits */
  55. int audio_stride; /* size of audio_shuffle table */
  56. int audio_min_samples[3]; /* min amount of audio samples */
  57. /* for 48kHz, 44.1kHz and 32kHz */
  58. int audio_samples_dist[5]; /* how many samples are supposed to be */
  59. /* in each frame in a 5 frames window */
  60. const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */
  61. } DVprofile;
  62. enum dv_section_type {
  63. dv_sect_header = 0x1f,
  64. dv_sect_subcode = 0x3f,
  65. dv_sect_vaux = 0x56,
  66. dv_sect_audio = 0x76,
  67. dv_sect_video = 0x96,
  68. };
  69. enum dv_pack_type {
  70. dv_header525 = 0x3f, /* see dv_write_pack for important details on */
  71. dv_header625 = 0xbf, /* these two packs */
  72. dv_timecode = 0x13,
  73. dv_audio_source = 0x50,
  74. dv_audio_control = 0x51,
  75. dv_audio_recdate = 0x52,
  76. dv_audio_rectime = 0x53,
  77. dv_video_source = 0x60,
  78. dv_video_control = 0x61,
  79. dv_video_recdate = 0x62,
  80. dv_video_rectime = 0x63,
  81. dv_unknown_pack = 0xff,
  82. };
  83. #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
  84. #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1))
  85. #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1))
  86. /* minimum number of bytes to read from a DV stream in order to
  87. determine the profile */
  88. #define DV_PROFILE_BYTES (6*80) /* 6 DIF blocks */
  89. /**
  90. * largest possible DV frame, in bytes (1080i50)
  91. */
  92. #define DV_MAX_FRAME_SIZE 576000
  93. /**
  94. * maximum number of blocks per macroblock in any DV format
  95. */
  96. #define DV_MAX_BPM 8
  97. const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,
  98. const uint8_t* frame, unsigned buf_size);
  99. const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys,
  100. const uint8_t* frame, unsigned buf_size);
  101. const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec);
  102. #endif /* AVCODEC_DVDATA_H */