[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10546: Allow manual override of _qu
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10546: Allow manual override of _quality setting. Clean up VideoRenderer. |
Date: |
Mon, 19 Jan 2009 14:00:51 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10546
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-01-19 14:00:51 +0100
message:
Allow manual override of _quality setting. Clean up VideoRenderer.
modified:
backend/render_handler.h
backend/render_handler_agg.cpp
libbase/rc.cpp
libbase/rc.h
libcore/character.cpp
libcore/gnash.h
libcore/movie_root.cpp
libcore/movie_root.h
libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
testsuite/gnashrc.in
------------------------------------------------------------
revno: 10545.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-01-19 09:05:42 +0100
message:
Movie Quality enum to gnash.h so it's easier to share.
Add an override for quality, using -1 for the AS / SWF quality setting,
otherwise a permanent manual override.
modified:
backend/render_handler.h
libbase/rc.cpp
libbase/rc.h
libcore/character.cpp
libcore/gnash.h
libcore/movie_root.cpp
libcore/movie_root.h
testsuite/gnashrc.in
------------------------------------------------------------
revno: 10545.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-01-19 09:19:48 +0100
message:
Correct quality override.
modified:
libbase/rc.cpp
libcore/movie_root.cpp
------------------------------------------------------------
revno: 10545.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-01-19 10:35:43 +0100
message:
Drop some unused code.
modified:
backend/render_handler_agg.cpp
------------------------------------------------------------
revno: 10545.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-01-19 11:38:11 +0100
message:
Clean up VideoRenderer and other bits of the agg renderer.
modified:
backend/render_handler_agg.cpp
------------------------------------------------------------
revno: 10545.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-01-19 12:24:43 +0100
message:
Line breaks.
modified:
libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
=== modified file 'backend/render_handler.h'
--- a/backend/render_handler.h 2009-01-16 18:00:27 +0000
+++ b/backend/render_handler.h 2009-01-19 08:05:42 +0000
@@ -145,6 +145,7 @@
#include "dsodefs.h" // for DSOEXPORT
+#include "gnash.h" // Quality
#include "shape_character_def.h"
#include "generic_character.h"
#include "Range2d.h"
@@ -192,16 +193,6 @@
{
public:
- /// The display quality.
- //
- enum Quality
- {
- QUALITY_LOW,
- QUALITY_MEDIUM,
- QUALITY_HIGH,
- QUALITY_BEST
- };
-
render_handler()
:
_quality(QUALITY_HIGH)
=== modified file 'backend/render_handler_agg.cpp'
--- a/backend/render_handler_agg.cpp 2009-01-16 18:00:27 +0000
+++ b/backend/render_handler_agg.cpp 2009-01-19 10:38:11 +0000
@@ -188,58 +188,18 @@
namespace gnash {
-
-// --- CACHE
-------------------------------------------------------------------
-/// This class holds a completely transformed path (fixed position). Speeds
-/// up characters that stay fixed on a certain position on the stage.
-// ***CURRENTLY***NOT***USED***
-
-class agg_transformed_path
-{
-public:
- /// Original transformation SWFMatrix
- SWFMatrix m_mat;
-
- /// Normal or rounded coordinates?
- bool m_rounded;
-
- /// Number of cache hits
- int m_hits;
-
- /// Contents of this cache item (AGG path).
- std::vector <agg::path_storage> m_data;
-};
-
-class agg_cache_manager : private render_cache_manager
-{
-
- std::vector <agg_transformed_path> m_items;
-
- /// Looks for a matching pre-computed path in the cache list
- /// Returns NULL if no cache item matches
- std::vector <agg::path_storage>* search(const SWFMatrix& mat, bool rounded) {
-
- const size_t ccount = m_items.size();
-
- for (size_t cno=0; cno<ccount; ++cno) {
- agg_transformed_path& item = m_items[cno];
-
- if ((item.m_mat == mat) && (item.m_rounded == rounded)) {
-
- // Found it!
- return &item.m_data;
-
- }
- }
-
- // could not find a matching item
- return NULL;
-
- }
-
-
-};
-
+namespace {
+
+template <class Rasterizer>
+inline void applyClipBox(Rasterizer& ras, const geometry::Range2d<int>& bounds)
+{
+ assert(bounds.isFinite());
+ ras.clip_box(static_cast<double>(bounds.getMinX()),
+ static_cast<double>(bounds.getMinY()),
+ static_cast<double>(bounds.getMaxX() + 1),
+ static_cast<double>(bounds.getMaxY()+1)
+ );
+}
// --- ALPHA MASK BUFFER CONTAINER
---------------------------------------------
// How masks are implemented: A mask is basically a full alpha buffer. Each
@@ -256,10 +216,11 @@
// be used anymore it's simply discarded so that the next mask becomes active
// again.
// To be exact, Flash is a bit restrictive regarding to what can be a mask
-// (dynamic text, shapes, ...) but our rebderer can build a mask from
everything
-// we can draw otherwise (except lines, which are excluded explicitely).
+// (dynamic text, shapes, ...) but our renderer can build a mask from
+// anything we can draw otherwise (except lines, which are excluded
+// explicitly).
-class agg_alpha_mask
+class AlphaMask
{
typedef agg::renderer_base<agg::pixfmt_gray8> renderer_base;
@@ -267,25 +228,21 @@
public:
- agg_alpha_mask(int width, int height)
+ AlphaMask(int width, int height)
:
- m_rbuf(0, width, height, width),
- m_pixf(m_rbuf),
- m_rbase(m_pixf),
- m_amask(m_rbuf),
+ _rbuf(0, width, height, width),
+ _pixf(_rbuf),
+ _rbase(_pixf),
+ _amask(_rbuf),
_buffer(new boost::uint8_t[width * height])
{
- m_rbuf.attach(_buffer.get(), width, height, width);
+ _rbuf.attach(_buffer.get(), width, height, width);
// NOTE: The buffer is *not* cleared. The clear() function must
// be called to clear the buffer (alpha=0). The reason is to avoid
// clearing the whole mask when only a small portion is really used.
}
- ~agg_alpha_mask()
- {
- }
-
void clear(const geometry::Range2d<int>& region)
{
if (region.isNull()) return;
@@ -303,37 +260,92 @@
const unsigned int max_y = region.getMaxY();
for (unsigned int y=region.getMinY(); y <= max_y; ++y)
{
- m_pixf.copy_hline(left, y, width, black);
+ _pixf.copy_hline(left, y, width, black);
}
}
renderer_base& get_rbase() {
- return m_rbase;
+ return _rbase;
}
amask_type& get_amask() {
- return m_amask;
+ return _amask;
}
private:
// agg class to access the buffer
- agg::rendering_buffer m_rbuf;
+ agg::rendering_buffer _rbuf;
// pixel access
- agg::pixfmt_gray8 m_pixf;
+ agg::pixfmt_gray8 _pixf;
// renderer base
- renderer_base m_rbase;
+ renderer_base _rbase;
// alpha mask
- amask_type m_amask;
+ amask_type _amask;
// in-memory buffer
boost::scoped_array<boost::uint8_t> _buffer;
};
+}
+
+
+// --- CACHE
-------------------------------------------------------------------
+/// This class holds a completely transformed path (fixed position). Speeds
+/// up characters that stay fixed on a certain position on the stage.
+// ***CURRENTLY***NOT***USED***
+
+class agg_transformed_path
+{
+public:
+ /// Original transformation SWFMatrix
+ SWFMatrix m_mat;
+
+ /// Normal or rounded coordinates?
+ bool m_rounded;
+
+ /// Number of cache hits
+ int m_hits;
+
+ /// Contents of this cache item (AGG path).
+ std::vector <agg::path_storage> m_data;
+};
+
+class agg_cache_manager : private render_cache_manager
+{
+
+ std::vector <agg_transformed_path> m_items;
+
+ /// Looks for a matching pre-computed path in the cache list
+ /// Returns NULL if no cache item matches
+ std::vector <agg::path_storage>* search(const SWFMatrix& mat, bool rounded) {
+
+ const size_t ccount = m_items.size();
+
+ for (size_t cno=0; cno<ccount; ++cno) {
+ agg_transformed_path& item = m_items[cno];
+
+ if ((item.m_mat == mat) && (item.m_rounded == rounded)) {
+
+ // Found it!
+ return &item.m_data;
+
+ }
+ }
+
+ // could not find a matching item
+ return NULL;
+
+ }
+
+
+};
+
+
// --- RENDER HANDLER
----------------------------------------------------------
@@ -346,7 +358,8 @@
{
typedef typename std::vector<geometry::Range2d<int> > ClipBounds;
- typedef typename std::vector<agg_alpha_mask*> AlphaMasks;
+ typedef typename std::vector<AlphaMask*> AlphaMasks;
+
private:
typedef agg::renderer_base<PixelFormat> renderer_base;
@@ -355,9 +368,6 @@
typedef agg::conv_stroke< agg::conv_curve<agg::path_storage> > stroke_type;
- // TODO: Change these!!
- unsigned char *memaddr;
- int memsize;
int xres;
int yres;
int bpp; // bits per pixel
@@ -388,31 +398,65 @@
/// Types used for different quality.
//
- /// This (affects scaling) should probably only be used when
- /// Video.smoothing is true.
+ /// This (affects scaling) is only presently used when smoothing is
+ /// requested in high quality.
typedef typename agg::span_image_filter_rgb_nn<Accessor,
- Interpolator> LowQualitySpanGenerator;
+ Interpolator> LowQualityFilter;
typedef typename agg::span_image_filter_rgb_bilinear<Accessor,
- Interpolator> HighQualitySpanGenerator;
+ Interpolator> HighQualityFilter;
typedef agg::trans_affine Matrix;
VideoRenderer(const ClipBounds& clipbounds, GnashImage* frame,
- Matrix& mat)
+ Matrix& mat, Quality quality)
:
_buf(frame->data(), frame->width(), frame->height(),
frame->pitch()),
_pixf(_buf),
_accessor(_pixf),
_interpolator(mat),
- _clipbounds(clipbounds)
+ _clipbounds(clipbounds),
+ _quality(quality)
{}
+ /// Change the rendering quality required.
+ void setQuality(Quality quality)
+ {
+ _quality = quality;
+ }
+
+ /// Set whether smoothing is requested
+ void smooth(bool b)
+ {
+ _smoothing = b;
+ }
+
+ void renderFrame(agg::path_storage& path, renderer_base& rbase,
+ const AlphaMasks& masks)
+ {
+ switch (_quality)
+ {
+ case QUALITY_BEST:
+ case QUALITY_HIGH:
+ if (_smoothing) {
+ renderFrame<HighQualityFilter>(path, rbase, masks);
+ }
+ else renderFrame<LowQualityFilter>(path, rbase, masks);
+ break;
+ case QUALITY_MEDIUM:
+ case QUALITY_LOW:
+ // FIXME: Should this be still lower quality?
+ renderFrame<LowQualityFilter>(path, rbase, masks);
+ break;
+ }
+ }
+
+ private:
+
/// Render a frame with or without alpha masks active.
template<typename SpanGenerator>
- void
- renderFrame(agg::path_storage& path, renderer_base& rbase,
+ void renderFrame(agg::path_storage& path, renderer_base& rbase,
const AlphaMasks& masks)
{
SpanGenerator sg(_accessor, _interpolator);
@@ -429,25 +473,20 @@
}
}
- private:
-
template<typename Scanline, typename SpanGenerator>
void renderScanlines(agg::path_storage& path, renderer_base& rbase,
- Scanline& sc, SpanGenerator& sg)
+ Scanline& sl, SpanGenerator& sg)
{
+ Rasterizer _ras;
for (ClipBounds::const_iterator i = _clipbounds.begin(),
e = _clipbounds.end(); i != e; ++i)
{
-
const ClipBounds::value_type& cb = *i;
- apply_clip_box<Rasterizer> (_ras, cb);
+ applyClipBox<Rasterizer> (_ras, cb);
- // <Udo>: AFAIK add_path() rewinds the vertex list (clears
- // previous path), so there should be no problem with
- // multiple clipbounds.
_ras.add_path(path);
- agg::render_scanlines_aa(_ras, sc, rbase, _sa, sg);
+ agg::render_scanlines_aa(_ras, sl, rbase, _sa, sg);
}
}
@@ -461,99 +500,98 @@
Interpolator _interpolator;
- Rasterizer _ras;
SpanAllocator _sa;
+
const ClipBounds& _clipbounds;
+
+ /// Quality of renderering
+ Quality _quality;
+
+ /// Whether smoothing is required.
+ bool _smoothing;
};
public:
- // Given an image, returns a pointer to a bitmap_info class
- // that can later be passed to fill_styleX_bitmap(), to set a
- // bitmap fill style.
- gnash::BitmapInfo* createBitmapInfo(std::auto_ptr<GnashImage> im)
- {
- return new agg_bitmap_info(im);
- }
+ // Given an image, returns a pointer to a bitmap_info class
+ // that can later be passed to fill_styleX_bitmap(), to set a
+ // bitmap fill style.
+ gnash::BitmapInfo* createBitmapInfo(std::auto_ptr<GnashImage> im)
+ {
+ return new agg_bitmap_info(im);
+ }
- void drawVideoFrame(GnashImage* frame, const SWFMatrix* source_mat,
- const rect* bounds, bool smooth) {
-
- // NOTE: Assuming that the source image is RGB 8:8:8
- // TODO: keep heavy instances alive accross frames for performance!
- // TODO: Maybe implement specialization for 1:1 scaled videos
-
- if (frame->type() == GNASH_IMAGE_RGBA)
+ void drawVideoFrame(GnashImage* frame, const SWFMatrix* source_mat,
+ const rect* bounds, bool smooth)
{
- LOG_ONCE(log_error(_("Can't render videos with alpha")));
- return;
- }
-
- assert(frame->type() == GNASH_IMAGE_RGB);
-
- SWFMatrix mat = stage_matrix;
- mat.concatenate(*source_mat);
-
- // compute video scaling relative to video obejct size
- double vscaleX = bounds->width() / static_cast<double>(frame->width());
- double vscaleY = bounds->height() / static_cast<double>(frame->height());
-
- // convert Gnash SWFMatrix to AGG SWFMatrix and scale down to
- // pixel coordinates while we're at it
- agg::trans_affine img_mtx(mat.sx / 65536.0, mat.shx / 65536.0,
- mat.shy / 65536.0, mat.sy / 65536.0, mat.tx, mat.ty);
-
- // invert SWFMatrix since this is used for the image source
- img_mtx.invert();
-
- // Apply video scale
- img_mtx *= agg::trans_affine_scaling(1.0 / vscaleX, 1.0 / vscaleY);
-
- // TODO: keep this alive and only image / matrix? I've no idea how
- // much reallocation that would save.
- VideoRenderer vr(_clipbounds, frame, img_mtx);
-
- // make a path for the video outline
- point a, b, c, d;
- mat.transform(&a, point(bounds->get_x_min(), bounds->get_y_min()));
- mat.transform(&b, point(bounds->get_x_max(), bounds->get_y_min()));
- mat.transform(&c, point(bounds->get_x_max(), bounds->get_y_max()));
- mat.transform(&d, point(bounds->get_x_min(), bounds->get_y_max()));
-
- agg::path_storage path;
- path.move_to(a.x, a.y);
- path.line_to(b.x, b.y);
- path.line_to(c.x, c.y);
- path.line_to(d.x, d.y);
- path.line_to(a.x, a.y);
-
- // renderer base for the stage buffer (not the frame image!)
- renderer_base& rbase = *m_rbase;
-
- // If smoothing is requested and _quality is set to HIGH or BEST,
- // use high-quality interpolation.
- if (smooth && _quality >= QUALITY_HIGH) {
- typedef typename VideoRenderer::HighQualitySpanGenerator HSG;
- vr.template renderFrame<HSG>(path, rbase, m_alpha_mask);
- }
- else {
- typedef typename VideoRenderer::LowQualitySpanGenerator LSG;
- vr.template renderFrame<LSG>(path, rbase, m_alpha_mask);
- }
-
- }
+
+ // NOTE: Assuming that the source image is RGB 8:8:8
+ // TODO: keep heavy instances alive accross frames for performance!
+ // TODO: Maybe implement specialization for 1:1 scaled videos
+
+ if (frame->type() == GNASH_IMAGE_RGBA) {
+ LOG_ONCE(log_error(_("Can't render videos with alpha")));
+ return;
+ }
+
+ assert(frame->type() == GNASH_IMAGE_RGB);
+
+ SWFMatrix mat = stage_matrix;
+ mat.concatenate(*source_mat);
+
+ // compute video scaling relative to video obejct size
+ double vscaleX = bounds->width() /
+ static_cast<double>(frame->width());
+
+ double vscaleY = bounds->height() /
+ static_cast<double>(frame->height());
+
+ // convert Gnash SWFMatrix to AGG SWFMatrix and scale down to
+ // pixel coordinates while we're at it
+ agg::trans_affine img_mtx(mat.sx / 65536.0, mat.shx / 65536.0,
+ mat.shy / 65536.0, mat.sy / 65536.0, mat.tx, mat.ty);
+
+ // invert SWFMatrix since this is used for the image source
+ img_mtx.invert();
+
+ // Apply video scale
+ img_mtx *= agg::trans_affine_scaling(1.0 / vscaleX, 1.0 / vscaleY);
+
+ // TODO: keep this alive and only update image / matrix? I've no
+ // idea how much reallocation that would save.
+ VideoRenderer vr(_clipbounds, frame, img_mtx, _quality);
+
+ vr.smooth(smooth);
+
+ // make a path for the video outline
+ point a, b, c, d;
+ mat.transform(&a, point(bounds->get_x_min(), bounds->get_y_min()));
+ mat.transform(&b, point(bounds->get_x_max(), bounds->get_y_min()));
+ mat.transform(&c, point(bounds->get_x_max(), bounds->get_y_max()));
+ mat.transform(&d, point(bounds->get_x_min(), bounds->get_y_max()));
+
+ agg::path_storage path;
+ path.move_to(a.x, a.y);
+ path.line_to(b.x, b.y);
+ path.line_to(c.x, c.y);
+ path.line_to(d.x, d.y);
+ path.line_to(a.x, a.y);
+
+ // renderer base for the stage buffer (not the frame image!)
+ renderer_base& rbase = *m_rbase;
+
+ // If smoothing is requested and _quality is set to HIGH or BEST,
+ // use high-quality interpolation.
+ vr.renderFrame(path, rbase, m_alpha_mask);
+
+ }
// Constructor
render_handler_agg(int bits_per_pixel)
:
- // Initialization list
- memaddr(NULL),
- memsize(0),
xres(1),
yres(1),
bpp(bits_per_pixel),
- /*xscale(1.0/20.0),
- yscale(1.0/20.0),*/
scale_set(false),
m_display_width(0.0),
m_display_height(0.0),
@@ -583,12 +621,10 @@
assert(x > 0);
assert(y > 0);
- memaddr = mem;
- memsize = size;
xres = x;
yres = y;
- m_rbuf.attach(memaddr, xres, yres, rowstride);
+ m_rbuf.attach(mem, xres, yres, rowstride);
// allocate pixel format accessor and renderer_base
m_pixf.reset(new PixelFormat(m_rbuf));
@@ -597,7 +633,8 @@
// by default allow drawing everywhere
set_invalidated_region_world();
- log_debug(_("Initialized AGG buffer <%p>, %d bytes, %dx%d, rowsize is %d
bytes"),
+ log_debug(_("Initialized AGG buffer <%p>, %d bytes, %dx%d, "
+ "rowsize is %d bytes"),
(void*)mem, size, x, y, rowstride);
}
@@ -670,19 +707,6 @@
// nothing to do
}
- template <class ras_type>
- static void apply_clip_box(ras_type& ras,
- const geometry::Range2d<int>& bounds)
- {
- assert(bounds.isFinite());
- ras.clip_box(
- (double)bounds.getMinX(),
- (double)bounds.getMinY(),
- (double)bounds.getMaxX()+1,
- (double)bounds.getMaxY()+1);
- }
-
-
// Draw the line strip formed by the sequence of points.
void draw_line_strip(const boost::int16_t* coords, int vertex_count,
@@ -736,7 +760,7 @@
const ClipBounds::value_type& bounds = _clipbounds[cno];
- apply_clip_box<ras_type> (ras, bounds);
+ applyClipBox<ras_type> (ras, bounds);
// The vectorial pipeline
ras.add_path(stroke);
@@ -760,7 +784,7 @@
const ClipBounds::value_type& bounds = _clipbounds[cno];
- apply_clip_box<ras_type> (ras, bounds);
+ applyClipBox<ras_type> (ras, bounds);
// The vectorial pipeline
ras.add_path(stroke);
@@ -782,7 +806,7 @@
// Set flag so that rendering of shapes is simplified (only solid fill)
m_drawing_mask = true;
- agg_alpha_mask* new_mask = new agg_alpha_mask(xres, yres);
+ AlphaMask* new_mask = new AlphaMask(xres, yres);
for (unsigned int cno=0; cno<_clipbounds.size(); ++cno)
new_mask->clear(_clipbounds[cno]);
@@ -952,12 +976,6 @@
if (have_shape)
build_agg_styles(sh, fill_styles, mat, cx);
- /*
- // prepare strokes
- std::vector<stroke_type*> strokes;
- build_agg_strokes(strokes, agg_paths, paths, line_styles, mat);
- */
-
// We need to separate sub-shapes during rendering.
const unsigned int subshape_count = count_sub_shapes(paths);
@@ -1258,7 +1276,7 @@
const size_t fcount = fill_styles.size();
for (size_t fno=0; fno<fcount; ++fno) {
- bool smooth=false;
+ bool smooth = false;
int fill_type = fill_styles[fno].get_type();
switch (fill_type) {
@@ -1304,7 +1322,7 @@
case SWF::FILL_TILED_BITMAP:
case SWF::FILL_CLIPPED_BITMAP:
- smooth=true; // continue with next case!
+ smooth= true; // continue with next case!
case SWF::FILL_TILED_BITMAP_HARD:
case SWF::FILL_CLIPPED_BITMAP_HARD:
@@ -1320,7 +1338,7 @@
(fill_styles[fno].get_bitmap_info()), m, cx,
(fill_type==SWF::FILL_TILED_BITMAP) ||
(fill_type==SWF::FILL_TILED_BITMAP_HARD),
- smooth && _quality <= QUALITY_MEDIUM);
+ smooth && _quality >= QUALITY_HIGH);
break;
}
@@ -1429,7 +1447,7 @@
const geometry::Range2d<int>* bounds = _clipbounds_selected[cno];
- apply_clip_box<ras_type> (rasc, *bounds);
+ applyClipBox<ras_type> (rasc, *bounds);
int current_subshape=0;
@@ -1666,7 +1684,7 @@
const geometry::Range2d<int>* bounds = _clipbounds_selected[cno];
- apply_clip_box<ras_type> (ras, *bounds);
+ applyClipBox<ras_type> (ras, *bounds);
int current_subshape=0;
@@ -1801,7 +1819,7 @@
for (unsigned int cno=0; cno<_clipbounds.size(); ++cno) {
const ClipBounds::value_type& bounds = _clipbounds[cno];
- apply_clip_box<ras_type> (ras, bounds);
+ applyClipBox<ras_type> (ras, bounds);
// fill polygon
@@ -2120,10 +2138,10 @@
}
-DSOEXPORT const char *agg_detect_pixel_format(unsigned int rofs, unsigned int
rsize,
- unsigned int gofs, unsigned int gsize,
- unsigned int bofs, unsigned int bsize,
- unsigned int bpp) {
+DSOEXPORT const char *agg_detect_pixel_format(unsigned int rofs,
+ unsigned int rsize, unsigned int gofs, unsigned int gsize,
+ unsigned int bofs, unsigned int bsize, unsigned int bpp)
+{
if (!is_little_endian_host() && (bpp>=24)) {
=== modified file 'libbase/rc.cpp'
--- a/libbase/rc.cpp 2008-10-28 15:03:40 +0000
+++ b/libbase/rc.cpp 2009-01-19 08:19:48 +0000
@@ -100,7 +100,8 @@
_lctrace(true),
// TODO: give a default value, and let 0 mean "disabled" -- 0 currently
is overridden by libbase/shm.cpp
_lcshmkey(0),
- _ignoreFSCommand(true)
+ _ignoreFSCommand(true),
+ _quality(-1)
{
expandPath(_solsandbox);
@@ -162,19 +163,17 @@
bool
RcInitFile::extractSetting(bool &var, const std::string &pattern,
- const std::string &variable, const std::string
&value)
+ const std::string &variable, const std::string &value)
{
StringNoCaseEqual noCaseCompare;
if ( noCaseCompare(variable, pattern) ) {
if ( noCaseCompare(value, "on") || noCaseCompare(value, "yes") ||
noCaseCompare(value, "true")) {
- //cout << variable << ": enabled" << endl;
var = true;
}
if (noCaseCompare(value, "off") || noCaseCompare(value, "no") ||
noCaseCompare(value, "false")) {
- //cout << variable << ": disabled" << endl;
var = false;
}
return true;
@@ -183,32 +182,11 @@
return false;
}
-bool
-RcInitFile::extractNumber(boost::uint32_t& num, const std::string& pattern,
- const std::string& variable, const std::string&
value)
-{
-
- StringNoCaseEqual noCaseCompare;
-
- if ( noCaseCompare(variable, pattern) ) {
- std::istringstream in(value);
- if (in >> num) return true;
-
- // If conversion fails, set value to 0 rather than leaving
- // it as the default.
- cerr << _("Conversion overflow in extractNumber: ") << value << endl;
- num = 0;
- return true;
- }
-
- return false;
-}
void
RcInitFile::parseList(PathList &list, const std::string &action,
const std::string &items)
{
-// GNASH_REPORT_FUNCTION;
if (action == "set") {
@@ -237,8 +215,7 @@
bool
RcInitFile::extractDouble(double& out, const std::string &pattern,
- const std::string &variable,
- const std::string &value)
+ const std::string &variable, const std::string &value)
{
StringNoCaseEqual noCaseCompare;
@@ -255,7 +232,6 @@
return false;
}
-/* static protected */
void
RcInitFile::expandPath (std::string& path)
{
@@ -380,9 +356,9 @@
// Empty line
continue;
}
- //cout << " " << lineno << ": '" << action << "'" << endl;
-
- // 'action' should never be empty, or (ss >> action) above would have
failed
+
+ // 'action' should never be empty, or (ss >> action)
+ // above would have failed
if ( action[0] == '#' ) continue; // discard comments
@@ -399,8 +375,9 @@
// The rest of the line is the value
if (!std::getline (ss, value))
{
- cerr << boost::format(_("Warning: missing value for variable
\"%s\" in rcfile %s,"
- " line %d")) % variable % filespec % lineno << endl;
+ cerr << boost::format(_("Warning: missing value for "
+ "variable \"%s\" in rcfile %s, line %d"))
+ % variable % filespec % lineno << endl;
continue;
}
@@ -410,7 +387,6 @@
// so value.erase(0, string::npos) is correct.
value.erase(0, value.find_first_not_of(' '));
-
if (noCaseCompare(variable, "urlOpenerFormat")) {
_urlOpenerFormat = value;
continue;
@@ -516,7 +492,8 @@
extractSetting(_lctrace, "LCTrace", variable,
value)
||
- extractNumber(_movieLibraryLimit, "movieLibraryLimit",
variable, value)
+ extractNumber(_movieLibraryLimit, "movieLibraryLimit",
+ variable, value)
||
extractNumber(_delay, "delay", variable, value)
||
@@ -524,12 +501,17 @@
||
extractNumber(_lcshmkey, "LCShmkey", variable, value)
||
- extractDouble(_streamsTimeout, "StreamsTimeout", variable,
value)
- ||
- extractSetting(_ignoreFSCommand, "ignoreFsCommand", variable,
value)
- ||
- cerr << boost::format(_("Warning: unrecognized directive
\"%s\" "
- "in rcfile %s line %d")) % variable % filespec % lineno <<
endl;
+ extractDouble(_streamsTimeout, "streamsTimeout", variable,
+ value)
+ ||
+ extractNumber(_quality, "quality", variable, value)
+ ||
+ extractSetting(_ignoreFSCommand, "ignoreFsCommand", variable,
+ value)
+ ||
+ cerr << boost::format(_("Warning: unrecognized directive "
+ "\"%s\" in rcfile %s line %d"))
+ % variable % filespec % lineno << endl;
}
}
else if (noCaseCompare(action, "include") )
@@ -646,7 +628,8 @@
// Bools and numbers. We want boolean values written as words, hex values
// prefixed with '0x'.
out << std::boolalpha << std::showbase <<
- _("# Generated by Gnash. Manual changes to this file may be overridden.")
<< endl <<
+ _("# Generated by Gnash. Manual changes to this file may be overridden.")
+ << endl <<
cmd << "splashScreen " << _splashScreen << endl <<
cmd << "localHost " << _localhostOnly << endl <<
cmd << "localDomain " << _localdomainOnly << endl <<
@@ -664,6 +647,7 @@
cmd << "startStopped " << _startStopped << endl <<
cmd << "streamsTimeout " << _streamsTimeout << endl <<
cmd << "movieLibraryLimit " << _movieLibraryLimit << endl <<
+ cmd << "quality " << _quality << endl <<
cmd << "delay " << _delay << endl <<
cmd << "verbosity " << _verbosity << endl <<
cmd << "solReadOnly " << _solreadonly << endl <<
=== modified file 'libbase/rc.h'
--- a/libbase/rc.h 2008-10-28 15:03:40 +0000
+++ b/libbase/rc.h 2009-01-19 08:05:42 +0000
@@ -18,16 +18,17 @@
#ifndef GNASH_RC_H
#define GNASH_RC_H
-// This is generated by autoconf
#ifdef HAVE_CONFIG_H
# include "gnashconfig.h"
#endif
#include "dsodefs.h"
+#include "StringPredicates.h"
#include <string>
#include <vector>
#include <iostream>
+#include <sstream>
#include <boost/cstdint.hpp>
#include <boost/tokenizer.hpp>
@@ -105,6 +106,9 @@
bool insecureSSL() const { return _insecureSSL; }
void insecureSSL(bool value) { _insecureSSL = value; }
+ int qualityLevel() const { return _quality; }
+ void qualityLevel(int value) { _quality = value; }
+
int verbosityLevel() const { return _verbosity; }
void verbosityLevel(int value) { _verbosity = value; }
@@ -368,11 +372,14 @@
/// (showmenu, quit etc)
bool _ignoreFSCommand;
+ /// The quality to display SWFs in. -1 to allow the SWF to override.
+ int _quality;
+
+protected:
+
// A function only for writing path lists to an outstream.
void writeList(const PathList& list, std::ostream& o);
-protected:
-
/// Construct only by getDefaultInstance()
RcInitFile();
@@ -406,8 +413,27 @@
/// @param pattern the pattern for matching
/// @variable the variable to match to pattern
/// @value the value to adopt if variable matches pattern.
- static bool extractNumber(boost::uint32_t &num, const std::string& pattern,
- const std::string &variable, const std::string &value);
+ template<typename T>
+ static bool extractNumber(T& num, const std::string& pattern,
+ const std::string &variable, const std::string &value)
+ {
+
+ StringNoCaseEqual noCaseCompare;
+
+ if (noCaseCompare(variable, pattern)) {
+ std::istringstream in(value);
+ if (in >> num) return true;
+
+ // If conversion fails, set value to 0 rather than leaving
+ // it as the default.
+ std::cerr << "Conversion overflow in extractNumber: " <<
+ value << std::endl;
+ num = 0;
+ return true;
+ }
+
+ return false;
+ }
/// \brief
/// If variable matches pattern (case-insensitive)
@@ -433,12 +459,9 @@
};
-//extern DSOEXPORT RcInitFile rcfile;
-
// End of gnash namespace
}
-// __RC_H__
#endif
=== modified file 'libcore/character.cpp'
--- a/libcore/character.cpp 2009-01-16 16:24:25 +0000
+++ b/libcore/character.cpp 2009-01-19 08:05:42 +0000
@@ -32,6 +32,7 @@
#include "render.h" // for bounds_in_clipping_area()
#include "ExecutableCode.h"
#include "namedStrings.h"
+#include "gnash.h" // Quality
#ifdef USE_SWFTREE
# include "tree.hh"
@@ -272,13 +273,13 @@
{
switch (mr.getQuality())
{
- case render_handler::QUALITY_BEST:
+ case QUALITY_BEST:
return as_value("BEST");
- case render_handler::QUALITY_HIGH:
+ case QUALITY_HIGH:
return as_value("HIGH");
- case render_handler::QUALITY_MEDIUM:
+ case QUALITY_MEDIUM:
return as_value("MEDIUM");
- case render_handler::QUALITY_LOW:
+ case QUALITY_LOW:
return as_value("LOW");
}
}
@@ -291,15 +292,15 @@
StringNoCaseEqual noCaseCompare;
- if (noCaseCompare(q, "BEST")) mr.setQuality(render_handler::QUALITY_BEST);
+ if (noCaseCompare(q, "BEST")) mr.setQuality(QUALITY_BEST);
else if (noCaseCompare(q, "HIGH")) {
- mr.setQuality(render_handler::QUALITY_HIGH);
+ mr.setQuality(QUALITY_HIGH);
}
else if (noCaseCompare(q, "MEDIUM")) {
- mr.setQuality(render_handler::QUALITY_MEDIUM);
+ mr.setQuality(QUALITY_MEDIUM);
}
else if (noCaseCompare(q, "LOW")) {
- mr.setQuality(render_handler::QUALITY_LOW);
+ mr.setQuality(QUALITY_LOW);
}
return as_value();
@@ -316,32 +317,32 @@
{
switch (mr.getQuality())
{
- case render_handler::QUALITY_BEST:
+ case QUALITY_BEST:
return as_value(2.0);
- case render_handler::QUALITY_HIGH:
+ case QUALITY_HIGH:
return as_value(1.0);
- case render_handler::QUALITY_MEDIUM:
- case render_handler::QUALITY_LOW:
+ case QUALITY_MEDIUM:
+ case QUALITY_LOW:
return as_value(0.0);
}
}
double q = fn.arg(0).to_number();
- if (q < 0) mr.setQuality(render_handler::QUALITY_HIGH);
- else if (q > 2) mr.setQuality(render_handler::QUALITY_BEST);
+ if (q < 0) mr.setQuality(QUALITY_HIGH);
+ else if (q > 2) mr.setQuality(QUALITY_BEST);
else {
int i = static_cast<int>(q);
switch(i)
{
case 0:
- mr.setQuality(render_handler::QUALITY_LOW);
+ mr.setQuality(QUALITY_LOW);
break;
case 1:
- mr.setQuality(render_handler::QUALITY_HIGH);
+ mr.setQuality(QUALITY_HIGH);
break;
case 2:
- mr.setQuality(render_handler::QUALITY_BEST);
+ mr.setQuality(QUALITY_BEST);
break;
}
}
=== modified file 'libcore/gnash.h'
--- a/libcore/gnash.h 2008-10-28 20:20:48 +0000
+++ b/libcore/gnash.h 2009-01-19 08:05:42 +0000
@@ -51,6 +51,17 @@
GNASH_FILETYPE_UNKNOWN
};
+/// The display quality.
+//
+/// Required for rendering and core.
+enum Quality
+{
+ QUALITY_LOW,
+ QUALITY_MEDIUM,
+ QUALITY_HIGH,
+ QUALITY_BEST
+};
+
// Sound callbacks stuff
/// Set the render handler. This is one of the first
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2009-01-16 16:13:37 +0000
+++ b/libcore/movie_root.cpp 2009-01-19 08:19:48 +0000
@@ -35,6 +35,7 @@
#include "sound_handler.h"
#include "timers.h" // for Timer use
#include "GnashKey.h" // key::code
+#include "gnash.h"
#include <boost/algorithm/string/replace.hpp>
#include <utility>
@@ -128,7 +129,7 @@
_lastMovieAdvancement(0)
{
// This takes care of informing the renderer (if present) too.
- setQuality(render_handler::QUALITY_HIGH);
+ setQuality(QUALITY_HIGH);
}
void
@@ -1436,9 +1437,19 @@
}
void
-movie_root::setQuality(render_handler::Quality q)
+movie_root::setQuality(Quality q)
{
- _quality = q;
+ gnash::RcInitFile& rcfile = gnash::RcInitFile::getDefaultInstance();
+
+ /// Overridden quality if not negative.
+ if (rcfile.qualityLevel() >= 0) {
+ int ql = rcfile.qualityLevel();
+ ql = std::min<int>(ql, QUALITY_BEST);
+ _quality = static_cast<Quality>(ql);
+ }
+ else {
+ _quality = q;
+ }
render_handler* renderer = get_render_handler();
if (renderer) renderer->setQuality(_quality);
}
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2009-01-16 16:13:37 +0000
+++ b/libcore/movie_root.h 2009-01-19 08:05:42 +0000
@@ -79,7 +79,7 @@
#include "GnashKey.h" // key::code
#include "movie_instance.h"
#include "RunInfo.h" // for initialization
-#include "render_handler.h"
+#include "gnash.h" // Quality
#ifdef USE_SWFTREE
# include "tree.hh"
@@ -510,10 +510,10 @@
};
/// Set the current display quality of the entire SWF.
- void setQuality(render_handler::Quality q);
+ void setQuality(Quality q);
/// Get the current display quality.
- render_handler::Quality getQuality() const { return _quality; }
+ Quality getQuality() const { return _quality; }
/// Sets movie_root's horizontal and vertical alignment to one
/// of the three possible positions for each dimension.
@@ -1140,7 +1140,7 @@
//
/// This is here, not just in the render_handler, so that AS compatibility
/// does not rely on the presence of a renderer.
- render_handler::Quality _quality;
+ Quality _quality;
std::bitset<4u> _alignMode;
=== modified file 'libmedia/ffmpeg/VideoDecoderFfmpeg.cpp'
--- a/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 2008-11-12 09:23:42 +0000
+++ b/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 2009-01-19 11:24:43 +0000
@@ -285,9 +285,10 @@
// to NULL once it's been created?
assert(_swsContext->getContext());
- int rv = sws_scale(_swsContext->getContext(),
const_cast<uint8_t**>(srcFrame.data),
- const_cast<int*>(srcFrame.linesize), 0, height, picture.data,
- picture.linesize);
+ int rv = sws_scale(_swsContext->getContext(),
+ const_cast<uint8_t**>(srcFrame.data),
+ const_cast<int*>(srcFrame.linesize), 0, height, picture.data,
+ picture.linesize);
if (rv == -1) {
im.reset();
@@ -301,7 +302,8 @@
}
std::auto_ptr<GnashImage>
-VideoDecoderFfmpeg::decode(const boost::uint8_t* input, boost::uint32_t
input_size)
+VideoDecoderFfmpeg::decode(const boost::uint8_t* input,
+ boost::uint32_t input_size)
{
// This object shouldn't exist if there's no codec, as it can'
// do anything anyway.
@@ -317,7 +319,8 @@
int bytes = 0;
// no idea why avcodec_decode_video wants a non-const input...
- avcodec_decode_video(_videoCodecCtx->getContext(), frame, &bytes,
const_cast<boost::uint8_t*>(input), input_size);
+ avcodec_decode_video(_videoCodecCtx->getContext(), frame, &bytes,
+ const_cast<boost::uint8_t*>(input), input_size);
if (!bytes) {
log_error("Decoding of a video frame failed");
=== modified file 'testsuite/gnashrc.in'
--- a/testsuite/gnashrc.in 2008-12-15 09:26:01 +0000
+++ b/testsuite/gnashrc.in 2009-01-19 08:05:42 +0000
@@ -31,6 +31,9 @@
# Open a can of worms by raising likelyhood of movie definition destruction
set movieLibraryLimit 1
+# Allow override of quality, or tests will fail.
+set quality -1
+
# No sense in starting stopped.
set startStopped false
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10546: Allow manual override of _quality setting. Clean up VideoRenderer.,
Benjamin Wolsey <=