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.

74 lines
3.3KB

  1. /*
  2. * DV format muxer/demuxer
  3. * Copyright (c) 2003 Roman Shaposhnik
  4. *
  5. * Many thanks to Dan Dennedy <dan@dennedy.org> for providing wealth
  6. * of DV technical info.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <time.h>
  23. #include "avformat.h"
  24. /*
  25. * DVprofile is used to express the differences between various
  26. * DV flavors. For now it's primarily used for differentiating
  27. * 525/60 and 625/50, but the plans are to use it for various
  28. * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
  29. */
  30. typedef struct DVprofile {
  31. int dsf; /* value of the dsf in the DV header */
  32. int frame_size; /* total size of one frame in bytes */
  33. int difseg_size; /* number of DIF segments */
  34. int frame_rate;
  35. int frame_rate_base;
  36. int ltc_divisor; /* FPS from the LTS standpoint */
  37. int height; /* picture height in pixels */
  38. uint16_t *video_place; /* positions of all DV macro blocks */
  39. int audio_stride; /* size of audio_shuffle table */
  40. int audio_min_samples[3]; /* min ammount of audio samples */
  41. /* for 48Khz, 44.1Khz and 32Khz */
  42. int audio_samples_dist[5];/* how many samples are supposed to be */
  43. /* in each frame in a 5 frames window */
  44. const uint16_t (*audio_shuffle)[9]; /* PCM shuffling table */
  45. } DVprofile;
  46. typedef struct DVMuxContext {
  47. const DVprofile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */
  48. uint8_t frame_buf[144000]; /* frame under contruction */
  49. FifoBuffer audio_data; /* Fifo for storing excessive amounts of PCM */
  50. int frames; /* Number of a current frame */
  51. time_t start_time; /* Start time of recording */
  52. uint8_t aspect; /* Aspect ID 0 - 4:3, 7 - 16:9 */
  53. int ast, vst; /* Audio and Video stream indecies */
  54. int has_audio; /* frame under contruction has audio */
  55. int has_video; /* frame under contruction has video */
  56. } DVMuxContext;
  57. void dv_format_frame(DVMuxContext *, uint8_t*);
  58. void dv_inject_audio(DVMuxContext *, const uint8_t*, uint8_t*);
  59. void dv_inject_video(DVMuxContext *, const uint8_t*, uint8_t*);
  60. int dv_extract_audio(uint8_t*, uint8_t*, AVCodecContext*);
  61. int dv_audio_frame_size(const DVprofile*, int);
  62. void dv_assemble_frame(DVMuxContext *c, const uint8_t*, const uint8_t*, int);
  63. int dv_core_init(DVMuxContext *, AVStream*[]);
  64. void dv_core_delete(DVMuxContext *);
  65. const DVprofile* dv_frame_profile(uint8_t*);