[GRASS-SVN] r53855 - grass/branches/develbranch_6/lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 17 04:09:26 PST 2012


Author: martinl
Date: 2012-11-17 04:09:26 -0800 (Sat, 17 Nov 2012)
New Revision: 53855

Modified:
   grass/branches/develbranch_6/lib/ogsf/gsd_img_mpeg.c
Log:
update ogsf for ffmpeg, replace deprecated fns
       (merge r53854 from trunk)


Modified: grass/branches/develbranch_6/lib/ogsf/gsd_img_mpeg.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gsd_img_mpeg.c	2012-11-17 12:07:49 UTC (rev 53854)
+++ grass/branches/develbranch_6/lib/ogsf/gsd_img_mpeg.c	2012-11-17 12:09:26 UTC (rev 53855)
@@ -27,6 +27,7 @@
 /* FFMPEG stuff */
 #ifdef HAVE_FFMPEG
 #include <avformat.h>
+#include <avio.h>
 
 /* 5 seconds stream duration */
 #define STREAM_DURATION   5.0
@@ -58,7 +59,7 @@
     AVCodecContext *c;
     AVStream *st;
 
-    st = av_new_stream(oc, 0);
+    st = avformat_new_stream(oc, NULL);
     if (!st) {
 	G_warning(_("Unable to allocate stream"));
 	return NULL;
@@ -97,7 +98,12 @@
 	c->flags |= CODEC_FLAG_GLOBAL_HEADER;
 
     c->flags |= CODEC_FLAG_QSCALE;
-    c->global_quality = st->quality = FF_QP2LAMBDA * 10;
+    /* Quality, as it has been removed from AVCodecContext and put in AVVideoFrame.
+       
+       \todo use AVVideoFrame
+       c->global_quality = st->quality = FF_QP2LAMBDA * 10;
+    */
+    c->global_quality = FF_QP2LAMBDA * 10;
 
     return st;
 }
@@ -158,7 +164,7 @@
     }
 
     /* open the codec */
-    if (avcodec_open(c, codec) < 0) {
+    if (avcodec_open2(c, codec, NULL) < 0) {
 	G_warning(_("Unable to open codec"));
 	return;
     }
@@ -261,7 +267,7 @@
    \param oc [unused]
    \param st
  */
-static void close_video(AVFormatContext * oc, AVStream * st)
+static void close_video(AVStream * st)
 {
     avcodec_close(st->codec);
     av_free(picture->data[0]);
@@ -333,12 +339,12 @@
     }
 
     /* set the output parameters (must be done even if no parameters). */
-    if (av_set_parameters(oc, NULL) < 0) {
+    if (avformat_write_header(oc, NULL) < 0) {
 	G_warning(_("Invalid output format parameters"));
 	return (-1);
     }
 
-    dump_format(oc, 0, filename, 1);
+    av_dump_format(oc, 0, filename, 1);
 
     /* now that all the parameters are set, we can open the audio and
        video codecs and allocate the necessary encode buffers */
@@ -347,14 +353,14 @@
 
     /* open the output file, if needed */
     if (!(fmt->flags & AVFMT_NOFILE)) {
-	if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
+	if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
 	    G_warning(_("Unable to open <%s>"), filename);
 	    return (-1);
 	}
     }
 
     /* write the stream header, if any */
-    av_write_header(oc);
+    avformat_write_header(oc, NULL);
 
 
 #else
@@ -374,8 +380,8 @@
 int gsd_write_mpegframe(void)
 {
 #ifdef HAVE_FFMPEG
-    unsigned int xsize, ysize;
-    int x, y, xy, xy_uv;
+    unsigned int xsize, ysize, x;
+    int y, xy, xy_uv;
     int yy, uu, vv;
     unsigned char *pixbuf;
 
@@ -421,9 +427,9 @@
 int gsd_close_mpeg(void)
 {
 #ifdef HAVE_FFMPEG
-    int i;
+    unsigned int i;
 
-    close_video(oc, video_st);
+    close_video(video_st);
 
     /* write the trailer, if any */
     av_write_trailer(oc);
@@ -436,11 +442,7 @@
 
     if (!(fmt->flags & AVFMT_NOFILE)) {
 	/* close the output file */
-#if (LIBAVFORMAT_VERSION_INT>>16) < 52
-	url_fclose(&oc->pb);
-#else
-	url_fclose(oc->pb);
-#endif
+	avio_close(oc->pb);
     }
 
     /* free the stream */



More information about the grass-commit mailing list