From af7bfcc8585d3fb6b87b1187e6cb62e0a060cecd Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 31 Mar 2007 03:23:46 +0000 Subject: [PATCH] Applied demi's patch to fix the view menu and committed some unfinished (commented out) rgb lavc code Originally committed to SVN as r966. --- aegisub/frame_main_events.cpp | 2 +- aegisub/video_provider_lavc.cpp | 34 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index 37842d31a..70595a636 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -268,7 +268,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Select option if (!showVideo && !showAudio) MenuBar->Check(Menu_View_Subs,true); else if (showVideo && !showAudio) MenuBar->Check(Menu_View_Video,true); - else if (showAudio && !showVideo) MenuBar->Check(Menu_View_Standard,true); + else if (showAudio && showVideo) MenuBar->Check(Menu_View_Standard,true); else MenuBar->Check(Menu_View_Audio,true); } diff --git a/aegisub/video_provider_lavc.cpp b/aegisub/video_provider_lavc.cpp index f74b3c604..98d0bd5b7 100644 --- a/aegisub/video_provider_lavc.cpp +++ b/aegisub/video_provider_lavc.cpp @@ -52,6 +52,7 @@ ///////////////////// // Link to libraries #if __VISUALC__ >= 1200 +#pragma comment(lib, "swscale-0.lib") #pragma comment(lib, "avcodec-51.lib") #pragma comment(lib, "avformat-51.lib") #pragma comment(lib, "avutil-49.lib") @@ -377,7 +378,27 @@ const AegiVideoFrame LAVCVideoProvider::DoGetFrame(int n) { #endif } - // Get frame + // Convert to RGB32 + AVFrame *useFrame = frame; + AVFrame *frameRGB = NULL; + //if (true) { + // // Set properties + // int w = codecContext->width; + // int h = codecContext->height; + // PixelFormat convFormat = PIX_FMT_RGB24; + // unsigned int dstSize = avpicture_get_size(convFormat,w,h); + + // // Allocate RGB32 buffer + // frameRGB = avcodec_alloc_frame(); + // uint8_t *buffer = new uint8_t[dstSize]; + // avpicture_fill((AVPicture*) frameRGB, buffer, convFormat, w, h); + + // // Convert to RGB32 + // img_convert((AVPicture*) frameRGB, convFormat, (AVPicture*) frame, codecContext->pix_fmt, w, h); + // useFrame = frameRGB; + //} + + // Get aegisub frame AegiVideoFrame &final = curFrame; if (frame) { // Set AegiVideoFrame @@ -402,16 +423,16 @@ const AegiVideoFrame LAVCVideoProvider::DoGetFrame(int n) { } // Allocate - for (int i=0;i<4;i++) final.pitch[i] = frame->linesize[i]; + for (int i=0;i<4;i++) final.pitch[i] = useFrame->linesize[i]; final.Allocate(); // Copy data if (final.format == FORMAT_YV12) { - memcpy(final.data[0],frame->data[0],frame->linesize[0] * final.h); - memcpy(final.data[1],frame->data[1],frame->linesize[1] * final.h / 2); - memcpy(final.data[2],frame->data[2],frame->linesize[2] * final.h / 2); + memcpy(final.data[0],useFrame->data[0],useFrame->linesize[0] * final.h); + memcpy(final.data[1],useFrame->data[1],useFrame->linesize[1] * final.h / 2); + memcpy(final.data[2],useFrame->data[2],useFrame->linesize[2] * final.h / 2); } - else memcpy(final.data[0],frame->data[0],size); + else memcpy(final.data[0],useFrame->data[0],size); } // No frame available @@ -421,6 +442,7 @@ const AegiVideoFrame LAVCVideoProvider::DoGetFrame(int n) { validFrame = true; //curFrame = final; frameNumber = n; + if (frameRGB) av_free(frameRGB); // Return return curFrame;