[xiph-commits] r7139 - trunk/ffmpeg2theora
j at dactyl.lonelymoon.com
j
Thu Jul 15 12:07:54 PDT 2004
Author: j
Date: Thu Jul 15 12:07:54 2004
New Revision: 7139
Modified:
trunk/ffmpeg2theora/ChangeLog
trunk/ffmpeg2theora/INSTALL
trunk/ffmpeg2theora/Makefile.am
trunk/ffmpeg2theora/configure.ac
trunk/ffmpeg2theora/ffmpeg2theora.c
trunk/ffmpeg2theora/theorautils.c
Log:
- fix problems with mpeg files using ffmpeg from cvs or versions higher than 0.4.8.
- remove --with-ffmpegcvs and detect changes by LIBAVCODEC_BUILD
Modified: trunk/ffmpeg2theora/ChangeLog
===================================================================
--- trunk/ffmpeg2theora/ChangeLog 2004-07-15 17:15:13 UTC (rev 7138)
+++ trunk/ffmpeg2theora/ChangeLog 2004-07-15 19:07:50 UTC (rev 7139)
@@ -1,3 +1,8 @@
+0.10.1 2004-07-15 21:03:15
+ - fix problems with mpeg files using ffmpeg from cvs or versions
+ higher than 0.4.8.
+ - remove --with-ffmpegcvs and detect changes by LIBAVCODEC_BUILD
+
0.10 2004-07-10 18:14:15
- write eos at the end of the file.
- fix memleak due to not enough calls of ogg_stream_pageout
Modified: trunk/ffmpeg2theora/INSTALL
===================================================================
--- trunk/ffmpeg2theora/INSTALL 2004-07-15 17:15:13 UTC (rev 7138)
+++ trunk/ffmpeg2theora/INSTALL 2004-07-15 19:07:50 UTC (rev 7139)
@@ -2,11 +2,9 @@
---------------------------------
you need
-the latest version of libtheora ( http://www.theora.org/files )
-- ffmpeg 0.4.8 or cvs ( http://ffmpeg.sf.net ) / by running ./get_ffmpeg_cvs.sh
+- ffmpeg 0.4.9-pre1 or cvs ( http://ffmpeg.sf.net ) / by running ./get_ffmpeg_cvs.sh
configure it with i.e.
- ./configure --enable-faad --enable-vorbis --disable-mp3lame --enable-pp --enable-a52 --disable-vhook --disable-v4l --disable-audio-oss --disable-dv1394 --disable-ffmpeg --disable-ffserver --disable-network --enable-gpl
- [note: if you use ffmpeg from cvs you have to run configure with
- --enable-ffmpegcvs ]
+ ./configure --enable-faad --enable-vorbis --disable-mp3lame --enable-pp --enable-a52 --enable-pthreads --disable-vhook --disable-v4l --disable-audio-oss --disable-dv1394 --disable-ffmpeg --disable-ffserver --disable-network --enable-gpl
now run:
./configure [--with-ffmpegprefix=/path/to/ffmpeg_src]
@@ -25,3 +23,4 @@
to build ffmpeg2theora
make -f Makefile.mingw32
+[ you might be able to compile it with the Makefile generated by automake too ]
Modified: trunk/ffmpeg2theora/Makefile.am
===================================================================
--- trunk/ffmpeg2theora/Makefile.am 2004-07-15 17:15:13 UTC (rev 7138)
+++ trunk/ffmpeg2theora/Makefile.am 2004-07-15 19:07:50 UTC (rev 7139)
@@ -2,7 +2,7 @@
SUBDIRS = kino_export
-EXTRA_DIST = Makefile.mingw32
+EXTRA_DIST = Makefile.mingw32 theorautils.h
EXTRA="-D_FILE_OFFSET_BITS=64"
Modified: trunk/ffmpeg2theora/configure.ac
===================================================================
--- trunk/ffmpeg2theora/configure.ac 2004-07-15 17:15:13 UTC (rev 7138)
+++ trunk/ffmpeg2theora/configure.ac 2004-07-15 19:07:50 UTC (rev 7139)
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(ffmpeg2theora,0.10)
+AC_INIT(ffmpeg2theora,0.10.1)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
@@ -16,10 +16,19 @@
[prefix to ffmpeg source, if libavcodec and libavformat are not in . (default=.)]),
ffmpegprefix="$withval", ffmpegprefix="ffmpeg")
-AC_CHECK_FILES([$ffmpegprefix/libavcodec/libavcodec.a $ffmpegprefix/libavformat/libavformat.a],[HAVE_FFMPEG=yes])
+dnl only check for libavcodec.a and libformat.a if not crosscompiling
+dnl
+if test "$cross_compiling" = yes; then
+ HAVE_FFMPEG=yes
+else
+ AC_CHECK_FILES([$ffmpegprefix $ffmpegprefix/libavcodec/libavcodec.a $ffmpegprefix/libavformat/libavformat.a],[HAVE_FFMPEG=yes])
+fi
+
+dnl if not using ffmpegprefix try to look for shared files
if test "x$HAVE_FFMPEG" != xyes; then
AC_CHECK_HEADER(ffmpeg/avcodec.h,[HAVE_SHARED_AVCODEC=yes])
AC_CHECK_HEADER(ffmpeg/avformat.h, [HAVE_SHARED_AVFORMAT=yes])
+ AC_CHECK_FILE(/usr/local/include/ffmpeg, [HAVE_FFMPEG_LOCAL=yes])
if test "x$HAVE_SHARED_AVCODEC$HAVE_SHARED_AVCODEC" != xyesyes; then
AC_MSG_ERROR([
you need libavcodec and libavformat from ffmpeg cvs
@@ -29,25 +38,21 @@
(see INSTALL for more information)
])
else
- dnl try to link against shared libs
- dnl might need to check for the libs
- FFMPEG_CFLAGS="-I/usr/include/ffmpeg -I/usr/local/include/ffmpeg"
+ if test "x$HAVE_FFMPEG_LOCAL" != xyes; then
+ FFMPEG_CFLAGS="-I/usr/include/ffmpeg"
+ else
+ FFMPEG_CFLAGS="-I/usr/local/include/ffmpeg"
+ fi
FFMPEG_EXTLIBS="-lm -lz"
- FFMPEG_LIBS="-lavformat -lavcodec -lm -lz"
+ FFMPEG_LIBS="-L/usr/local/lib -L/usr/lib -lavformat -lavcodec $FFMPEG_EXTLIBS"
fi
- break
+
else
- dnl just link against shared libs for now.
FFMPEG_CFLAGS="-I$ffmpegprefix/libavformat -I$ffmpegprefix/libavcodec"
FFMPEG_EXTLIBS="-lm -lz"
FFMPEG_LIBS="$ffmpegprefix/libavformat/libavformat.a $ffmpegprefix/libavcodec/libavcodec.a $FFMPEG_EXTLIBS"
fi
-dnl keep track of the api
-AC_ARG_ENABLE(ffmpegcvs,AS_HELP_STRING([--enable-ffmpegcvs],[use ffmpeg from cvs(to track api changes)]),ffmpegcvs="yes",ffmpegcvs="no")
-if test "x$ffmpegcvs" = xyes; then
- FFMPEG_CFLAGS="$FFMPEG_CFLAGS -DFFMPEGCVS"
-fi
AC_CHECK_LIB(faad,faacDecClose, [
AC_CHECK_HEADER(faad.h, [HAVE_FAAD=yes])
Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c 2004-07-15 17:15:13 UTC (rev 7138)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c 2004-07-15 19:07:50 UTC (rev 7139)
@@ -64,7 +64,9 @@
}
*ff2theora;
-/* Allocate and initialise an AVFrame. */
+/**
+ * Allocate and initialise an AVFrame.
+ */
AVFrame *alloc_picture (int pix_fmt, int width, int height){
AVFrame *picture;
uint8_t *picture_buf;
@@ -84,10 +86,13 @@
return picture;
}
+/**
+ * initialize ff2theora with default values
+ * @return ff2theora struct
+ */
ff2theora ff2theora_init (){
ff2theora this = calloc (1, sizeof (*this));
if (this != NULL){
- // initialise with sane values here.
this->disable_audio=0;
this->video_index = -1;
this->audio_index = -1;
@@ -171,29 +176,29 @@
fprintf(stderr," Deinterlace: off\n");
-#ifdef FFMPEGCVS
+#if LIBAVCODEC_BUILD<=4680 // ffmpeg-0.48
+ if(venc->aspect_ratio!=0){
+#else
if(venc->sample_aspect_ratio.num!=0){
-#else
- if(venc->aspect_ratio!=0){
#endif
-#ifdef FFMPEGCVS
+#if LIBAVCODEC_BUILD<=4680 // ffmpeg-0.48
// just use the ratio from the input
- this->aspect_numerator=venc->sample_aspect_ratio.num;
- this->aspect_denominator=venc->sample_aspect_ratio.den;
+ av_reduce(&this->aspect_numerator,&this->aspect_denominator,
+ rint(10000*venc->aspect_ratio*venc->height),rint(10000*venc->width),10000);
// or we use ratio for the output
if(this->output_height){
av_reduce(&this->aspect_numerator,&this->aspect_denominator,
- venc->sample_aspect_ratio.num*venc->width*this->output_height,
- venc->sample_aspect_ratio.den*venc->height*this->output_width,10000);
+ rint(venc->aspect_ratio*10000*this->output_height),
+ rint(10000*this->output_width),10000);
#else
// just use the ratio from the input
- av_reduce(&this->aspect_numerator,&this->aspect_denominator,
- rint(10000*venc->aspect_ratio*venc->height),rint(10000*venc->width),10000);
+ this->aspect_numerator=venc->sample_aspect_ratio.num;
+ this->aspect_denominator=venc->sample_aspect_ratio.den;
// or we use ratio for the output
if(this->output_height){
av_reduce(&this->aspect_numerator,&this->aspect_denominator,
- rint(venc->aspect_ratio*10000*this->output_height),
- rint(10000*this->output_width),10000);
+ venc->sample_aspect_ratio.num*venc->width*this->output_height,
+ venc->sample_aspect_ratio.den*venc->height*this->output_width,10000);
#endif
frame_aspect=(float)(this->aspect_numerator*this->output_width)/
(this->aspect_denominator*this->output_height);
@@ -217,23 +222,22 @@
int frame_padtop=0, frame_padbottom=0;
int frame_padleft=0, frame_padright=0;
/* ffmpeg cvs version */
-#ifdef FFMPEGCVS
+#if LIBAVCODEC_BUILD<=4680 // ffmpeg-0.48
this->img_resample_ctx = img_resample_full_init(
this->output_width, this->output_height,
venc->width, venc->height,
frame_topBand, frame_bottomBand,
- frame_leftBand, frame_rightBand,
- frame_padtop, frame_padbottom,
- frame_padleft, frame_padright
- );
+ frame_leftBand, frame_rightBand
+ );
#else
- /* ffmpeg 0.48 */
this->img_resample_ctx = img_resample_full_init(
- this->output_width, this->output_height,
- venc->width, venc->height,
- frame_topBand, frame_bottomBand,
- frame_leftBand, frame_rightBand
- );
+ this->output_width, this->output_height,
+ venc->width, venc->height,
+ frame_topBand, frame_bottomBand,
+ frame_leftBand, frame_rightBand,
+ frame_padtop, frame_padbottom,
+ frame_padleft, frame_padright
+ );
#endif
fprintf(stderr," Resize: %dx%d => %dx%d\n",venc->width,venc->height,this->output_width,this->output_height);
}
@@ -363,7 +367,11 @@
/* main decoding loop */
do{
- ret = av_read_packet (this->context, &pkt);
+#if LIBAVFORMAT_BUILD<=4608 // ffmpeg-0.48
+ ret = av_read_packet(this->context,&pkt);
+#else
+ ret = av_read_frame(this->context,&pkt);
+#endif
if(ret<0){
e_o_s=1;
}
@@ -375,6 +383,7 @@
fprintf (stderr, "no frame available\n");
}
while(e_o_s || len > 0){
+
if(len >0 &&
(len1 = avcodec_decode_video(&vstream->codec,
frame,&got_picture, ptr, len))>0) {
@@ -531,7 +540,9 @@
"\t --v2v-preset,-p\tencode file with v2v preset, \n"
"\t\t\t\t right now there is preview and pro,\n"
"\t\t\t\t '"PACKAGE" -p info' for more informations\n"
- "\t --nice\t\tset niceness to n\n"
+#ifndef _WIN32
+ "\t --nice\t\t\tset niceness to n\n"
+#endif
"\t --debug\t\toutputt some more information during encoding\n"
"\t --help,-h\t\tthis message\n"
"\n Examples:\n"
@@ -659,9 +670,11 @@
case 'N':
n = atoi(optarg);
if (n) {
+#ifndef _WIN32
if (nice(n)<0) {
fprintf(stderr,"error setting %d for niceness", n);
}
+#endif
}
break;
case 'D':
@@ -703,8 +716,8 @@
}
if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, NULL) >= 0){
- info.outfile = fopen(outputfile_name,"wb");
if (av_find_stream_info (convert->context) >= 0){
+ info.outfile = fopen(outputfile_name,"wb");
dump_format (convert->context, 0,inputfile_name, 0);
if(convert->disable_audio){
fprintf(stderr," [audio disabled].\n");
Modified: trunk/ffmpeg2theora/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/theorautils.c 2004-07-15 17:15:13 UTC (rev 7138)
+++ trunk/ffmpeg2theora/theorautils.c 2004-07-15 19:07:50 UTC (rev 7139)
@@ -153,10 +153,14 @@
/**
- theora_add_video adds the video the the stream
- data hold the one frame in the format provided by img_convert
- if e_o_s is 1 the end of the logical bitstream will be marked.
-**/
+ * adds a video frame to the encoding sink
+ * if e_o_s is 1 the end of the logical bitstream will be marked.
+ * @param data hold the one frame in the format provided by img_convert
+ * @param width frame width in pixel
+ * @param height frame height in pixel
+ * @param linesize of data
+ * @param e_o_s 1 indicates ond of stream
+ */
int theoraframes_add_video (uint8_t * data, int width, int height, int linesize,int e_o_s){
/* map some things from info struk to local variables,
* just to understand the code better */
@@ -184,8 +188,13 @@
return 0;
}
-/** theora_add_audio: fill the audio buffer
- copy from the encoder_example.c need to be reworkes in order to work. */
+/**
+ * adds audio samples to encoding sink
+ * @param buffer pointer to buffer
+ * @param bytes bytes in buffer
+ * @param samples samples in buffer
+ * @param e_o_s 1 indicates end of stream.
+ */
int theoraframes_add_audio (int16_t * buffer, int bytes, int samples, int e_o_s){
int i,j, count = 0;
float **vorbis_buffer;
@@ -309,8 +318,6 @@
}
void theoraframes_close (){
- /* do we have to write last page do output file with EOS and stuff??*/
- /* pysical pages */
ogg_stream_clear (&info.vo);
vorbis_block_clear (&info.vb);
vorbis_dsp_clear (&info.vd);
More information about the commits
mailing list