Mercurial > libavformat.hg
changeset 1268:a6f690337d6c libavformat
support vdva fourcc (dv + dv audio in mov)
author | bcoudurier |
---|---|
date | Thu, 24 Aug 2006 08:28:11 +0000 |
parents | 47ade5d414f9 |
children | f9ba65ef0dbf |
files | mov.c |
diffstat | 1 files changed, 38 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mov.c Thu Aug 24 08:22:26 2006 +0000 +++ b/mov.c Thu Aug 24 08:28:11 2006 +0000 @@ -24,6 +24,7 @@ #include "avformat.h" #include "riff.h" #include "isom.h" +#include "dv.h" #ifdef CONFIG_ZLIB #include <zlib.h> @@ -144,6 +145,8 @@ { CODEC_ID_AC3, MKTAG('m', 's', 0x20, 0x00) }, /* Dolby AC-3 */ { CODEC_ID_ALAC,MKTAG('a', 'l', 'a', 'c') }, /* Apple Lossless */ { CODEC_ID_QDM2,MKTAG('Q', 'D', 'M', '2') }, /* QDM2 */ + { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') }, + { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') }, { CODEC_ID_NONE, 0 }, }; @@ -250,6 +253,7 @@ long current_sample; MOV_esds_t esds; AVRational sample_size_v1; + int dv_audio_container; } MOVStreamContext; typedef struct MOVContext { @@ -275,6 +279,8 @@ AVPaletteControl palette_control; MOV_mdat_atom_t *mdat_list; int mdat_count; + DVDemuxContext *dv_demux; + AVFormatContext *dv_fctx; } MOVContext; @@ -1033,6 +1039,16 @@ case CODEC_ID_MP3ON4: st->codec->sample_rate= 0; /* let decoder init parameters properly */ break; + case CODEC_ID_DVAUDIO: + c->dv_fctx = av_alloc_format_context(); + c->dv_demux = dv_init_demux(c->dv_fctx); + if (!c->dv_demux) { + av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n"); + return -1; + } + sc->dv_audio_container = 1; + st->codec->codec_id = CODEC_ID_PCM_S16LE; + break; default: break; } @@ -1522,7 +1538,7 @@ int stss_index = 0; int i, j, k; - if (sc->sample_sizes || st->codec->codec_type == CODEC_TYPE_VIDEO) { + if (sc->sample_sizes || st->codec->codec_type == CODEC_TYPE_VIDEO || sc->dv_audio_container) { int keyframe, sample_size; int current_sample = 0; int stts_sample = 0; @@ -1712,8 +1728,19 @@ av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%llx: partial file\n", sc->ffindex, sample->pos); return -1; } - url_fseek(&s->pb, sample->pos, SEEK_SET); - av_get_packet(&s->pb, pkt, sample->size); + + if (sc->dv_audio_container) { + dv_get_packet(mov->dv_demux, pkt); + dprintf("dv audio pkt size %d\n", pkt->size); + } else { + url_fseek(&s->pb, sample->pos, SEEK_SET); + av_get_packet(&s->pb, pkt, sample->size); + if (mov->dv_demux) { + void *pkt_destruct_func = pkt->destruct; + dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size); + pkt->destruct = pkt_destruct_func; + } + } pkt->stream_index = sc->ffindex; pkt->dts = sample->timestamp; if (sc->ctts_data) { @@ -1799,6 +1826,14 @@ /* free color tabs */ for(i=0; i<mov->ctab_size; i++) av_freep(&mov->ctab[i]); + if(mov->dv_demux){ + for(i=0; i<mov->dv_fctx->nb_streams; i++){ + av_freep(&mov->dv_fctx->streams[i]->codec); + av_freep(&mov->dv_fctx->streams[i]); + } + av_freep(&mov->dv_fctx); + av_freep(&mov->dv_demux); + } av_freep(&mov->ctab); return 0; }