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.

125 lines
3.6KB

  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 "avcodec.h"
  28. #include "dsputil.h"
  29. #include "get_bits.h"
  30. #include "dv_profile.h"
  31. typedef struct DVVideoContext {
  32. const DVprofile *sys;
  33. AVFrame picture;
  34. AVCodecContext *avctx;
  35. uint8_t *buf;
  36. uint8_t dv_zigzag[2][64];
  37. void (*get_pixels)(DCTELEM *block, const uint8_t *pixels, int line_size);
  38. void (*fdct[2])(DCTELEM *block);
  39. void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block);
  40. me_cmp_func ildct_cmp;
  41. } DVVideoContext;
  42. enum dv_section_type {
  43. dv_sect_header = 0x1f,
  44. dv_sect_subcode = 0x3f,
  45. dv_sect_vaux = 0x56,
  46. dv_sect_audio = 0x76,
  47. dv_sect_video = 0x96,
  48. };
  49. enum dv_pack_type {
  50. dv_header525 = 0x3f, /* see dv_write_pack for important details on */
  51. dv_header625 = 0xbf, /* these two packs */
  52. dv_timecode = 0x13,
  53. dv_audio_source = 0x50,
  54. dv_audio_control = 0x51,
  55. dv_audio_recdate = 0x52,
  56. dv_audio_rectime = 0x53,
  57. dv_video_source = 0x60,
  58. dv_video_control = 0x61,
  59. dv_video_recdate = 0x62,
  60. dv_video_rectime = 0x63,
  61. dv_unknown_pack = 0xff,
  62. };
  63. extern const uint8_t ff_dv_quant_shifts[22][4];
  64. extern const uint8_t ff_dv_quant_offset[4];
  65. extern const int ff_dv_iweight_88[64];
  66. extern const int ff_dv_iweight_248[64];
  67. extern const int ff_dv_iweight_1080_y[64];
  68. extern const int ff_dv_iweight_1080_c[64];
  69. extern const int ff_dv_iweight_720_y[64];
  70. extern const int ff_dv_iweight_720_c[64];
  71. #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
  72. #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1))
  73. #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1))
  74. /**
  75. * largest possible DV frame, in bytes (1080i50)
  76. */
  77. #define DV_MAX_FRAME_SIZE 576000
  78. /**
  79. * maximum number of blocks per macroblock in any DV format
  80. */
  81. #define DV_MAX_BPM 8
  82. #define TEX_VLC_BITS 9
  83. extern RL_VLC_ELEM ff_dv_rl_vlc[1184];
  84. int ff_dv_init_dynamic_tables(const DVprofile *d);
  85. int ff_dvvideo_init(AVCodecContext *avctx);
  86. static inline int dv_work_pool_size(const DVprofile *d)
  87. {
  88. int size = d->n_difchan*d->difseg_size*27;
  89. if (DV_PROFILE_IS_1080i50(d))
  90. size -= 3*27;
  91. if (DV_PROFILE_IS_720p50(d))
  92. size -= 4*27;
  93. return size;
  94. }
  95. static inline void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y)
  96. {
  97. *mb_x = work_chunk->mb_coordinates[m] & 0xff;
  98. *mb_y = work_chunk->mb_coordinates[m] >> 8;
  99. /* We work with 720p frames split in half. The odd half-frame (chan==2,3) is displaced :-( */
  100. if (s->sys->height == 720 && !(s->buf[1]&0x0C)) {
  101. *mb_y -= (*mb_y>17)?18:-72; /* shifting the Y coordinate down by 72/2 macro blocks */
  102. }
  103. }
  104. #endif /* AVCODEC_DVDATA_H */