Skip to content

Commit 6638f41

Browse files
authored
Merge pull request #475 from ferdnyc/ffmpeg-writer
Memory-safety fixes to FFmpegWriter, FrameMapper, DummyReader
2 parents 8cc33b2 + ca31359 commit 6638f41

File tree

5 files changed

+102
-98
lines changed

5 files changed

+102
-98
lines changed

include/FFmpegUtilities.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#ifndef IS_FFMPEG_3_2
4141
#define IS_FFMPEG_3_2 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 64, 101))
4242
#endif
43-
43+
4444
#ifndef HAVE_HW_ACCEL
4545
#define HAVE_HW_ACCEL (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 107, 100))
4646
#endif
@@ -177,13 +177,13 @@
177177
#define AV_OUTPUT_CONTEXT(output_context, path) avformat_alloc_output_context2( output_context, NULL, NULL, path)
178178
#define AV_OPTION_FIND(priv_data, name) av_opt_find(priv_data, name, NULL, 0, 0)
179179
#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);
180-
#define AV_FORMAT_NEW_STREAM(oc, st_codec, av_codec, av_st) av_st = avformat_new_stream(oc, NULL);\
180+
#define AV_FORMAT_NEW_STREAM(oc, st_codec_ctx, av_codec, av_st) av_st = avformat_new_stream(oc, NULL);\
181181
if (!av_st) \
182182
throw OutOfMemory("Could not allocate memory for the video stream.", path); \
183183
c = avcodec_alloc_context3(av_codec); \
184-
st_codec = c; \
184+
st_codec_ctx = c; \
185185
av_st->codecpar->codec_id = av_codec->id;
186-
#define AV_COPY_PARAMS_FROM_CONTEXT(av_stream, av_codec) avcodec_parameters_from_context(av_stream->codecpar, av_codec);
186+
#define AV_COPY_PARAMS_FROM_CONTEXT(av_stream, av_codec_ctx) avcodec_parameters_from_context(av_stream->codecpar, av_codec_ctx);
187187
#elif IS_FFMPEG_3_2
188188
#define AV_REGISTER_ALL av_register_all();
189189
#define AVCODEC_REGISTER_ALL avcodec_register_all();

include/FFmpegWriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ namespace openshot {
164164
AVOutputFormat *fmt;
165165
AVFormatContext *oc;
166166
AVStream *audio_st, *video_st;
167-
AVCodecContext *video_codec;
168-
AVCodecContext *audio_codec;
167+
AVCodecContext *video_codec_ctx;
168+
AVCodecContext *audio_codec_ctx;
169169
SwsContext *img_convert_ctx;
170170
int16_t *samples;
171171
uint8_t *audio_outbuf;

include/FrameMapper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ namespace openshot
138138
*/
139139
class FrameMapper : public ReaderBase {
140140
private:
141-
bool is_open;
142141
bool field_toggle; // Internal odd / even toggle (used when building the mapping)
143142
Fraction original; // The original frame rate
144143
Fraction target; // The target frame rate

0 commit comments

Comments
 (0)