Skip to content

play music some times produce sigsegv in VideoDecoderFFmpegBase::decode at avcodec_decode_video2 #1420

Description

@SGD9919

class:
VideoDecoderFFmpegBase

part:
ret = avcodec_decode_video2(d.codec_ctx, d.frame, &got_frame_ptr,sendPacket);

debug:
I use qtcreator find d.codec_ctx is 0x0; I got an qt wanning log Audio Decode failed in console
The problem is random, and it is normal for the music file to play again。

may resolve:
check the codec_ctx is null or return false;

I add those in the decode function;I've been testing it for a while
if(!d.codec_ctx||!d.is_open)
{
qWarning("codec context not ready");
return false;
}

deep problem:

in AVDecoderPrivate at line 99;
codec_ctx = avcodec_alloc_context3(NULL);
in ffmpeg introduce:
/**

  • Allocate an AVCodecContext and set its fields to default values. The
  • resulting struct should be freed with avcodec_free_context().
  • @PARAM codec if non-NULL, allocate private data and initialize defaults
  •          for the given codec. It is illegal to then call avcodec_open2()
    
  •          with a different codec.
    
  •          If NULL, then the codec-specific defaults won't be initialized,
    
  •          which may result in suboptimal default settings (this is
    
  •          important mainly for encoders, e.g. libx264).
    
  • @return An AVCodecContext filled with default values or NULL on failure.
    */
    AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);

this function may return null ,but it is not check by any if code。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions