-/* === S I N F G =========================================================== */
+/* === S Y N F I G ========================================================= */
/*! \file trgt.cpp
** \brief \writeme
**
** $Id: trgt_av.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $
**
** \legal
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
**
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
** \endlegal
*/
/* ========================================================================= */
/* === H E A D E R S ======================================================= */
-#define SINFG_NO_ANGLE
+#define SYNFIG_NO_ANGLE
#ifdef USING_PCH
# include "pch.h"
#include "libavformat/avformat.h"
}
-#include <sinfg/general.h>
+#include <synfig/general.h>
#include <cstdio>
#include <algorithm>
/* === U S I N G =========================================================== */
-using namespace sinfg;
+using namespace synfig;
using namespace std;
using namespace etl;
/* === I N F O ============================================================= */
-SINFG_TARGET_INIT(Target_LibAVCodec);
-SINFG_TARGET_SET_NAME(Target_LibAVCodec,"libav");
-SINFG_TARGET_SET_EXT(Target_LibAVCodec,"avi");
-SINFG_TARGET_SET_VERSION(Target_LibAVCodec,"0.1");
-SINFG_TARGET_SET_CVS_ID(Target_LibAVCodec,"$Id: trgt_av.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $");
+SYNFIG_TARGET_INIT(Target_LibAVCodec);
+SYNFIG_TARGET_SET_NAME(Target_LibAVCodec,"libav");
+SYNFIG_TARGET_SET_EXT(Target_LibAVCodec,"avi");
+SYNFIG_TARGET_SET_VERSION(Target_LibAVCodec,"0.1");
+SYNFIG_TARGET_SET_CVS_ID(Target_LibAVCodec,"$Id: trgt_av.cpp,v 1.1.1.1 2005/01/04 01:23:11 darco Exp $");
/* === C L A S S E S & S T R U C T S ======================================= */
codec = avcodec_find_encoder(context->codec_id);
if(!codec)
{
- sinfg::warning("audio-open: could not find codec");
+ synfig::warning("audio-open: could not find codec");
return 0;
}
//open the codec
if(avcodec_open(context, codec) < 0)
{
- sinfg::warning("audio-open: could not open codec");
+ synfig::warning("audio-open: could not open codec");
return 0;
}
//write the compressed audio to a file
if(av_write_frame(formatc, stream->index, &audiobuffer[0], size) != 0)
{
- sinfg::warning("audio-write_frame: unable to write the entire audio frame");
+ synfig::warning("audio-write_frame: unable to write the entire audio frame");
return 0;
}
{
if(!formatc || !stream)
{
- sinfg::warning("Attempt to open a video codec with a bad format or stream");
+ synfig::warning("Attempt to open a video codec with a bad format or stream");
return false;
}
codec = avcodec_find_encoder(context->codec_id);
if(!codec)
{
- sinfg::warning("Open_video: could not find desired codec");
+ synfig::warning("Open_video: could not find desired codec");
return 0;
}
//try to open the codec
if(avcodec_open(context, codec) < 0)
{
- sinfg::warning("open_video: could not open desired codec");
+ synfig::warning("open_video: could not open desired codec");
return 0;
}
/*picture = alloc_picture(PIX_FMT_RGBA32, context->width, context->height);
if(!picture)
{
- sinfg::warning("open_video: could not allocate the picture to be encoded");
+ synfig::warning("open_video: could not allocate the picture to be encoded");
return 0;
}*/
encodable = alloc_picture(context->pix_fmt, context->width, context->height);
if(!encodable)
{
- sinfg::warning("open_video: could not allocate encodable picture");
+ synfig::warning("open_video: could not allocate encodable picture");
return 0;
}
}
{
if(!formatc || !stream)
{
- sinfg::warning("Attempt to open a video codec with a bad format or stream");
+ synfig::warning("Attempt to open a video codec with a bad format or stream");
return false;
}
//error detect - possibly throw later...
if(ret != 0)
{
- sinfg::warning("write_frame: error while writing video frame");
+ synfig::warning("write_frame: error while writing video frame");
return false;
}
}
if(!format)
{
- sinfg::warning("Unable to Guess the output, defaulting to mpeg");
+ synfig::warning("Unable to Guess the output, defaulting to mpeg");
format = guess_format("mpeg", NULL, NULL);
}
if(!format)
{
- sinfg::warning("Unable to find output format");
+ synfig::warning("Unable to find output format");
return 0;
}
formatc = (AVFormatContext *)av_mallocz(sizeof(AVFormatContext));
if(!formatc)
{
- sinfg::warning("Memory error\n");
+ synfig::warning("Memory error\n");
return 0;
}
//set the output format to the one we found
if(av_set_parameters(formatc, ap) < 0)
{
- sinfg::warning("Invalid output formatting parameters");
+ synfig::warning("Invalid output formatting parameters");
return 0;
}
{
if(!vid.open(formatc, video_st))
{
- sinfg::warning("Could not open video encoder");
+ synfig::warning("Could not open video encoder");
return 0;
}
}
{
if(!aud.open(formatc, audio_st))
{
- sinfg::warning("Could not open audio encoder");
+ synfig::warning("Could not open audio encoder");
return 0;
}
}*/
//use libav's file open function (what does it do differently????)
if(url_fopen(&formatc->pb, filename, URL_WRONLY) < 0)
{
- sinfg::warning("Unable to open file: %s", filename);
+ synfig::warning("Unable to open file: %s", filename);
return 0;
}
}
picture = alloc_picture(PIX_FMT_RGB24,vInfo.w,vInfo.h);//video_st->codec.width, video_st->codec.height);
if(!picture)
{
- sinfg::warning("Unable to allocate the temporary AVFrame surface");
+ synfig::warning("Unable to allocate the temporary AVFrame surface");
return 0;
}
st = av_new_stream(formatc, 0);
if(!st)
{
- sinfg::warning("video-add_stream: Unable to allocate stream");
+ synfig::warning("video-add_stream: Unable to allocate stream");
return 0;
}
stream = av_new_stream(formatc, 1);
if(!stream)
{
- sinfg::warning("could not alloc stream");
+ synfig::warning("could not alloc stream");
return 0;
}
//encode the frame and write it to the file
if(!data->vid.write_frame(formatc,video_st,data->picture))
{
- sinfg::warning("Unable to write a frame");
+ synfig::warning("Unable to write a frame");
}
data->frame_count++;
}
bool
-Target_LibAVCodec::start_frame(sinfg::ProgressCallback *callback)
+Target_LibAVCodec::start_frame(synfig::ProgressCallback *callback)
{
//prepare all the color buffer stuff, etc.
//hardcode test for mpeg
if(!data->Initialize(filename.c_str(),NULL))
{
- sinfg::warning("Unable to Initialize the audio video encoders");
+ synfig::warning("Unable to Initialize the audio video encoders");
return 0;
}