Forums
  News| Documentation| Screenshots| Downloads| Support| Forums| Wiki| Shop| Search| Donate| Contact Home
FAQFAQ SearchSearch MemberlistMemberlist UsergroupsUsergroups RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in

sws_scale swscaler ffmpeg patch

 
Donate $20 Donate $40
Post new topic   Reply to topic    ZoneMinder Forum Index -> ZoneMinder Previous Versions
View previous topic :: View next topic  
Author Message
kruton



Joined: 12 May 2006
Posts: 2
Location: KS, USA

PostPosted: Sun Oct 21, 2007 4:41 am    Post subject: sws_scale swscaler ffmpeg patch Reply with quote

I didn't see anyone talking about this issue, but with the latest FFMPEG packages from ATrpms, it uses the swscaler interface and deprecates the img_convert function. As such, ZoneMinder 1.22.3 doesn't work. I wrote a patch to enable it if HAVE_SWSCALER is setup.

Code:
--- /tmp/ZoneMinder-1.22.3/src/zm_mpeg.cpp  2006-01-17 04:56:30.000000000 -0600
+++ /tmp/ZoneMinder-1.22.3/src/zm_mpeg.cpp  2007-10-20 23:33:43.000000000 -0500
@@ -27,6 +27,10 @@
 
 bool VideoStream::initialised = false;
 
+#if HAVE_SWSCALER
+static int sws_flags = SWS_BICUBIC;
+#endif
+
 VideoStream::MimeData VideoStream::mime_data[] = {
      { "asf", "video/x-ms-asf" },
      { "swf", "application/x-shockwave-flash" },
@@ -116,6 +120,9 @@
        // some formats want stream headers to be seperate
        if(!strcmp(ofc->oformat->name, "mp4") || !strcmp(ofc->oformat->name, "mov") || !strcmp(ofc->oformat->name, "3gp"))
                c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+#if HAVE_SWSCALER
+       swsContext = NULL;
+#endif
      }
 }
 
@@ -268,6 +275,13 @@
      /* write the trailer, if any */
      av_write_trailer(ofc);
 
+#if HAVE_SWSCALER
+     if (swsContext) {
+       sws_freeContext(swsContext);
+       swsContext = NULL;
+     }
+#endif
+
      /* free the streams */
      for( int i = 0; i < ofc->nb_streams; i++)
      {
@@ -302,12 +316,33 @@
 #else
      AVCodecContext *c = &ost->codec;
 #endif
+
      if (c->pix_fmt != pf)
      {
        memcpy( tmp_opicture->data[0], buffer, buffer_size );
+#ifndef HAVE_SWSCALER
        img_convert((AVPicture *)opicture, c->pix_fmt,
                        (AVPicture *)tmp_opicture, pf,
                        c->width, c->height);
+#else
+       swsContext = sws_getCachedContext(swsContext,
+                 c->width, c->height, pf,
+                 c->width, c->height, c->pix_fmt,
+                 sws_flags, NULL, NULL, NULL);
+
+       if (swsContext == NULL)
+       {
+               Fatal(( "swscale context initialization failed" ));
+               return 1;
+       }
+
+       sws_scale(swsContext,
+                 ((AVPicture *)tmp_opicture)->data,
+                 ((AVPicture *)tmp_opicture)->linesize,
+                 0, c->height,
+                 ((AVPicture *)opicture)->data,
+                 ((AVPicture *)opicture)->linesize);
+#endif
      }
      else
      {
diff -urN /tmp/ZoneMinder-1.22.3/src/zm_mpeg.h /tmp/ZoneMinder-1.22.3/src/zm_mpeg.h
--- /tmp/ZoneMinder-1.22.3/src/zm_mpeg.h 2006-07-04 05:46:16.000000000 -0500
+++ /tmp/ZoneMinder-1.22.3/src/zm_mpeg.h 2007-10-20 23:33:13.000000000 -0500
@@ -26,6 +26,10 @@
 
 #include <ffmpeg/avformat.h>
 
+#if HAVE_SWSCALER
+#include <ffmpeg/swscale.h>
+#endif
+
 #if FFMPEG_VERSION_INT == 0x000408
 #define ZM_FFMPEG_048  1
 #elif FFMPEG_VERSION_INT == 0x000409
@@ -63,6 +67,9 @@
      uint8_t *video_outbuf;
      int video_outbuf_size;
      double pts;
+#if HAVE_SWSCALER
+     struct SwsContext *swsContext;
+#endif
 
 protected:
      static void Initialise();
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ZoneMinder Forum Index -> ZoneMinder Previous Versions All times are GMT
Page 1 of 1

 
  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
 ©2007 Triornis Ltd News • Documentation • Screenshots • Downloads • Support • Forums • Wiki • Shop • Search • Donate • Contact • Home