Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-01-14 06:13:32 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2020-01-15 01:00:35 +0300
commit56a04b7c38e15b5a698ca15bc3e940f06777e315 (patch)
treebd193e6ea110c64ea4f53b61ff84074b6f300ca4 /libavformat/segafilmenc.c
parent30859c270fa5f14d9bb13382f86f90affc3a4c3e (diff)
avformat/segafilmenc: Check early whether video is allowed
The current code only checks when writing the trailer whether the video format and Codec ID are actually compatible with the container. At this point, a lot of data will already have been written (in vain, of course), so check during the init function instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/segafilmenc.c')
-rw-r--r--libavformat/segafilmenc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
index 56fc59a811..bd7c03faf5 100644
--- a/libavformat/segafilmenc.c
+++ b/libavformat/segafilmenc.c
@@ -181,6 +181,17 @@ static int film_init(AVFormatContext *format_context)
av_log(format_context, AV_LOG_ERROR, "Sega FILM allows a maximum of one video stream.\n");
return AVERROR(EINVAL);
}
+ if (st->codecpar->codec_id != AV_CODEC_ID_CINEPAK &&
+ st->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ av_log(format_context, AV_LOG_ERROR,
+ "Incompatible video stream format.\n");
+ return AVERROR(EINVAL);
+ }
+ if (st->codecpar->format != AV_PIX_FMT_RGB24) {
+ av_log(format_context, AV_LOG_ERROR,
+ "Pixel format must be rgb24.\n");
+ return AVERROR(EINVAL);
+ }
film->video_index = i;
}
}
@@ -293,11 +304,6 @@ static int film_write_header(AVFormatContext *format_context)
}
}
- if (video->codecpar->format != AV_PIX_FMT_RGB24) {
- av_log(format_context, AV_LOG_ERROR, "Pixel format must be rgb24.\n");
- return AVERROR(EINVAL);
- }
-
/* First, write the FILM header; this is very simple */
ffio_wfourcc(pb, "FILM");
@@ -320,9 +326,6 @@ static int film_write_header(AVFormatContext *format_context)
case AV_CODEC_ID_RAWVIDEO:
ffio_wfourcc(pb, "raw ");
break;
- default:
- av_log(format_context, AV_LOG_ERROR, "Incompatible video stream format.\n");
- return AVERROR(EINVAL);
}
avio_wb32(pb, video->codecpar->height);