Commit a56a98f3 authored by romansh's avatar romansh

   * experimental dynamic audio stream allocation for DV demuxer. This
     should make Nathan Kurz and if I don't hear too much complaints
     about it -- that's the way it will be from now on.

   * updating regressions


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3527 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 4855ff10
...@@ -538,7 +538,7 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) ...@@ -538,7 +538,7 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame)
{ {
const uint8_t* as_pack; const uint8_t* as_pack;
const DVprofile* sys; const DVprofile* sys;
int freq, smpls, quant, i; int freq, smpls, quant, i, ach;
sys = dv_frame_profile(frame); sys = dv_frame_profile(frame);
as_pack = dv_extract_pack(frame, dv_audio_source); as_pack = dv_extract_pack(frame, dv_audio_source);
...@@ -550,23 +550,24 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) ...@@ -550,23 +550,24 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame)
smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */ smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */
freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */ freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */
quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */
c->ach = (quant && freq == 2) ? 2 : 1; ach = (quant && freq == 2) ? 2 : 1;
/* The second stereo channel could appear in IEC 61834 stream only */ /* Dynamic handling of the audio streams in DV */
if (c->ach == 2 && !c->ast[1]) { for (i=0; i<ach; i++) {
c->ast[1] = av_new_stream(c->fctx, 0); if (!c->ast[i]) {
if (c->ast[1]) { c->ast[i] = av_new_stream(c->fctx, 0);
av_set_pts_info(c->ast[1], 64, 1, 30000); if (!c->ast[i])
c->ast[1]->codec.codec_type = CODEC_TYPE_AUDIO; break;
c->ast[1]->codec.codec_id = CODEC_ID_PCM_S16LE; av_set_pts_info(c->ast[i], 64, 1, 30000);
} else c->ast[i]->codec.codec_type = CODEC_TYPE_AUDIO;
c->ach = 1; c->ast[i]->codec.codec_id = CODEC_ID_PCM_S16LE;
} }
for (i=0; i<c->ach; i++) {
c->ast[i]->codec.sample_rate = dv_audio_frequency[freq]; c->ast[i]->codec.sample_rate = dv_audio_frequency[freq];
c->ast[i]->codec.channels = 2; c->ast[i]->codec.channels = 2;
c->ast[i]->codec.bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->codec.bit_rate = 2 * dv_audio_frequency[freq] * 16;
c->ast[i]->start_time = 0;
} }
c->ach = i;
return (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */; return (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */;
} }
...@@ -732,14 +733,14 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s) ...@@ -732,14 +733,14 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s)
return NULL; return NULL;
c->vst = av_new_stream(s, 0); c->vst = av_new_stream(s, 0);
c->ast[0] = av_new_stream(s, 0); if (!c->vst) {
if (!c->vst || !c->ast[0]) av_free(c);
goto fail; return NULL;
}
av_set_pts_info(c->vst, 64, 1, 30000); av_set_pts_info(c->vst, 64, 1, 30000);
av_set_pts_info(c->ast[0], 64, 1, 30000);
c->fctx = s; c->fctx = s;
c->ast[1] = NULL; c->ast[0] = c->ast[1] = NULL;
c->ach = 0; c->ach = 0;
c->frames = 0; c->frames = 0;
c->abytes = 0; c->abytes = 0;
...@@ -751,21 +752,7 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s) ...@@ -751,21 +752,7 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s)
c->vst->codec.bit_rate = 25000000; c->vst->codec.bit_rate = 25000000;
c->vst->start_time = 0; c->vst->start_time = 0;
c->ast[0]->codec.codec_type = CODEC_TYPE_AUDIO;
c->ast[0]->codec.codec_id = CODEC_ID_PCM_S16LE;
c->ast[0]->codec.sample_rate = 48000;
c->ast[0]->codec.channels = 2;
c->ast[0]->start_time = 0;
return c; return c;
fail:
if (c->vst)
av_free(c->vst);
if (c->ast[0])
av_free(c->ast[0]);
av_free(c);
return NULL;
} }
static void __destruct_pkt(struct AVPacket *pkt) static void __destruct_pkt(struct AVPacket *pkt)
......
...@@ -25,7 +25,7 @@ b57e3c4e0f27cbd0bf7b7fafb142fe7f *./data/b-libav.ffm ...@@ -25,7 +25,7 @@ b57e3c4e0f27cbd0bf7b7fafb142fe7f *./data/b-libav.ffm
fea20ced22451312dd463110e594eda6 *./data/b-libav.nut fea20ced22451312dd463110e594eda6 *./data/b-libav.nut
332415 ./data/b-libav.nut 332415 ./data/b-libav.nut
./data/b-libav.nut CRC=001a3415 ./data/b-libav.nut CRC=001a3415
f96648fa4a0968f5386d0c6ed9190d98 *./data/b-libav.dv e62f54ddedb85e0f605abf295a18a08e *./data/b-libav.dv
3600000 ./data/b-libav.dv 3600000 ./data/b-libav.dv
./data/b-libav.dv CRC=82e03e76 ./data/b-libav.dv CRC=82e03e76
9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm 9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment