Skip to content

Commit

Permalink
VapourSynth/video_output.c, video_output.h: fix alpha byte order of A…
Browse files Browse the repository at this point in the history
…V_PIX_FMT_RGBA64BE

This should really fix #9.

Signed-off-by: akarin <i@akarin.info>
  • Loading branch information
AkarinVS committed Sep 13, 2021
1 parent 1adeabf commit 8ba7892
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions VapourSynth/video_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ static void make_frame_planar_alpha16
int vs_frame_linesize = vsapi->getStride( vs_frame, 0 );
int vs_pixel_offset = 0;
int av_pixel_offset = 0;
const int be = component_reorder_is_bigendian(component_reorder[3]);
for( int i = 0; i < av_picture->height; i++ )
{
uint16_t *av_pixel = (uint16_t *)(av_picture->data[0] + av_pixel_offset) + component_reorder[3];
uint16_t *av_pixel = (uint16_t *)(av_picture->data[0] + av_pixel_offset) + component_reorder_get_order(component_reorder[3]);
uint16_t *vs_pixel = (uint16_t *)(vs_frame_data + vs_pixel_offset);
for( int j = 0; j < av_picture->width; j++ )
{
*(vs_pixel++) = *av_pixel;
*(vs_pixel++) = be ? ((*av_pixel >> 8) | ((*av_pixel & 0xff) << 8)) : *av_pixel;
av_pixel += 4;
}
av_pixel_offset += av_picture->linesize[0];
Expand Down Expand Up @@ -479,7 +480,7 @@ static const component_reorder_t *get_component_reorder( enum AVPixelFormat av_o
{ AV_PIX_FMT_BGR48LE, { 2, 1, 0, -1 } },
{ AV_PIX_FMT_RGBA64LE, { 0, 1, 2, 3 } },
{ AV_PIX_FMT_BGRA64LE, { 2, 1, 0, 3 } },
{ AV_PIX_FMT_RGBA64BE, { 0, 1, 2, 3 } },
{ AV_PIX_FMT_RGBA64BE, { 0, 1, 2, 3 | component_reorder_bigendian } },
{ AV_PIX_FMT_NONE, { 0, 1, 2, 3 } }
};
int i = 0;
Expand Down
3 changes: 3 additions & 0 deletions VapourSynth/video_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "../common/video_output.h"

typedef int component_reorder_t;
enum { component_reorder_bigendian = 0x80 };
#define component_reorder_get_order(order) ((order) & ~component_reorder_bigendian)
#define component_reorder_is_bigendian(order) (!!((order) & component_reorder_bigendian))

typedef void func_make_black_background
(
Expand Down

0 comments on commit 8ba7892

Please sign in to comment.