Mercurial > libavcodec.hg
comparison dvdata.h @ 8051:fed91eaa6444 libavcodec
prettyprinting cosmetics
| author | diego |
|---|---|
| date | Fri, 24 Oct 2008 21:41:27 +0000 |
| parents | 4eac1822bc65 |
| children | 890df98a7848 |
comparison
equal
deleted
inserted
replaced
| 8050:4eac1822bc65 | 8051:fed91eaa6444 |
|---|---|
| 35 * DV flavors. For now it's primarily used for differentiating | 35 * DV flavors. For now it's primarily used for differentiating |
| 36 * 525/60 and 625/50, but the plans are to use it for various | 36 * 525/60 and 625/50, but the plans are to use it for various |
| 37 * DV specs as well (e.g. SMPTE314M vs. IEC 61834). | 37 * DV specs as well (e.g. SMPTE314M vs. IEC 61834). |
| 38 */ | 38 */ |
| 39 typedef struct DVprofile { | 39 typedef struct DVprofile { |
| 40 int dsf; /* value of the dsf in the DV header */ | 40 int dsf; /* value of the dsf in the DV header */ |
| 41 int video_stype; /* stype for VAUX source pack */ | 41 int video_stype; /* stype for VAUX source pack */ |
| 42 int frame_size; /* total size of one frame in bytes */ | 42 int frame_size; /* total size of one frame in bytes */ |
| 43 int difseg_size; /* number of DIF segments per DIF channel */ | 43 int difseg_size; /* number of DIF segments per DIF channel */ |
| 44 int n_difchan; /* number of DIF channels per frame */ | 44 int n_difchan; /* number of DIF channels per frame */ |
| 45 AVRational time_base; /* 1/framerate */ | 45 AVRational time_base; /* 1/framerate */ |
| 46 int ltc_divisor; /* FPS from the LTS standpoint */ | 46 int ltc_divisor; /* FPS from the LTS standpoint */ |
| 47 int height; /* picture height in pixels */ | 47 int height; /* picture height in pixels */ |
| 48 int width; /* picture width in pixels */ | 48 int width; /* picture width in pixels */ |
| 49 AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */ | 49 AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */ |
| 50 const uint16_t *video_place; /* positions of all DV macroblocks */ | 50 const uint16_t *video_place; /* positions of all DV macroblocks */ |
| 51 enum PixelFormat pix_fmt; /* picture pixel format */ | 51 enum PixelFormat pix_fmt; /* picture pixel format */ |
| 52 int bpm; /* blocks per macroblock */ | 52 int bpm; /* blocks per macroblock */ |
| 53 const uint8_t *block_sizes; /* AC block sizes, in bits */ | 53 const uint8_t *block_sizes; /* AC block sizes, in bits */ |
| 54 int audio_stride; /* size of audio_shuffle table */ | 54 int audio_stride; /* size of audio_shuffle table */ |
| 55 int audio_min_samples[3];/* min amount of audio samples */ | 55 int audio_min_samples[3]; /* min amount of audio samples */ |
| 56 /* for 48kHz, 44.1kHz and 32kHz */ | 56 /* for 48kHz, 44.1kHz and 32kHz */ |
| 57 int audio_samples_dist[5];/* how many samples are supposed to be */ | 57 int audio_samples_dist[5]; /* how many samples are supposed to be */ |
| 58 /* in each frame in a 5 frames window */ | 58 /* in each frame in a 5 frames window */ |
| 59 const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */ | 59 const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */ |
| 60 } DVprofile; | 60 } DVprofile; |
| 61 | 61 |
| 62 #define NB_DV_VLC 409 | 62 #define NB_DV_VLC 409 |
| 63 | 63 |
| 64 /* | 64 /* |
| 230 0, 0, 0, 0, 0, 0, 0, 0, | 230 0, 0, 0, 0, 0, 0, 0, 0, |
| 231 127, | 231 127, |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 static const uint8_t dv_vlc_level[409] = { | 234 static const uint8_t dv_vlc_level[409] = { |
| 235 1, 2, 1, 3, 4, 1, 2, 5, | 235 1, 2, 1, 3, 4, 1, 2, 5, |
| 236 6, 1, 1, 7, 8, 1, 1, 2, | 236 6, 1, 1, 7, 8, 1, 1, 2, |
| 237 3, 4, 9, 10, 11, 1, 1, 1, | 237 3, 4, 9, 10, 11, 1, 1, 1, |
| 238 1, 2, 2, 3, 5, 6, 7, 12, | 238 1, 2, 2, 3, 5, 6, 7, 12, |
| 239 13, 14, 15, 16, 17, 1, 1, 1, | 239 13, 14, 15, 16, 17, 1, 1, 1, |
| 240 1, 2, 2, 3, 3, 4, 5, 8, | 240 1, 2, 2, 3, 3, 4, 5, 8, |
| 241 18, 19, 20, 21, 22, 3, 4, 5, | 241 18, 19, 20, 21, 22, 3, 4, 5, |
| 242 6, 9, 10, 11, 0, 0, 3, 4, | 242 6, 9, 10, 11, 0, 0, 3, 4, |
| 243 6, 12, 13, 14, 0, 0, 0, 0, | 243 6, 12, 13, 14, 0, 0, 0, 0, |
| 244 2, 2, 2, 2, 3, 3, 5, 7, | 244 2, 2, 2, 2, 3, 3, 5, 7, |
| 245 7, 8, 9, 10, 11, 15, 16, 17, | 245 7, 8, 9, 10, 11, 15, 16, 17, |
| 246 0, 0, 0, 0, 0, 0, 0, 0, | 246 0, 0, 0, 0, 0, 0, 0, 0, |
| 247 0, 0, 0, 0, 0, 0, 0, 0, | 247 0, 0, 0, 0, 0, 0, 0, 0, |
| 248 0, 0, 0, 0, 0, 0, 0, 0, | 248 0, 0, 0, 0, 0, 0, 0, 0, |
| 249 0, 0, 0, 0, 0, 0, 0, 0, | 249 0, 0, 0, 0, 0, 0, 0, 0, |
| 250 0, 0, 0, 0, 0, 0, 0, 0, | 250 0, 0, 0, 0, 0, 0, 0, 0, |
| 251 0, 0, 0, 0, 0, 0, 0, 0, | 251 0, 0, 0, 0, 0, 0, 0, 0, |
| 252 0, 0, 0, 0, 0, 0, 0, 0, | 252 0, 0, 0, 0, 0, 0, 0, 0, |
| 253 0, 0, 0, 0, 0, 0, 0, 0, | 253 0, 0, 0, 0, 0, 0, 0, 0, |
| 254 0, 1, 2, 3, 4, 5, 6, 7, | 254 0, 1, 2, 3, 4, 5, 6, 7, |
| 255 8, 9, 10, 11, 12, 13, 14, 15, | 255 8, 9, 10, 11, 12, 13, 14, 15, |
| 256 16, 17, 18, 19, 20, 21, 22, 23, | 256 16, 17, 18, 19, 20, 21, 22, 23, |
| 257 24, 25, 26, 27, 28, 29, 30, 31, | 257 24, 25, 26, 27, 28, 29, 30, 31, |
| 258 32, 33, 34, 35, 36, 37, 38, 39, | 258 32, 33, 34, 35, 36, 37, 38, 39, |
| 259 40, 41, 42, 43, 44, 45, 46, 47, | 259 40, 41, 42, 43, 44, 45, 46, 47, |
| 260 48, 49, 50, 51, 52, 53, 54, 55, | 260 48, 49, 50, 51, 52, 53, 54, 55, |
| 261 56, 57, 58, 59, 60, 61, 62, 63, | 261 56, 57, 58, 59, 60, 61, 62, 63, |
| 262 64, 65, 66, 67, 68, 69, 70, 71, | 262 64, 65, 66, 67, 68, 69, 70, 71, |
| 263 72, 73, 74, 75, 76, 77, 78, 79, | 263 72, 73, 74, 75, 76, 77, 78, 79, |
| 264 80, 81, 82, 83, 84, 85, 86, 87, | 264 80, 81, 82, 83, 84, 85, 86, 87, |
| 265 88, 89, 90, 91, 92, 93, 94, 95, | 265 88, 89, 90, 91, 92, 93, 94, 95, |
| 266 96, 97, 98, 99, 100, 101, 102, 103, | 266 96, 97, 98, 99, 100, 101, 102, 103, |
| 267 104, 105, 106, 107, 108, 109, 110, 111, | 267 104, 105, 106, 107, 108, 109, 110, 111, |
| 268 112, 113, 114, 115, 116, 117, 118, 119, | 268 112, 113, 114, 115, 116, 117, 118, 119, |
| 269 120, 121, 122, 123, 124, 125, 126, 127, | 269 120, 121, 122, 123, 124, 125, 126, 127, |
| 270 128, 129, 130, 131, 132, 133, 134, 135, | 270 128, 129, 130, 131, 132, 133, 134, 135, |
| 271 136, 137, 138, 139, 140, 141, 142, 143, | 271 136, 137, 138, 139, 140, 141, 142, 143, |
| 281 216, 217, 218, 219, 220, 221, 222, 223, | 281 216, 217, 218, 219, 220, 221, 222, 223, |
| 282 224, 225, 226, 227, 228, 229, 230, 231, | 282 224, 225, 226, 227, 228, 229, 230, 231, |
| 283 232, 233, 234, 235, 236, 237, 238, 239, | 283 232, 233, 234, 235, 236, 237, 238, 239, |
| 284 240, 241, 242, 243, 244, 245, 246, 247, | 284 240, 241, 242, 243, 244, 245, 246, 247, |
| 285 248, 249, 250, 251, 252, 253, 254, 255, | 285 248, 249, 250, 251, 252, 253, 254, 255, |
| 286 0, | 286 0, |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 /* unquant tables (not used directly) */ | 289 /* unquant tables (not used directly) */ |
| 290 static const uint8_t dv_quant_shifts[22][4] = { | 290 static const uint8_t dv_quant_shifts[22][4] = { |
| 291 { 3,3,4,4 }, | 291 { 3,3,4,4 }, |
| 310 { 0,0,0,0 }, | 310 { 0,0,0,0 }, |
| 311 { 0,0,0,0 }, | 311 { 0,0,0,0 }, |
| 312 { 0,0,0,0 }, | 312 { 0,0,0,0 }, |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 }; | 315 static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 }; |
| 316 static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 }; | 316 static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 }; |
| 317 | 317 |
| 318 /* quantization quanta by QNO for DV100 */ | 318 /* quantization quanta by QNO for DV100 */ |
| 319 static const uint8_t dv100_qstep[16] = { | 319 static const uint8_t dv100_qstep[16] = { |
| 320 1, /* QNO = 0 and 1 both have no quantization */ | 320 1, /* QNO = 0 and 1 both have no quantization */ |
| 321 1, | 321 1, |
| 6358 | 6358 |
| 6359 #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10) | 6359 #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10) |
| 6360 #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1)) | 6360 #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1)) |
| 6361 #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1)) | 6361 #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1)) |
| 6362 | 6362 |
| 6363 /* minimum number of bytes to read from a DV stream in order to determine the profile */ | 6363 /* minimum number of bytes to read from a DV stream in order to |
| 6364 determine the profile */ | |
| 6364 #define DV_PROFILE_BYTES (6*80) /* 6 DIF blocks */ | 6365 #define DV_PROFILE_BYTES (6*80) /* 6 DIF blocks */ |
| 6365 | 6366 |
| 6366 /** | 6367 /** |
| 6367 * largest possible DV frame, in bytes (1080i50) | 6368 * largest possible DV frame, in bytes (1080i50) |
| 6368 */ | 6369 */ |
| 6396 static const DVprofile* dv_codec_profile(AVCodecContext* codec) | 6397 static const DVprofile* dv_codec_profile(AVCodecContext* codec) |
| 6397 { | 6398 { |
| 6398 int i; | 6399 int i; |
| 6399 | 6400 |
| 6400 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) | 6401 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) |
| 6401 if (codec->height == dv_profiles[i].height && codec->pix_fmt == dv_profiles[i].pix_fmt && | 6402 if (codec->height == dv_profiles[i].height && |
| 6402 codec->width == dv_profiles[i].width) | 6403 codec->pix_fmt == dv_profiles[i].pix_fmt && |
| 6404 codec->width == dv_profiles[i].width) | |
| 6403 return &dv_profiles[i]; | 6405 return &dv_profiles[i]; |
| 6404 | 6406 |
| 6405 return NULL; | 6407 return NULL; |
| 6406 } | 6408 } |
| 6407 | 6409 |
| 6408 static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, uint8_t seq_num, | 6410 static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, |
| 6409 uint8_t dif_num, uint8_t* buf) | 6411 uint8_t seq_num, uint8_t dif_num, |
| 6412 uint8_t* buf) | |
| 6410 { | 6413 { |
| 6411 buf[0] = (uint8_t)t; /* Section type */ | 6414 buf[0] = (uint8_t)t; /* Section type */ |
| 6412 buf[1] = (seq_num<<4) | /* DIF seq number 0-9 for 525/60; 0-11 for 625/50 */ | 6415 buf[1] = (seq_num << 4) | /* DIF seq number 0-9 for 525/60; 0-11 for 625/50 */ |
| 6413 (chan_num << 3) | /* FSC: for 50Mb/s 0 - first channel; 1 - second */ | 6416 (chan_num << 3) | /* FSC: for 50Mb/s 0 - first channel; 1 - second */ |
| 6414 7; /* reserved -- always 1 */ | 6417 7; /* reserved -- always 1 */ |
| 6415 buf[2] = dif_num; /* DIF block number Video: 0-134, Audio: 0-8 */ | 6418 buf[2] = dif_num; /* DIF block number Video: 0-134, Audio: 0-8 */ |
| 6416 return 3; | 6419 return 3; |
| 6417 } | 6420 } |
| 6418 | 6421 |
| 6419 | 6422 |
| 6420 static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t* buf) | 6423 static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t* buf) |
| 6421 { | 6424 { |
| 6422 if (syb_num == 0 || syb_num == 6) { | 6425 if (syb_num == 0 || syb_num == 6) { |
| 6423 buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ | 6426 buf[0] = (fr << 7) | /* FR ID 1 - first half of each channel; 0 - second */ |
| 6424 (0<<4) | /* AP3 (Subcode application ID) */ | 6427 (0 << 4) | /* AP3 (Subcode application ID) */ |
| 6425 0x0f; /* reserved -- always 1 */ | 6428 0x0f; /* reserved -- always 1 */ |
| 6426 } | 6429 } |
| 6427 else if (syb_num == 11) { | 6430 else if (syb_num == 11) { |
| 6428 buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ | 6431 buf[0] = (fr << 7) | /* FR ID 1 - first half of each channel; 0 - second */ |
| 6429 0x7f; /* reserved -- always 1 */ | 6432 0x7f; /* reserved -- always 1 */ |
| 6430 } | 6433 } |
| 6431 else { | 6434 else { |
| 6432 buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ | 6435 buf[0] = (fr << 7) | /* FR ID 1 - first half of each channel; 0 - second */ |
| 6433 (0<<4) | /* APT (Track application ID) */ | 6436 (0 << 4) | /* APT (Track application ID) */ |
| 6434 0x0f; /* reserved -- always 1 */ | 6437 0x0f; /* reserved -- always 1 */ |
| 6435 } | 6438 } |
| 6436 buf[1] = 0xf0 | /* reserved -- always 1 */ | 6439 buf[1] = 0xf0 | /* reserved -- always 1 */ |
| 6437 (syb_num & 0x0f); /* SSYB number 0 - 11 */ | 6440 (syb_num & 0x0f); /* SSYB number 0 - 11 */ |
| 6438 buf[2] = 0xff; /* reserved -- always 1 */ | 6441 buf[2] = 0xff; /* reserved -- always 1 */ |
| 6439 return 3; | 6442 return 3; |
