summaryrefslogtreecommitdiff
path: root/ffmpeg/libavformat/lxfdec.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavformat/lxfdec.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavformat/lxfdec.c')
-rw-r--r--ffmpeg/libavformat/lxfdec.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/ffmpeg/libavformat/lxfdec.c b/ffmpeg/libavformat/lxfdec.c
index 876f988..f0a9639 100644
--- a/ffmpeg/libavformat/lxfdec.c
+++ b/ffmpeg/libavformat/lxfdec.c
@@ -29,7 +29,6 @@
#define LXF_IDENT "LEITCH\0"
#define LXF_IDENT_LENGTH 8
#define LXF_SAMPLERATE 48000
-#define LXF_MAX_AUDIO_PACKET (8008*15*4) ///< 15-channel 32-bit NTSC audio frame
static const AVCodecTag lxf_tags[] = {
{ AV_CODEC_ID_MJPEG, 0 },
@@ -116,7 +115,7 @@ static int get_packet_header(AVFormatContext *s)
uint32_t version, audio_format, header_size, channels, tmp;
AVStream *st;
uint8_t header[LXF_MAX_PACKET_HEADER_SIZE];
- const uint8_t *p;
+ const uint8_t *p = header + LXF_IDENT_LENGTH;
//find and read the ident
if ((ret = sync(s, header)) < 0)
@@ -126,11 +125,11 @@ static int get_packet_header(AVFormatContext *s)
if (ret != 8)
return ret < 0 ? ret : AVERROR_EOF;
- p = header + LXF_IDENT_LENGTH;
version = bytestream_get_le32(&p);
header_size = bytestream_get_le32(&p);
if (version > 1)
- avpriv_request_sample(s, "format version %i", version);
+ avpriv_request_sample(s, "Unknown format version %i\n", version);
+
if (header_size < (version ? 72 : 60) ||
header_size > LXF_MAX_PACKET_HEADER_SIZE ||
(header_size & 3)) {
@@ -141,9 +140,8 @@ static int get_packet_header(AVFormatContext *s)
//read the rest of the packet header
if ((ret = avio_read(pb, header + (p - header),
header_size - (p - header))) !=
- header_size - (p - header)) {
+ header_size - (p - header))
return ret < 0 ? ret : AVERROR_EOF;
- }
if (check_checksum(header, header_size))
av_log(s, AV_LOG_ERROR, "checksum error\n");
@@ -163,16 +161,19 @@ static int get_packet_header(AVFormatContext *s)
break;
case 1:
//audio
- if (!s->streams || !(st = s->streams[1])) {
+ if (s->nb_streams < 2) {
av_log(s, AV_LOG_INFO, "got audio packet, but no audio stream present\n");
break;
}
- if (version == 0) p += 8;
+ if (version == 0)
+ p += 8;
audio_format = bytestream_get_le32(&p);
channels = bytestream_get_le32(&p);
track_size = bytestream_get_le32(&p);
+ st = s->streams[1];
+
//set codec based on specified audio bitdepth
//we only support tightly packed 16-, 20-, 24- and 32-bit PCM at the moment
st->codec->bits_per_coded_sample = (audio_format >> 6) & 0x3F;
@@ -258,6 +259,7 @@ static int lxf_read_header(AVFormatContext *s)
st->codec->bit_rate = 1000000 * ((video_params >> 14) & 0xFF);
st->codec->codec_tag = video_params & 0xF;
st->codec->codec_id = ff_codec_get_id(lxf_tags, st->codec->codec_tag);
+ st->need_parsing = AVSTREAM_PARSE_HEADERS;
av_log(s, AV_LOG_DEBUG, "record: %x = %i-%02i-%02i\n",
record_date, 1900 + (record_date & 0x7F), (record_date >> 7) & 0xF,
@@ -290,7 +292,6 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
LXFDemuxContext *lxf = s->priv_data;
AVIOContext *pb = s->pb;
- AVStream *ast = NULL;
uint32_t stream;
int ret, ret2;
@@ -304,18 +305,11 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EAGAIN);
}
- if (stream == 1 && !(ast = s->streams[1])) {
+ if (stream == 1 && s->nb_streams < 2) {
av_log(s, AV_LOG_ERROR, "got audio packet without having an audio stream\n");
return AVERROR_INVALIDDATA;
}
- //make sure the data fits in the de-planerization buffer
- if (ast && ret > LXF_MAX_AUDIO_PACKET) {
- av_log(s, AV_LOG_ERROR, "audio packet too large (%i > %i)\n",
- ret, LXF_MAX_AUDIO_PACKET);
- return AVERROR_INVALIDDATA;
- }
-
if ((ret2 = av_new_packet(pkt, ret)) < 0)
return ret2;
@@ -326,7 +320,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = stream;
- if (!ast) {
+ if (!stream) {
//picture type (0 = closed I, 1 = open I, 2 = P, 3 = B)
if (((lxf->video_format >> 22) & 0x3) < 2)
pkt->flags |= AV_PKT_FLAG_KEY;