Skip to content

Commit

Permalink
Merge pull request #475 from ferdnyc/ffmpeg-writer
Browse files Browse the repository at this point in the history
Memory-safety fixes to FFmpegWriter, FrameMapper, DummyReader
  • Loading branch information
ferdnyc committed Jul 12, 2020
2 parents 8cc33b2 + ca31359 commit 6638f41
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 98 deletions.
8 changes: 4 additions & 4 deletions include/FFmpegUtilities.h
Expand Up @@ -40,7 +40,7 @@
#ifndef IS_FFMPEG_3_2
#define IS_FFMPEG_3_2 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 64, 101))
#endif

#ifndef HAVE_HW_ACCEL
#define HAVE_HW_ACCEL (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 107, 100))
#endif
Expand Down Expand Up @@ -177,13 +177,13 @@
#define AV_OUTPUT_CONTEXT(output_context, path) avformat_alloc_output_context2( output_context, NULL, NULL, path)
#define AV_OPTION_FIND(priv_data, name) av_opt_find(priv_data, name, NULL, 0, 0)
#define AV_OPTION_SET( av_stream, priv_data, name, value, avcodec) av_opt_set(priv_data, name, value, 0); avcodec_parameters_from_context(av_stream->codecpar, avcodec);
#define AV_FORMAT_NEW_STREAM(oc, st_codec, av_codec, av_st) av_st = avformat_new_stream(oc, NULL);\
#define AV_FORMAT_NEW_STREAM(oc, st_codec_ctx, av_codec, av_st) av_st = avformat_new_stream(oc, NULL);\
if (!av_st) \
throw OutOfMemory("Could not allocate memory for the video stream.", path); \
c = avcodec_alloc_context3(av_codec); \
st_codec = c; \
st_codec_ctx = c; \
av_st->codecpar->codec_id = av_codec->id;
#define AV_COPY_PARAMS_FROM_CONTEXT(av_stream, av_codec) avcodec_parameters_from_context(av_stream->codecpar, av_codec);
#define AV_COPY_PARAMS_FROM_CONTEXT(av_stream, av_codec_ctx) avcodec_parameters_from_context(av_stream->codecpar, av_codec_ctx);
#elif IS_FFMPEG_3_2
#define AV_REGISTER_ALL av_register_all();
#define AVCODEC_REGISTER_ALL avcodec_register_all();
Expand Down
4 changes: 2 additions & 2 deletions include/FFmpegWriter.h
Expand Up @@ -164,8 +164,8 @@ namespace openshot {
AVOutputFormat *fmt;
AVFormatContext *oc;
AVStream *audio_st, *video_st;
AVCodecContext *video_codec;
AVCodecContext *audio_codec;
AVCodecContext *video_codec_ctx;
AVCodecContext *audio_codec_ctx;
SwsContext *img_convert_ctx;
int16_t *samples;
uint8_t *audio_outbuf;
Expand Down
1 change: 0 additions & 1 deletion include/FrameMapper.h
Expand Up @@ -138,7 +138,6 @@ namespace openshot
*/
class FrameMapper : public ReaderBase {
private:
bool is_open;
bool field_toggle; // Internal odd / even toggle (used when building the mapping)
Fraction original; // The original frame rate
Fraction target; // The target frame rate
Expand Down

0 comments on commit 6638f41

Please sign in to comment.