X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_libavcodec%2Ftrgt_av.cpp;h=5ad733aba2220061eee63975a0e280c3115e2217;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=e58b56713ebc9edb236ecaa6c094f2e31c305d21;hpb=cc54c38609ee9745ad678e5e9b9d7d2912be9c95;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/trgt_av.cpp b/synfig-core/trunk/src/modules/mod_libavcodec/trgt_av.cpp index e58b567..5ad733a 100644 --- a/synfig-core/trunk/src/modules/mod_libavcodec/trgt_av.cpp +++ b/synfig-core/trunk/src/modules/mod_libavcodec/trgt_av.cpp @@ -6,6 +6,8 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Paul Wise +** Copyright (c) 2008 Gerco Ballintijn ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -35,7 +37,30 @@ extern "C" { -#include + +/* + ffmpeg library headers have historically had multiple locations. + We should check all of the locations to be more portable. +*/ + +#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H +# include +#elif defined(HAVE_AVFORMAT_H) +# include +#elif defined(HAVE_FFMPEG_AVFORMAT_H) +# include +#endif + +#ifdef WITH_LIBSWSCALE +#ifdef HAVE_LIBSWSCALE_SWSCALE_H +# include +#elif defined(HAVE_SWSCALE_H) +# include +#elif defined(HAVE_FFMPEG_SWSCALE_H) +# include +#endif +#endif + } #include @@ -286,7 +311,7 @@ public: class VideoEncoder { public: - AVFrame *encodable; //for compressiong and output to a file (in compatible pixel format) + AVFrame *encodable; //for compression and output to a file (in compatible pixel format) vector videobuffer; @@ -378,7 +403,7 @@ public: /* If pict is invalid (NULL), then we are done compressing frames and we are trying to get - the buffer cleared out (or if it's already in the right format) so no transofrm necessary + the buffer cleared out (or if it's already in the right format) so no transform necessary */ if ( pict ) { @@ -389,9 +414,23 @@ public: if ( pict && context->pix_fmt != PIX_FMT_RGB24 ) { //We're using RGBA at the moment, write custom conversion code later (get less accuracy errors) +#ifdef WITH_LIBSWSCALE + struct SwsContext* img_convert_ctx = + sws_getContext(context->width, context->height, PIX_FMT_RGB24, + context->width, context->height, context->pix_fmt, + SWS_BICUBIC, NULL, NULL, NULL); + + sws_scale(img_convert_ctx, pict->data, pict->linesize, + + 0, context->height, encodable->data, + encodable->linesize); + + sws_freeContext (img_convert_ctx); +#else img_convert((AVPicture *)encodable, context->pix_fmt, (AVPicture *)pict, PIX_FMT_RGB24, context->width, context->height); +#endif pict = encodable; } @@ -406,7 +445,7 @@ public: if( context->coded_frame && context->coded_frame->key_frame) pkt.flags |= PKT_FLAG_KEY; - //cludge for raw picture format (they said they'd fix) + //kluge for raw picture format (they said they'd fix) if (formatc->oformat->flags & AVFMT_RAWPICTURE) { ret = av_write_frame(formatc, &pkt); @@ -454,7 +493,7 @@ public: return true; } - void close(AVFormatContext *formatc, AVStream *stream) + void close(AVFormatContext */*formatc*/, AVStream *stream) { if(stream) avcodec_close(stream->codec); @@ -642,7 +681,7 @@ public: void CleanUp() { - int i; + unsigned int i; if(picture) free_picture(picture); @@ -674,7 +713,11 @@ public: if(!(format->flags & AVFMT_NOFILE)) { /* close the output file */ +#if LIBAVFORMAT_VERSION_INT >= (52<<16) + url_fclose(formatc->pb); +#else url_fclose(&formatc->pb); +#endif } /* free the stream */ @@ -745,7 +788,7 @@ public: } // add an audio output stream - AVStream *add_audio_stream(int codec_id,const AudioInfo &aInfo) + AVStream *add_audio_stream(int codec_id,const AudioInfo &/*aInfo*/) { AVCodecContext *context; AVStream *stream; @@ -905,7 +948,7 @@ Target_LibAVCodec::end_frame() } bool -Target_LibAVCodec::start_frame(synfig::ProgressCallback *callback) +Target_LibAVCodec::start_frame(synfig::ProgressCallback */*callback*/) { //prepare all the color buffer stuff, etc. @@ -929,7 +972,7 @@ Target_LibAVCodec::end_scanline() bool Target_LibAVCodec::init() { - //hardcode test for mpeg + //hardcoded test for mpeg if(!data->Initialize(filename.c_str(),NULL)) { synfig::warning("Unable to Initialize the audio video encoders");