Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2014-07-17 12:57:57 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2014-07-30 12:01:55 +0400
commitf5811458dc9302231cc38caae9124780708e475a (patch)
tree7c851880ac69f0c9beb7037677d23670c79bb86f /demuxer
parent1c193f6ece3035ead997f6275baefbe0087d5b5d (diff)
Fix palette for VobSub tracks in MP4.
FFmpeg now outputs the palette converted to RGB instead of the raw MP4-specific YUV palette.
Diffstat (limited to 'demuxer')
-rw-r--r--demuxer/Demuxers/LAVFStreamInfo.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/demuxer/Demuxers/LAVFStreamInfo.cpp b/demuxer/Demuxers/LAVFStreamInfo.cpp
index 3e385909..788d195b 100644
--- a/demuxer/Demuxers/LAVFStreamInfo.cpp
+++ b/demuxer/Demuxers/LAVFStreamInfo.cpp
@@ -374,32 +374,19 @@ STDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStr
#include "libavformat/isom.h"
-static std::string CreateVOBSubHeaderFromMP4(int vidW, int vidH, MOVStreamContext *context, const BYTE *buffer, int buf_size)
+static std::string CreateVOBSubHeaderFromMP4(int vidW, int vidH, MOVStreamContext *context, const char *buffer, int buf_size)
{
std::ostringstream header;
- if (buf_size >= 16*4) {
+ if (buffer && buf_size) {
int w = context && context->width ? context->width : vidW;
int h = context && context->height ? context->height : vidH;
header << "# VobSub index file, v7 (do not modify this line!)\n";
- header << "size: " << w << "x" << h << "\n";
- header << "palette: ";
-
- const BYTE *pal = buffer;
- char rgb[7];
- for(int i = 0; i < 16*4; i += 4) {
- BYTE y = (pal[i+1]-16)*255/219;
- BYTE u = pal[i+2];
- BYTE v = pal[i+3];
- BYTE r = (BYTE)min(max(1.0*y + 1.4022*(v-128), 0), 255);
- BYTE g = (BYTE)min(max(1.0*y - 0.3456*(u-128) - 0.7145*(v-128), 0), 255);
- BYTE b = (BYTE)min(max(1.0*y + 1.7710*(u-128), 0) , 255);
- sprintf_s(rgb, "%02x%02x%02x", r, g, b);
- if (i)
- header << ",";
- header << rgb;
+ // ffmpeg might provide us with the size already
+ if (strncmp(buffer, "size:", 5) != 0) {
+ header << "size: " << w << "x" << h << "\n";
}
- header << "\n";
+ header.write(buffer, buf_size);
}
return header.str();
}
@@ -467,7 +454,7 @@ STDMETHODIMP CLAVFStreamInfo::CreateSubtitleMediaType(AVFormatContext *avctx, AV
// Extradata
if (m_containerFormat == "mp4" && avstream->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
- std::string strVobSubHeader = CreateVOBSubHeaderFromMP4(vidStream ? vidStream->codec->width : 720, vidStream ? vidStream->codec->height : 576, (MOVStreamContext *)avstream->priv_data, avstream->codec->extradata, extra);
+ std::string strVobSubHeader = CreateVOBSubHeaderFromMP4(vidStream ? vidStream->codec->width : 720, vidStream ? vidStream->codec->height : 576, (MOVStreamContext *)avstream->priv_data, (char*)avstream->codec->extradata, extra);
size_t len = strVobSubHeader.length();
mtype.ReallocFormatBuffer((ULONG)(sizeof(SUBTITLEINFO) + len));
memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), strVobSubHeader.c_str(), len);