diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-11-01 21:47:42 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-11-01 21:47:42 +0400 |
commit | 1e0520a3d390b05f701b8384f92b34c558cbd12f (patch) | |
tree | d4196696b2f04e9f95bb0d4b745822652dd6aee6 | |
parent | 43f4d093a62a5c244c5040e197eddee62bdefb4c (diff) |
Communicate the video size from the decoder to the subtitle renderer.
-rw-r--r-- | decoder/LAVVideo/LAVVideo.cpp | 7 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp | 1 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h | 3 | ||||
-rw-r--r-- | decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp | 8 |
4 files changed, 19 insertions, 0 deletions
diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index 3f6c773d..7caf737c 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -766,6 +766,12 @@ HRESULT CLAVVideo::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin) m_SubtitleConsumer = new CLAVSubtitleConsumer(this); m_SubtitleConsumer->AddRef(); m_pSubtitleInput->SetSubtitleConsumer(m_SubtitleConsumer); + + BITMAPINFOHEADER *pBIH = NULL; + videoFormatTypeHandler(m_pInput->CurrentMediaType(), &pBIH); + if (pBIH) { + m_SubtitleConsumer->SetVideoSize(pBIH->biWidth, pBIH->biHeight); + } } } return S_OK; @@ -1394,6 +1400,7 @@ HRESULT CLAVVideo::DeliverToRenderer(LAVFrame *pFrame) BOOL bRGBOut = (m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB24 || m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB32); // And blend subtitles if we're on YUV output before blending (because the output YUV formats are more complicated to handle) if (m_SubtitleConsumer && m_SubtitleConsumer->HasProvider()) { + m_SubtitleConsumer->SetVideoSize(width, height); m_SubtitleConsumer->RequestFrame(pFrame->rtStart, pFrame->rtStop); if (!bRGBOut) m_SubtitleConsumer->ProcessFrame(pFrame); diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp index cb2489cc..f3679a7e 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp +++ b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp @@ -25,6 +25,7 @@ static const SubRenderOption options[] = { { "name", OFFSET(name), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, { "version", OFFSET(version), SROPT_TYPE_STRING, SROPT_FLAG_READONLY }, + { "originalVideoSize", OFFSET(originalVideoSize), SROPT_TYPE_SIZE, SROPT_FLAG_READONLY }, { "redraw", OFFSET(redraw), SROPT_TYPE_BOOL, 0 }, { 0 } diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h index 17e2da8c..72c7bfe7 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h +++ b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h @@ -35,6 +35,7 @@ typedef struct LAVSubtitleConsumerContext { LPWSTR name; ///< name of the Consumer LPWSTR version; ///< Version of the Consumer + SIZE originalVideoSize; ///< Size of the video bool redraw; } LAVSubtitleConsumerContext; @@ -66,6 +67,8 @@ public: BOOL HasProvider() const { return m_pProvider != NULL; } + void SetVideoSize(LONG w, LONG h) { context.originalVideoSize.cx = w; context.originalVideoSize.cy = h; } + private: STDMETHODIMP ProcessSubtitleBitmap(LAVPixelFormat pixFmt, int bpp, RECT videoRect, BYTE *videoData[4], int videoStride[4], RECT subRect, POINT subPosition, SIZE subSize, const uint8_t *rgbData, int pitch); diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp index 2ddc0d31..69bd5187 100644 --- a/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp +++ b/decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp @@ -98,6 +98,14 @@ STDMETHODIMP CLAVSubtitleProvider::RequestFrame(REFERENCE_TIME start, REFERENCE_ CLAVSubtitleFrame *subtitleFrame = new CLAVSubtitleFrame(); subtitleFrame->AddRef(); + if (m_pAVCtx->width == 720 && m_pAVCtx->height == 480) { + SIZE videoSize; + m_pConsumer->GetSize("originalVideoSize", &videoSize); + if (videoSize.cx == 720) { + m_pAVCtx->height = videoSize.cy; + } + } + RECT outputRect; ::SetRect(&outputRect, 0, 0, m_pAVCtx->width, m_pAVCtx->height); subtitleFrame->SetOutputRect(outputRect); |