summaryrefslogtreecommitdiffstats
path: root/core/Resizer.cpp
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2006-01-14 12:53:59 +0000
committerhandbrake <[email protected]>2006-01-14 12:53:59 +0000
commita9a84221af31ca7d11d1aa182d8b152270203f9f (patch)
treeda452de9a4d3bb509d59de4a65fe12e9fb8e7825 /core/Resizer.cpp
parent939b35fc70bb688d38b086afebd8d14d8193d2c9 (diff)
HandBrake 0.3
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'core/Resizer.cpp')
-rw-r--r--core/Resizer.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/core/Resizer.cpp b/core/Resizer.cpp
new file mode 100644
index 000000000..e3cae3986
--- /dev/null
+++ b/core/Resizer.cpp
@@ -0,0 +1,89 @@
+/* $Id: Resizer.cpp,v 1.3 2003/09/30 14:38:15 titer Exp $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://beos.titer.org/handbrake/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#include "Resizer.h"
+#include "Manager.h"
+#include "Fifo.h"
+
+#include <ffmpeg/avcodec.h>
+
+HBResizer::HBResizer( HBManager * manager, HBTitle * title )
+ : HBThread( "resizer" )
+{
+ fManager = manager;
+ fTitle = title;
+}
+
+void HBResizer::DoWork()
+{
+ /* Init libavcodec */
+ ImgReSampleContext * resampleContext =
+ img_resample_full_init( fTitle->fOutWidth, fTitle->fOutHeight,
+ fTitle->fInWidth, fTitle->fInHeight,
+ fTitle->fTopCrop, fTitle->fBottomCrop,
+ fTitle->fLeftCrop, fTitle->fRightCrop );
+
+ /* Buffers & pictures */
+ HBBuffer * rawBuffer, * deinterlacedBuffer, * resizedBuffer;
+ AVPicture rawPicture, deinterlacedPicture, resizedPicture;
+
+ deinterlacedBuffer = new HBBuffer( 3 * fTitle->fInWidth *
+ fTitle->fInHeight / 2 );
+ avpicture_fill( &deinterlacedPicture, deinterlacedBuffer->fData,
+ PIX_FMT_YUV420P, fTitle->fInWidth,
+ fTitle->fInHeight );
+
+ for( ;; )
+ {
+ while( fSuspend )
+ {
+ Snooze( 10000 );
+ }
+
+ if( !( rawBuffer = Pop( fTitle->fRawFifo ) ) )
+ {
+ break;
+ }
+
+ avpicture_fill( &rawPicture, rawBuffer->fData,
+ PIX_FMT_YUV420P, fTitle->fInWidth,
+ fTitle->fInHeight );
+
+ resizedBuffer = new HBBuffer( 3 * fTitle->fOutWidth *
+ fTitle->fOutHeight / 2 );
+ resizedBuffer->fPosition = rawBuffer->fPosition;
+ resizedBuffer->fPass = rawBuffer->fPass;
+ avpicture_fill( &resizedPicture, resizedBuffer->fData,
+ PIX_FMT_YUV420P, fTitle->fOutWidth,
+ fTitle->fOutHeight );
+
+
+ if( fTitle->fDeinterlace )
+ {
+ avpicture_deinterlace( &deinterlacedPicture, &rawPicture,
+ PIX_FMT_YUV420P,
+ fTitle->fInWidth,
+ fTitle->fInHeight );
+ img_resample( resampleContext, &resizedPicture,
+ &deinterlacedPicture );
+ }
+ else
+ {
+ img_resample( resampleContext, &resizedPicture,
+ &rawPicture );
+ }
+
+ Push( fTitle->fResizedFifo, resizedBuffer );
+ delete rawBuffer;
+ }
+
+ /* Free memory */
+ delete deinterlacedBuffer;
+
+ /* Close libavcodec */
+ img_resample_close( resampleContext );
+}
+