comparison mov.c @ 820:feca73904e67 libavformat

changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
author michael
date Sun, 17 Jul 2005 22:24:36 +0000
parents 6ace9fde011e
children 2614d3c1f415
comparison
equal deleted inserted replaced
819:a6c035e7f429 820:feca73904e67
479 479
480 if(ctype == MKTAG('m', 'h', 'l', 'r')) { /* MOV */ 480 if(ctype == MKTAG('m', 'h', 'l', 'r')) { /* MOV */
481 /* helps parsing the string hereafter... */ 481 /* helps parsing the string hereafter... */
482 c->mp4 = 0; 482 c->mp4 = 0;
483 if(type == MKTAG('v', 'i', 'd', 'e')) 483 if(type == MKTAG('v', 'i', 'd', 'e'))
484 st->codec.codec_type = CODEC_TYPE_VIDEO; 484 st->codec->codec_type = CODEC_TYPE_VIDEO;
485 else if(type == MKTAG('s', 'o', 'u', 'n')) 485 else if(type == MKTAG('s', 'o', 'u', 'n'))
486 st->codec.codec_type = CODEC_TYPE_AUDIO; 486 st->codec->codec_type = CODEC_TYPE_AUDIO;
487 } else if(ctype == 0) { /* MP4 */ 487 } else if(ctype == 0) { /* MP4 */
488 /* helps parsing the string hereafter... */ 488 /* helps parsing the string hereafter... */
489 c->mp4 = 1; 489 c->mp4 = 1;
490 if(type == MKTAG('v', 'i', 'd', 'e')) 490 if(type == MKTAG('v', 'i', 'd', 'e'))
491 st->codec.codec_type = CODEC_TYPE_VIDEO; 491 st->codec->codec_type = CODEC_TYPE_VIDEO;
492 else if(type == MKTAG('s', 'o', 'u', 'n')) 492 else if(type == MKTAG('s', 'o', 'u', 'n'))
493 st->codec.codec_type = CODEC_TYPE_AUDIO; 493 st->codec->codec_type = CODEC_TYPE_AUDIO;
494 } 494 }
495 get_be32(pb); /* component manufacture */ 495 get_be32(pb); /* component manufacture */
496 get_be32(pb); /* component flags */ 496 get_be32(pb); /* component flags */
497 get_be32(pb); /* component flags mask */ 497 get_be32(pb); /* component flags mask */
498 498
589 //av_log(NULL, AV_LOG_DEBUG, "LEN %d TAG %d m:%d a:%d\n", len, tag, sc->esds.max_bitrate, sc->esds.avg_bitrate); 589 //av_log(NULL, AV_LOG_DEBUG, "LEN %d TAG %d m:%d a:%d\n", len, tag, sc->esds.max_bitrate, sc->esds.avg_bitrate);
590 if (tag == MP4DecSpecificDescrTag) { 590 if (tag == MP4DecSpecificDescrTag) {
591 #ifdef DEBUG 591 #ifdef DEBUG
592 av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len); 592 av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len);
593 #endif 593 #endif
594 st->codec.extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); 594 st->codec->extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
595 if (st->codec.extradata) { 595 if (st->codec->extradata) {
596 get_buffer(pb, st->codec.extradata, len); 596 get_buffer(pb, st->codec->extradata, len);
597 st->codec.extradata_size = len; 597 st->codec->extradata_size = len;
598 } 598 }
599 } 599 }
600 } 600 }
601 /* in any case, skip garbage */ 601 /* in any case, skip garbage */
602 url_fskip(pb, atom.size - ((url_ftell(pb) - start_pos))); 602 url_fskip(pb, atom.size - ((url_ftell(pb) - start_pos)));
701 if((uint64_t)atom.size > (1<<30)) 701 if((uint64_t)atom.size > (1<<30))
702 return -1; 702 return -1;
703 703
704 // currently SVQ3 decoder expect full STSD header - so let's fake it 704 // currently SVQ3 decoder expect full STSD header - so let's fake it
705 // this should be fixed and just SMI header should be passed 705 // this should be fixed and just SMI header should be passed
706 av_free(st->codec.extradata); 706 av_free(st->codec->extradata);
707 st->codec.extradata_size = 0x5a + atom.size; 707 st->codec->extradata_size = 0x5a + atom.size;
708 st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 708 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
709 709
710 if (st->codec.extradata) { 710 if (st->codec->extradata) {
711 strcpy(st->codec.extradata, "SVQ3"); // fake 711 strcpy(st->codec->extradata, "SVQ3"); // fake
712 get_buffer(pb, st->codec.extradata + 0x5a, atom.size); 712 get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
713 //av_log(NULL, AV_LOG_DEBUG, "Reading SMI %Ld %s\n", atom.size, (char*)st->codec.extradata + 0x5a); 713 //av_log(NULL, AV_LOG_DEBUG, "Reading SMI %Ld %s\n", atom.size, (char*)st->codec->extradata + 0x5a);
714 } else 714 } else
715 url_fskip(pb, atom.size); 715 url_fskip(pb, atom.size);
716 716
717 return 0; 717 return 0;
718 } 718 }
722 AVStream *st = c->fc->streams[c->fc->nb_streams-1]; 722 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
723 723
724 if((uint64_t)atom.size > (1<<30)) 724 if((uint64_t)atom.size > (1<<30))
725 return -1; 725 return -1;
726 726
727 av_free(st->codec.extradata); 727 av_free(st->codec->extradata);
728 728
729 st->codec.extradata_size = atom.size; 729 st->codec->extradata_size = atom.size;
730 st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 730 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
731 731
732 if (st->codec.extradata) { 732 if (st->codec->extradata) {
733 get_buffer(pb, st->codec.extradata, atom.size); 733 get_buffer(pb, st->codec->extradata, atom.size);
734 } else 734 } else
735 url_fskip(pb, atom.size); 735 url_fskip(pb, atom.size);
736 736
737 return 0; 737 return 0;
738 } 738 }
827 id = codec_get_id(mov_video_tags, format); 827 id = codec_get_id(mov_video_tags, format);
828 if (id >= 0) { 828 if (id >= 0) {
829 AVCodec *codec; 829 AVCodec *codec;
830 codec = avcodec_find_decoder(id); 830 codec = avcodec_find_decoder(id);
831 if (codec) 831 if (codec)
832 st->codec.codec_type = codec->type; 832 st->codec->codec_type = codec->type;
833 } 833 }
834 #ifdef DEBUG 834 #ifdef DEBUG
835 av_log(NULL, AV_LOG_DEBUG, "size=%d 4CC= %c%c%c%c codec_type=%d\n", 835 av_log(NULL, AV_LOG_DEBUG, "size=%d 4CC= %c%c%c%c codec_type=%d\n",
836 size, 836 size,
837 (format >> 0) & 0xff, 837 (format >> 0) & 0xff,
838 (format >> 8) & 0xff, 838 (format >> 8) & 0xff,
839 (format >> 16) & 0xff, 839 (format >> 16) & 0xff,
840 (format >> 24) & 0xff, 840 (format >> 24) & 0xff,
841 st->codec.codec_type); 841 st->codec->codec_type);
842 #endif 842 #endif
843 st->codec.codec_tag = format; 843 st->codec->codec_tag = format;
844 if(st->codec.codec_type==CODEC_TYPE_VIDEO) { 844 if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
845 MOV_atom_t a = { 0, 0, 0 }; 845 MOV_atom_t a = { 0, 0, 0 };
846 st->codec.codec_id = id; 846 st->codec->codec_id = id;
847 get_be16(pb); /* version */ 847 get_be16(pb); /* version */
848 get_be16(pb); /* revision level */ 848 get_be16(pb); /* revision level */
849 get_be32(pb); /* vendor */ 849 get_be32(pb); /* vendor */
850 get_be32(pb); /* temporal quality */ 850 get_be32(pb); /* temporal quality */
851 get_be32(pb); /* spacial quality */ 851 get_be32(pb); /* spacial quality */
852 if(st->codec.codec_id == CODEC_ID_MPEG4){ //FIXME this is silly 852 if(st->codec->codec_id == CODEC_ID_MPEG4){ //FIXME this is silly
853 get_be16(pb); 853 get_be16(pb);
854 get_be16(pb); 854 get_be16(pb);
855 }else{ 855 }else{
856 st->codec.width = get_be16(pb); /* width */ 856 st->codec->width = get_be16(pb); /* width */
857 st->codec.height = get_be16(pb); /* height */ 857 st->codec->height = get_be16(pb); /* height */
858 } 858 }
859 get_be32(pb); /* horiz resolution */ 859 get_be32(pb); /* horiz resolution */
860 get_be32(pb); /* vert resolution */ 860 get_be32(pb); /* vert resolution */
861 get_be32(pb); /* data size, always 0 */ 861 get_be32(pb); /* data size, always 0 */
862 frames_per_sample = get_be16(pb); /* frames per samples */ 862 frames_per_sample = get_be16(pb); /* frames per samples */
863 #ifdef DEBUG 863 #ifdef DEBUG
864 av_log(NULL, AV_LOG_DEBUG, "frames/samples = %d\n", frames_per_sample); 864 av_log(NULL, AV_LOG_DEBUG, "frames/samples = %d\n", frames_per_sample);
865 #endif 865 #endif
866 get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */ 866 get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */
867 if (codec_name[0] <= 31) { 867 if (codec_name[0] <= 31) {
868 memcpy(st->codec.codec_name, &codec_name[1],codec_name[0]); 868 memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
869 st->codec.codec_name[codec_name[0]] = 0; 869 st->codec->codec_name[codec_name[0]] = 0;
870 } 870 }
871 871
872 st->codec.bits_per_sample = get_be16(pb); /* depth */ 872 st->codec->bits_per_sample = get_be16(pb); /* depth */
873 st->codec.color_table_id = get_be16(pb); /* colortable id */ 873 st->codec->color_table_id = get_be16(pb); /* colortable id */
874 874
875 /* These are set in mov_read_stts and might already be set! 875 /* These are set in mov_read_stts and might already be set!
876 st->codec.time_base.den = 25; 876 st->codec->time_base.den = 25;
877 st->codec.time_base.num = 1; 877 st->codec->time_base.num = 1;
878 */ 878 */
879 size -= (16+8*4+2+32+2*2); 879 size -= (16+8*4+2+32+2*2);
880 #if 0 880 #if 0
881 while (size >= 8) { 881 while (size >= 8) {
882 MOV_atom_t a; 882 MOV_atom_t a;
946 url_fskip(pb, size); 946 url_fskip(pb, size);
947 } 947 }
948 #else 948 #else
949 949
950 /* figure out the palette situation */ 950 /* figure out the palette situation */
951 color_depth = st->codec.bits_per_sample & 0x1F; 951 color_depth = st->codec->bits_per_sample & 0x1F;
952 color_greyscale = st->codec.bits_per_sample & 0x20; 952 color_greyscale = st->codec->bits_per_sample & 0x20;
953 953
954 /* if the depth is 2, 4, or 8 bpp, file is palettized */ 954 /* if the depth is 2, 4, or 8 bpp, file is palettized */
955 if ((color_depth == 2) || (color_depth == 4) || 955 if ((color_depth == 2) || (color_depth == 4) ||
956 (color_depth == 8)) { 956 (color_depth == 8)) {
957 957
968 color_index -= color_dec; 968 color_index -= color_dec;
969 if (color_index < 0) 969 if (color_index < 0)
970 color_index = 0; 970 color_index = 0;
971 } 971 }
972 972
973 } else if (st->codec.color_table_id & 0x08) { 973 } else if (st->codec->color_table_id & 0x08) {
974 974
975 /* if flag bit 3 is set, use the default palette */ 975 /* if flag bit 3 is set, use the default palette */
976 color_count = 1 << color_depth; 976 color_count = 1 << color_depth;
977 if (color_depth == 2) 977 if (color_depth == 2)
978 color_table = ff_qt_default_palette_4; 978 color_table = ff_qt_default_palette_4;
1010 c->palette_control.palette[j] = 1010 c->palette_control.palette[j] =
1011 (r << 16) | (g << 8) | (b); 1011 (r << 16) | (g << 8) | (b);
1012 } 1012 }
1013 } 1013 }
1014 1014
1015 st->codec.palctrl = &c->palette_control; 1015 st->codec->palctrl = &c->palette_control;
1016 st->codec.palctrl->palette_changed = 1; 1016 st->codec->palctrl->palette_changed = 1;
1017 } else 1017 } else
1018 st->codec.palctrl = NULL; 1018 st->codec->palctrl = NULL;
1019 1019
1020 a.size = size; 1020 a.size = size;
1021 mov_read_default(c, pb, a); 1021 mov_read_default(c, pb, a);
1022 #endif 1022 #endif
1023 } else { 1023 } else {
1024 st->codec.codec_id = codec_get_id(mov_audio_tags, format); 1024 st->codec->codec_id = codec_get_id(mov_audio_tags, format);
1025 if(st->codec.codec_id==CODEC_ID_AMR_NB || st->codec.codec_id==CODEC_ID_AMR_WB) //from TS26.244 1025 if(st->codec->codec_id==CODEC_ID_AMR_NB || st->codec->codec_id==CODEC_ID_AMR_WB) //from TS26.244
1026 { 1026 {
1027 #ifdef DEBUG 1027 #ifdef DEBUG
1028 av_log(NULL, AV_LOG_DEBUG, "AMR-NB or AMR-WB audio identified!!\n"); 1028 av_log(NULL, AV_LOG_DEBUG, "AMR-NB or AMR-WB audio identified!!\n");
1029 #endif 1029 #endif
1030 get_be32(pb);get_be32(pb); //Reserved_8 1030 get_be32(pb);get_be32(pb); //Reserved_8
1043 get_be16(pb); //mode_set 1043 get_be16(pb); //mode_set
1044 get_byte(pb); //mode_change_period 1044 get_byte(pb); //mode_change_period
1045 get_byte(pb); //frames_per_sample 1045 get_byte(pb); //frames_per_sample
1046 1046
1047 st->duration = AV_NOPTS_VALUE;//Not possible to get from this info, must count number of AMR frames 1047 st->duration = AV_NOPTS_VALUE;//Not possible to get from this info, must count number of AMR frames
1048 if(st->codec.codec_id==CODEC_ID_AMR_NB) 1048 if(st->codec->codec_id==CODEC_ID_AMR_NB)
1049 { 1049 {
1050 st->codec.sample_rate=8000; 1050 st->codec->sample_rate=8000;
1051 st->codec.channels=1; 1051 st->codec->channels=1;
1052 } 1052 }
1053 else //AMR-WB 1053 else //AMR-WB
1054 { 1054 {
1055 st->codec.sample_rate=16000; 1055 st->codec->sample_rate=16000;
1056 st->codec.channels=1; 1056 st->codec->channels=1;
1057 } 1057 }
1058 st->codec.bits_per_sample=16; 1058 st->codec->bits_per_sample=16;
1059 st->codec.bit_rate=0; /*It is not possible to tell this before we have 1059 st->codec->bit_rate=0; /*It is not possible to tell this before we have
1060 an audio frame and even then every frame can be different*/ 1060 an audio frame and even then every frame can be different*/
1061 } 1061 }
1062 else if( st->codec.codec_tag == MKTAG( 'm', 'p', '4', 's' )) 1062 else if( st->codec->codec_tag == MKTAG( 'm', 'p', '4', 's' ))
1063 { 1063 {
1064 //This is some stuff for the hint track, lets ignore it! 1064 //This is some stuff for the hint track, lets ignore it!
1065 //Do some mp4 auto detect. 1065 //Do some mp4 auto detect.
1066 c->mp4=1; 1066 c->mp4=1;
1067 size-=(16); 1067 size-=(16);
1068 url_fskip(pb, size); /* The mp4s atom also contians a esds atom that we can skip*/ 1068 url_fskip(pb, size); /* The mp4s atom also contians a esds atom that we can skip*/
1069 } 1069 }
1070 else if( st->codec.codec_tag == MKTAG( 'm', 'p', '4', 'a' )) 1070 else if( st->codec->codec_tag == MKTAG( 'm', 'p', '4', 'a' ))
1071 { 1071 {
1072 MOV_atom_t a; 1072 MOV_atom_t a;
1073 int mp4_version; 1073 int mp4_version;
1074 1074
1075 /* Handle mp4 audio tag */ 1075 /* Handle mp4 audio tag */
1076 mp4_version=get_be16(pb);/*version*/ 1076 mp4_version=get_be16(pb);/*version*/
1077 get_be16(pb); /*revesion*/ 1077 get_be16(pb); /*revesion*/
1078 get_be32(pb); 1078 get_be32(pb);
1079 st->codec.channels = get_be16(pb); /* channels */ 1079 st->codec->channels = get_be16(pb); /* channels */
1080 st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ 1080 st->codec->bits_per_sample = get_be16(pb); /* bits per sample */
1081 get_be32(pb); 1081 get_be32(pb);
1082 st->codec.sample_rate = get_be16(pb); /* sample rate, not always correct */ 1082 st->codec->sample_rate = get_be16(pb); /* sample rate, not always correct */
1083 get_be16(pb); 1083 get_be16(pb);
1084 c->mp4=1; 1084 c->mp4=1;
1085 1085
1086 if(mp4_version==1) 1086 if(mp4_version==1)
1087 { 1087 {
1094 a.offset=url_ftell(pb); 1094 a.offset=url_ftell(pb);
1095 1095
1096 mov_read_default(c, pb, a); 1096 mov_read_default(c, pb, a);
1097 1097
1098 /* Get correct sample rate from extradata */ 1098 /* Get correct sample rate from extradata */
1099 if(st->codec.extradata_size) { 1099 if(st->codec->extradata_size) {
1100 const int samplerate_table[] = { 1100 const int samplerate_table[] = {
1101 96000, 88200, 64000, 48000, 44100, 32000, 1101 96000, 88200, 64000, 48000, 44100, 32000,
1102 24000, 22050, 16000, 12000, 11025, 8000, 1102 24000, 22050, 16000, 12000, 11025, 8000,
1103 7350, 0, 0, 0 1103 7350, 0, 0, 0
1104 }; 1104 };
1105 unsigned char *px = st->codec.extradata; 1105 unsigned char *px = st->codec->extradata;
1106 // 5 bits objectTypeIndex, 4 bits sampleRateIndex, 4 bits channels 1106 // 5 bits objectTypeIndex, 4 bits sampleRateIndex, 4 bits channels
1107 int samplerate_index = ((px[0] & 7) << 1) + ((px[1] >> 7) & 1); 1107 int samplerate_index = ((px[0] & 7) << 1) + ((px[1] >> 7) & 1);
1108 st->codec.sample_rate = samplerate_table[samplerate_index]; 1108 st->codec->sample_rate = samplerate_table[samplerate_index];
1109 st->codec.channels = (px[1] >> 3) & 15; 1109 st->codec->channels = (px[1] >> 3) & 15;
1110 } 1110 }
1111 } 1111 }
1112 else if( st->codec.codec_tag == MKTAG( 'a', 'l', 'a', 'c' )) 1112 else if( st->codec->codec_tag == MKTAG( 'a', 'l', 'a', 'c' ))
1113 { 1113 {
1114 /* Handle alac audio tag + special extradata */ 1114 /* Handle alac audio tag + special extradata */
1115 get_be32(pb); /* version */ 1115 get_be32(pb); /* version */
1116 get_be32(pb); 1116 get_be32(pb);
1117 st->codec.channels = get_be16(pb); /* channels */ 1117 st->codec->channels = get_be16(pb); /* channels */
1118 st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ 1118 st->codec->bits_per_sample = get_be16(pb); /* bits per sample */
1119 get_be32(pb); 1119 get_be32(pb);
1120 st->codec.sample_rate = get_be16(pb); 1120 st->codec->sample_rate = get_be16(pb);
1121 get_be16(pb); 1121 get_be16(pb);
1122 1122
1123 /* fetch the 36-byte extradata needed for alac decoding */ 1123 /* fetch the 36-byte extradata needed for alac decoding */
1124 st->codec.extradata_size = 36; 1124 st->codec->extradata_size = 36;
1125 st->codec.extradata = (uint8_t*) 1125 st->codec->extradata = (uint8_t*)
1126 av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 1126 av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
1127 get_buffer(pb, st->codec.extradata, st->codec.extradata_size); 1127 get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
1128 } 1128 }
1129 else if(size>=(16+20)) 1129 else if(size>=(16+20))
1130 {//16 bytes read, reading atleast 20 more 1130 {//16 bytes read, reading atleast 20 more
1131 uint16_t version; 1131 uint16_t version;
1132 #ifdef DEBUG 1132 #ifdef DEBUG
1134 #endif 1134 #endif
1135 version = get_be16(pb); /* version */ 1135 version = get_be16(pb); /* version */
1136 get_be16(pb); /* revision level */ 1136 get_be16(pb); /* revision level */
1137 get_be32(pb); /* vendor */ 1137 get_be32(pb); /* vendor */
1138 1138
1139 st->codec.channels = get_be16(pb); /* channel count */ 1139 st->codec->channels = get_be16(pb); /* channel count */
1140 st->codec.bits_per_sample = get_be16(pb); /* sample size */ 1140 st->codec->bits_per_sample = get_be16(pb); /* sample size */
1141 1141
1142 /* handle specific s8 codec */ 1142 /* handle specific s8 codec */
1143 get_be16(pb); /* compression id = 0*/ 1143 get_be16(pb); /* compression id = 0*/
1144 get_be16(pb); /* packet size = 0 */ 1144 get_be16(pb); /* packet size = 0 */
1145 1145
1146 st->codec.sample_rate = ((get_be32(pb) >> 16)); 1146 st->codec->sample_rate = ((get_be32(pb) >> 16));
1147 //av_log(NULL, AV_LOG_DEBUG, "CODECID %d %d %.4s\n", st->codec.codec_id, CODEC_ID_PCM_S16BE, (char*)&format); 1147 //av_log(NULL, AV_LOG_DEBUG, "CODECID %d %d %.4s\n", st->codec->codec_id, CODEC_ID_PCM_S16BE, (char*)&format);
1148 1148
1149 switch (st->codec.codec_id) { 1149 switch (st->codec->codec_id) {
1150 case CODEC_ID_PCM_S16BE: 1150 case CODEC_ID_PCM_S16BE:
1151 if (st->codec.bits_per_sample == 8) 1151 if (st->codec->bits_per_sample == 8)
1152 st->codec.codec_id = CODEC_ID_PCM_S8; 1152 st->codec->codec_id = CODEC_ID_PCM_S8;
1153 /* fall */ 1153 /* fall */
1154 case CODEC_ID_PCM_U8: 1154 case CODEC_ID_PCM_U8:
1155 st->codec.bit_rate = st->codec.sample_rate * 8; 1155 st->codec->bit_rate = st->codec->sample_rate * 8;
1156 break; 1156 break;
1157 default: 1157 default:
1158 ; 1158 ;
1159 } 1159 }
1160 1160
1346 duration+=sample_duration*sample_count; 1346 duration+=sample_duration*sample_count;
1347 total_sample_count+=sample_count; 1347 total_sample_count+=sample_count;
1348 } 1348 }
1349 1349
1350 av_set_pts_info(st, 64, 1, c->streams[c->fc->nb_streams-1]->time_scale); 1350 av_set_pts_info(st, 64, 1, c->streams[c->fc->nb_streams-1]->time_scale);
1351 // st->codec.time_base.num = 1; 1351 // st->codec->time_base.num = 1;
1352 // st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale; 1352 // st->codec->time_base.den = c->streams[c->fc->nb_streams-1]->time_scale;
1353 st->nb_frames= total_sample_count; 1353 st->nb_frames= total_sample_count;
1354 if(duration) 1354 if(duration)
1355 st->duration= duration; 1355 st->duration= duration;
1356 return 0; 1356 return 0;
1357 } 1357 }
1398 return -1; 1398 return -1;
1399 } 1399 }
1400 1400
1401 sc->sample_to_chunk_index = -1; 1401 sc->sample_to_chunk_index = -1;
1402 st->priv_data = sc; 1402 st->priv_data = sc;
1403 st->codec.codec_type = CODEC_TYPE_MOV_OTHER; 1403 st->codec->codec_type = CODEC_TYPE_MOV_OTHER;
1404 st->start_time = 0; /* XXX: check */ 1404 st->start_time = 0; /* XXX: check */
1405 c->streams[c->fc->nb_streams-1] = sc; 1405 c->streams[c->fc->nb_streams-1] = sc;
1406 1406
1407 return mov_read_default(c, pb, atom); 1407 return mov_read_default(c, pb, atom);
1408 } 1408 }
1441 get_be16(pb); /* reserved */ 1441 get_be16(pb); /* reserved */
1442 1442
1443 url_fskip(pb, 36); /* display matrix */ 1443 url_fskip(pb, 36); /* display matrix */
1444 1444
1445 /* those are fixed-point */ 1445 /* those are fixed-point */
1446 /*st->codec.width =*/ get_be32(pb) >> 16; /* track width */ 1446 /*st->codec->width =*/ get_be32(pb) >> 16; /* track width */
1447 /*st->codec.height =*/ get_be32(pb) >> 16; /* track height */ 1447 /*st->codec->height =*/ get_be32(pb) >> 16; /* track height */
1448 1448
1449 return 0; 1449 return 0;
1450 } 1450 }
1451 1451
1452 /* this atom should be null (from specs), but some buggy files put the 'moov' atom inside it... */ 1452 /* this atom should be null (from specs), but some buggy files put the 'moov' atom inside it... */
1753 #endif 1753 #endif
1754 mov->total_streams = nb = s->nb_streams; 1754 mov->total_streams = nb = s->nb_streams;
1755 1755
1756 #if 1 1756 #if 1
1757 for(i=0; i<s->nb_streams;) { 1757 for(i=0; i<s->nb_streams;) {
1758 if(s->streams[i]->codec.codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */ 1758 if(s->streams[i]->codec->codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */
1759 av_free(s->streams[i]); 1759 av_free(s->streams[i]);
1760 for(j=i+1; j<s->nb_streams; j++) 1760 for(j=i+1; j<s->nb_streams; j++)
1761 s->streams[j-1] = s->streams[j]; 1761 s->streams[j-1] = s->streams[j];
1762 s->nb_streams--; 1762 s->nb_streams--;
1763 } else 1763 } else
1892 for(i=0; i<(sc->sample_to_chunk_sz); i++) { 1892 for(i=0; i<(sc->sample_to_chunk_sz); i++) {
1893 if( (sc->sample_to_chunk[i].first)<=(sc->next_chunk) ) 1893 if( (sc->sample_to_chunk[i].first)<=(sc->next_chunk) )
1894 { 1894 {
1895 // I can't figure out why for PCM audio sample_size is always 1 1895 // I can't figure out why for PCM audio sample_size is always 1
1896 // (it should actually be channels*bits_per_second/8) but it is. 1896 // (it should actually be channels*bits_per_second/8) but it is.
1897 AVCodecContext* cod = &s->streams[sc->ffindex]->codec; 1897 AVCodecContext* cod = s->streams[sc->ffindex]->codec;
1898 if (sc->sample_size == 1 && (cod->codec_id == CODEC_ID_PCM_S16BE || cod->codec_id == CODEC_ID_PCM_S16LE)) 1898 if (sc->sample_size == 1 && (cod->codec_id == CODEC_ID_PCM_S16BE || cod->codec_id == CODEC_ID_PCM_S16LE))
1899 foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8; 1899 foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8;
1900 else 1900 else
1901 foundsize=sc->sample_to_chunk[i].count*sc->sample_size; 1901 foundsize=sc->sample_to_chunk[i].count*sc->sample_size;
1902 } 1902 }