* 50 Mbps (DVCPRO50) support
* Copyright (c) 2006 Daniel Maas <dmaas@maasdigital.com>
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <time.h>
#include "avformat.h"
-#include "dvdata.h"
+#include "libavcodec/dvdata.h"
#include "dv.h"
struct DVDemuxContext {
return NULL;
}
- return (frame[offs] == t ? &frame[offs] : NULL);
+ return frame[offs] == t ? &frame[offs] : NULL;
}
/*
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
const DVprofile* sys = dv_codec_profile(c->vst->codec);
int64_t offset;
- int64_t size = url_fsize(&s->pb);
+ int64_t size = url_fsize(s->pb);
int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size;
offset = sys->frame_size * timestamp;
return offset;
}
-void dv_flush_audio_packets(DVDemuxContext *c)
+void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
+ c->frames= frame_offset;
+ if (c->ach)
+ c->abytes= av_rescale(c->frames,
+ c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
+ 8*c->sys->frame_rate);
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
}
if (!c->dv_demux)
return -1;
- if (get_buffer(&s->pb, c->buf, DV_PROFILE_BYTES) <= 0 ||
- url_fseek(&s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
- return AVERROR_IO;
+ if (get_buffer(s->pb, c->buf, DV_PROFILE_BYTES) <= 0 ||
+ url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
+ return AVERROR(EIO);
c->dv_demux->sys = dv_frame_profile(c->buf);
s->bit_rate = av_rescale(c->dv_demux->sys->frame_size * 8,
if (size < 0) {
size = c->dv_demux->sys->frame_size;
- if (get_buffer(&s->pb, c->buf, size) <= 0)
- return AVERROR_IO;
+ if (get_buffer(s->pb, c->buf, size) <= 0)
+ return AVERROR(EIO);
size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
}
DVDemuxContext *c = r->dv_demux;
int64_t offset= dv_frame_offset(s, c, timestamp, flags);
- c->frames= offset / c->sys->frame_size;
- if (c->ach)
- c->abytes= av_rescale(c->frames,
- c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
- 8*c->sys->frame_rate);
+ dv_offset_reset(c, offset / c->sys->frame_size);
- dv_flush_audio_packets(c);
- return url_fseek(&s->pb, offset, SEEK_SET);
+ offset = url_fseek(s->pb, offset, SEEK_SET);
+ return (offset < 0)?offset:0;
}
static int dv_read_close(AVFormatContext *s)
#ifdef CONFIG_DV_DEMUXER
AVInputFormat dv_demuxer = {
"dv",
- "DV video format",
+ NULL_IF_CONFIG_SMALL("DV video format"),
sizeof(RawDVContext),
NULL,
dv_read_header,