uint8_t audio_buf[4][8192];
int ach;
int frames;
- uint64_t abytes;
};
static inline uint16_t dv_audio_12to16(uint16_t sample)
c->ast[i] = avformat_new_stream(c->fctx, NULL);
if (!c->ast[i])
break;
- avpriv_set_pts_info(c->ast[i], 64, 1, 30000);
+ avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, c->sys->time_base.den);
c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
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);
+ av_timecode_make_smpte_tc_string2(tc, av_inv_q(c->sys->time_base), AV_RB32(tc_pack + 1), prevent_df, 1);
return 1;
}
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]->codecpar->bit_rate;
+ c->audio_pkt[i].pts = (c->sys->height == 720) ? (c->frames & ~1) : c->frames;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} else {
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
- c->abytes += size;
}
- } else {
- c->abytes += size;
}
/* Now it's time to return video packet */
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
c->frames = frame_offset;
- if (c->ach) {
- if (c->sys) {
- c->abytes = av_rescale_q(c->frames, c->sys->time_base,
- (AVRational) { 8, c->ast[0]->codecpar->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;
}
int64_t pos = avio_tell(s->pb);
// Read 3 DIF blocks: Header block and 2 Subcode blocks.
- int partial_frame_size = 3 * 80;
- uint8_t *partial_frame = av_mallocz(sizeof(*partial_frame) *
- partial_frame_size);
-
+#define PARTIAL_FRAME_SIZE (3 * 80)
+ uint8_t partial_frame[PARTIAL_FRAME_SIZE];
RawDVContext *c = s->priv_data;
- if (!partial_frame)
- return AVERROR(ENOMEM);
- ret = avio_read(s->pb, partial_frame, partial_frame_size);
+ ret = avio_read(s->pb, partial_frame, PARTIAL_FRAME_SIZE);
if (ret < 0)
goto finish;
- if (ret < partial_frame_size) {
+ if (ret < PARTIAL_FRAME_SIZE) {
ret = -1;
goto finish;
}
av_log(s, AV_LOG_ERROR, "Detected timecode is invalid\n");
finish:
- av_free(partial_frame);
avio_seek(s->pb, pos, SEEK_SET);
return ret;
}
return 0;
}
-AVInputFormat ff_dv_demuxer = {
+const AVInputFormat ff_dv_demuxer = {
.name = "dv",
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
.priv_data_size = sizeof(RawDVContext),