switch (t) {
case dv_audio_source:
- offs = (80*6 + 80*16*3 + 3);
+ offs = (80 * 6 + 80 * 16 * 3 + 3);
break;
case dv_audio_control:
- offs = (80*6 + 80*16*4 + 3);
+ offs = (80 * 6 + 80 * 16 * 4 + 3);
break;
case dv_video_control:
- offs = (80*5 + 48 + 5);
+ offs = (80 * 5 + 48 + 5);
break;
+ case dv_timecode:
+ offs = (80*1 + 3 + 3);
+ break;
default:
return NULL;
}
avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
c->sys->time_base.den);
- avctx->time_base= c->sys->time_base;
+ avctx->time_base = c->sys->time_base;
- if (!avctx->width) {
- avctx->width = c->sys->width;
- avctx->height = c->sys->height;
- }
- avctx->pix_fmt = c->sys->pix_fmt;
/* finding out SAR is a little bit messy */
vsc_pack = dv_extract_pack(frame, dv_video_control);
return size;
}
- /*
- * The following 3 functions constitute our interface to the world
- */
+static int dv_extract_timecode(DVDemuxContext* c, uint8_t* frame, char *tc)
+{
+ const uint8_t *tc_pack;
+
+ // For PAL systems, drop frame bit is replaced by an arbitrary
+ // bit so its value should not be considered. Drop frame timecode
+ // is only relevant for NTSC systems.
+ int prevent_df = c->sys->ltc_divisor == 25 || c->sys->ltc_divisor == 50;
+
+ tc_pack = dv_extract_pack(frame, dv_timecode);
+ if (!tc_pack)
+ return 0;
+ av_timecode_make_smpte_tc_string(tc, AV_RB32(tc_pack + 1), prevent_df);
+ return 1;
+}
+
+ /* The following 3 functions constitute our interface to the world */
- DVDemuxContext* avpriv_dv_init_demux(AVFormatContext *s)
+ DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
{
DVDemuxContext *c;
}
int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
- uint8_t* buf, int buf_size, int64_t pos)
- uint8_t *buf, int buf_size)
++ uint8_t *buf, int buf_size, int64_t pos)
{
int size, i;
- uint8_t *ppcm[4] = {0};
+ uint8_t *ppcm[4] = { 0 };
if (buf_size < DV_PROFILE_BYTES ||
!(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
/* 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].pos = pos;
c->audio_pkt[i].size = size;
- c->audio_pkt[i].pts = c->abytes * 30000 * 8 / c->ast[i]->codec->bit_rate;
+ c->audio_pkt[i].pts = c->abytes * 30000 * 8 /
+ c->ast[i]->codec->bit_rate;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
- c->frames= frame_offset;
+ c->frames = frame_offset;
- if (c->ach)
+ if (c->ach) {
+ if (c->sys) {
- c->abytes= av_rescale_q(c->frames, c->sys->time_base,
- (AVRational){8, c->ast[0]->codec->bit_rate});
- }else
+ c->abytes = av_rescale_q(c->frames, c->sys->time_base,
+ (AVRational) { 8, c->ast[0]->codec->bit_rate });
-
++ } else
+ av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
+ }
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
}
return -1;
}
- s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size, (AVRational){8,1},
+ s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size,
+ (AVRational) { 8, 1 },
c->dv_demux->sys->time_base);
+ if (s->pb->seekable)
+ dv_read_timecode(s);
+
return 0;
}