|
|
|
@ -230,24 +230,24 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) |
|
|
|
|
|
|
|
|
|
/* Dynamic handling of the audio streams in DV */ |
|
|
|
|
for (i = 0; i < ach; i++) { |
|
|
|
|
if (!c->ast[i]) { |
|
|
|
|
c->ast[i] = avformat_new_stream(c->fctx, NULL); |
|
|
|
|
if (!c->ast[i]) |
|
|
|
|
break; |
|
|
|
|
avpriv_set_pts_info(c->ast[i], 64, 1, 30000); |
|
|
|
|
c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
|
|
|
|
c->ast[i]->codec->codec_id = AV_CODEC_ID_PCM_S16LE; |
|
|
|
|
|
|
|
|
|
av_init_packet(&c->audio_pkt[i]); |
|
|
|
|
c->audio_pkt[i].size = 0; |
|
|
|
|
c->audio_pkt[i].data = c->audio_buf[i]; |
|
|
|
|
c->audio_pkt[i].stream_index = c->ast[i]->index; |
|
|
|
|
c->audio_pkt[i].flags |= AV_PKT_FLAG_KEY; |
|
|
|
|
} |
|
|
|
|
c->ast[i]->codec->sample_rate = dv_audio_frequency[freq]; |
|
|
|
|
c->ast[i]->codec->channels = 2; |
|
|
|
|
c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16; |
|
|
|
|
c->ast[i]->start_time = 0; |
|
|
|
|
if (!c->ast[i]) { |
|
|
|
|
c->ast[i] = avformat_new_stream(c->fctx, NULL); |
|
|
|
|
if (!c->ast[i]) |
|
|
|
|
break; |
|
|
|
|
avpriv_set_pts_info(c->ast[i], 64, 1, 30000); |
|
|
|
|
c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
|
|
|
|
c->ast[i]->codec->codec_id = AV_CODEC_ID_PCM_S16LE; |
|
|
|
|
|
|
|
|
|
av_init_packet(&c->audio_pkt[i]); |
|
|
|
|
c->audio_pkt[i].size = 0; |
|
|
|
|
c->audio_pkt[i].data = c->audio_buf[i]; |
|
|
|
|
c->audio_pkt[i].stream_index = c->ast[i]->index; |
|
|
|
|
c->audio_pkt[i].flags |= AV_PKT_FLAG_KEY; |
|
|
|
|
} |
|
|
|
|
c->ast[i]->codec->sample_rate = dv_audio_frequency[freq]; |
|
|
|
|
c->ast[i]->codec->channels = 2; |
|
|
|
|
c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16; |
|
|
|
|
c->ast[i]->start_time = 0; |
|
|
|
|
} |
|
|
|
|
c->ach = i; |
|
|
|
|
|
|
|
|
@ -265,7 +265,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) |
|
|
|
|
avctx = c->vst->codec; |
|
|
|
|
|
|
|
|
|
avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num, |
|
|
|
|
c->sys->time_base.den); |
|
|
|
|
c->sys->time_base.den); |
|
|
|
|
avctx->time_base= c->sys->time_base; |
|
|
|
|
if (!avctx->width){ |
|
|
|
|
avctx->width = c->sys->width; |
|
|
|
@ -277,7 +277,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) |
|
|
|
|
vsc_pack = dv_extract_pack(frame, dv_video_control); |
|
|
|
|
apt = frame[4] & 0x07; |
|
|
|
|
is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || |
|
|
|
|
(!apt && (vsc_pack[2] & 0x07) == 0x07))); |
|
|
|
|
(!apt && (vsc_pack[2] & 0x07) == 0x07))); |
|
|
|
|
c->vst->sample_aspect_ratio = c->sys->sar[is16_9]; |
|
|
|
|
avctx->bit_rate = av_rescale_q(c->sys->frame_size, (AVRational){8,1}, |
|
|
|
|
c->sys->time_base); |
|
|
|
@ -319,12 +319,12 @@ int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < c->ach; i++) { |
|
|
|
|
if (c->ast[i] && c->audio_pkt[i].size) { |
|
|
|
|
*pkt = c->audio_pkt[i]; |
|
|
|
|
c->audio_pkt[i].size = 0; |
|
|
|
|
size = pkt->size; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (c->ast[i] && c->audio_pkt[i].size) { |
|
|
|
|
*pkt = c->audio_pkt[i]; |
|
|
|
|
c->audio_pkt[i].size = 0; |
|
|
|
|
size = pkt->size; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return size; |
|
|
|
@ -339,16 +339,16 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, |
|
|
|
|
if (buf_size < DV_PROFILE_BYTES || |
|
|
|
|
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || |
|
|
|
|
buf_size < c->sys->frame_size) { |
|
|
|
|
return -1; /* Broken frame, or not enough data */ |
|
|
|
|
return -1; /* Broken frame, or not enough data */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Queueing audio packet */ |
|
|
|
|
/* FIXME: in case of no audio/bad audio we have to do something */ |
|
|
|
|
size = dv_extract_audio_info(c, buf); |
|
|
|
|
for (i = 0; i < c->ach; i++) { |
|
|
|
|
c->audio_pkt[i].size = size; |
|
|
|
|
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate; |
|
|
|
|
ppcm[i] = c->audio_buf[i]; |
|
|
|
|
c->audio_pkt[i].size = size; |
|
|
|
|
c->audio_pkt[i].pts = c->abytes * 30000 * 8 / c->ast[i]->codec->bit_rate; |
|
|
|
|
ppcm[i] = c->audio_buf[i]; |
|
|
|
|
} |
|
|
|
|
if (c->ach) |
|
|
|
|
dv_extract_audio(buf, ppcm, c->sys); |
|
|
|
|