Skip to content

Commit 0e97fba

Browse files
committed
lavc video: fixed crash when reinit fails
Fixed a crash in situation where compressing stream with properties A, then B but init fails and then again A. This can occur when using switcher for 1->2->1 when compress reconf fails for 2. But because `saved_desc` is set if reconf succeeds and was already set on first configure, the state is inconsistent because partially de/configured for 2 but it looks like it is still correctly configured to input 1 because `saved_desc` was not cleared. refers to GH-365
1 parent 683718a commit 0e97fba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/video_compress/libavcodec.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Martin Pulec <[email protected]>
44
*/
55
/*
6-
* Copyright (c) 2013-2023 CESNET, z. s. p. o.
6+
* Copyright (c) 2013-2024 CESNET, z. s. p. o.
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -253,7 +253,7 @@ struct state_video_compress_libav {
253253
struct module module_data;
254254

255255
struct video_desc saved_desc{};
256-
struct to_lavc_vid_conv *pixfmt_conversion = nullptr;;
256+
struct to_lavc_vid_conv *pixfmt_conversion = nullptr;
257257
AVPacket *pkt = av_packet_alloc();
258258
// for every core - parts of the above
259259
AVCodecContext *codec_ctx = nullptr;
@@ -1057,6 +1057,7 @@ try_open_remaining_pixfmts(state_video_compress_libav *s, video_desc desc,
10571057

10581058
static bool configure_with(struct state_video_compress_libav *s, struct video_desc desc)
10591059
{
1060+
s->saved_desc = {};
10601061
codec_t ug_codec = s->requested_codec_id == VIDEO_CODEC_NONE ? DEFAULT_CODEC : s->requested_codec_id;
10611062
AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
10621063
const AVCodec *codec = nullptr;

0 commit comments

Comments
 (0)