]> Pileus Git - ~andy/sunrise/blob - media-libs/libinstrudeo/files/img_convert_to_sws_scale.patch
976f27a5c6c7f68408d6716d63596692d859d4e1
[~andy/sunrise] / media-libs / libinstrudeo / files / img_convert_to_sws_scale.patch
1 Index: libinstrudeo-0.1.4/configure.ac
2 ===================================================================
3 --- libinstrudeo-0.1.4.orig/configure.ac
4 +++ libinstrudeo-0.1.4/configure.ac
5 @@ -92,6 +92,7 @@ AC_CHECK_LIB([vorbisenc], [vorbis_encode
6  AC_CHECK_LIB([theora], [theora_info_init], , AC_MSG_ERROR([*** theora missing - please install libtheora development package ***]))
7  AC_CHECK_LIB([avcodec], [avcodec_init], , AC_MSG_ERROR([*** avcodec missing - please install avcodec development package ***]), [-lavutil])
8  AC_CHECK_LIB([avformat], [av_open_input_stream], , AC_MSG_ERROR([*** avformat missing - please install avformat development package ***]), [-lavutil])
9 +AC_CHECK_LIB([swscale], [sws_scale], , AC_MSG_ERROR([*** swscale missing - please install swscale development package ***]), [-lswscale])
10  dnl This should pass, since we successfully linked in the two previous checks
11  dnl This step add the necessary -lavutil to the LIBS variable
12  dnl Note: specifying a method caused troubles, so I switched to main
13 @@ -144,4 +145,4 @@ AC_FUNC_STRTOD
14  AC_CHECK_FUNCS([ftime gethostbyname gettimeofday localtime_r memset munmap select setlocale socket sqrt strchr strdup strerror strrchr strstr strtoull])
15  
16  AC_CONFIG_FILES(Makefile src/Makefile src/libinstrudeo/webservice/Makefile src/libinstrudeo/Makefile src/isdexport/Makefile data/Makefile data/commentboxes/Makefile data/fonts/Makefile)
17 -AC_OUTPUT
18 \ Pas de fin de ligne à la fin du fichier.
19 +AC_OUTPUT
20 Index: libinstrudeo-0.1.4/src/libinstrudeo/isdffmpegexporter.cpp
21 ===================================================================
22 --- libinstrudeo-0.1.4.orig/src/libinstrudeo/isdffmpegexporter.cpp
23 +++ libinstrudeo-0.1.4/src/libinstrudeo/isdffmpegexporter.cpp
24 @@ -79,6 +79,7 @@ ISDFFmpegExporter::~ISDFFmpegExporter()
25  ISDObject::ISDErrorCode ISDFFmpegExporter::doExport(char* pixelBuffer)
26  {
27      char* grabBuffer;
28 +    struct SwsContext *toYUV_convert_ctx;
29      
30      if (!initOK) {
31         LOG_WARNING("Export routine called without initializing the encoder.");
32 @@ -96,6 +97,10 @@ ISDObject::ISDErrorCode ISDFFmpegExporte
33         grabBuffer = (char*)malloc(bufSize);
34      }
35  
36 +    toYUV_convert_ctx = sws_getContext(codecContext->width, codecContext->height, inputPixFmt,
37 +                    outputContext->streams[0]->codec->width, outputContext->streams[0]->codec->height,
38 +                    FFMPEG_STREAM_PIX_FMT, SWS_BICUBIC, NULL, NULL, NULL);
39 +
40      /*
41       * Note: video time is in milliseconds, so if we have a framerate
42       * of 25, we must increment the loop with 1000/25 milliseconds
43 @@ -126,13 +131,13 @@ ISDObject::ISDErrorCode ISDFFmpegExporte
44         }
45             
46         //convert input pic to yuv420p
47 -       if (img_convert(&yuvInputPicture, FFMPEG_STREAM_PIX_FMT, &inputPicture, 
48 -                       inputPixFmt, codecContext->width, codecContext->height) < 0)
49 -           {
50 -               LOG_WARNING("Pixel format conversion not handled while exporting.");
51 -               RETURN_ERROR(ISD_EXPORT_FORMAT_ERROR);
52 -           }
53 -           
54 +        if (sws_scale(toYUV_convert_ctx, inputPicture.data, inputPicture.linesize, 0, codecContext->height,
55 +                        yuvInputPicture.data, yuvInputPicture.linesize) < 0)
56 +            {
57 +                LOG_WARNING("Pixel format conversion not handled while exporting.");
58 +                RETURN_ERROR(ISD_EXPORT_FORMAT_ERROR);
59 +            }
60 +
61         outSize = avcodec_encode_video(codecContext, outputBuf, outputBufSize, inputFrame);
62         //if zero size, it means the image was buffered
63         if (outSize > 0) {
64 Index: libinstrudeo-0.1.4/src/libinstrudeo/isdffmpegexporter.h
65 ===================================================================
66 --- libinstrudeo-0.1.4.orig/src/libinstrudeo/isdffmpegexporter.h
67 +++ libinstrudeo-0.1.4/src/libinstrudeo/isdffmpegexporter.h
68 @@ -47,8 +47,11 @@
69  
70  #include <libinstrudeo/isdexporter.h>
71  
72 +extern "C" {
73  #include <libavcodec/avcodec.h>
74  #include <libavformat/avformat.h>
75 +#include <libswscale/swscale.h>
76 +}
77  
78  using namespace std;
79