]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dvdata.h
remove useless static cm variable
[ffmpeg] / libavcodec / dvdata.h
index a3d42d66c17f7f5272f69099bd84f6cd5074a526..e688ffbb05cbb7e053938e2e0a5acdd878ba4cc1 100644 (file)
@@ -2,18 +2,20 @@
  * Constants for DV codec
  * Copyright (c) 2002 Fabrice Bellard.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -47,7 +49,7 @@ typedef struct DVprofile {
                                           /* for 48Khz, 44.1Khz and 32Khz */
     int              audio_samples_dist[5];/* how many samples are supposed to be */
                                          /* in each frame in a 5 frames window */
-    const uint16_t (*audio_shuffle)[9];  /* PCM shuffling table */
+    const uint8_t  (*audio_shuffle)[9];  /* PCM shuffling table */
 } DVprofile;
 
 #define NB_DV_VLC 409
@@ -2502,7 +2504,7 @@ static const int dv_iweight_248[64] = {
  22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642,
 };
 
-static const uint16_t dv_audio_shuffle525[10][9] = {
+static const uint8_t dv_audio_shuffle525[10][9] = {
   {  0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
   {  6, 36, 66, 26, 56, 86, 16, 46, 76 },
   { 12, 42, 72,  2, 32, 62, 22, 52, 82 },
@@ -2516,7 +2518,7 @@ static const uint16_t dv_audio_shuffle525[10][9] = {
   { 25, 55, 85, 15, 45, 75,  5, 35, 65 },
 };
 
-static const uint16_t dv_audio_shuffle625[12][9] = {
+static const uint8_t dv_audio_shuffle625[12][9] = {
   {   0,  36,  72,  26,  62,  98,  16,  52,  88}, /* 1st channel */
   {   6,  42,  78,  32,  68, 104,  22,  58,  94},
   {  12,  48,  84,   2,  38,  74,  28,  64, 100},
@@ -2624,6 +2626,29 @@ static const DVprofile dv_profiles[] = {
     }
 };
 
+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,
+};
+
 /* minimum number of bytes to read from a DV stream in order to determine the profile */
 #define DV_PROFILE_BYTES (6*80) /* 6 DIF blocks */
 
@@ -2663,3 +2688,37 @@ static inline const DVprofile* dv_codec_profile(AVCodecContext* codec)
 
     return NULL;
 }
+
+static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, uint8_t seq_num,
+                                  uint8_t dif_num, uint8_t* buf)
+{
+    buf[0] = (uint8_t)t;    /* Section type */
+    buf[1] = (seq_num<<4) | /* DIF seq number 0-9 for 525/60; 0-11 for 625/50 */
+             (chan_num << 3) | /* FSC: for 50Mb/s 0 - first channel; 1 - second */
+             7;             /* reserved -- always 1 */
+    buf[2] = dif_num;       /* DIF block number Video: 0-134, Audio: 0-8 */
+    return 3;
+}
+
+
+static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t* buf)
+{
+    if (syb_num == 0 || syb_num == 6) {
+        buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */
+                 (0<<4)  | /* AP3 (Subcode application ID) */
+                 0x0f;     /* reserved -- always 1 */
+    }
+    else if (syb_num == 11) {
+        buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */
+                 0x7f;     /* reserved -- always 1 */
+    }
+    else {
+        buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */
+                 (0<<4)  | /* APT (Track application ID) */
+                 0x0f;     /* reserved -- always 1 */
+    }
+    buf[1] = 0xf0 |            /* reserved -- always 1 */
+             (syb_num & 0x0f); /* SSYB number 0 - 11   */
+    buf[2] = 0xff;             /* reserved -- always 1 */
+    return 3;
+}