Revision 7458ccbb libavcodec/dvdata.h

View differences:

libavcodec/dvdata.h
21 21
 * @file dvdata.h
22 22
 * Constants for DV codec.
23 23
 */
24
 
24

  
25
/* 
26
 * DVprofile is used to express the differences between various 
27
 * DV flavors. For now it's primarily used for differentiating
28
 * 525/60 and 625/50, but the plans are to use it for various
29
 * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
30
 */
31
typedef struct DVprofile {
32
    int              dsf;                 /* value of the dsf in the DV header */
33
    int              frame_size;          /* total size of one frame in bytes */
34
    int              difseg_size;         /* number of DIF segments */
35
    int              frame_rate;      
36
    int              frame_rate_base;
37
    int              ltc_divisor;         /* FPS from the LTS standpoint */
38
    int              height;              /* picture height in pixels */
39
    int              width;               /* picture width in pixels */
40
    const uint16_t  *video_place;         /* positions of all DV macro blocks */
41
    enum PixelFormat pix_fmt;             /* picture pixel format */
42
    
43
    int              audio_stride;        /* size of audio_shuffle table */
44
    int              audio_min_samples[3];/* min ammount of audio samples */
45
                                          /* for 48Khz, 44.1Khz and 32Khz */
46
    int              audio_samples_dist[5];/* how many samples are supposed to be */
47
                                         /* in each frame in a 5 frames window */
48
    const uint16_t (*audio_shuffle)[9];  /* PCM shuffling table */
49
} DVprofile;
50

  
25 51
#define NB_DV_VLC 409
26
#define AAUX_AS_OFFSET  (80*6 + 80*16*3 + 3)
27
#define AAUX_ASC_OFFSET (80*6 + 80*16*4 + 3)
28
#define VAUX_TC61_OFFSET (80*5 + 48 + 5)
29 52

  
30 53
static const uint16_t dv_vlc_bits[409] = {
31 54
 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
......
283 306
    1,2,2,3,3,3,3,3,
284 307
};
285 308

  
286
static uint8_t dv_quant_shifts[22][4] = {
309
static const uint8_t dv_quant_shifts[22][4] = {
287 310
  { 3,3,4,4 }, 
288 311
  { 3,3,4,4 }, 
289 312
  { 2,3,3,4 }, 
......
1240 1263
 0x0834, 0x2320, 0x2f44, 0x3810, 0x1658,
1241 1264
};
1242 1265

  
1243
static const uint16_t dv_place_audio60[10][9] = {
1266
static const uint16_t dv_audio_shuffle525[10][9] = {
1244 1267
  {  0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
1245 1268
  {  6, 36, 66, 26, 56, 86, 16, 46, 76 },
1246 1269
  { 12, 42, 72,  2, 32, 62, 22, 52, 82 },
......
1254 1277
  { 25, 55, 85, 15, 45, 75,  5, 35, 65 },
1255 1278
};
1256 1279

  
1257
static const uint16_t dv_place_audio50[12][9] = {
1280
static const uint16_t dv_audio_shuffle625[12][9] = {
1258 1281
  {   0,  36,  72,  26,  62,  98,  16,  52,  88}, /* 1st channel */
1259 1282
  {   6,  42,  78,  32,  68, 104,  22,  58,  94},
1260 1283
  {  12,  48,  84,   2,  38,  74,  28,  64, 100},
......
1271 1294
};
1272 1295

  
1273 1296
static const int dv_audio_frequency[3] = {
1274
    48000, 44100, 32000, 
1297
    48000, 44100, 32000,
1275 1298
};
1276

  
1277
static const int dv_audio_min_samples[2][3] = {
1278
    { 1580, 1452, 1053 }, /* 60 fields */
1279
    { 1896, 1742, 1264 }, /* 50 fileds */
1299
    
1300
static const DVprofile dv_profiles[] = {
1301
    { .dsf = 0,
1302
      .frame_size = 120000,        /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
1303
      .difseg_size = 10,
1304
      .frame_rate = 30000,
1305
      .ltc_divisor = 30,
1306
      .frame_rate_base = 1001,
1307
      .height = 480,
1308
      .width = 720,
1309
      .video_place = dv_place_411,
1310
      .pix_fmt = PIX_FMT_YUV411P,
1311
      .audio_stride = 90,
1312
      .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32Khz */
1313
      .audio_samples_dist = { 1602, 1601, 1602, 1601, 1602 },
1314
      .audio_shuffle = dv_audio_shuffle525,
1315
    }, 
1316
    { .dsf = 1,
1317
      .frame_size = 144000,        /* IEC 61834 - 625/50 (PAL) */
1318
      .difseg_size = 12,
1319
      .frame_rate = 25,
1320
      .frame_rate_base = 1,
1321
      .ltc_divisor = 25,
1322
      .height = 576,
1323
      .width = 720,
1324
      .video_place = dv_place_420,
1325
      .pix_fmt = PIX_FMT_YUV420P,
1326
      .audio_stride = 108,
1327
      .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */
1328
      .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
1329
      .audio_shuffle = dv_audio_shuffle625,
1330
    },
1331
    { .dsf = 1,
1332
      .frame_size = 144000,        /* SMPTE-314M - 625/50 (PAL) */
1333
      .difseg_size = 12,
1334
      .frame_rate = 25,
1335
      .frame_rate_base = 1,
1336
      .ltc_divisor = 25,
1337
      .height = 576,
1338
      .width = 720,
1339
      .video_place = dv_place_411P,
1340
      .pix_fmt = PIX_FMT_YUV411P,
1341
      .audio_stride = 108,
1342
      .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */
1343
      .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
1344
      .audio_shuffle = dv_audio_shuffle625,
1345
     }
1280 1346
};
1347

  
1348
static inline const DVprofile* dv_frame_profile(uint8_t* frame)
1349
{
1350
    if ((frame[3] & 0x80) == 0) {      /* DSF flag */
1351
        return &dv_profiles[0];
1352
    }
1353
    else if ((frame[5] & 0x07) == 0) { /* APT flag */
1354
        return &dv_profiles[1];
1355
    }
1356
    else 
1357
        return &dv_profiles[2];
1358
}
1359

  
1360
static inline const DVprofile* dv_codec_profile(AVCodecContext* codec)
1361
{
1362
    if (codec->width != 720) {
1363
        return NULL;
1364
    } 
1365
    else if (codec->height == 480) {
1366
        return &dv_profiles[0];
1367
    } 
1368
    else 
1369
        return &dv_profiles[1];
1370
}

Also available in: Unified diff