gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libmedia/sdl/VideoDecoderFfmpeg...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog libmedia/sdl/VideoDecoderFfmpeg...
Date: Thu, 06 Dec 2007 12:50:25 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   07/12/06 12:50:24

Modified files:
        .              : ChangeLog 
        libmedia/sdl   : VideoDecoderFfmpeg.cpp 
        server/swf     : tag_loaders.cpp 

Log message:
                * server/swf/tag_loaders.cpp: Omit read of evidently optional 
latency
                  bytes in MP3 audio. (Unused anyway).
                * libmedia/sdl/VideoDecoderFfmpeg.cpp: set FLV source line width
                  to next multiple of four. Fixes slanted video rendering in 
bug #21712
                  and doesn't appear to break other cases. Minor cleanups.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5097&r2=1.5098
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sdl/VideoDecoderFfmpeg.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.160&r2=1.161

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5097
retrieving revision 1.5098
diff -u -b -r1.5097 -r1.5098
--- ChangeLog   6 Dec 2007 11:10:24 -0000       1.5097
+++ ChangeLog   6 Dec 2007 12:50:24 -0000       1.5098
@@ -1,3 +1,11 @@
+2007-12-06 Benjamin Wolsey <address@hidden>
+
+       * server/swf/tag_loaders.cpp: Omit read of evidently optional latency
+         bytes in MP3 audio. (Unused anyway).
+       * libmedia/sdl/VideoDecoderFfmpeg.cpp: set FLV source line width
+         to next multiple of four. Fixes slanted video rendering in bug #21712
+         and doesn't appear to break other cases. Minor cleanups.
+
 2007-12-06 Sandro Santilli <address@hidden>
 
        * testsuite/misc-swfc.all/Makefile.am: fix deps for

Index: libmedia/sdl/VideoDecoderFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/sdl/VideoDecoderFfmpeg.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libmedia/sdl/VideoDecoderFfmpeg.cpp 4 Dec 2007 11:45:27 -0000       1.10
+++ libmedia/sdl/VideoDecoderFfmpeg.cpp 6 Dec 2007 12:50:24 -0000       1.11
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-// $Id: VideoDecoderFfmpeg.cpp,v 1.10 2007/12/04 11:45:27 strk Exp $
+// $Id: VideoDecoderFfmpeg.cpp,v 1.11 2007/12/06 12:50:24 bwy Exp $
 
 #include "VideoDecoderFfmpeg.h"
 
@@ -39,7 +39,11 @@
 
 VideoDecoderFfmpeg::~VideoDecoderFfmpeg()
 {
-       if (_videoCodec) avcodec_close(_videoCodecCtx);
+       if (_videoCodecCtx)
+       {
+               avcodec_close(_videoCodecCtx);
+               av_free(_videoCodecCtx);
+       }
 }
 
 bool VideoDecoderFfmpeg::setup(
@@ -70,7 +74,8 @@
                        codec_id = CODEC_ID_FLASHSV;
                        break;
                default:
-                       log_error(_("Unsupported video codec %d"), 
static_cast<int>(format));
+                       log_error(_("Unsupported video codec %d"),
+                                               static_cast<int>(format));
                        return false;
        }
 
@@ -89,7 +94,6 @@
 
        int ret = avcodec_open(_videoCodecCtx, _videoCodec);
        if (ret < 0) {
-               avcodec_close(_videoCodecCtx);
                log_error(_("libavcodec failed to initialize codec"));
                return false;
        }
@@ -124,14 +128,16 @@
                                codec_id = CODEC_ID_FLASHSV;
                                break;
                        default:
-                               log_error(_("Unsupported video codec %d"), 
static_cast<int>(info->codec));
+                               log_error(_("Unsupported video codec %d"),
+                                               static_cast<int>(info->codec));
                                return false;
                }
                _videoCodec = 
avcodec_find_decoder(static_cast<CodecID>(codec_id));
        } else if (info->type == FFMPEG) {
                _videoCodec = 
avcodec_find_decoder(static_cast<CodecID>(info->codec));
        } else {
-               //log_error("Video codecType unknown: %d, %d, %d", info->type, 
FLASH, FFMPEG);
+               //log_error("Video codecType unknown: %d, %d, %d",
+               //                              info->type, FLASH, FFMPEG);
                return false;
        }
 
@@ -155,7 +161,6 @@
 
        int ret = avcodec_open(_videoCodecCtx, _videoCodec);
        if (ret < 0) {
-               avcodec_close(_videoCodecCtx);
                log_error(_("libavcodec failed to initialize codec"));
                return false;
        }
@@ -181,17 +186,21 @@
        AVPicture picture;
 
        avpicture_fill(&picture, buffer, PIX_FMT_RGB24, width, height);
+
 #ifndef HAVE_SWSCALE_H
