[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/Makefile.am server/impl...
From: |
Tomas Groth |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/Makefile.am server/impl... |
Date: |
Thu, 08 Feb 2007 13:25:42 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Tomas Groth <tgc> 07/02/08 13:25:42
Modified files:
. : ChangeLog
libbase : Makefile.am
server : impl.cpp video_stream_instance.cpp
video_stream_instance.h
server/asobj : NetStreamFfmpeg.cpp NetStreamFfmpeg.h
server/parser : movie_def_impl.h video_stream_def.cpp
video_stream_def.h
server/swf : tag_loaders.cpp
Added files:
libbase : embedVideoDecoder.h embedVideoDecoderFfmpeg.cpp
embedVideoDecoderFfmpeg.h
Log message:
* libbase/Makefile.am: Added embedVideoDecoder.h,
embedVideoDecoderFfmpeg.{h,cpp}
* libbase/embedVideoDecoderFfmpeg.{h,cpp} Added. Decoder for embedded
video
using ffmpeg.
* server/impl.cpp: Added support for parsing swf embedded in a player
(.exe)
* server/asobj/NetStreamFfmpeg.{cpp,h}: Fixed some warnings.
* server/parser/movie_def_impl.h: Removed unused soundstream list.
* server/video_stream_instance.{cpp,h},
server/parser/video_stream_def.{cpp,h}, server/swf/tag_loaders.cpp:
Added support for embedded video.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2273&r2=1.2274
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Makefile.am?cvsroot=gnash&r1=1.55&r2=1.56
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/embedVideoDecoder.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/embedVideoDecoderFfmpeg.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/embedVideoDecoderFfmpeg.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&r1=1.87&r2=1.88
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/video_stream_def.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/video_stream_def.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.73&r2=1.74
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2273
retrieving revision 1.2274
diff -u -b -r1.2273 -r1.2274
--- ChangeLog 8 Feb 2007 13:14:36 -0000 1.2273
+++ ChangeLog 8 Feb 2007 13:25:41 -0000 1.2274
@@ -1,3 +1,16 @@
+2007-02-08 Tomas Groth Christensen <address@hidden>
+
+ * libbase/Makefile.am: Added embedVideoDecoder.h,
+ embedVideoDecoderFfmpeg.{h,cpp}
+ * libbase/embedVideoDecoderFfmpeg.{h,cpp} Added. Decoder for embedded
video
+ using ffmpeg.
+ * server/impl.cpp: Added support for parsing swf embedded in a player
(.exe)
+ * server/asobj/NetStreamFfmpeg.{cpp,h}: Fixed some warnings.
+ * server/parser/movie_def_impl.h: Removed unused soundstream list.
+ * server/video_stream_instance.{cpp,h},
+ server/parser/video_stream_def.{cpp,h}, server/swf/tag_loaders.cpp:
+ Added support for embedded video.
+
2007-02-08 Sandro Santilli <address@hidden>
* server/character.{h,cpp} (get_relative_target_common):
Index: libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libbase/Makefile.am,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- libbase/Makefile.am 17 Jan 2007 11:50:13 -0000 1.55
+++ libbase/Makefile.am 8 Feb 2007 13:25:41 -0000 1.56
@@ -139,6 +139,14 @@
libgnashbase_la_LIBADD += $(GSTREAMER_LIBS) -lgstbase-0.10
endif
+if USE_FFMPEG_ENGINE
+libgnashbase_la_SOURCES += embedVideoDecoderFfmpeg.cpp
+noinst_HEADERS += embedVideoDecoderFfmpeg.h
+libgnashbase_la_LIBADD += $(FFMPEG_LIBS)
+libgnashbase_la_CPPFLAGS+= $(FFMPEG_CFLAGS)
+endif
+
+
# libgnashbase_la_LDFLAGS = -export-dynamic
libgnashbase_la_LDFLAGS = -avoid-version
Index: server/impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/impl.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -b -r1.87 -r1.88
--- server/impl.cpp 10 Jan 2007 17:28:49 -0000 1.87
+++ server/impl.cpp 8 Feb 2007 13:25:41 -0000 1.88
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: impl.cpp,v 1.87 2007/01/10 17:28:49 strk Exp $ */
+/* $Id: impl.cpp,v 1.88 2007/02/08 13:25:41 tgc Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -338,9 +338,9 @@
{
in->set_position(0);
- unsigned char buf[5];
- memset(buf, 0, 5);
- if ( 4 < in->read_bytes(buf, 4) )
+ unsigned char buf[3];
+ memset(buf, 0, 3);
+ if ( 3 < in->read_bytes(buf, 3) )
{
log_error("Can't read file header!\n");
return "unknown";
@@ -349,6 +349,7 @@
// This is the magic number for any JPEG format file
if ((buf[0] == 0xff) && (buf[1] == 0xd8) && (buf[2] == 0xff))
{
+ in->set_position(0);
return "jpeg";
}
@@ -357,9 +358,24 @@
(buf[1] == 'W') &&
(buf[2] == 'S') )
{
+ in->set_position(0);
return "swf";
}
+ // Check if it is an swf embedded in a player (.exe-file)
+ if ((buf[0] == 'M') && (buf[1] == 'Z')) {
+
+ if ( 3 < in->read_bytes(buf, 3) ) return "unknown";
+
+ while (buf[0]!='F' && buf[0]!='C' || buf[1]!='W' ||
buf[2]!='S') {
+ buf[0] = buf[1];
+ buf[1] = buf[2];
+ buf[2] = in->read_byte();
+ if (in->get_eof()) return "unknown";
+ }
+ in->set_position(in->get_position()-3);
+ return "swf";
+ }
return "unknown";
}
@@ -370,8 +386,6 @@
create_swf_movie(std::auto_ptr<tu_file> in, const std::string& url, bool
startLoaderThread)
{
- in->set_position(0);
-
// Avoid leaks on error
std::auto_ptr<movie_def_impl> m(
new movie_def_impl(DO_LOAD_BITMAPS, DO_LOAD_FONT_SHAPES)
Index: server/video_stream_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/video_stream_instance.cpp 30 Jan 2007 12:49:03 -0000 1.7
+++ server/video_stream_instance.cpp 8 Feb 2007 13:25:41 -0000 1.8
@@ -1,10 +1,29 @@
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+// $Id: video_stream_instance.cpp,v 1.8 2007/02/08 13:25:41 tgc Exp $
+
+#include "sprite_instance.h"
#include "video_stream_instance.h"
#include "video_stream_def.h"
#include "fn_call.h"
#include "as_value.h"
#include "NetStream.h"
#include "render.h"
-//#include <SDL.h>
namespace gnash {
@@ -41,20 +60,23 @@
assert(m_def);
// FIXME: use new layout
init_member("attachVideo", &attach_video);
+ m_decoder = m_def->get_decoder();
}
video_stream_instance::~video_stream_instance()
{
+ delete m_decoder;
}
void
video_stream_instance::display()
{
- if (_ns)
- {
matrix m = get_world_matrix();
rect bounds(0.0f, 0.0f, PIXELS_TO_TWIPS(m_def->m_width),
PIXELS_TO_TWIPS(m_def->m_height));
+
+ if (_ns)
+ {
NetStream* nso = _ns;
if (nso->playing())
@@ -65,6 +87,22 @@
gnash::render::drawVideoFrame(i, &m, &bounds);
}
}
+ } else {
+ // If _ns is null, this must be a VideoFrame (embedded video)
+
+ uint8_t* data = 0;
+ int size = 0;
+ int current_frame =
get_parent()->to_movie()->get_current_frame();
+ m_def->get_frame_data(current_frame, &data, &size);
+
+ image::image_base* i = m_decoder->decodeFrame(data, size);
+ if (i)
+ {
+ gnash::render::drawVideoFrame(i, &m, &bounds);
+ } else {
+ log_warning("An error occured while decoding video
frame.");
+ }
+
}
}
Index: server/video_stream_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/video_stream_instance.h 30 Jan 2007 12:49:03 -0000 1.6
+++ server/video_stream_instance.h 8 Feb 2007 13:25:41 -0000 1.7
@@ -1,8 +1,28 @@
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+// $Id: video_stream_instance.h,v 1.7 2007/02/08 13:25:41 tgc Exp $
+
#ifndef GNASH_VIDEO_STREAM_INSTANCE_H
#define GNASH_VIDEO_STREAM_INSTANCE_H
#include "character.h" // for inheritance
#include "video_stream_def.h"
+#include "embedVideoDecoder.h"
// Forward declarations
namespace gnash {
@@ -44,6 +64,7 @@
// Who owns this ? Should it be an intrusive ptr ?
NetStream* _ns;
+ embedVideoDecoder* m_decoder;
};
} // end namespace gnash
Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/asobj/NetStreamFfmpeg.cpp 5 Feb 2007 22:22:32 -0000 1.13
+++ server/asobj/NetStreamFfmpeg.cpp 8 Feb 2007 13:25:41 -0000 1.14
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetStreamFfmpeg.cpp,v 1.13 2007/02/05 22:22:32 tgc Exp $ */
+/* $Id: NetStreamFfmpeg.cpp,v 1.14 2007/02/08 13:25:41 tgc Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -301,8 +301,8 @@
// Find the first video & audio stream
ns->m_video_index = -1;
ns->m_audio_index = -1;
- assert(ns->m_FormatCtx->nb_streams >= 0);
- for (int i = 0; i < ns->m_FormatCtx->nb_streams; i++)
+ //assert(ns->m_FormatCtx->nb_streams >= 0); useless assert.
+ for (unsigned int i = 0; i < ns->m_FormatCtx->nb_streams; i++)
{
AVCodecContext* enc = ns->m_FormatCtx->streams[i]->codec;
Index: server/asobj/NetStreamFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/NetStreamFfmpeg.h 5 Feb 2007 22:22:32 -0000 1.10
+++ server/asobj/NetStreamFfmpeg.h 8 Feb 2007 13:25:41 -0000 1.11
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetStreamFfmpeg.h,v 1.10 2007/02/05 22:22:32 tgc Exp $ */
+/* $Id: NetStreamFfmpeg.h,v 1.11 2007/02/08 13:25:41 tgc Exp $ */
#ifndef __NETSTREAMFFMPEG_H__
#define __NETSTREAMFFMPEG_H__
@@ -192,6 +192,12 @@
ReSampleContext *m_Resample;
+ boost::thread *m_thread;
+ boost::thread *startThread;
+ boost::mutex decoding_mutex;
+ boost::mutex start_mutex;
+ boost::mutex::scoped_lock *lock;
+
volatile bool m_go;
unsigned int runtime;
@@ -199,12 +205,6 @@
double m_video_clock;
- boost::thread *m_thread;
- boost::thread *startThread;
- boost::mutex decoding_mutex;
- boost::mutex start_mutex;
- boost::mutex::scoped_lock *lock;
-
multithread_queue <raw_videodata_t*> m_qaudio;
multithread_queue <raw_videodata_t*> m_qvideo;
bool m_pause;
Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/parser/movie_def_impl.h 29 Jan 2007 18:16:25 -0000 1.30
+++ server/parser/movie_def_impl.h 8 Feb 2007 13:25:42 -0000 1.31
@@ -193,7 +193,6 @@
hash<int, boost::intrusive_ptr<font> > m_fonts;
hash<int, boost::intrusive_ptr<bitmap_character_def> >
m_bitmap_characters;
hash<int, boost::intrusive_ptr<sound_sample> > m_sound_samples;
- hash<int, boost::intrusive_ptr<sound_sample> > m_sound_streams;
/// A list of movie control events for each frame.
std::vector<PlayList> m_playlist;
Index: server/parser/video_stream_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/video_stream_def.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/parser/video_stream_def.cpp 27 Oct 2006 14:30:52 -0000 1.1
+++ server/parser/video_stream_def.cpp 8 Feb 2007 13:25:42 -0000 1.2
@@ -1,36 +1,76 @@
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+// $Id: video_stream_def.cpp,v 1.2 2007/02/08 13:25:42 tgc Exp $
+
+#include "embedVideoDecoderFfmpeg.h"
#include "video_stream_def.h"
#include "video_stream_instance.h"
+#include "render.h"
namespace gnash {
+video_stream_definition::video_stream_definition(uint16_t char_id)
+ :
+ m_char_id(char_id)
+{
+}
+
+
+video_stream_definition::~video_stream_definition()
+{
+}
+
void
video_stream_definition::read(stream* in, SWF::tag_type tag, movie_definition*
m)
{
- // Character ID has been read already
- assert(tag == SWF::DEFINEVIDEOSTREAM ||
- tag == SWF::VIDEOFRAME);
+ // Character ID has been read already, and was loaded in the constructor
+
+ assert(tag == SWF::DEFINEVIDEOSTREAM || tag == SWF::VIDEOFRAME);
if (tag == SWF::DEFINEVIDEOSTREAM)
{
+ m_start_frame = m->get_loading_frame();
- uint16_t numframes = in->read_u16();
- m_frames.resize(numframes);
+ m_num_frames = in->read_u16();
m_width = in->read_u16();
m_height = in->read_u16();
- uint8_t reserved_flags = in->read_uint(5);
+ m_reserved_flags = in->read_uint(5);
m_deblocking_flags = in->read_uint(2);
m_smoothing_flags = in->read_uint(1) ? true : false;
m_codec_id = in->read_u8();
+
}
- else
- if (tag == SWF::VIDEOFRAME)
+ else if (tag == SWF::VIDEOFRAME)
+ {
+ int frameNum = in->read_u16();
+ int size = in->get_tag_end_position() - in->get_position();
+ uint8_t* data = new uint8_t[size];
+ for (int i = 0; i < size; i++)
{
- uint16_t n = in->read_u16();
- m_frames[n] = NULL;
+ data[i] = in->read_u8();
+ }
+ m_video_frames.push_back(data);
+ m_video_frames_size.push_back(size);
+
}
}
@@ -43,5 +83,38 @@
return ch;
}
+embedVideoDecoder*
+video_stream_definition::get_decoder(){
+
+ if (m_num_frames == 0) return NULL;
+
+ embedVideoDecoder* decoder;
+
+#ifdef USE_FFMPEG
+ decoder = new embedVideoDecoderFfmpeg();
+//#elif defined(SOUND_GST)
+// decoder = new embedVideoDecoderGst();
+#else
+ decoder = new embedVideoDecoder();
+#endif
+ decoder->createDecoder(
+ m_width,
+ m_height,
+ m_deblocking_flags,
+ m_smoothing_flags,
+ m_codec_id,
+ gnash::render::videoFrameFormat());
+ return decoder;
+
+}
+
+void
+video_stream_definition::get_frame_data(int frameNum, uint8_t** data, int*
size){
+ int cur_frame = frameNum - m_start_frame;
+ *size = m_video_frames_size[cur_frame];
+ *data = m_video_frames[cur_frame];
+ if (data == NULL) printf("data is NULL\n");
+}
+
}
Index: server/parser/video_stream_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/video_stream_def.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/parser/video_stream_def.h 1 Dec 2006 16:35:39 -0000 1.2
+++ server/parser/video_stream_def.h 8 Feb 2007 13:25:42 -0000 1.3
@@ -1,3 +1,22 @@
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+// $Id: video_stream_def.h,v 1.3 2007/02/08 13:25:42 tgc Exp $
+
#ifndef GNASH_VIDEO_STREAM_DEF_H
#define GNASH_VIDEO_STREAM_DEF_H
@@ -6,6 +25,9 @@
#include "movie_definition.h"
#include "swf.h"
#include "rect.h" // for composition
+#include "execute_tag.h"
+#include "embedVideoDecoder.h"
+#include "image.h"
namespace gnash {
@@ -13,8 +35,8 @@
{
public:
-// video_stream_definition();
-// virtual ~video_stream_definition();
+ video_stream_definition(uint16_t char_id);
+ ~video_stream_definition();
character* create_character_instance(character* parent, int id);
@@ -23,22 +45,35 @@
return m_unused_rect;
}
+ embedVideoDecoder* get_decoder();
+
+ void get_frame_data(int frameNum, uint8_t** data, int* size);
+
uint16_t m_width;
uint16_t m_height;
private:
-// uint8_t reserved_flags;
+ uint16_t m_char_id;
+ uint8_t m_reserved_flags;
uint8_t m_deblocking_flags;
bool m_smoothing_flags;
+ uint16_t m_start_frame;
+ uint16_t m_num_frames;
+
// 0: extern file
// 2: H.263
// 3: screen video (Flash 7+ only)
// 4: VP6
uint8_t m_codec_id;
- std::vector<void*> m_frames;
rect m_unused_rect;
+
+ /// The undecoded video frames
+ std::vector<uint8_t*> m_video_frames;
+
+ /// Size the undecoded video frames
+ std::vector<int> m_video_frames_size;
};
} // end namespace gnash
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- server/swf/tag_loaders.cpp 7 Feb 2007 16:29:36 -0000 1.73
+++ server/swf/tag_loaders.cpp 8 Feb 2007 13:25:42 -0000 1.74
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: tag_loaders.cpp,v 1.73 2007/02/07 16:29:36 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.74 2007/02/08 13:25:42 tgc Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1871,7 +1871,7 @@
assert(tag == SWF::DEFINEVIDEOSTREAM); // 60
uint16_t character_id = in->read_u16();
- video_stream_definition* ch = new video_stream_definition;
+ video_stream_definition* ch = new video_stream_definition(character_id);
ch->read(in, tag, m);
m->add_character(character_id, ch);
@@ -1891,6 +1891,7 @@
assert(ch != NULL);
ch->read(in, tag, m);
+
}
void
Index: libbase/embedVideoDecoder.h
===================================================================
RCS file: libbase/embedVideoDecoder.h
diff -N libbase/embedVideoDecoder.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/embedVideoDecoder.h 8 Feb 2007 13:25:41 -0000 1.1
@@ -0,0 +1,69 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+//
+//
+
+// $Id: embedVideoDecoder.h,v 1.1 2007/02/08 13:25:41 tgc Exp $
+
+#ifndef __EMBEDVIDEODECODER_H__
+#define __EMBEDVIDEODECODER_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "image.h"
+
+//
+// Decoder for embedded video.
+//
+
+class embedVideoDecoder
+{
+public:
+
+ enum videoOutputFormat
+ {
+ NONE,
+ YUV,
+ RGB
+ };
+
+ enum codecType
+ {
+ CODEC_H263 = 2, // H263/SVQ3 video codec
+ CODEC_SCREENVIDEO = 3, // Screenvideo codec
+ CODEC_VP6 = 4, // On2 VP6 video codec
+ };
+
+ // Assign handles however you like.
+ virtual void createDecoder(
+ int /*width*/,
+ int /*height*/,
+ int /*deblocking*/,
+ bool /*smoothing*/,
+ int /*format*/,
+ int /*outputFormat*/){}
+
+ // gnash calls this when it wants you to decode the given videoframe
+ virtual image::image_base* decodeFrame(uint8_t* /*data*/, int
/*size*/) { return NULL; }
+
+ virtual ~embedVideoDecoder() {};
+};
+
+#endif // __EMBEDVIDEODECODER_H__
Index: libbase/embedVideoDecoderFfmpeg.cpp
===================================================================
RCS file: libbase/embedVideoDecoderFfmpeg.cpp
diff -N libbase/embedVideoDecoderFfmpeg.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/embedVideoDecoderFfmpeg.cpp 8 Feb 2007 13:25:41 -0000 1.1
@@ -0,0 +1,152 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// $Id: embedVideoDecoderFfmpeg.cpp,v 1.1 2007/02/08 13:25:41 tgc Exp $
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef USE_FFMPEG
+
+#include "embedVideoDecoderFfmpeg.h"
+
+embedVideoDecoderFfmpeg::embedVideoDecoderFfmpeg()
+{
+}
+
+void
+embedVideoDecoderFfmpeg::createDecoder(int widthi, int heighti, int
deblockingi, bool smoothingi, int formati, int outputFormati)
+{
+ // Init the avdecoder-decoder
+ avcodec_init();
+ avcodec_register_all();
+
+ // Save video attributes
+ width = widthi;
+ height = heighti;
+ deblocking = deblockingi;
+ smoothing = smoothingi;
+ format = formati;
+ outputFormat = outputFormati;
+
+ // Find the decoder and init the parser
+ if (format == CODEC_H263) {
+ codec = avcodec_find_decoder(CODEC_ID_FLV1);
+ } else if (format == CODEC_VP6) {
+ codec = avcodec_find_decoder(CODEC_ID_VP6);
+ } else if (format == CODEC_SCREENVIDEO) {
+ return;
+ }
+
+ if (codec == NULL) {
+ return;
+ }
+
+ cc = avcodec_alloc_context();
+ avcodec_open(cc, codec);
+ cc->width = width;
+ cc->height = height;
+
+ // Determine required buffer size and allocate buffer
+ if (outputFormat == YUV) {
+ decodedFrame = new image::yuv(width, height);
+ } else if (outputFormat == RGB) {
+ decodedFrame = new image::rgb(width, height);
+ }
+}
+
+embedVideoDecoderFfmpeg::~embedVideoDecoderFfmpeg()
+{
+ if (decodedFrame) delete decodedFrame;
+
+ if (cc) avcodec_close(cc);
+
+}
+// gnash calls this when it wants you to decode the given videoframe
+image::image_base*
+embedVideoDecoderFfmpeg::decodeFrame(uint8_t* data, int size)
+{
+
+ if (data == NULL) return decodedFrame;
+
+ // Allocate a frame to store the decoded frame in
+ AVFrame* frame = avcodec_alloc_frame();
+
+ int got = 0;
+ avcodec_decode_video(cc, frame, &got, data, size);
+
+ if (got) {
+ uint8_t *buffer = NULL;
+
+ if (outputFormat == NONE) { // NullGui?
+ av_free(frame);
+ return NULL;
+
+ } else if (outputFormat == YUV && cc->pix_fmt !=
PIX_FMT_YUV420P) {
+ //assert(0); // TODO
+ //img_convert((AVPicture*) pFrameYUV, PIX_FMT_YUV420P,
(AVPicture*) pFrame, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
+
+ } else if (outputFormat == RGB && cc->pix_fmt != PIX_FMT_RGB24)
{
+ AVFrame* frameRGB = avcodec_alloc_frame();
+ unsigned int numBytes =
avpicture_get_size(PIX_FMT_RGB24, cc->width, cc->height);
+ buffer = new uint8_t[numBytes];
+ avpicture_fill((AVPicture *)frameRGB, buffer,
PIX_FMT_RGB24, cc->width, cc->height);
+ img_convert((AVPicture*) frameRGB, PIX_FMT_RGB24,
(AVPicture*) frame, cc->pix_fmt, cc->width, cc->height);
+ av_free(frame);
+ frame = frameRGB;
+ }
+
+ if (outputFormat == YUV) {
+ image::yuv* yuvframe =
static_cast<image::yuv*>(decodedFrame);
+ int copied = 0;
+ uint8_t* ptr = yuvframe->m_data;
+ for (int i = 0; i < 3 ; i++)
+ {
+ int shift = (i == 0 ? 0 : 1);
+ uint8_t* yuv_factor = frame->data[i];
+ int h = cc->height >> shift;
+ int w = cc->width >> shift;
+ for (int j = 0; j < h; j++)
+ {
+ copied += w;
+ //assert(copied <= yuvframe->size());
+ memcpy(ptr, yuv_factor, w);
+ yuv_factor += frame->linesize[i];
+ ptr += w;
+ }
+ }
+ yuvframe->m_size = copied;
+ } else if (outputFormat == RGB) {
+ for(int line = 0; line < cc->height; line++)
+ {
+ for(int byte = 0; byte < (cc->width*3); byte++)
+ {
+ decodedFrame->m_data[byte +
(line*cc->width*3)] = (unsigned char)
*(frame->data[0]+(line*frame->linesize[0])+byte);
+ }
+ }
+ }
+ delete [] buffer;
+ } else {
+ return decodedFrame;
+ }
+
+ return decodedFrame;
+}
+
+
+
+#endif // USE_FFMPEG
Index: libbase/embedVideoDecoderFfmpeg.h
===================================================================
RCS file: libbase/embedVideoDecoderFfmpeg.h
diff -N libbase/embedVideoDecoderFfmpeg.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/embedVideoDecoderFfmpeg.h 8 Feb 2007 13:25:41 -0000 1.1
@@ -0,0 +1,75 @@
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// $Id: embedVideoDecoderFfmpeg.h,v 1.1 2007/02/08 13:25:41 tgc Exp $
+
+#ifndef __EMBEDVIDEODECODERFFMPEG_H__
+#define __EMBEDVIDEODECODERFFMPEG_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef USE_FFMPEG
+
+#include <vector>
+#include "embedVideoDecoder.h"
+#include <ffmpeg/avcodec.h>
+#include "image.h"
+
+
+
+class embedVideoDecoderFfmpeg: public embedVideoDecoder {
+public:
+ embedVideoDecoderFfmpeg();
+
+ ~embedVideoDecoderFfmpeg();
+
+ void createDecoder(
+ int width,
+ int height,
+ int deblocking,
+ bool smoothing,
+ int format,
+ int outputFormat);
+
+ // gnash calls this when it wants you to decode the given videoframe
+ image::image_base* decodeFrame(uint8_t* data, int size);
+
+
+private:
+
+ /// ffmpeg stuff
+ AVCodec *codec;
+ AVCodecContext *cc;
+
+ /// Info from the video tag header. Might be usefull...
+ uint32_t width;
+ uint32_t height;
+ int deblocking;
+ bool smoothing;
+ int format;
+ int outputFormat;
+
+ /// Last decoded frame
+ image::image_base* decodedFrame;
+
+};
+
+
+#endif // USE_FFMPEG
+
+#endif // __EMBEDVIDEODECODERFFMPEG_H__
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/Makefile.am server/impl...,
Tomas Groth <=