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:35 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2020-02-25 21:57:16 +0300
commitab44f0aee88032d2a406b689ff2ff144cf26b0ef (patch)
tree1607d44a0d79474a206e48a730b7ccc50c2ffb1f /libavformat/segafilmenc.c
parentba2581adb26f5df1c8b605ae80fc3005f4e53ee0 (diff)
avformat/segafilmenc: Combine several checks
by moving them around. 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.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
index 5253c14368..7778609e9a 100644
--- a/libavformat/segafilmenc.c
+++ b/libavformat/segafilmenc.c
@@ -155,7 +155,6 @@ static int get_audio_codec_id(enum AVCodecID codec_id)
static int film_init(AVFormatContext *format_context)
{
- AVStream *audio = NULL;
FILMOutputContext *film = format_context->priv_data;
film->audio_index = -1;
film->video_index = -1;
@@ -171,8 +170,12 @@ static int film_init(AVFormatContext *format_context)
av_log(format_context, AV_LOG_ERROR, "Sega FILM allows a maximum of one audio stream.\n");
return AVERROR(EINVAL);
}
+ if (get_audio_codec_id(st->codecpar->codec_id) < 0) {
+ av_log(format_context, AV_LOG_ERROR,
+ "Incompatible audio stream format.\n");
+ return AVERROR(EINVAL);
+ }
film->audio_index = i;
- audio = st;
}
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -200,11 +203,6 @@ static int film_init(AVFormatContext *format_context)
return AVERROR(EINVAL);
}
- if (audio != NULL && get_audio_codec_id(audio->codecpar->codec_id) < 0) {
- av_log(format_context, AV_LOG_ERROR, "Incompatible audio stream format.\n");
- return AVERROR(EINVAL);
- }
-
return 0;
}
@@ -269,11 +267,9 @@ static int film_write_header(AVFormatContext *format_context)
{
int ret = 0;
int64_t sample_table_size, stabsize, headersize;
- int8_t audio_codec;
AVIOContext *pb = format_context->pb;
FILMOutputContext *film = format_context->priv_data;
FILMPacket *prev, *packet;
- AVStream *audio = NULL;
AVStream *video = NULL;
/* Calculate how much we need to reserve for the header;
@@ -290,13 +286,6 @@ static int film_write_header(AVFormatContext *format_context)
/* Seek back to the beginning to start writing the header now */
avio_seek(pb, 0, SEEK_SET);
- if (film->audio_index > -1)
- audio = format_context->streams[film->audio_index];
-
- if (audio != NULL) {
- audio_codec = get_audio_codec_id(audio->codecpar->codec_id);
- }
-
/* First, write the FILM header; this is very simple */
ffio_wfourcc(pb, "FILM");
@@ -327,7 +316,10 @@ static int film_write_header(AVFormatContext *format_context)
avio_wb32(pb, video->codecpar->width);
avio_w8(pb, 24); /* Bits per pixel - observed to always be 24 */
- if (audio != NULL) {
+ if (film->audio_index > -1) {
+ AVStream *audio = format_context->streams[film->audio_index];
+ int audio_codec = get_audio_codec_id(audio->codecpar->codec_id);
+
avio_w8(pb, audio->codecpar->channels); /* Audio channels */
avio_w8(pb, audio->codecpar->bits_per_coded_sample); /* Audio bit depth */
avio_w8(pb, audio_codec); /* Compression - 0 is PCM, 2 is ADX */