ffmpeg | branch: master | Michael Niedermayer <[email protected]> | Sat 
Aug  8 12:36:49 2015 +0200| [c382d9e8cbee7635755a559fcd03834aa3daa3a7] | 
committer: Michael Niedermayer

swscale: Add sws_alloc_set_opts()

This simplifies allocating and initializing swscale contexts with custom 
options.
The function is internal currently but could be moved into the public header

Signed-off-by: Michael Niedermayer <[email protected]>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c382d9e8cbee7635755a559fcd03834aa3daa3a7
---

 libswscale/swscale_internal.h |   11 +++++++++++
 libswscale/utils.c            |   23 +++++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 737c179..eeeef2d 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -890,6 +890,17 @@ void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, 
int16_t *dst2,
                             int dstWidth, const uint8_t *src1,
                             const uint8_t *src2, int srcW, int xInc);
 
+/**
+ * Allocate and return an SwsContext.
+ * This is like sws_getContext() but does not perform the init step, allowing
+ * the user to set additional AVOptions.
+ *
+ * @see sws_getContext()
+ */
+struct SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat 
srcFormat,
+                                      int dstW, int dstH, enum AVPixelFormat 
dstFormat,
+                                      int flags, const double *param);
+
 static inline void fillPlane16(uint8_t *plane, int stride, int width, int 
height, int y,
                                int alpha, int bits, const int big_endian)
 {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 565c904..106101a 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1632,10 +1632,9 @@ fail: // FIXME replace things by appropriate error codes
     return -1;
 }
 
-SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
-                           int dstW, int dstH, enum AVPixelFormat dstFormat,
-                           int flags, SwsFilter *srcFilter,
-                           SwsFilter *dstFilter, const double *param)
+SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat 
srcFormat,
+                               int dstW, int dstH, enum AVPixelFormat 
dstFormat,
+                               int flags, const double *param)
 {
     SwsContext *c;
 
@@ -1655,6 +1654,22 @@ SwsContext *sws_getContext(int srcW, int srcH, enum 
AVPixelFormat srcFormat,
         c->param[1] = param[1];
     }
 
+    return c;
+}
+
+SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
+                           int dstW, int dstH, enum AVPixelFormat dstFormat,
+                           int flags, SwsFilter *srcFilter,
+                           SwsFilter *dstFilter, const double *param)
+{
+    SwsContext *c;
+
+    c = sws_alloc_set_opts(srcW, srcH, srcFormat,
+                           dstW, dstH, dstFormat,
+                           flags, param);
+    if (!c)
+        return NULL;
+
     if (sws_init_context(c, srcFilter, dstFilter) < 0) {
         sws_freeContext(c);
         return NULL;

_______________________________________________
ffmpeg-cvslog mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to