-       img_convert(&picture, PIX_FMT_RGB24, (AVPicture*) srcFrame, 
srcCtx->pix_fmt,
-                   width, height);
+       img_convert(&picture, PIX_FMT_RGB24, (AVPicture*) srcFrame,
+                       srcCtx->pix_fmt, width, height);
 #else
        static SwsContext* context = NULL;
 
-       if (!context) {
+       if (!context)
+       {
                context = sws_getContext(width, height, srcCtx->pix_fmt,
                                         width, height, PIX_FMT_RGB24,
                                         SWS_FAST_BILINEAR, NULL, NULL, NULL);
-               if (!context) {
+               
+               if (!context)
+               {
                        delete [] buffer;
                        return NULL;
                }
@@ -199,7 +208,8 @@
 
        int rv = sws_scale(context, srcFrame->data, srcFrame->linesize, 0, 
                           width, picture.data, picture.linesize);
-       if (rv == -1) {
+       if (rv == -1)
+       {
                delete [] buffer;
                return NULL;
        }
@@ -212,7 +222,9 @@
        return buffer;
 }
 
-uint8_t* VideoDecoderFfmpeg::decode(uint8_t* input, boost::uint32_t inputSize, 
boost::uint32_t& outputSize)
+uint8_t* VideoDecoderFfmpeg::decode(uint8_t* input,
+                               boost::uint32_t inputSize,
+                               boost::uint32_t& outputSize)
 {
        // Allocate a frame to store the decoded frame in
        AVFrame* frame = avcodec_alloc_frame();
@@ -223,22 +235,34 @@
        }
 
        int got = 0;
+       
        avcodec_decode_video(_videoCodecCtx, frame, &got, input, inputSize);
-       if (got) {
+       
+       if (got)
+       {
                boost::scoped_array<uint8_t> buffer;
 
-               uint8_t* decodedData = new uint8_t[_videoCodecCtx->width * 
_videoCodecCtx->height * 3];
+               // Set to the next multiple of four. Some videos have
+               // padding bytes, so that the source width is more than three 
times
+               // the video width. A likely explanation (supported by
+               // tests) is that it is always padded out to a multiple of 4.
+               // Have found no documenation on this.
+               unsigned int srcwidth = (_videoCodecCtx->width * 3 + 3) &~ 3; 
+
+               uint8_t* decodedData = new uint8_t[srcwidth * 
_videoCodecCtx->height];
                buffer.reset(convertRGB24(_videoCodecCtx, frame));
 
                // Copy the data to the buffer in the correct RGB format
                uint8_t* srcptr = frame->data[0];
-               uint8_t* srcend = frame->data[0] + frame->linesize[0] * 
_videoCodecCtx->height;
+               uint8_t* srcend = frame->data[0]
+                                       + frame->linesize[0]
+                                       * _videoCodecCtx->height;
                uint8_t* dstptr = decodedData;
-               unsigned int srcwidth = _videoCodecCtx->width * 3;
 
                outputSize = 0;
 
-               while (srcptr < srcend) {
+               while (srcptr < srcend)
+               {
                        memcpy(dstptr, srcptr, srcwidth);
                        srcptr += frame->linesize[0];
                        dstptr += srcwidth;
@@ -312,7 +336,9 @@
                        }
 
                }*/
-       } else {
+       }
+       else
+       {
                log_error("Decoding of a video frame failed");
                av_free(frame);
                return NULL;
@@ -325,11 +351,15 @@
        boost::uint32_t outputSize = 0;
        uint8_t* decodedData = decode(input, inputSize, outputSize);
 
-       if (!decodedData || outputSize == 0) {
+       if (!decodedData || outputSize == 0)
+       {
                return std::auto_ptr<image::image_base>(NULL);
        }
 
-       std::auto_ptr<image::image_base> ret(new 
image::rgb(_videoCodecCtx->width, _videoCodecCtx->height));
+       std::auto_ptr<image::image_base> ret(new image::rgb(
+                                               _videoCodecCtx->width,
+                                               _videoCodecCtx->height
+                                               ));
        ret->update(decodedData);
        delete [] decodedData;
        return ret;

Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -b -r1.160 -r1.161
--- server/swf/tag_loaders.cpp  4 Dec 2007 11:45:33 -0000       1.160
+++ server/swf/tag_loaders.cpp  6 Dec 2007 12:50:24 -0000       1.161
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: tag_loaders.cpp,v 1.160 2007/12/04 11:45:33 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.161 2007/12/06 12:50:24 bwy Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1255,8 +1255,8 @@
     int latency = 0;
     if (format == media::AUDIO_CODEC_MP3)
     {
-        in->ensureBytes(2);
-        latency = in->read_s16(); // UNUSED !!
+        //in->ensureBytes(2);
+        //latency = in->read_s16(); // UNUSED !!
         //garbage = in->read_uint(16);
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]