diff options
Diffstat (limited to 'libavformat/swfenc.c')
-rw-r--r-- | libavformat/swfenc.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index f8db3e9196..3733a0442c 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -3,24 +3,25 @@ * Copyright (c) 2000 Fabrice Bellard * Copyright (c) 2003 Tinic Uro * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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.1 of the License, or (at your option) any later version. * - * Libav 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 Libav; 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 "libavcodec/put_bits.h" +#include "libavutil/avassert.h" #include "avformat.h" #include "swf.h" @@ -56,7 +57,7 @@ static void put_swf_end_tag(AVFormatContext *s) avio_wl16(pb, (tag << 6) | 0x3f); avio_wl32(pb, tag_len - 4); } else { - assert(tag_len < 0x3f); + av_assert0(tag_len < 0x3f); avio_wl16(pb, (tag << 6) | tag_len); } avio_seek(pb, pos, SEEK_SET); @@ -231,7 +232,7 @@ static int swf_write_header(AVFormatContext *s) } if (!swf->audio_par) - swf->samples_per_frame = (44100.0 * rate_base) / rate; + swf->samples_per_frame = (44100LL * rate_base) / rate; else swf->samples_per_frame = (swf->audio_par->sample_rate * rate_base) / rate; @@ -251,6 +252,10 @@ static int swf_write_header(AVFormatContext *s) (will be patched if not streamed) */ put_swf_rect(pb, 0, width * 20, 0, height * 20); + if ((rate * 256LL) / rate_base >= (1<<16)) { + av_log(s, AV_LOG_ERROR, "Invalid (too large) frame rate %d/%d\n", rate, rate_base); + return AVERROR(EINVAL); + } avio_wl16(pb, (rate * 256) / rate_base); /* frame rate */ swf->duration_pos = avio_tell(pb); avio_wl16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */ @@ -274,8 +279,8 @@ static int swf_write_header(AVFormatContext *s) avio_w8(pb, 0x41); /* clipped bitmap fill */ avio_wl16(pb, BITMAP_ID); /* bitmap ID */ /* position of the bitmap */ - put_swf_matrix(pb, (int)(1.0 * (1 << FRAC_BITS)), 0, - 0, (int)(1.0 * (1 << FRAC_BITS)), 0, 0); + put_swf_matrix(pb, 1 << FRAC_BITS, 0, + 0, 1 << FRAC_BITS, 0, 0); avio_w8(pb, 0); /* no line style */ /* shape drawing */ @@ -427,8 +432,7 @@ static int swf_write_video(AVFormatContext *s, put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG); avio_wl16(pb, swf->sound_samples); avio_wl16(pb, 0); // seek samples - av_fifo_generic_read(swf->audio_fifo, pb, frame_size, - (void (*)(void *, void *, int)) &avio_write); + av_fifo_generic_read(swf->audio_fifo, pb, frame_size, (void*)avio_write); put_swf_end_tag(s); /* update FIFO */ @@ -487,8 +491,9 @@ static int swf_write_trailer(AVFormatContext *s) par = s->streams[i]->codecpar; if (par->codec_type == AVMEDIA_TYPE_VIDEO) video_par = par; - else - av_fifo_free(swf->audio_fifo); + else { + av_fifo_freep(&swf->audio_fifo); + } } put_swf_tag(s, TAG_END); @@ -501,8 +506,10 @@ static int swf_write_trailer(AVFormatContext *s) avio_wl32(pb, file_size); avio_seek(pb, swf->duration_pos, SEEK_SET); avio_wl16(pb, swf->video_frame_number); + if (swf->vframes_pos) { avio_seek(pb, swf->vframes_pos, SEEK_SET); avio_wl16(pb, swf->video_frame_number); + } avio_seek(pb, file_size, SEEK_SET); } return 0; |