Skip to content

Commit

Permalink
lavc video: fixed crash when reinit fails
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MartinPulec committed Jan 3, 2024
1 parent 683718a commit 0e97fba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/video_compress/libavcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Martin Pulec <[email protected]>
*/
/*
* Copyright (c) 2013-2023 CESNET, z. s. p. o.
* Copyright (c) 2013-2024 CESNET, z. s. p. o.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -253,7 +253,7 @@ struct state_video_compress_libav {
struct module module_data;

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

static bool configure_with(struct state_video_compress_libav *s, struct video_desc desc)
{
s->saved_desc = {};
codec_t ug_codec = s->requested_codec_id == VIDEO_CODEC_NONE ? DEFAULT_CODEC : s->requested_codec_id;
AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
const AVCodec *codec = nullptr;
Expand Down

0 comments on commit 0e97fba

Please sign in to comment.