cellAdec: fix uninitialized default size of AVPacketHolder (#12077)

This commit is contained in:
Megamouse 2022-05-25 11:40:51 +02:00 committed by GitHub
parent 961d41d0bd
commit 88ee62be26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -456,19 +456,19 @@ public:
struct AVPacketHolder : AVPacket struct AVPacketHolder : AVPacket
{ {
AVPacketHolder(u32 size) AVPacketHolder(u32 data_size)
{ {
av_init_packet(this); av_init_packet(this);
if (size) if (data_size)
{ {
data = static_cast<u8*>(av_calloc(1, size + AV_INPUT_BUFFER_PADDING_SIZE)); this->data = static_cast<u8*>(av_calloc(1, data_size + AV_INPUT_BUFFER_PADDING_SIZE));
this->size = size + AV_INPUT_BUFFER_PADDING_SIZE; this->size = data_size + AV_INPUT_BUFFER_PADDING_SIZE;
} }
else else
{ {
data = nullptr; this->data = nullptr;
size = 0; this->size = 0;
} }
} }

View File

@ -324,8 +324,6 @@ namespace utils
} }
// Prepare to read data // Prepare to read data
AVPacket packet;
av_init_packet(&packet);
av.frame = av_frame_alloc(); av.frame = av_frame_alloc();
if (!av.frame) if (!av.frame)
{ {
@ -335,6 +333,9 @@ namespace utils
} }
duration_ms = stream->duration / 1000; duration_ms = stream->duration / 1000;
AVPacket packet{};
av_init_packet(&packet);
// Iterate through frames // Iterate through frames
while (thread_ctrl::state() != thread_state::aborting && av_read_frame(av.format, &packet) >= 0) while (thread_ctrl::state() != thread_state::aborting && av_read_frame(av.format, &packet) >= 0)