Skip to content

Commit

Permalink
Point fix: Align memory for libav sws buffer
Browse files Browse the repository at this point in the history
The libav backend had a bug in software scaling. It set alignment
requirements for a buffer used for software scaling to 16 bytes, which
worked fine in past versions, but results in crashes nowadays with
videos that do not happen to naturally align as needed. This commit sets
the alignment to 64 byes, under the (unverified) assumption that ffmpeg
now uses vector instructions with that alignment requirement.

This change fixes the crash observed in #247 for the example file.
  • Loading branch information
phillipberndt committed Oct 31, 2024
1 parent b251f01 commit 2f040df
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ For some advanced uses of pqiv, take a look at these resouces:
Changelog
---------

pqiv 2.13.1
pqiv 2.13.2
* Revert to not adding `--browse` to desktop files (fixes #232)
* Fix crash for videos with unusual resolutions (fixes #247)

pqiv 2.13
* Fix `toggle_fullscreen(1/2)` behavior when already fullscreen
Expand Down
2 changes: 1 addition & 1 deletion backends/libav.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void file_type_libav_load(file_t *file, GInputStream *data, GError **error_point
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55, 0, 0)
size_t num_bytes = avpicture_get_size(PIX_FMT_RGB32, file->width, file->height);
#else
size_t num_bytes = av_image_get_buffer_size(AV_PIX_FMT_RGB32, file->width, file->height, 16);
size_t num_bytes = av_image_get_buffer_size(AV_PIX_FMT_RGB32, file->width, file->height, 64);
#endif
private->buffer = (uint8_t *)g_malloc(num_bytes * sizeof(uint8_t));

Expand Down
2 changes: 1 addition & 1 deletion pqiv.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" vim:filetype=groff
.TH pqiv 1 "March 2024" "2.13.1"
.TH pqiv 1 "March 2024" "2.13.2"
.SH NAME
pqiv \- powerful quick image viewer
.\"
Expand Down
2 changes: 1 addition & 1 deletion pqiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "lib/bostree.h"

#ifndef PQIV_VERSION
#define PQIV_VERSION "2.13.1"
#define PQIV_VERSION "2.13.2"
#endif

#define FILE_FLAGS_ANIMATION (guint)(1)
Expand Down

0 comments on commit 2f040df

Please sign in to comment.