Mercurial > libavcodec.hg
comparison dvdata.h @ 10409:3c13cad19e29 libavcodec
Split parts of dvdata.h into dvdata.c, this ensures that things like
work_chunks_* and dv_idct_factor_* variables appear only once in the binary
instead of 3 times.
Saves 3264 bytes in .rodata and 312416 bytes in .bss on x86_64.
author | reimar |
---|---|
date | Fri, 16 Oct 2009 07:55:57 +0000 |
parents | 9acd9b34b2b9 |
children | 85d679e0b591 |
comparison
equal
deleted
inserted
replaced
10408:8fd8f6c1cdcc | 10409:3c13cad19e29 |
---|---|
458 | 458 |
459 static const uint8_t block_sizes_dv100[8] = { | 459 static const uint8_t block_sizes_dv100[8] = { |
460 80, 80, 80, 80, 80, 80, 64, 64, | 460 80, 80, 80, 80, 80, 80, 64, 64, |
461 }; | 461 }; |
462 | 462 |
463 static DVwork_chunk work_chunks_dv25pal [1*12*27]; | |
464 static DVwork_chunk work_chunks_dv25pal411[1*12*27]; | |
465 static DVwork_chunk work_chunks_dv25ntsc [1*10*27]; | |
466 static DVwork_chunk work_chunks_dv50pal [2*12*27]; | |
467 static DVwork_chunk work_chunks_dv50ntsc [2*10*27]; | |
468 static DVwork_chunk work_chunks_dv100palp [2*12*27]; | |
469 static DVwork_chunk work_chunks_dv100ntscp[2*10*27]; | |
470 static DVwork_chunk work_chunks_dv100pali [4*12*27]; | |
471 static DVwork_chunk work_chunks_dv100ntsci[4*10*27]; | |
472 | |
473 static uint32_t dv_idct_factor_sd [2*2*22*64]; | |
474 static uint32_t dv_idct_factor_hd1080[2*4*16*64]; | |
475 static uint32_t dv_idct_factor_hd720 [2*4*16*64]; | |
476 | |
477 static const DVprofile dv_profiles[] = { | |
478 { .dsf = 0, | |
479 .video_stype = 0x0, | |
480 .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */ | |
481 .difseg_size = 10, | |
482 .n_difchan = 1, | |
483 .time_base = { 1001, 30000 }, | |
484 .ltc_divisor = 30, | |
485 .height = 480, | |
486 .width = 720, | |
487 .sar = {{10, 11}, {40, 33}}, | |
488 .work_chunks = &work_chunks_dv25ntsc[0], | |
489 .idct_factor = &dv_idct_factor_sd[0], | |
490 .pix_fmt = PIX_FMT_YUV411P, | |
491 .bpm = 6, | |
492 .block_sizes = block_sizes_dv2550, | |
493 .audio_stride = 90, | |
494 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */ | |
495 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */ | |
496 .audio_shuffle = dv_audio_shuffle525, | |
497 }, | |
498 { .dsf = 1, | |
499 .video_stype = 0x0, | |
500 .frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */ | |
501 .difseg_size = 12, | |
502 .n_difchan = 1, | |
503 .time_base = { 1, 25 }, | |
504 .ltc_divisor = 25, | |
505 .height = 576, | |
506 .width = 720, | |
507 .sar = {{59, 54}, {118, 81}}, | |
508 .work_chunks = &work_chunks_dv25pal[0], | |
509 .idct_factor = &dv_idct_factor_sd[0], | |
510 .pix_fmt = PIX_FMT_YUV420P, | |
511 .bpm = 6, | |
512 .block_sizes = block_sizes_dv2550, | |
513 .audio_stride = 108, | |
514 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */ | |
515 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, | |
516 .audio_shuffle = dv_audio_shuffle625, | |
517 }, | |
518 { .dsf = 1, | |
519 .video_stype = 0x0, | |
520 .frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */ | |
521 .difseg_size = 12, | |
522 .n_difchan = 1, | |
523 .time_base = { 1, 25 }, | |
524 .ltc_divisor = 25, | |
525 .height = 576, | |
526 .width = 720, | |
527 .sar = {{59, 54}, {118, 81}}, | |
528 .work_chunks = &work_chunks_dv25pal411[0], | |
529 .idct_factor = &dv_idct_factor_sd[0], | |
530 .pix_fmt = PIX_FMT_YUV411P, | |
531 .bpm = 6, | |
532 .block_sizes = block_sizes_dv2550, | |
533 .audio_stride = 108, | |
534 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */ | |
535 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, | |
536 .audio_shuffle = dv_audio_shuffle625, | |
537 }, | |
538 { .dsf = 0, | |
539 .video_stype = 0x4, | |
540 .frame_size = 240000, /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */ | |
541 .difseg_size = 10, /* also known as "DVCPRO50" */ | |
542 .n_difchan = 2, | |
543 .time_base = { 1001, 30000 }, | |
544 .ltc_divisor = 30, | |
545 .height = 480, | |
546 .width = 720, | |
547 .sar = {{10, 11}, {40, 33}}, | |
548 .work_chunks = &work_chunks_dv50ntsc[0], | |
549 .idct_factor = &dv_idct_factor_sd[0], | |
550 .pix_fmt = PIX_FMT_YUV422P, | |
551 .bpm = 6, | |
552 .block_sizes = block_sizes_dv2550, | |
553 .audio_stride = 90, | |
554 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */ | |
555 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */ | |
556 .audio_shuffle = dv_audio_shuffle525, | |
557 }, | |
558 { .dsf = 1, | |
559 .video_stype = 0x4, | |
560 .frame_size = 288000, /* SMPTE-314M - 625/50 (PAL) 50 Mbps */ | |
561 .difseg_size = 12, /* also known as "DVCPRO50" */ | |
562 .n_difchan = 2, | |
563 .time_base = { 1, 25 }, | |
564 .ltc_divisor = 25, | |
565 .height = 576, | |
566 .width = 720, | |
567 .sar = {{59, 54}, {118, 81}}, | |
568 .work_chunks = &work_chunks_dv50pal[0], | |
569 .idct_factor = &dv_idct_factor_sd[0], | |
570 .pix_fmt = PIX_FMT_YUV422P, | |
571 .bpm = 6, | |
572 .block_sizes = block_sizes_dv2550, | |
573 .audio_stride = 108, | |
574 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */ | |
575 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, | |
576 .audio_shuffle = dv_audio_shuffle625, | |
577 }, | |
578 { .dsf = 0, | |
579 .video_stype = 0x14, | |
580 .frame_size = 480000, /* SMPTE-370M - 1080i60 100 Mbps */ | |
581 .difseg_size = 10, /* also known as "DVCPRO HD" */ | |
582 .n_difchan = 4, | |
583 .time_base = { 1001, 30000 }, | |
584 .ltc_divisor = 30, | |
585 .height = 1080, | |
586 .width = 1280, | |
587 .sar = {{1, 1}, {1, 1}}, | |
588 .work_chunks = &work_chunks_dv100ntsci[0], | |
589 .idct_factor = &dv_idct_factor_hd1080[0], | |
590 .pix_fmt = PIX_FMT_YUV422P, | |
591 .bpm = 8, | |
592 .block_sizes = block_sizes_dv100, | |
593 .audio_stride = 90, | |
594 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */ | |
595 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */ | |
596 .audio_shuffle = dv_audio_shuffle525, | |
597 }, | |
598 { .dsf = 1, | |
599 .video_stype = 0x14, | |
600 .frame_size = 576000, /* SMPTE-370M - 1080i50 100 Mbps */ | |
601 .difseg_size = 12, /* also known as "DVCPRO HD" */ | |
602 .n_difchan = 4, | |
603 .time_base = { 1, 25 }, | |
604 .ltc_divisor = 25, | |
605 .height = 1080, | |
606 .width = 1440, | |
607 .sar = {{1, 1}, {1, 1}}, | |
608 .work_chunks = &work_chunks_dv100pali[0], | |
609 .idct_factor = &dv_idct_factor_hd1080[0], | |
610 .pix_fmt = PIX_FMT_YUV422P, | |
611 .bpm = 8, | |
612 .block_sizes = block_sizes_dv100, | |
613 .audio_stride = 108, | |
614 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */ | |
615 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, | |
616 .audio_shuffle = dv_audio_shuffle625, | |
617 }, | |
618 { .dsf = 0, | |
619 .video_stype = 0x18, | |
620 .frame_size = 240000, /* SMPTE-370M - 720p60 100 Mbps */ | |
621 .difseg_size = 10, /* also known as "DVCPRO HD" */ | |
622 .n_difchan = 2, | |
623 .time_base = { 1001, 60000 }, | |
624 .ltc_divisor = 60, | |
625 .height = 720, | |
626 .width = 960, | |
627 .sar = {{1, 1}, {1, 1}}, | |
628 .work_chunks = &work_chunks_dv100ntscp[0], | |
629 .idct_factor = &dv_idct_factor_hd720[0], | |
630 .pix_fmt = PIX_FMT_YUV422P, | |
631 .bpm = 8, | |
632 .block_sizes = block_sizes_dv100, | |
633 .audio_stride = 90, | |
634 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32kHz */ | |
635 .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */ | |
636 .audio_shuffle = dv_audio_shuffle525, | |
637 }, | |
638 { .dsf = 1, | |
639 .video_stype = 0x18, | |
640 .frame_size = 288000, /* SMPTE-370M - 720p50 100 Mbps */ | |
641 .difseg_size = 12, /* also known as "DVCPRO HD" */ | |
642 .n_difchan = 2, | |
643 .time_base = { 1, 50 }, | |
644 .ltc_divisor = 50, | |
645 .height = 720, | |
646 .width = 960, | |
647 .sar = {{1, 1}, {1, 1}}, | |
648 .work_chunks = &work_chunks_dv100palp[0], | |
649 .idct_factor = &dv_idct_factor_hd720[0], | |
650 .pix_fmt = PIX_FMT_YUV422P, | |
651 .bpm = 8, | |
652 .block_sizes = block_sizes_dv100, | |
653 .audio_stride = 90, | |
654 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */ | |
655 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, | |
656 .audio_shuffle = dv_audio_shuffle625, | |
657 }, | |
658 { .dsf = 1, | |
659 .video_stype = 0x1, | |
660 .frame_size = 144000, /* IEC 61883-5 - 625/50 (PAL) */ | |
661 .difseg_size = 12, | |
662 .n_difchan = 1, | |
663 .time_base = { 1, 25 }, | |
664 .ltc_divisor = 25, | |
665 .height = 576, | |
666 .width = 720, | |
667 .sar = {{59, 54}, {118, 81}}, | |
668 .work_chunks = &work_chunks_dv25pal[0], | |
669 .idct_factor = &dv_idct_factor_sd[0], | |
670 .pix_fmt = PIX_FMT_YUV420P, | |
671 .bpm = 6, | |
672 .block_sizes = block_sizes_dv2550, | |
673 .audio_stride = 108, | |
674 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32kHz */ | |
675 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, | |
676 .audio_shuffle = dv_audio_shuffle625, | |
677 } | |
678 }; | |
679 | |
680 enum dv_section_type { | 463 enum dv_section_type { |
681 dv_sect_header = 0x1f, | 464 dv_sect_header = 0x1f, |
682 dv_sect_subcode = 0x3f, | 465 dv_sect_subcode = 0x3f, |
683 dv_sect_vaux = 0x56, | 466 dv_sect_vaux = 0x56, |
684 dv_sect_audio = 0x76, | 467 dv_sect_audio = 0x76, |
716 /** | 499 /** |
717 * maximum number of blocks per macroblock in any DV format | 500 * maximum number of blocks per macroblock in any DV format |
718 */ | 501 */ |
719 #define DV_MAX_BPM 8 | 502 #define DV_MAX_BPM 8 |
720 | 503 |
721 static inline | 504 const DVprofile* ff_dv_frame_profile(const DVprofile *sys, |
722 const DVprofile* dv_frame_profile(const DVprofile *sys, | 505 const uint8_t* frame, unsigned buf_size); |
723 const uint8_t* frame, unsigned buf_size) | 506 const DVprofile* ff_dv_codec_profile(AVCodecContext* codec); |
724 { | |
725 int i; | |
726 | |
727 int dsf = (frame[3] & 0x80) >> 7; | |
728 | |
729 int stype = frame[80*5 + 48 + 3] & 0x1f; | |
730 | |
731 /* 576i50 25Mbps 4:1:1 is a special case */ | |
732 if (dsf == 1 && stype == 0 && frame[5] & 0x07) { | |
733 return &dv_profiles[2]; | |
734 } | |
735 | |
736 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) | |
737 if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype) | |
738 return &dv_profiles[i]; | |
739 | |
740 /* check if old sys matches and assumes corrupted input */ | |
741 if (sys && buf_size == sys->frame_size) | |
742 return sys; | |
743 | |
744 return NULL; | |
745 } | |
746 | |
747 static const DVprofile* dv_codec_profile(AVCodecContext* codec) | |
748 { | |
749 int i; | |
750 | |
751 for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++) | |
752 if (codec->height == dv_profiles[i].height && | |
753 codec->pix_fmt == dv_profiles[i].pix_fmt && | |
754 codec->width == dv_profiles[i].width) | |
755 return &dv_profiles[i]; | |
756 | |
757 return NULL; | |
758 } | |
759 | 507 |
760 static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, | 508 static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, |
761 uint8_t seq_num, uint8_t dif_num, | 509 uint8_t seq_num, uint8_t dif_num, |
762 uint8_t* buf) | 510 uint8_t* buf) |
763 { | 511 { |