1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

support vdva fourcc (dv + dv audio in mov)

Originally committed as revision 6064 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Baptiste Coudurier 2006-08-24 08:28:11 +00:00
parent 5bce834e84
commit b60c04547c

View File

@ -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 @@ static const CodecTag mov_audio_tags[] = {
{ 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 @@ typedef struct MOVStreamContext {
long current_sample;
MOV_esds_t esds;
AVRational sample_size_v1;
int dv_audio_container;
} MOVStreamContext;
typedef struct MOVContext {
@ -275,6 +279,8 @@ typedef struct MOVContext {
AVPaletteControl palette_control;
MOV_mdat_atom_t *mdat_list;
int mdat_count;
DVDemuxContext *dv_demux;
AVFormatContext *dv_fctx;
} MOVContext;
@ -1033,6 +1039,16 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
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 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
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 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
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 @@ static int mov_read_close(AVFormatContext *s)
/* 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;
}