mirror of https://git.ffmpeg.org/ffmpeg.git
* let DV muxer generate audioless DV streams. This might not be 100%
complaint with the SMPTE & IEC specs, but it seems harmless enough. The way we "specify" that there's no audio is by simply leaving audio DIFs filled with 0xff (I bet there's a way to mark this properly in the system info section!). Originally committed as revision 3526 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
e4a185ac14
commit
96319c3922
|
@ -377,9 +377,9 @@ static void dv_format_frame(DVMuxContext *c, uint8_t* buf)
|
||||||
/* DV Audio/Video: 135 Video DIFs + 9 Audio DIFs */
|
/* DV Audio/Video: 135 Video DIFs + 9 Audio DIFs */
|
||||||
for (j = 0; j < 135; j++) {
|
for (j = 0; j < 135; j++) {
|
||||||
if (j%15 == 0) {
|
if (j%15 == 0) {
|
||||||
|
memset(buf, 0xff, 80);
|
||||||
buf += dv_write_dif_id(dv_sect_audio, i, j/15, buf);
|
buf += dv_write_dif_id(dv_sect_audio, i, j/15, buf);
|
||||||
buf += dv_write_pack(dv_aaux_packs_dist[i][j/15], c, buf);
|
buf += 77; /* audio control & shuffled PCM audio */
|
||||||
buf += 72; /* shuffled PCM audio */
|
|
||||||
}
|
}
|
||||||
buf += dv_write_dif_id(dv_sect_video, i, j, buf);
|
buf += dv_write_dif_id(dv_sect_video, i, j, buf);
|
||||||
buf += 77; /* 1 video macro block: 1 bytes control
|
buf += 77; /* 1 video macro block: 1 bytes control
|
||||||
|
@ -397,6 +397,7 @@ static void dv_inject_audio(DVMuxContext *c, const uint8_t* pcm, uint8_t* frame_
|
||||||
for (i = 0; i < c->sys->difseg_size; i++) {
|
for (i = 0; i < c->sys->difseg_size; i++) {
|
||||||
frame_ptr += 6 * 80; /* skip DIF segment header */
|
frame_ptr += 6 * 80; /* skip DIF segment header */
|
||||||
for (j = 0; j < 9; j++) {
|
for (j = 0; j < 9; j++) {
|
||||||
|
dv_write_pack(dv_aaux_packs_dist[i][j], c, &frame_ptr[3]);
|
||||||
for (d = 8; d < 80; d+=2) {
|
for (d = 8; d < 80; d+=2) {
|
||||||
of = c->sys->audio_shuffle[i][j] + (d - 8)/2 * c->sys->audio_stride;
|
of = c->sys->audio_shuffle[i][j] + (d - 8)/2 * c->sys->audio_stride;
|
||||||
if (of*2 >= size)
|
if (of*2 >= size)
|
||||||
|
@ -614,7 +615,9 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
|
||||||
if (c->has_audio && c->has_video) { /* must be a stale frame */
|
if (c->has_audio && c->has_video) { /* must be a stale frame */
|
||||||
dv_format_frame(c, *frame);
|
dv_format_frame(c, *frame);
|
||||||
c->frames++;
|
c->frames++;
|
||||||
c->has_audio = c->has_video = 0;
|
if (c->has_audio > 0)
|
||||||
|
c->has_audio = 0;
|
||||||
|
c->has_video = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
|
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
|
||||||
|
@ -625,6 +628,8 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
|
||||||
dv_inject_video(c, data, *frame);
|
dv_inject_video(c, data, *frame);
|
||||||
c->has_video = 1;
|
c->has_video = 1;
|
||||||
data_size = 0;
|
data_size = 0;
|
||||||
|
if (c->has_audio < 0)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames);
|
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames);
|
||||||
|
@ -649,56 +654,59 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
|
||||||
fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr);
|
fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
return (c->has_audio && c->has_video) ? c->sys->frame_size : 0;
|
return (c->has_audio && c->has_video) ? c->sys->frame_size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DVMuxContext* dv_init_mux(AVFormatContext* s)
|
DVMuxContext* dv_init_mux(AVFormatContext* s)
|
||||||
{
|
{
|
||||||
DVMuxContext *c;
|
DVMuxContext *c;
|
||||||
AVStream *vst;
|
AVStream *vst = NULL;
|
||||||
AVStream *ast;
|
AVStream *ast = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (s->nb_streams > 2)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
c = av_mallocz(sizeof(DVMuxContext));
|
c = av_mallocz(sizeof(DVMuxContext));
|
||||||
if (!c)
|
if (!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (s->nb_streams != 2)
|
|
||||||
goto bail_out;
|
|
||||||
|
|
||||||
/* We have to sort out where audio and where video stream is */
|
/* We have to sort out where audio and where video stream is */
|
||||||
if (s->streams[0]->codec.codec_type == CODEC_TYPE_VIDEO &&
|
for (i=0; i<s->nb_streams; i++) {
|
||||||
s->streams[1]->codec.codec_type == CODEC_TYPE_AUDIO) {
|
switch (s->streams[i]->codec.codec_type) {
|
||||||
vst = s->streams[0];
|
case CODEC_TYPE_VIDEO:
|
||||||
ast = s->streams[1];
|
vst = s->streams[i];
|
||||||
}
|
break;
|
||||||
else if (s->streams[1]->codec.codec_type == CODEC_TYPE_VIDEO &&
|
case CODEC_TYPE_AUDIO:
|
||||||
s->streams[0]->codec.codec_type == CODEC_TYPE_AUDIO) {
|
ast = s->streams[i];
|
||||||
vst = s->streams[1];
|
break;
|
||||||
ast = s->streams[0];
|
default:
|
||||||
} else
|
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Some checks -- DV format is very picky about its incoming streams */
|
/* Some checks -- DV format is very picky about its incoming streams */
|
||||||
if (vst->codec.codec_id != CODEC_ID_DVVIDEO ||
|
if (!vst || vst->codec.codec_id != CODEC_ID_DVVIDEO)
|
||||||
ast->codec.codec_id != CODEC_ID_PCM_S16LE)
|
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
if (ast->codec.sample_rate != 48000 ||
|
if (ast && (ast->codec.codec_id != CODEC_ID_PCM_S16LE ||
|
||||||
ast->codec.channels != 2)
|
ast->codec.sample_rate != 48000 ||
|
||||||
|
ast->codec.channels != 2))
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
|
|
||||||
c->sys = dv_codec_profile(&vst->codec);
|
c->sys = dv_codec_profile(&vst->codec);
|
||||||
if (!c->sys)
|
if (!c->sys)
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
|
|
||||||
/* Ok, everything seems to be in working order */
|
/* Ok, everything seems to be in working order */
|
||||||
c->frames = 0;
|
c->frames = 0;
|
||||||
c->has_audio = c->has_video = 0;
|
c->has_audio = ast ? 0 : -1;
|
||||||
|
c->has_video = 0;
|
||||||
c->start_time = (time_t)s->timestamp;
|
c->start_time = (time_t)s->timestamp;
|
||||||
c->aspect = 0; /* 4:3 is the default */
|
c->aspect = 0; /* 4:3 is the default */
|
||||||
if ((int)(av_q2d(vst->codec.sample_aspect_ratio) * vst->codec.width / vst->codec.height * 10) == 17) /* 16:9 */
|
if ((int)(av_q2d(vst->codec.sample_aspect_ratio) * vst->codec.width / vst->codec.height * 10) == 17) /* 16:9 */
|
||||||
c->aspect = 0x07;
|
c->aspect = 0x07;
|
||||||
|
|
||||||
if (fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0)
|
if (ast && fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0)
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
|
|
||||||
dv_format_frame(c, &c->frame_buf[0]);
|
dv_format_frame(c, &c->frame_buf[0]);
|
||||||
|
|
Loading…
Reference in New Issue