- AVFormatContext* fctx;
- AVStream* vst;
- AVStream* ast[2];
- AVPacket audio_pkt[2];
- uint8_t audio_buf[2][8192];
- int ach;
- int frames;
- uint64_t abytes;
-};
-
-struct DVMuxContext {
- const DVprofile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */
- int n_ast; /* Number of stereo audio streams (up to 2) */
- AVStream *ast[2]; /* Stereo audio streams */
- FifoBuffer audio_data[2]; /* Fifo for storing excessive amounts of PCM */
- int frames; /* Number of a current frame */
- time_t start_time; /* Start time of recording */
- uint8_t aspect; /* Aspect ID 0 - 4:3, 7 - 16:9 */
- int has_audio; /* frame under contruction has audio */
- int has_video; /* frame under contruction has video */
- uint8_t frame_buf[DV_MAX_FRAME_SIZE]; /* frame under contruction */
-};
-
-enum dv_section_type {
- dv_sect_header = 0x1f,
- dv_sect_subcode = 0x3f,
- dv_sect_vaux = 0x56,
- dv_sect_audio = 0x76,
- dv_sect_video = 0x96,
-};
-
-enum dv_pack_type {
- dv_header525 = 0x3f, /* see dv_write_pack for important details on */
- dv_header625 = 0xbf, /* these two packs */
- dv_timecode = 0x13,
- dv_audio_source = 0x50,
- dv_audio_control = 0x51,
- dv_audio_recdate = 0x52,
- dv_audio_rectime = 0x53,
- dv_video_source = 0x60,
- dv_video_control = 0x61,
- dv_video_recdate = 0x62,
- dv_video_rectime = 0x63,
- dv_unknown_pack = 0xff,
-};
-
-
-
-/*
- * The reason why the following three big ugly looking tables are
- * here is my lack of DV spec IEC 61834. The tables were basically
- * constructed to make code that places packs in SSYB, VAUX and
- * AAUX blocks very simple and table-driven. They conform to the
- * SMPTE 314M and the output of my personal DV camcorder, neither
- * of which is sufficient for a reliable DV stream producing. Thus
- * while code is still in development I'll be gathering input from
- * people with different DV equipment and modifying the tables to
- * accommodate all the quirks. Later on, if possible, some of them
- * will be folded into smaller tables and/or switch-if logic. For
- * now, my only excuse is -- they don't eat up that much of a space.
- */
-
-static const int dv_ssyb_packs_dist[12][6] = {
- { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 },
- { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 },
- { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 },
- { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 },
- { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 },
- { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 },
- { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 },
- { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 },
- { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 },
- { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 },
- { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 },
- { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 },
-};
-
-static const int dv_vaux_packs_dist[12][15] = {
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
- { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x60, 0x61, 0x62, 0x63, 0xff, 0xff },
-};
-
-static const int dv_aaux_packs_dist[12][9] = {
- { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
- { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
- { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
- { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
- { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
- { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
- { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
- { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },