[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev51192 - in src: add-ons/media/plugins/ffmpeg apps/mediaplayer/supplier
From:       pulkomandy () pulkomandy ! tk
Date:       2017-05-29 19:52:36
Message-ID: 20170529195236.67DC75C05FE () vmrepo ! haiku-os ! org
[Download RAW message or body]

hrev51192 adds 2 changesets to branch 'master'
old head: ea5cc6995ed45b3b9f4723ebb0f74eb84bab5c9e
new head: 15afaf0bccce20ce19242f483d8145c8bd3d632c
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=15afaf0bccce+%5Eea5cc6995ed4

----------------------------------------------------------------------------

982fc0c2229f: ffmpeg: implement conversion for the GBRP pixel format
  
  ffmpeg decodes some videos in this format: separate planes for G, R and
  B values of the pixels. It does not manage to perform the conversion on
  its own (we would need to use swscale for that), so provide our own
  converter (the code is trivial anyways).

15afaf0bccce: MediaPlayer: detect and convert encoding in subtitles.
  
  The SRT file format unfortunately does not specify a text encoding (in
  fact, there isn't even really a specification for it). Just loading the
  bytes and assuming UTF-8 does not work so well, so we now try to detect
  the encoding from the first line of text found.
  
  Fixes #9668
  
  (sometimes watching a movie is all an adventure!)

                             [ Adrien Destugues <pulkomandy@pulkomandy.tk> ]

----------------------------------------------------------------------------

4 files changed, 48 insertions(+), 2 deletions(-)
src/add-ons/media/plugins/ffmpeg/gfx_conv_c.cpp | 24 +++++++++++++++++++++
src/add-ons/media/plugins/ffmpeg/gfx_conv_c.h   |  2 ++
src/add-ons/media/plugins/ffmpeg/gfx_util.cpp   |  5 +++++
src/apps/mediaplayer/supplier/SubTitlesSRT.cpp  | 19 ++++++++++++++--

############################################################################

Commit:      982fc0c2229fbe35cfd3bc2a5b44be2d0875a078
URL:         http://cgit.haiku-os.org/haiku/commit/?id=982fc0c2229f
Author:      Adrien Destugues <pulkomandy@pulkomandy.tk>
Date:        Mon May 29 19:02:27 2017 UTC

ffmpeg: implement conversion for the GBRP pixel format

ffmpeg decodes some videos in this format: separate planes for G, R and
B values of the pixels. It does not manage to perform the conversion on
its own (we would need to use swscale for that), so provide our own
converter (the code is trivial anyways).

----------------------------------------------------------------------------

diff --git a/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.cpp \
b/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.cpp index e9bb102..09df531 100644
--- a/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.cpp
@@ -295,3 +295,27 @@ gfx_conv_YCbCr422_RGB32_c(AVFrame *in, AVFrame *out, int width, \
int height)  }
 
 }
+
+
+void
+gfx_conv_GBRP_RGB32_c(AVFrame *in, AVFrame *out, int width, int height)
+{
+	uint8 *gBase = (uint8 *)in->data[0];
+	uint8 *bBase = (uint8 *)in->data[1];
+	uint8 *rBase = (uint8 *)in->data[2];
+
+	uint32 *rgbBase = (uint32 *)out->data[0];
+
+	for (int32 i = 0; i < height; i++) {
+
+		for (int32 j = 0; j < width; j ++) {
+			rgbBase[j] = gBase[j] | (bBase[j] << 8) | (rBase[j] << 16);
+		}
+
+		gBase += in->linesize[0];
+		bBase += in->linesize[1];
+		rBase += in->linesize[2];
+
+		rgbBase += out->linesize[0] / 4;
+	}
+}
diff --git a/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.h \
b/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.h index efbdc00..7860ba3 100644
--- a/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.h
+++ b/src/add-ons/media/plugins/ffmpeg/gfx_conv_c.h
@@ -30,6 +30,8 @@ void gfx_conv_YCbCr420p_RGB32_c(AVFrame *in, AVFrame *out, int \
width,  int height);
 void gfx_conv_YCbCr422_RGB32_c(AVFrame *in, AVFrame *out, int width,
 	int height);
+void gfx_conv_GBRP_RGB32_c(AVFrame *in, AVFrame *out, int width,
+	int height);
 
 
 #endif // _GFX_CONV_C_H
diff --git a/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp \
b/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp index a2496cb..bb83dc8 100644
--- a/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp
@@ -45,6 +45,7 @@ extern "C" {
 #define AV_PIX_FMT_BGR565 PIX_FMT_BGR565
 #define AV_PIX_FMT_BGR555 PIX_FMT_BGR555
 #define AV_PIX_FMT_RGB32 PIX_FMT_RGB32
+#define AV_PIX_FMT_GBRP PIX_FMT_GBRP
 #endif
 
 
@@ -106,6 +107,10 @@ resolve_colorspace(color_space colorSpace, AVPixelFormat \
pixelFormat, int width,  return gfx_conv_YCbCr422_RGB32_c;
 			}
 
+			if (pixelFormat == AV_PIX_FMT_GBRP) {
+				return gfx_conv_GBRP_RGB32_c;
+			}
+
 			// Packed Formats
 			if (pixelFormat == AV_PIX_FMT_YUYV422) {
 #ifndef __x86_64__

############################################################################

Revision:    hrev51192
Commit:      15afaf0bccce20ce19242f483d8145c8bd3d632c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=15afaf0bccce
Author:      Adrien Destugues <pulkomandy@pulkomandy.tk>
Date:        Mon May 29 19:33:12 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/9668

MediaPlayer: detect and convert encoding in subtitles.

The SRT file format unfortunately does not specify a text encoding (in
fact, there isn't even really a specification for it). Just loading the
bytes and assuming UTF-8 does not work so well, so we now try to detect
the encoding from the first line of text found.

Fixes #9668

(sometimes watching a movie is all an adventure!)

----------------------------------------------------------------------------

diff --git a/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp \
b/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp index 55eb48a..8186de9 100644
--- a/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp
+++ b/src/apps/mediaplayer/supplier/SubTitlesSRT.cpp
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 
 #include <File.h>
+#include <TextEncoding.h>
 
 #include "FileReadWrite.h"
 
@@ -38,6 +39,8 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
 	int32 lastSequenceNumber = 0;
 	int32 currentLine = 0;
 
+	BPrivate::BTextEncoding* decoder = NULL;
+
 	int32 state = EXPECT_SEQUENCE_NUMBER;
 	while (lineProvider.Next(line)) {
 		line.RemoveAll("\n");
@@ -123,8 +126,20 @@ SubTitlesSRT::SubTitlesSRT(BFile* file, const char* name)
 					subTitle.duration = 0;
 
 					state = EXPECT_SEQUENCE_NUMBER;
-				} else
-					subTitle.text << line << '\n';
+				} else {
+					if (decoder == NULL) {
+						// We try to guess the encoding from the first line of
+						// text in the subtitle file.
+						decoder = new BPrivate::BTextEncoding(line.String(),
+							line.Length());
+					}
+					char buffer[line.Length() * 4];
+					size_t inLength = line.Length();
+					size_t outLength = line.Length() * 4;
+					decoder->Decode(line.String(), inLength, buffer, outLength);
+					buffer[outLength] = 0;
+					subTitle.text << buffer << '\n';
+				}
 				break;
 		}
 		line.SetTo("");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic