comparison mov.c @ 1834:384f199303aa libavformat

use generic atom to extradata reading function
author bcoudurier
date Fri, 02 Mar 2007 12:12:29 +0000
parents 746ff3525dd7
children 1a6eaec0fad0
comparison
equal deleted inserted replaced
1833:09a67819763e 1834:384f199303aa
645 } 645 }
646 } 646 }
647 return 0; 647 return 0;
648 } 648 }
649 649
650 static int mov_read_alac(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) 650 /* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
651 static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
651 { 652 {
652 AVStream *st = c->fc->streams[c->fc->nb_streams-1]; 653 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
653 654 if((uint64_t)atom.size > (1<<30))
654 // currently ALAC decoder expect full atom header - so let's fake it 655 return -1;
655 // this should be fixed and just ALAC header should be passed
656
657 av_free(st->codec->extradata); 656 av_free(st->codec->extradata);
658 st->codec->extradata_size = 36; 657 st->codec->extradata_size = atom.size + 8;
659 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 658 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
660
661 if (st->codec->extradata) { 659 if (st->codec->extradata) {
662 memcpy(st->codec->extradata + 4, "alac", 4); // fake 660 AV_WL32(st->codec->extradata + 4, atom.type);
663 get_buffer(pb, st->codec->extradata + 8, 36 - 8); 661 get_buffer(pb, st->codec->extradata + 8, atom.size);
664 dprintf("Reading alac %d %s\n", st->codec->extradata_size, st->codec->extradata);
665 } else 662 } else
666 url_fskip(pb, atom.size); 663 url_fskip(pb, atom.size);
667 return 0; 664 return 0;
668 } 665 }
669 666
684 get_buffer(pb, st->codec->extradata, atom.size); 681 get_buffer(pb, st->codec->extradata, atom.size);
685 } else 682 } else
686 url_fskip(pb, atom.size); 683 url_fskip(pb, atom.size);
687 } else if (atom.size > 8) { /* to read frma, esds atoms */ 684 } else if (atom.size > 8) { /* to read frma, esds atoms */
688 mov_read_default(c, pb, atom); 685 mov_read_default(c, pb, atom);
689 } else
690 url_fskip(pb, atom.size);
691 return 0;
692 }
693
694 static int mov_read_jp2h(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
695 {
696 AVStream *st = c->fc->streams[c->fc->nb_streams-1];
697
698 if((uint64_t)atom.size > (1<<30))
699 return -1;
700
701 av_free(st->codec->extradata);
702
703 st->codec->extradata_size = atom.size + 8;
704 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
705
706 /* pass all jp2h atom to codec */
707 if (st->codec->extradata) {
708 memcpy(st->codec->extradata + 4, "jp2h", 4);
709 get_buffer(pb, st->codec->extradata + 8, atom.size);
710 } else 686 } else
711 url_fskip(pb, atom.size); 687 url_fskip(pb, atom.size);
712 return 0; 688 return 0;
713 } 689 }
714 690
1390 { MKTAG( 'e', 'd', 't', 's' ), mov_read_default }, 1366 { MKTAG( 'e', 'd', 't', 's' ), mov_read_default },
1391 { MKTAG( 'e', 'l', 's', 't' ), mov_read_elst }, 1367 { MKTAG( 'e', 'l', 's', 't' ), mov_read_elst },
1392 { MKTAG( 'e', 'n', 'd', 'a' ), mov_read_enda }, 1368 { MKTAG( 'e', 'n', 'd', 'a' ), mov_read_enda },
1393 { MKTAG( 'f', 't', 'y', 'p' ), mov_read_ftyp }, 1369 { MKTAG( 'f', 't', 'y', 'p' ), mov_read_ftyp },
1394 { MKTAG( 'h', 'd', 'l', 'r' ), mov_read_hdlr }, 1370 { MKTAG( 'h', 'd', 'l', 'r' ), mov_read_hdlr },
1395 { MKTAG( 'j', 'p', '2', 'h' ), mov_read_jp2h }, 1371 { MKTAG( 'j', 'p', '2', 'h' ), mov_read_extradata },
1396 { MKTAG( 'm', 'd', 'a', 't' ), mov_read_mdat }, 1372 { MKTAG( 'm', 'd', 'a', 't' ), mov_read_mdat },
1397 { MKTAG( 'm', 'd', 'h', 'd' ), mov_read_mdhd }, 1373 { MKTAG( 'm', 'd', 'h', 'd' ), mov_read_mdhd },
1398 { MKTAG( 'm', 'd', 'i', 'a' ), mov_read_default }, 1374 { MKTAG( 'm', 'd', 'i', 'a' ), mov_read_default },
1399 { MKTAG( 'm', 'i', 'n', 'f' ), mov_read_default }, 1375 { MKTAG( 'm', 'i', 'n', 'f' ), mov_read_default },
1400 { MKTAG( 'm', 'o', 'o', 'v' ), mov_read_moov }, 1376 { MKTAG( 'm', 'o', 'o', 'v' ), mov_read_moov },
1401 { MKTAG( 'm', 'v', 'h', 'd' ), mov_read_mvhd }, 1377 { MKTAG( 'm', 'v', 'h', 'd' ), mov_read_mvhd },
1402 { MKTAG( 'S', 'M', 'I', ' ' ), mov_read_smi }, /* Sorenson extension ??? */ 1378 { MKTAG( 'S', 'M', 'I', ' ' ), mov_read_smi }, /* Sorenson extension ??? */
1403 { MKTAG( 'a', 'l', 'a', 'c' ), mov_read_alac }, /* alac specific atom */ 1379 { MKTAG( 'a', 'l', 'a', 'c' ), mov_read_extradata }, /* alac specific atom */
1404 { MKTAG( 'a', 'v', 'c', 'C' ), mov_read_avcC }, 1380 { MKTAG( 'a', 'v', 'c', 'C' ), mov_read_avcC },
1405 { MKTAG( 's', 't', 'b', 'l' ), mov_read_default }, 1381 { MKTAG( 's', 't', 'b', 'l' ), mov_read_default },
1406 { MKTAG( 's', 't', 'c', 'o' ), mov_read_stco }, 1382 { MKTAG( 's', 't', 'c', 'o' ), mov_read_stco },
1407 { MKTAG( 's', 't', 's', 'c' ), mov_read_stsc }, 1383 { MKTAG( 's', 't', 's', 'c' ), mov_read_stsc },
1408 { MKTAG( 's', 't', 's', 'd' ), mov_read_stsd }, /* sample description */ 1384 { MKTAG( 's', 't', 's', 'd' ), mov_read_stsd }, /* sample description */