Commit 1f8336fd authored by Cameron Cawley's avatar Cameron Cawley Committed by Michael Niedermayer

avformat/rpl: Allow a file to have audio, but not video

Signed-off-by: 's avatarCameron Cawley <ccawley2011@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent dcf3f8b3
...@@ -124,7 +124,7 @@ static int rpl_read_header(AVFormatContext *s) ...@@ -124,7 +124,7 @@ static int rpl_read_header(AVFormatContext *s)
uint32_t i; uint32_t i;
int32_t audio_format, chunk_catalog_offset, number_of_chunks; int32_t video_format, audio_format, chunk_catalog_offset, number_of_chunks;
AVRational fps; AVRational fps;
char line[RPL_LINE_LENGTH]; char line[RPL_LINE_LENGTH];
...@@ -144,17 +144,16 @@ static int rpl_read_header(AVFormatContext *s) ...@@ -144,17 +144,16 @@ static int rpl_read_header(AVFormatContext *s)
av_dict_set(&s->metadata, "author" , line, 0); av_dict_set(&s->metadata, "author" , line, 0);
// video headers // video headers
video_format = read_line_and_int(pb, &error);
if (video_format) {
vst = avformat_new_stream(s, NULL); vst = avformat_new_stream(s, NULL);
if (!vst) if (!vst)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_tag = read_line_and_int(pb, &error); // video format vst->codecpar->codec_tag = video_format;
vst->codecpar->width = read_line_and_int(pb, &error); // video width vst->codecpar->width = read_line_and_int(pb, &error); // video width
vst->codecpar->height = read_line_and_int(pb, &error); // video height vst->codecpar->height = read_line_and_int(pb, &error); // video height
vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample
error |= read_line(pb, line, sizeof(line)); // video frames per second
fps = read_fps(line, &error);
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
// Figure out the video codec // Figure out the video codec
switch (vst->codecpar->codec_tag) { switch (vst->codecpar->codec_tag) {
...@@ -176,6 +175,15 @@ static int rpl_read_header(AVFormatContext *s) ...@@ -176,6 +175,15 @@ static int rpl_read_header(AVFormatContext *s)
av_fourcc2str(vst->codecpar->codec_tag)); av_fourcc2str(vst->codecpar->codec_tag));
vst->codecpar->codec_id = AV_CODEC_ID_NONE; vst->codecpar->codec_id = AV_CODEC_ID_NONE;
} }
} else {
for (i = 0; i < 3; i++)
error |= read_line(pb, line, sizeof(line));
}
error |= read_line(pb, line, sizeof(line)); // video frames per second
fps = read_fps(line, &error);
if (vst)
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
// Audio headers // Audio headers
...@@ -246,7 +254,7 @@ static int rpl_read_header(AVFormatContext *s) ...@@ -246,7 +254,7 @@ static int rpl_read_header(AVFormatContext *s)
} }
rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk
if (rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124) if (vst && rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124)
av_log(s, AV_LOG_WARNING, av_log(s, AV_LOG_WARNING,
"Don't know how to split frames for video format %s. " "Don't know how to split frames for video format %s. "
"Video stream will be broken!\n", av_fourcc2str(vst->codecpar->codec_tag)); "Video stream will be broken!\n", av_fourcc2str(vst->codecpar->codec_tag));
...@@ -261,6 +269,7 @@ static int rpl_read_header(AVFormatContext *s) ...@@ -261,6 +269,7 @@ static int rpl_read_header(AVFormatContext *s)
read_line_and_int(pb, &error); // (file index) read_line_and_int(pb, &error); // (file index)
error |= read_line(pb, line, sizeof(line)); // offset to "helpful" sprite error |= read_line(pb, line, sizeof(line)); // offset to "helpful" sprite
error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite
if (vst)
error |= read_line(pb, line, sizeof(line)); // offset to key frame list error |= read_line(pb, line, sizeof(line)); // offset to key frame list
// Read the index // Read the index
...@@ -274,6 +283,7 @@ static int rpl_read_header(AVFormatContext *s) ...@@ -274,6 +283,7 @@ static int rpl_read_header(AVFormatContext *s)
error = -1; error = -1;
continue; continue;
} }
if (vst)
av_add_index_entry(vst, offset, i * rpl->frames_per_chunk, av_add_index_entry(vst, offset, i * rpl->frames_per_chunk,
video_size, rpl->frames_per_chunk, 0); video_size, rpl->frames_per_chunk, 0);
if (ast) if (ast)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment