From 42dd59957956bfa09d0385a51632f1fd059073a7 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Wed, 26 Nov 2008 02:03:53 +0000 Subject: [PATCH] Make ffmpeg and ffms video providers endianness-aware and always get the video in pixel format expected by the video display. Originally committed to SVN as r2492. --- aegisub/video_provider_ffmpegsource.cpp | 10 ++++++++-- aegisub/video_provider_lavc.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/aegisub/video_provider_ffmpegsource.cpp b/aegisub/video_provider_ffmpegsource.cpp index cb5f81600..5578e620b 100644 --- a/aegisub/video_provider_ffmpegsource.cpp +++ b/aegisub/video_provider_ffmpegsource.cpp @@ -40,6 +40,7 @@ #include "video_provider_ffmpegsource.h" #include "video_context.h" #include "options.h" +#include "aegisub_endian.h" /////////////// @@ -217,13 +218,18 @@ const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int _n, int FormatType) // this is what we'll return eventually AegiVideoFrame &DstFrame = CurFrame; + + bool big_endian = Endian::BigToMachine((int)1)==(int)1; // choose output format - if (FormatType & FORMAT_RGB32) { + if (FormatType & FORMAT_RGB32 && big_endian) { + DstFormat = FFMS_PIX_FMT_BGR32_1; + DstFrame.format = FORMAT_RGB32; + } else if (FormatType & FORMAT_RGB32 && !big_endian) { DstFormat = FFMS_PIX_FMT_RGB32; DstFrame.format = FORMAT_RGB32; } else if (FormatType & FORMAT_RGB24) { - DstFormat = FFMS_PIX_FMT_RGB24; + DstFormat = FFMS_PIX_FMT_BGR24; DstFrame.format = FORMAT_RGB24; } else if (FormatType & FORMAT_YV12) { DstFormat = FFMS_PIX_FMT_YUV420P; // may or may not work diff --git a/aegisub/video_provider_lavc.cpp b/aegisub/video_provider_lavc.cpp index 4eb7aa699..b11bbb69f 100644 --- a/aegisub/video_provider_lavc.cpp +++ b/aegisub/video_provider_lavc.cpp @@ -283,7 +283,7 @@ const AegiVideoFrame LAVCVideoProvider::GetFrame(int n,int formatType) { int w = codecContext->width; int h = codecContext->height; PixelFormat srcFormat = codecContext->pix_fmt; - PixelFormat dstFormat = PIX_FMT_RGB32; + PixelFormat dstFormat = PIX_FMT_BGRA; // Allocate RGB32 buffer if(!sws_context) //first frame