comparison mov.c @ 1338:531c75b73254 libavformat

remove useless casts
author bcoudurier
date Fri, 29 Sep 2006 10:30:52 +0000
parents 229734e5c3ef
children c2e922377f8b
comparison
equal deleted inserted replaced
1337:229734e5c3ef 1338:531c75b73254
489 st->codec->codec_id= codec_get_id(ff_mov_obj_type, sc->esds.object_type_id); 489 st->codec->codec_id= codec_get_id(ff_mov_obj_type, sc->esds.object_type_id);
490 dprintf("esds object type id %d\n", sc->esds.object_type_id); 490 dprintf("esds object type id %d\n", sc->esds.object_type_id);
491 len = mov_mp4_read_descr(pb, &tag); 491 len = mov_mp4_read_descr(pb, &tag);
492 if (tag == MP4DecSpecificDescrTag) { 492 if (tag == MP4DecSpecificDescrTag) {
493 dprintf("Specific MPEG4 header len=%d\n", len); 493 dprintf("Specific MPEG4 header len=%d\n", len);
494 st->codec->extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); 494 st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
495 if (st->codec->extradata) { 495 if (st->codec->extradata) {
496 get_buffer(pb, st->codec->extradata, len); 496 get_buffer(pb, st->codec->extradata, len);
497 st->codec->extradata_size = len; 497 st->codec->extradata_size = len;
498 /* from mplayer */ 498 /* from mplayer */
499 if ((*(uint8_t *)st->codec->extradata >> 3) == 29) { 499 if ((*(uint8_t *)st->codec->extradata >> 3) == 29) {
643 643
644 // currently SVQ3 decoder expect full STSD header - so let's fake it 644 // currently SVQ3 decoder expect full STSD header - so let's fake it
645 // this should be fixed and just SMI header should be passed 645 // this should be fixed and just SMI header should be passed
646 av_free(st->codec->extradata); 646 av_free(st->codec->extradata);
647 st->codec->extradata_size = 0x5a + atom.size; 647 st->codec->extradata_size = 0x5a + atom.size;
648 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 648 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
649 649
650 if (st->codec->extradata) { 650 if (st->codec->extradata) {
651 strcpy(st->codec->extradata, "SVQ3"); // fake 651 strcpy(st->codec->extradata, "SVQ3"); // fake
652 get_buffer(pb, (uint8_t *)st->codec->extradata + 0x5a, atom.size); 652 get_buffer(pb, (uint8_t *)st->codec->extradata + 0x5a, atom.size);
653 dprintf("Reading SMI %"PRId64" %s\n", atom.size, (char*)st->codec->extradata + 0x5a); 653 dprintf("Reading SMI %"PRId64" %s\n", atom.size, (char*)st->codec->extradata + 0x5a);
684 // currently ALAC decoder expect full atom header - so let's fake it 684 // currently ALAC decoder expect full atom header - so let's fake it
685 // this should be fixed and just ALAC header should be passed 685 // this should be fixed and just ALAC header should be passed
686 686
687 av_free(st->codec->extradata); 687 av_free(st->codec->extradata);
688 st->codec->extradata_size = 36; 688 st->codec->extradata_size = 36;
689 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 689 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
690 690
691 if (st->codec->extradata) { 691 if (st->codec->extradata) {
692 strcpy((char *)st->codec->extradata + 4, "alac"); // fake 692 strcpy((char *)st->codec->extradata + 4, "alac"); // fake
693 get_buffer(pb, (uint8_t *)st->codec->extradata + 8, 36 - 8); 693 get_buffer(pb, (uint8_t *)st->codec->extradata + 8, 36 - 8);
694 dprintf("Reading alac %d %s\n", st->codec->extradata_size, (char*)st->codec->extradata); 694 dprintf("Reading alac %d %s\n", st->codec->extradata_size, (char*)st->codec->extradata);
706 706
707 if (st->codec->codec_id == CODEC_ID_QDM2) { 707 if (st->codec->codec_id == CODEC_ID_QDM2) {
708 // pass all frma atom to codec, needed at least for QDM2 708 // pass all frma atom to codec, needed at least for QDM2
709 av_free(st->codec->extradata); 709 av_free(st->codec->extradata);
710 st->codec->extradata_size = atom.size; 710 st->codec->extradata_size = atom.size;
711 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 711 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
712 712
713 if (st->codec->extradata) { 713 if (st->codec->extradata) {
714 get_buffer(pb, st->codec->extradata, atom.size); 714 get_buffer(pb, st->codec->extradata, atom.size);
715 } else 715 } else
716 url_fskip(pb, atom.size); 716 url_fskip(pb, atom.size);
729 return -1; 729 return -1;
730 730
731 av_free(st->codec->extradata); 731 av_free(st->codec->extradata);
732 732
733 st->codec->extradata_size = atom.size + 8; 733 st->codec->extradata_size = atom.size + 8;
734 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 734 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
735 735
736 /* pass all jp2h atom to codec */ 736 /* pass all jp2h atom to codec */
737 if (st->codec->extradata) { 737 if (st->codec->extradata) {
738 strcpy((char *)st->codec->extradata + 4, "jp2h"); 738 strcpy((char *)st->codec->extradata + 4, "jp2h");
739 get_buffer(pb, (uint8_t *)st->codec->extradata + 8, atom.size); 739 get_buffer(pb, (uint8_t *)st->codec->extradata + 8, atom.size);
750 return -1; 750 return -1;
751 751
752 av_free(st->codec->extradata); 752 av_free(st->codec->extradata);
753 753
754 st->codec->extradata_size = atom.size; 754 st->codec->extradata_size = atom.size;
755 st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 755 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
756 756
757 if (st->codec->extradata) { 757 if (st->codec->extradata) {
758 get_buffer(pb, st->codec->extradata, atom.size); 758 get_buffer(pb, st->codec->extradata, atom.size);
759 } else 759 } else
760 url_fskip(pb, atom.size); 760 url_fskip(pb, atom.size);
775 775
776 if(entries >= UINT_MAX/sizeof(int64_t)) 776 if(entries >= UINT_MAX/sizeof(int64_t))
777 return -1; 777 return -1;
778 778
779 sc->chunk_count = entries; 779 sc->chunk_count = entries;
780 sc->chunk_offsets = (int64_t*) av_malloc(entries * sizeof(int64_t)); 780 sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
781 if (!sc->chunk_offsets) 781 if (!sc->chunk_offsets)
782 return -1; 782 return -1;
783 if (atom.type == MKTAG('s', 't', 'c', 'o')) { 783 if (atom.type == MKTAG('s', 't', 'c', 'o')) {
784 for(i=0; i<entries; i++) { 784 for(i=0; i<entries; i++) {
785 sc->chunk_offsets[i] = get_be32(pb); 785 sc->chunk_offsets[i] = get_be32(pb);
1094 1094
1095 #ifdef DEBUG 1095 #ifdef DEBUG
1096 av_log(NULL, AV_LOG_DEBUG, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries); 1096 av_log(NULL, AV_LOG_DEBUG, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
1097 #endif 1097 #endif
1098 sc->sample_to_chunk_sz = entries; 1098 sc->sample_to_chunk_sz = entries;
1099 sc->sample_to_chunk = (MOV_sample_to_chunk_tbl*) av_malloc(entries * sizeof(MOV_sample_to_chunk_tbl)); 1099 sc->sample_to_chunk = av_malloc(entries * sizeof(MOV_sample_to_chunk_tbl));
1100 if (!sc->sample_to_chunk) 1100 if (!sc->sample_to_chunk)
1101 return -1; 1101 return -1;
1102 for(i=0; i<entries; i++) { 1102 for(i=0; i<entries; i++) {
1103 sc->sample_to_chunk[i].first = get_be32(pb); 1103 sc->sample_to_chunk[i].first = get_be32(pb);
1104 sc->sample_to_chunk[i].count = get_be32(pb); 1104 sc->sample_to_chunk[i].count = get_be32(pb);
1123 1123
1124 sc->keyframe_count = entries; 1124 sc->keyframe_count = entries;
1125 #ifdef DEBUG 1125 #ifdef DEBUG
1126 av_log(NULL, AV_LOG_DEBUG, "keyframe_count = %ld\n", sc->keyframe_count); 1126 av_log(NULL, AV_LOG_DEBUG, "keyframe_count = %ld\n", sc->keyframe_count);
1127 #endif 1127 #endif
1128 sc->keyframes = (long*) av_malloc(entries * sizeof(long)); 1128 sc->keyframes = av_malloc(entries * sizeof(long));
1129 if (!sc->keyframes) 1129 if (!sc->keyframes)
1130 return -1; 1130 return -1;
1131 for(i=0; i<entries; i++) { 1131 for(i=0; i<entries; i++) {
1132 sc->keyframes[i] = get_be32(pb); 1132 sc->keyframes[i] = get_be32(pb);
1133 #ifdef DEBUG 1133 #ifdef DEBUG
1158 return 0; 1158 return 0;
1159 1159
1160 #ifdef DEBUG 1160 #ifdef DEBUG
1161 av_log(NULL, AV_LOG_DEBUG, "sample_size = %ld sample_count = %ld\n", sc->sample_size, sc->sample_count); 1161 av_log(NULL, AV_LOG_DEBUG, "sample_size = %ld sample_count = %ld\n", sc->sample_size, sc->sample_count);
1162 #endif 1162 #endif
1163 sc->sample_sizes = (long*) av_malloc(entries * sizeof(long)); 1163 sc->sample_sizes = av_malloc(entries * sizeof(long));
1164 if (!sc->sample_sizes) 1164 if (!sc->sample_sizes)
1165 return -1; 1165 return -1;
1166 for(i=0; i<entries; i++) { 1166 for(i=0; i<entries; i++) {
1167 sc->sample_sizes[i] = get_be32(pb); 1167 sc->sample_sizes[i] = get_be32(pb);
1168 #ifdef DEBUG 1168 #ifdef DEBUG
1258 AVStream *st; 1258 AVStream *st;
1259 MOVStreamContext *sc; 1259 MOVStreamContext *sc;
1260 1260
1261 st = av_new_stream(c->fc, c->fc->nb_streams); 1261 st = av_new_stream(c->fc, c->fc->nb_streams);
1262 if (!st) return -2; 1262 if (!st) return -2;
1263 sc = (MOVStreamContext*) av_mallocz(sizeof(MOVStreamContext)); 1263 sc = av_mallocz(sizeof(MOVStreamContext));
1264 if (!sc) { 1264 if (!sc) {
1265 av_free(st); 1265 av_free(st);
1266 return -1; 1266 return -1;
1267 } 1267 }
1268 1268
1366 if (get_le32(pb) != MKTAG( 'c', 'm', 'v', 'd' )) 1366 if (get_le32(pb) != MKTAG( 'c', 'm', 'v', 'd' ))
1367 return -1; 1367 return -1;
1368 moov_len = get_be32(pb); /* uncompressed size */ 1368 moov_len = get_be32(pb); /* uncompressed size */
1369 cmov_len = atom.size - 6 * 4; 1369 cmov_len = atom.size - 6 * 4;
1370 1370
1371 cmov_data = (uint8_t *) av_malloc(cmov_len); 1371 cmov_data = av_malloc(cmov_len);
1372 if (!cmov_data) 1372 if (!cmov_data)
1373 return -1; 1373 return -1;
1374 moov_data = (uint8_t *) av_malloc(moov_len); 1374 moov_data = av_malloc(moov_len);
1375 if (!moov_data) { 1375 if (!moov_data) {
1376 av_free(cmov_data); 1376 av_free(cmov_data);
1377 return -1; 1377 return -1;
1378 } 1378 }
1379 get_buffer(pb, cmov_data, cmov_len); 1379 get_buffer(pb, cmov_data, cmov_len);