comparison dvdata.h @ 1489:337d13aee605 libavcodec

* DV handling was streamlined for both muxing/demuxing and decoding. All muxing/demuxing functionality is now available in libavformat/dv.[ch]. * dv1394.c and avidec.c were hooked up with general DV demuxer. * DVAUDIO is dead! Long live pcm_s16le! * DV audio is now always recognized -- which means we can now hear all those ducks quaking in pond.dv.
author romansh
date Mon, 29 Sep 2003 17:54:07 +0000
parents 35b80080b2db
children b340e83b8d0d
comparison
equal deleted inserted replaced
1488:766a2f4edbea 1489:337d13aee605
19 19
20 /** 20 /**
21 * @file dvdata.h 21 * @file dvdata.h
22 * Constants for DV codec. 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 #define NB_DV_VLC 409 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 static const uint16_t dv_vlc_bits[409] = { 53 static const uint16_t dv_vlc_bits[409] = {
31 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016, 54 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
32 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a, 55 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a,
33 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2, 56 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2,
281 1,1,2,2,2,3,3,3, 304 1,1,2,2,2,3,3,3,
282 1,2,2,2,3,3,3,3, 305 1,2,2,2,3,3,3,3,
283 1,2,2,3,3,3,3,3, 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 { 3,3,4,4 }, 310 { 3,3,4,4 },
288 { 3,3,4,4 }, 311 { 3,3,4,4 },
289 { 2,3,3,4 }, 312 { 2,3,3,4 },
290 { 2,3,3,4 }, 313 { 2,3,3,4 },
291 { 2,2,3,3 }, 314 { 2,2,3,3 },
1238 0x0634, 0x2120, 0x2d44, 0x3610, 0x1258, 1261 0x0634, 0x2120, 0x2d44, 0x3610, 0x1258,
1239 0x0734, 0x2220, 0x2e44, 0x3710, 0x1458, 1262 0x0734, 0x2220, 0x2e44, 0x3710, 0x1458,
1240 0x0834, 0x2320, 0x2f44, 0x3810, 0x1658, 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 { 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */ 1267 { 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
1245 { 6, 36, 66, 26, 56, 86, 16, 46, 76 }, 1268 { 6, 36, 66, 26, 56, 86, 16, 46, 76 },
1246 { 12, 42, 72, 2, 32, 62, 22, 52, 82 }, 1269 { 12, 42, 72, 2, 32, 62, 22, 52, 82 },
1247 { 18, 48, 78, 8, 38, 68, 28, 58, 88 }, 1270 { 18, 48, 78, 8, 38, 68, 28, 58, 88 },
1248 { 24, 54, 84, 14, 44, 74, 4, 34, 64 }, 1271 { 24, 54, 84, 14, 44, 74, 4, 34, 64 },
1252 { 13, 43, 73, 3, 33, 63, 23, 53, 83 }, 1275 { 13, 43, 73, 3, 33, 63, 23, 53, 83 },
1253 { 19, 49, 79, 9, 39, 69, 29, 59, 89 }, 1276 { 19, 49, 79, 9, 39, 69, 29, 59, 89 },
1254 { 25, 55, 85, 15, 45, 75, 5, 35, 65 }, 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 { 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */ 1281 { 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */
1259 { 6, 42, 78, 32, 68, 104, 22, 58, 94}, 1282 { 6, 42, 78, 32, 68, 104, 22, 58, 94},
1260 { 12, 48, 84, 2, 38, 74, 28, 64, 100}, 1283 { 12, 48, 84, 2, 38, 74, 28, 64, 100},
1261 { 18, 54, 90, 8, 44, 80, 34, 70, 106}, 1284 { 18, 54, 90, 8, 44, 80, 34, 70, 106},
1262 { 24, 60, 96, 14, 50, 86, 4, 40, 76}, 1285 { 24, 60, 96, 14, 50, 86, 4, 40, 76},
1269 { 25, 61, 97, 15, 51, 87, 5, 41, 77}, 1292 { 25, 61, 97, 15, 51, 87, 5, 41, 77},
1270 { 31, 67, 103, 21, 57, 93, 11, 47, 83}, 1293 { 31, 67, 103, 21, 57, 93, 11, 47, 83},
1271 }; 1294 };
1272 1295
1273 static const int dv_audio_frequency[3] = { 1296 static const int dv_audio_frequency[3] = {
1274 48000, 44100, 32000, 1297 48000, 44100, 32000,
1275 }; 1298 };
1276 1299
1277 static const int dv_audio_min_samples[2][3] = { 1300 static const DVprofile dv_profiles[] = {
1278 { 1580, 1452, 1053 }, /* 60 fields */ 1301 { .dsf = 0,
1279 { 1896, 1742, 1264 }, /* 50 fileds */ 1302 .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
1280 }; 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 }
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 }