[Redbutton-devel] SF.net SVN: redbutton: [489] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2008-06-11 14:50:02
|
Revision: 489
http://redbutton.svn.sourceforge.net/redbutton/?rev=489&view=rev
Author: skilvington
Date: 2008-06-11 07:50:00 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
use swscale rather than img_convert. based on patch from Andrea
Modified Paths:
--------------
redbutton-browser/trunk/MHEGDisplay.c
redbutton-browser/trunk/Makefile
redbutton-browser/trunk/videoout_xshm.c
redbutton-browser/trunk/videoout_xshm.h
Modified: redbutton-browser/trunk/MHEGDisplay.c
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.c 2008-06-11 09:10:16 UTC (rev 488)
+++ redbutton-browser/trunk/MHEGDisplay.c 2008-06-11 14:50:00 UTC (rev 489)
@@ -14,6 +14,7 @@
#include <X11/Shell.h>
#include <X11/keysym.h>
#include <ffmpeg/avformat.h>
+#include <ffmpeg/swscale.h>
#include "MHEGEngine.h"
#include "MHEGDisplay.h"
@@ -908,13 +909,20 @@
else
{
/* convert to RGBA */
+ struct SwsContext *sws_ctx;
width = codec_ctx->width;
height = codec_ctx->height;
if((nbytes = avpicture_get_size(PIX_FMT_RGBA32, width, height)) < 0)
fatal("Invalid MPEG image");
rgba = safe_malloc(nbytes);
avpicture_fill((AVPicture *) rgb_frame, rgba, PIX_FMT_RGBA32, width, height);
- img_convert((AVPicture *) rgb_frame, PIX_FMT_RGBA32, (AVPicture*) yuv_frame, codec_ctx->pix_fmt, width, height);
+ //img_convert((AVPicture *) rgb_frame, PIX_FMT_RGBA32, (AVPicture*) yuv_frame, codec_ctx->pix_fmt, width, height);
+ if((sws_ctx = sws_getContext(width, height, codec_ctx->pix_fmt,
+ width, height, PIX_FMT_RGBA32,
+ SWS_FAST_BILINEAR, NULL, NULL, NULL)) == NULL)
+ fatal("Out of memory");
+ sws_scale(sws_ctx, yuv_frame->data, yuv_frame->linesize, 0, height, rgb_frame->data, rgb_frame->linesize);
+ sws_freeContext(sws_ctx);
/* convert the PIX_FMT_RGBA32 data to a MHEGBitmap */
b = MHEGBitmap_fromRGBA(d, rgba, width, height);
}
Modified: redbutton-browser/trunk/Makefile
===================================================================
--- redbutton-browser/trunk/Makefile 2008-06-11 09:10:16 UTC (rev 488)
+++ redbutton-browser/trunk/Makefile 2008-06-11 14:50:00 UTC (rev 489)
@@ -11,6 +11,9 @@
INCS=`freetype-config --cflags`
LIBS=-lm -lz -L/usr/X11R6/lib -lX11 -lXext -lXt -lXrender -lXft -lpng -lavformat -lavcodec -lavutil -lasound -lpthread
+# if libswscale is not in libavcodec, add a -lswscale to the LIBS
+LIBS+=`[ -f /usr/lib/libswscale.so -o -f /usr/local/lib/libswscale.so ] && echo "-lswscale"`
+
CLASSES=ActionClass.o \
ApplicationClass.o \
AudioClass.o \
Modified: redbutton-browser/trunk/videoout_xshm.c
===================================================================
--- redbutton-browser/trunk/videoout_xshm.c 2008-06-11 09:10:16 UTC (rev 488)
+++ redbutton-browser/trunk/videoout_xshm.c 2008-06-11 14:50:00 UTC (rev 489)
@@ -38,8 +38,7 @@
v->current_frame = NULL;
- v->resize_ctx = NULL;
- v->resized_data = NULL;
+ v->sws_ctx = NULL;
return v;
}
@@ -49,10 +48,9 @@
{
vo_xshm_ctx *v = (vo_xshm_ctx *) ctx;
- if(v->resize_ctx != NULL)
+ if(v->sws_ctx != NULL)
{
- img_resample_close(v->resize_ctx);
- safe_free(v->resized_data);
+ sws_freeContext(v->sws_ctx);
}
if(v->current_frame != NULL)
@@ -67,8 +65,6 @@
vo_xshm_prepareFrame(void *ctx, VideoFrame *f, unsigned int out_width, unsigned int out_height)
{
vo_xshm_ctx *v = (vo_xshm_ctx *) ctx;
- AVPicture *yuv_frame;
- int resized_size;
/* have we created the output frame yet */
if(v->current_frame == NULL)
@@ -78,41 +74,28 @@
if(v->current_frame->width != out_width || v->current_frame->height != out_height)
vo_xshm_resize_frame(v, out_width, out_height);
- /* see if the input size is different than the output size */
- if(f->width != out_width || f->height != out_height)
+ /* have the input or output dimensions changed */
+ if(v->sws_ctx == NULL
+ || v->resize_in.width != f->width || v->resize_in.height != f->height
+ || v->resize_out.width != out_width || v->resize_out.height != out_height)
{
- /* have the resize input or output dimensions changed */
- if(v->resize_ctx == NULL
- || v->resize_in.width != f->width || v->resize_in.height != f->height
- || v->resize_out.width != out_width || v->resize_out.height != out_height)
- {
- /* get rid of any existing resize context */
- if(v->resize_ctx != NULL)
- img_resample_close(v->resize_ctx);
- if((v->resize_ctx = img_resample_init(out_width, out_height, f->width, f->height)) == NULL)
- fatal("Out of memory");
- /* remember the resize input and output dimensions */
- v->resize_in.width = f->width;
- v->resize_in.height = f->height;
- v->resize_out.width = out_width;
- v->resize_out.height = out_height;
- /* somewhere to store the resized frame */
- if((resized_size = avpicture_get_size(f->pix_fmt, out_width, out_height)) < 0)
- fatal("vo_xshm_prepareFrame: invalid frame size");
- v->resized_data = safe_realloc(v->resized_data, resized_size);
- avpicture_fill(&v->resized_frame, v->resized_data, f->pix_fmt, out_width, out_height);
- }
- /* resize it */
- img_resample(v->resize_ctx, &v->resized_frame, &f->frame);
- yuv_frame = &v->resized_frame;
+ /* get rid of any existing resize context */
+ if(v->sws_ctx != NULL)
+ sws_freeContext(v->sws_ctx);
+ if((v->sws_ctx = sws_getContext(f->width, f->height, f->pix_fmt,
+ out_width, out_height, v->out_format,
+ SWS_FAST_BILINEAR, NULL, NULL, NULL)) == NULL)
+ fatal("Out of memory");
+ verbose("videoout_xshm: input=%d,%d output=%d,%d", f->width, f->height, out_width, out_height);
+ /* remember the resize input and output dimensions */
+ v->resize_in.width = f->width;
+ v->resize_in.height = f->height;
+ v->resize_out.width = out_width;
+ v->resize_out.height = out_height;
}
- else
- {
- yuv_frame = &f->frame;
- }
- /* convert the frame to RGB */
- img_convert(&v->rgb_frame, v->out_format, yuv_frame, f->pix_fmt, out_width, out_height);
+ /* resize it (if needed) and convert to RGB */
+ sws_scale(v->sws_ctx, f->frame.data, f->frame.linesize, 0, f->height, v->rgb_frame.data, v->rgb_frame.linesize);
return;
}
Modified: redbutton-browser/trunk/videoout_xshm.h
===================================================================
--- redbutton-browser/trunk/videoout_xshm.h 2008-06-11 09:10:16 UTC (rev 488)
+++ redbutton-browser/trunk/videoout_xshm.h 2008-06-11 14:50:00 UTC (rev 489)
@@ -9,6 +9,7 @@
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <ffmpeg/avcodec.h>
+#include <ffmpeg/swscale.h>
typedef struct
{
@@ -22,11 +23,9 @@
XShmSegmentInfo shm; /* shared memory used by current_frame */
AVPicture rgb_frame; /* ffmpeg wrapper for current_frame SHM data */
enum PixelFormat out_format; /* rgb_frame ffmpeg pixel format */
- ImgReSampleContext *resize_ctx; /* NULL if we do not need to resize the frame */
- FrameSize resize_in; /* resize_ctx input dimensions */
- FrameSize resize_out; /* resize_ctx output dimensions */
- AVPicture resized_frame; /* resized output frame */
- uint8_t *resized_data; /* resized_frame data buffer */
+ struct SwsContext *sws_ctx; /* converts to RGB and resizes if needed */
+ FrameSize resize_in; /* input dimensions */
+ FrameSize resize_out; /* output dimensions */
} vo_xshm_ctx;
extern MHEGVideoOutputMethod vo_xshm_fns;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|