From 19341c58e0f7210046286e08ae5f955a14ee3e3f Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 9 Dec 2011 11:06:02 +0100 Subject: [PATCH 01/21] Dxtory capture format decoder Signed-off-by: Anton Khirnov --- Changelog | 1 + doc/general.texi | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/dxtory.c | 109 +++++++++++++++++++++++++++++++++++++++++ libavformat/riff.c | 1 + 7 files changed, 115 insertions(+) create mode 100644 libavcodec/dxtory.c diff --git a/Changelog b/Changelog index ab4136aed5..0d72c53ebd 100644 --- a/Changelog +++ b/Changelog @@ -106,6 +106,7 @@ easier to use. The changes are: - Playstation Portable PMP format demuxer - PCM format support in OMA demuxer - CLJR encoder +- Dxtory capture format decoder version 0.7: diff --git a/doc/general.texi b/doc/general.texi index db1e0d4901..b4838f5ae9 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -452,6 +452,7 @@ following image formats are supported: @item Duck TrueMotion 2.0 @tab @tab X @tab fourcc: TM20 @item DV (Digital Video) @tab X @tab X +@item Dxtory capture format @tab @tab X @item Feeble Files/ScummVM DXA @tab @tab X @tab Codec originally used in Feeble Files game. @item Electronic Arts CMV video @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a78cd8171e..383039ac26 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -125,6 +125,7 @@ OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o OBJS-$(CONFIG_DXA_DECODER) += dxa.o +OBJS-$(CONFIG_DXTORY_DECODER) += dxtory.o OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3_data.o OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc.o ac3enc_float.o \ ac3tab.o ac3.o kbdwin.o eac3_data.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 59795b116a..208af1f059 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -96,6 +96,7 @@ void avcodec_register_all(void) REGISTER_DECODER (DSICINVIDEO, dsicinvideo); REGISTER_ENCDEC (DVVIDEO, dvvideo); REGISTER_DECODER (DXA, dxa); + REGISTER_DECODER (DXTORY, dxtory); REGISTER_DECODER (EACMV, eacmv); REGISTER_DECODER (EAMAD, eamad); REGISTER_DECODER (EATGQ, eatgq); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 83fb39b99e..669afe80ba 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -252,6 +252,7 @@ enum CodecID { CODEC_ID_UTVIDEO, CODEC_ID_BMV_VIDEO, CODEC_ID_VBLE, + CODEC_ID_DXTORY, /* various PCM "codecs" */ CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c new file mode 100644 index 0000000000..5f67fbdbef --- /dev/null +++ b/libavcodec/dxtory.c @@ -0,0 +1,109 @@ +/* + * Dxtory decoder + * + * Copyright (c) 2011 Konstantin Shishkov + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avcodec.h" +#include "libavutil/intreadwrite.h" + +static av_cold int decode_init(AVCodecContext *avctx) +{ + avctx->pix_fmt = PIX_FMT_YUV420P; + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->coded_frame) + return AVERROR(ENOMEM); + + return 0; +} + +static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, + AVPacket *avpkt) +{ + int h, w; + AVFrame *pic = avctx->coded_frame; + const uint8_t *src = avpkt->data; + uint8_t *Y1, *Y2, *U, *V; + int ret; + + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + + if (avpkt->size < avctx->width * avctx->height * 3 / 2 + 16) { + av_log(avctx, AV_LOG_ERROR, "packet too small\n"); + return AVERROR_INVALIDDATA; + } + + pic->reference = 0; + if ((ret = avctx->get_buffer(avctx, pic)) < 0) + return ret; + + pic->pict_type = AV_PICTURE_TYPE_I; + pic->key_frame = 1; + + if (AV_RL32(src) != 0x01000002) { + av_log_ask_for_sample(avctx, "Unknown frame header %X\n", AV_RL32(src)); + return AVERROR_PATCHWELCOME; + } + src += 16; + + Y1 = pic->data[0]; + Y2 = pic->data[0] + pic->linesize[0]; + U = pic->data[1]; + V = pic->data[2]; + for (h = 0; h < avctx->height; h += 2) { + for (w = 0; w < avctx->width; w += 2) { + AV_WN16A(Y1 + w, AV_RN16A(src)); + AV_WN16A(Y2 + w, AV_RN16A(src + 2)); + U[w >> 1] = src[4] + 0x80; + V[w >> 1] = src[5] + 0x80; + src += 6; + } + Y1 += pic->linesize[0] << 1; + Y2 += pic->linesize[0] << 1; + U += pic->linesize[1]; + V += pic->linesize[2]; + } + + *data_size = sizeof(AVFrame); + *(AVFrame*)data = *pic; + + return avpkt->size; +} + +static av_cold int decode_close(AVCodecContext *avctx) +{ + AVFrame *pic = avctx->coded_frame; + if (pic->data[0]) + avctx->release_buffer(avctx, pic); + av_freep(&avctx->coded_frame); + + return 0; +} + +AVCodec ff_dxtory_decoder = { + .name = "dxtory", + .long_name = NULL_IF_CONFIG_SMALL("Dxtory"), + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_DXTORY, + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, +}; diff --git a/libavformat/riff.c b/libavformat/riff.c index 1161e975e9..db3f9584ed 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -280,6 +280,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '0') }, { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '2') }, { CODEC_ID_VBLE, MKTAG('V', 'B', 'L', 'E') }, + { CODEC_ID_DXTORY, MKTAG('x', 't', 'o', 'r') }, { CODEC_ID_NONE, 0 } }; From 0395d37abb304ba9eb5b3aa9aec48a63724b3229 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 10 Dec 2011 01:52:05 +0100 Subject: [PATCH 02/21] doc: remove some stale entries from the faq Some entries should be still amended. --- doc/faq.texi | 135 --------------------------------------------------- 1 file changed, 135 deletions(-) diff --git a/doc/faq.texi b/doc/faq.texi index affe88b813..91a380e573 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -11,22 +11,6 @@ @chapter General Questions -@section When will the next Libav version be released? / Why are Libav releases so few and far between? - -Like most open source projects Libav suffers from a certain lack of -manpower. For this reason the developers have to prioritize the work -they do and putting out releases is not at the top of the list, fixing -bugs and reviewing patches takes precedence. Please don't complain or -request more timely and/or frequent releases unless you are willing to -help out creating them. - -@section I have a problem with an old version of Libav; where should I report it? -Nowhere. We do not support old Libav versions in any way, we simply lack -the time, motivation and manpower to do so. If you have a problem with an -old version of Libav, upgrade to the latest git snapshot. If you -still experience the problem, then you can report it according to our -@uref{http://libav.org/bugreports.html, bug reporting guidelines}. - @section Why doesn't Libav support feature [xyz]? Because no one has taken on that task yet. Libav development is @@ -40,31 +24,6 @@ No. Windows DLLs are not portable, bloated and often slow. Moreover Libav strives to support all codecs natively. A DLL loader is not conducive to that goal. -@section My bug report/mail to libav-devel/user has not received any replies. - -Likely reasons -@itemize -@item We are busy and haven't had time yet to read your report or -investigate the issue. -@item You did not follow our - @uref{http://libav.org/bugreports.html, bug reporting guidelines}. -@item You didn't use git master. -@item You reported a segmentation fault without gdb output. -@item You describe a problem but not how to reproduce it. -@item It's unclear if you use ffmpeg as command line tool or use -libav* from another application. -@item You speak about a video having problems on playback but -not what you use to play it. -@item We have no faint clue what you are talking about besides -that it is related to Libav. -@end itemize - -@section Is there a forum for Libav? I do not like mailing lists. - -You may view our mailing lists with a more forum-alike look here: -@url{http://dir.gmane.org/gmane.comp.video.ffmpeg.user}, -but, if you post, please remember that our mailing list rules still apply there. - @section I cannot read this file although this format seems to be supported by ffmpeg. Even if ffmpeg can read the container format, it may not support all its @@ -218,44 +177,6 @@ a different fourcc, use the '-vtag' option. E.g., '-vtag xvid' will force the fourcc 'xvid' to be stored as the video fourcc rather than the default. -@section How do I encode videos which play on the iPod? - -@table @option -@item needed stuff --acodec libfaac -vcodec mpeg4 width<=320 height<=240 -@item working stuff -mv4, title -@item non-working stuff -B-frames -@item example command line -ffmpeg -i input -acodec libfaac -ab 128k -vcodec mpeg4 -b 1200k -mbd 2 -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -s 320x180 -metadata title=X output.mp4 -@end table - -@section How do I encode videos which play on the PSP? - -@table @option -@item needed stuff --acodec libfaac -vcodec mpeg4 width*height<=76800 width%16=0 height%16=0 -ar 24000 -r 30000/1001 or 15000/1001 -f psp -@item working stuff -mv4, title -@item non-working stuff -B-frames -@item example command line -ffmpeg -i input -acodec libfaac -ab 128k -vcodec mpeg4 -b 1200k -ar 24000 -mbd 2 -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -metadata title=X -f psp output.mp4 -@item needed stuff for H.264 --acodec libfaac -vcodec libx264 width*height<=76800 width%16=0? height%16=0? -ar 48000 -coder 1 -r 30000/1001 or 15000/1001 -f psp -@item working stuff for H.264 -title, loop filter -@item non-working stuff for H.264 -CAVLC -@item example command line -ffmpeg -i input -acodec libfaac -ab 128k -vcodec libx264 -b 1200k -ar 48000 -mbd 2 -coder 1 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -metadata title=X -f psp -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 output.mp4 -@item higher resolution for newer PSP firmwares, width<=480, height<=272 --vcodec libx264 -level 21 -coder 1 -f psp -@item example command line -ffmpeg -i input -acodec libfaac -ab 128k -ac 2 -ar 48000 -vcodec libx264 -level 21 -b 640k -coder 1 -f psp -flags +loop -trellis 2 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -g 250 -s 480x272 output.mp4 -@end table - @section Which are good parameters for encoding high quality MPEG-4? '-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2', @@ -351,24 +272,6 @@ ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \ rm temp[12].[av] all.[av] @end example -@section The ffmpeg program does not respect the -maxrate setting, some frames are bigger than maxrate/fps. - -Read the MPEG spec about video buffer verifier. - -@section I want CBR, but no matter what I do frame sizes differ. - -You do not understand what CBR is, please read the MPEG spec. -Read about video buffer verifier and constant bitrate. -The one sentence summary is that there is a buffer and the input rate is -constant, the output can vary as needed. - -@section How do I check if a stream is CBR? - -To quote the MPEG-2 spec: -"There is no way to tell that a bitstream is constant bitrate without -examining all of the vbv_delay values and making complicated computations." - - @chapter Development @section Are there examples illustrating how to use the Libav libraries, particularly libavcodec and libavformat? @@ -424,14 +327,6 @@ Yes, as long as the code is optional and can easily and cleanly be placed under #if CONFIG_GPL without breaking anything. So for example a new codec or filter would be OK under GPL while a bug fix to LGPL code would not. -@section I want to compile xyz.c alone but my compiler produced many errors. - -Common code is in its own files in libav* and is used by the individual -codecs. They will not work without the common parts, you have to compile -the whole libav*. If you wish, disable some parts with configure switches. -You can also try to hack it and remove more, but if you had problems fixing -the compilation failure then you are probably not qualified for this. - @section I'm using libavcodec from within my C++ application but the linker complains about missing symbols which seem to be available. Libav is a pure C project, so to use the libraries within your C++ application @@ -450,34 +345,4 @@ to use them you have to append -D__STDC_CONSTANT_MACROS to your CXXFLAGS You have to implement a URLProtocol, see @file{libavformat/file.c} in Libav and @file{libmpdemux/demux_lavf.c} in MPlayer sources. -@section I get "No compatible shell script interpreter found." in MSys. - -The standard MSys bash (2.04) is broken. You need to install 2.05 or later. - -@section I get "./configure: line : pr: command not found" in MSys. - -The standard MSys install doesn't come with pr. You need to get it from the coreutils package. - -@section Where can I find libav* headers for Pascal/Delphi? - -see @url{http://www.iversenit.dk/dev/ffmpeg-headers/} - -@section Where is the documentation about ffv1, msmpeg4, asv1, 4xm? - -see @url{http://www.ffmpeg.org/~michael/} - -@section How do I feed H.263-RTP (and other codecs in RTP) to libavcodec? - -Even if peculiar since it is network oriented, RTP is a container like any -other. You have to @emph{demux} RTP before feeding the payload to libavcodec. -In this specific case please look at RFC 4629 to see how it should be done. - -@section AVStream.r_frame_rate is wrong, it is much larger than the framerate. - -r_frame_rate is NOT the average framerate, it is the smallest framerate -that can accurately represent all timestamps. So no, it is not -wrong if it is larger than the average! -For example, if you have mixed 25 and 30 fps content, then r_frame_rate -will be 150. - @bye From 708060d7d12bcd6f3267f9dd8129f8947bcd92fd Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 10 Dec 2011 01:58:04 +0100 Subject: [PATCH 03/21] doc: update to refer to avconv --- doc/faq.texi | 72 ++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/doc/faq.texi b/doc/faq.texi index 91a380e573..f3ddbbe811 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -24,10 +24,10 @@ No. Windows DLLs are not portable, bloated and often slow. Moreover Libav strives to support all codecs natively. A DLL loader is not conducive to that goal. -@section I cannot read this file although this format seems to be supported by ffmpeg. +@section I cannot read this file although this format seems to be supported by avconv. -Even if ffmpeg can read the container format, it may not support all its -codecs. Please consult the supported codec list in the ffmpeg +Even if avconv can read the container format, it may not support all its +codecs. Please consult the supported codec list in the avconv documentation. @section Which codecs are supported by Windows? @@ -81,12 +81,6 @@ problem and an NP-hard problem... @chapter Usage -@section ffmpeg does not work; what is wrong? - -Try a @code{make distclean} in the ffmpeg source directory before the build. -If this does not help see our -@uref{http://libav.org/bugreports.html, bug reporting guidelines}. - @section How do I encode single pictures into movies? First, rename your pictures to follow a numerical sequence. @@ -94,7 +88,7 @@ For example, img1.jpg, img2.jpg, img3.jpg,... Then you may run: @example - ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg + avconv -f image2 -i img%d.jpg /tmp/a.mpg @end example Notice that @samp{%d} is replaced by the image number. @@ -117,17 +111,17 @@ If you want to sequence them by oldest modified first, substitute Then run: @example - ffmpeg -f image2 -i /tmp/img%03d.jpg /tmp/a.mpg + avconv -f image2 -i /tmp/img%03d.jpg /tmp/a.mpg @end example -The same logic is used for any image format that ffmpeg reads. +The same logic is used for any image format that avconv reads. @section How do I encode movie to single pictures? Use: @example - ffmpeg -i movie.mpg movie%d.jpg + avconv -i movie.mpg movie%d.jpg @end example The @file{movie.mpg} used as input will be converted to @@ -135,15 +129,15 @@ The @file{movie.mpg} used as input will be converted to Instead of relying on file format self-recognition, you may also use @table @option -@item -vcodec ppm -@item -vcodec png -@item -vcodec mjpeg +@item -c:v ppm +@item -c:v png +@item -c:v mjpeg @end table to force the encoding. Applying that to the previous example: @example - ffmpeg -i movie.mpg -f image2 -vcodec mjpeg menu%d.jpg + avconv -i movie.mpg -f image2 -c:v mjpeg menu%d.jpg @end example Beware that there is no "jpeg" codec. Use "mjpeg" instead. @@ -165,13 +159,13 @@ Try '-f image2 test%d.jpg'. @section Why can I not change the framerate? Some codecs, like MPEG-1/2, only allow a small number of fixed framerates. -Choose a different codec with the -vcodec command line option. +Choose a different codec with the -c:v command line option. -@section How do I encode Xvid or DivX video with ffmpeg? +@section How do I encode Xvid or DivX video with avconv? Both Xvid and DivX (version 4+) are implementations of the ISO MPEG-4 standard (note that there are many other coding formats that use this -same standard). Thus, use '-vcodec mpeg4' to encode in these formats. The +same standard). Thus, use '-c:v mpeg4' to encode in these formats. The default fourcc stored in an MPEG-4-coded file will be 'FMP4'. If you want a different fourcc, use the '-vtag' option. E.g., '-vtag xvid' will force the fourcc 'xvid' to be stored as the video fourcc rather than the @@ -188,7 +182,7 @@ things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd'. but beware the '-g 100' might cause problems with some decoders. Things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd. -@section Interlaced video looks very bad when encoded with ffmpeg, what is wrong? +@section Interlaced video looks very bad when encoded with avconv, what is wrong? You should use '-flags +ilme+ildct' and maybe '-flags +alt' for interlaced material, and try '-top 0/1' if the result looks really messed-up. @@ -203,9 +197,9 @@ Just create an "input.avs" text file with this single line ... @example DirectShowSource("C:\path to your file\yourfile.asf") @end example -... and then feed that text file to ffmpeg: +... and then feed that text file to avconv: @example - ffmpeg -i input.avs + avconv -i input.avs @end example For ANY other help on Avisynth, please visit the @@ -222,13 +216,13 @@ equally humble @code{copy} under Windows), and finally transcoding back to your format of choice. @example -ffmpeg -i input1.avi -sameq intermediate1.mpg -ffmpeg -i input2.avi -sameq intermediate2.mpg +avconv -i input1.avi -same_quant intermediate1.mpg +avconv -i input2.avi -same_quant intermediate2.mpg cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg -ffmpeg -i intermediate_all.mpg -sameq output.avi +avconv -i intermediate_all.mpg -same_quant output.avi @end example -Notice that you should either use @code{-sameq} or set a reasonably high +Notice that you should either use @code{-same_quant} or set a reasonably high bitrate for your intermediate and output files, if you want to preserve video quality. @@ -238,10 +232,10 @@ of named pipes, should your platform support it: @example mkfifo intermediate1.mpg mkfifo intermediate2.mpg -ffmpeg -i input1.avi -sameq -y intermediate1.mpg < /dev/null & -ffmpeg -i input2.avi -sameq -y intermediate2.mpg < /dev/null & +avconv -i input1.avi -same_quant -y intermediate1.mpg < /dev/null & +avconv -i input2.avi -same_quant -y intermediate2.mpg < /dev/null & cat intermediate1.mpg intermediate2.mpg |\ -ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 -acodec libmp3lame output.avi +avconv -f mpeg -i - -same_quant -c:v mpeg4 -acodec libmp3lame output.avi @end example Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also @@ -260,15 +254,15 @@ mkfifo temp2.a mkfifo temp2.v mkfifo all.a mkfifo all.v -ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null & -ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null & -ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null & -@{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; @} & +avconv -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null & +avconv -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null & +avconv -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null & +@{ avconv -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; @} & cat temp1.a temp2.a > all.a & cat temp1.v temp2.v > all.v & -ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \ +avconv -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \ -f yuv4mpegpipe -i all.v \ - -sameq -y output.flv + -same_quant -y output.flv rm temp[12].[av] all.[av] @end example @@ -304,7 +298,7 @@ the silver bullet that solves this problem, feel free to shoot it at us. We strongly recommend you to move over from MSVC++ to MinGW tools. -@section Can I use Libav or libavcodec under Windows? +@section Can I use Libav under Windows? Yes, but the Cygwin or MinGW tools @emph{must} be used to compile Libav. Read the @emph{Windows} section in the Libav documentation to find more @@ -314,7 +308,7 @@ information. No. These tools are too bloated and they complicate the build. -@section Why not rewrite ffmpeg in object-oriented C++? +@section Why not rewrite Libav in object-oriented C++? Libav is already organized in a highly modular manner and does not need to be rewritten in a formal object language. Further, many of the developers @@ -327,7 +321,7 @@ Yes, as long as the code is optional and can easily and cleanly be placed under #if CONFIG_GPL without breaking anything. So for example a new codec or filter would be OK under GPL while a bug fix to LGPL code would not. -@section I'm using libavcodec from within my C++ application but the linker complains about missing symbols which seem to be available. +@section I'm using Libav from within my C++ application but the linker complains about missing symbols which seem to be available. Libav is a pure C project, so to use the libraries within your C++ application you need to explicitly state that you are using a C library. You can do this by From 97334f106cfbf9787808b922bfb3c2973712f47d Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Fri, 9 Dec 2011 00:31:33 +0000 Subject: [PATCH 04/21] utvideo: add fate tests covering all codec variants Signed-off-by: Janne Grunau --- tests/fate2.mak | 24 ++++++++++++++++++++++++ tests/ref/fate/utvideo_rgb_left | 4 ++++ tests/ref/fate/utvideo_rgb_median | 5 +++++ tests/ref/fate/utvideo_rgba_left | 5 +++++ tests/ref/fate/utvideo_rgba_median | 5 +++++ tests/ref/fate/utvideo_yuv420_left | 7 +++++++ tests/ref/fate/utvideo_yuv420_median | 4 ++++ tests/ref/fate/utvideo_yuv422_left | 4 ++++ tests/ref/fate/utvideo_yuv422_median | 4 ++++ 9 files changed, 62 insertions(+) create mode 100644 tests/ref/fate/utvideo_rgb_left create mode 100644 tests/ref/fate/utvideo_rgb_median create mode 100644 tests/ref/fate/utvideo_rgba_left create mode 100644 tests/ref/fate/utvideo_rgba_median create mode 100644 tests/ref/fate/utvideo_yuv420_left create mode 100644 tests/ref/fate/utvideo_yuv420_median create mode 100644 tests/ref/fate/utvideo_yuv422_left create mode 100644 tests/ref/fate/utvideo_yuv422_median diff --git a/tests/fate2.mak b/tests/fate2.mak index 2881eb15b8..66c219ccc5 100644 --- a/tests/fate2.mak +++ b/tests/fate2.mak @@ -229,3 +229,27 @@ fate-iirfilter: CMD = run libavcodec/iirfilter-test FATE_TESTS += fate-vble fate-vble: CMD = framecrc -i $(SAMPLES)/vble/flowers-partial-2MB.avi + +FATE_TESTS += fate-utvideo_rgba_left +fate-utvideo_rgba_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgba_left.avi + +FATE_TESTS += fate-utvideo_rgba_median +fate-utvideo_rgba_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgba_median.avi + +FATE_TESTS += fate-utvideo_rgb_left +fate-utvideo_rgb_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgb_left.avi + +FATE_TESTS += fate-utvideo_rgb_median +fate-utvideo_rgb_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_rgb_median.avi + +FATE_TESTS += fate-utvideo_yuv420_left +fate-utvideo_yuv420_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_yuv420_left.avi + +FATE_TESTS += fate-utvideo_yuv420_median +fate-utvideo_yuv420_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_yuv420_median.avi + +FATE_TESTS += fate-utvideo_yuv422_left +fate-utvideo_yuv422_left: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_yuv422_left.avi + +FATE_TESTS += fate-utvideo_yuv422_median +fate-utvideo_yuv422_median: CMD = framecrc -i $(SAMPLES)/utvideo/utvideo_yuv422_median.avi diff --git a/tests/ref/fate/utvideo_rgb_left b/tests/ref/fate/utvideo_rgb_left new file mode 100644 index 0000000000..5d2b73ca8a --- /dev/null +++ b/tests/ref/fate/utvideo_rgb_left @@ -0,0 +1,4 @@ +0, 0, 921600, 0x27e6001e +0, 3003, 921600, 0x7c0a92bc +0, 6006, 921600, 0x4d2be42c +0, 9009, 921600, 0x58ddd0be diff --git a/tests/ref/fate/utvideo_rgb_median b/tests/ref/fate/utvideo_rgb_median new file mode 100644 index 0000000000..69141537b9 --- /dev/null +++ b/tests/ref/fate/utvideo_rgb_median @@ -0,0 +1,5 @@ +0, 0, 921600, 0x9776611f +0, 3003, 921600, 0xdbfa64f4 +0, 6006, 921600, 0xed2a0580 +0, 9009, 921600, 0x6ecc80bc +0, 12012, 921600, 0x58ddd0be diff --git a/tests/ref/fate/utvideo_rgba_left b/tests/ref/fate/utvideo_rgba_left new file mode 100644 index 0000000000..7d3800e970 --- /dev/null +++ b/tests/ref/fate/utvideo_rgba_left @@ -0,0 +1,5 @@ +0, 0, 1228800, 0xf1bc9432 +0, 3003, 1228800, 0x8480d1e5 +0, 6006, 1228800, 0xb01d5fb2 +0, 9009, 1228800, 0x53cb42c4 +0, 12012, 1228800, 0x2b2ea176 diff --git a/tests/ref/fate/utvideo_rgba_median b/tests/ref/fate/utvideo_rgba_median new file mode 100644 index 0000000000..7d3800e970 --- /dev/null +++ b/tests/ref/fate/utvideo_rgba_median @@ -0,0 +1,5 @@ +0, 0, 1228800, 0xf1bc9432 +0, 3003, 1228800, 0x8480d1e5 +0, 6006, 1228800, 0xb01d5fb2 +0, 9009, 1228800, 0x53cb42c4 +0, 12012, 1228800, 0x2b2ea176 diff --git a/tests/ref/fate/utvideo_yuv420_left b/tests/ref/fate/utvideo_yuv420_left new file mode 100644 index 0000000000..bdb90a6168 --- /dev/null +++ b/tests/ref/fate/utvideo_yuv420_left @@ -0,0 +1,7 @@ +0, 0, 460800, 0xece98fc8 +0, 3003, 460800, 0x9baf786b +0, 6006, 460800, 0x8e8e0510 +0, 9009, 460800, 0x27c1f2ba +0, 12012, 460800, 0x6a817987 +0, 15015, 460800, 0x2f713ec2 +0, 18018, 460800, 0x003b560e diff --git a/tests/ref/fate/utvideo_yuv420_median b/tests/ref/fate/utvideo_yuv420_median new file mode 100644 index 0000000000..5cd3bc84ee --- /dev/null +++ b/tests/ref/fate/utvideo_yuv420_median @@ -0,0 +1,4 @@ +0, 0, 460800, 0x6a817987 +0, 3003, 460800, 0x2f713ec2 +0, 6006, 460800, 0x003b560e +0, 9009, 460800, 0x9e1bbf63 diff --git a/tests/ref/fate/utvideo_yuv422_left b/tests/ref/fate/utvideo_yuv422_left new file mode 100644 index 0000000000..d68bf4e26e --- /dev/null +++ b/tests/ref/fate/utvideo_yuv422_left @@ -0,0 +1,4 @@ +0, 0, 614400, 0x9a6b8802 +0, 3003, 614400, 0xaa8687e2 +0, 6006, 614400, 0x2fe5bd40 +0, 9009, 614400, 0x1c8f3737 diff --git a/tests/ref/fate/utvideo_yuv422_median b/tests/ref/fate/utvideo_yuv422_median new file mode 100644 index 0000000000..d68bf4e26e --- /dev/null +++ b/tests/ref/fate/utvideo_yuv422_median @@ -0,0 +1,4 @@ +0, 0, 614400, 0x9a6b8802 +0, 3003, 614400, 0xaa8687e2 +0, 6006, 614400, 0x2fe5bd40 +0, 9009, 614400, 0x1c8f3737 From 2b53e696c864c4ade3c38707f8595e17a998bedc Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 10 Dec 2011 12:55:08 +0100 Subject: [PATCH 05/21] ptx: emit a warning on insufficient picture data Return the whole packet as consumed in this case and not the size the packet should have had. Move the insufficient data check into the for condition to fix a ISO C90 error on bigendian. --- libavcodec/ptx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index eee0d58994..75b42d5073 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -84,9 +84,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, ptr = p->data[0]; stride = p->linesize[0]; - for (y=0; ypicture; *data_size = sizeof(AVPicture); + if (y < h) { + av_log(avctx, AV_LOG_WARNING, "incomplete packet\n"); + return avpkt->size; + } + return offset + w*h*bytes_per_pixel; } From 28101f6c4eb341fca0c3f7e237f8236b0fde9530 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Fri, 9 Dec 2011 22:51:30 -0500 Subject: [PATCH 06/21] flac muxer: fix writing of file header and STREAMINFO header from extradata fixes Bug 119 --- libavformat/flacenc_header.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c index ad8d55b380..c1f7c86554 100644 --- a/libavformat/flacenc_header.c +++ b/libavformat/flacenc_header.c @@ -37,13 +37,11 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec, if (!avpriv_flac_is_extradata_valid(codec, &format, &streaminfo)) return -1; - /* write "fLaC" stream marker and first metadata block header if needed */ - if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) { - avio_write(pb, header, 8); - } + /* write "fLaC" stream marker and first metadata block header */ + avio_write(pb, header, 8); - /* write STREAMINFO or full header */ - avio_write(pb, codec->extradata, codec->extradata_size); + /* write STREAMINFO */ + avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE); return 0; } From 8d61eef917f736ebd4bc23c36d1b0cb3934e7dd6 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 10 Dec 2011 16:57:32 +0100 Subject: [PATCH 07/21] ptx: fix inverted check for sufficient data Fix regression introduced in 2b53e69. --- libavcodec/ptx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index 75b42d5073..fd4933c1d6 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -84,7 +84,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, ptr = p->data[0]; stride = p->linesize[0]; - for (y = 0; y < h && buf_end - buf < w * bytes_per_pixel; y++) { + for (y = 0; y < h && buf_end - buf >= w * bytes_per_pixel; y++) { #if HAVE_BIGENDIAN unsigned int x; for (x=0; x Date: Sat, 10 Dec 2011 04:53:30 +0000 Subject: [PATCH 08/21] flacdec: Support for tracks in cuesheet metadata block Signed-off-by: Justin Ruggles --- libavformat/flacdec.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index c5a6ac9b43..f3831c19ba 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -25,6 +25,7 @@ #include "rawdec.h" #include "oggdec.h" #include "vorbiscomment.h" +#include "libavcodec/bytestream.h" static int flac_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -54,6 +55,7 @@ static int flac_read_header(AVFormatContext *s, switch (metadata_type) { /* allocate and read metadata block for supported types */ case FLAC_METADATA_TYPE_STREAMINFO: + case FLAC_METADATA_TYPE_CUESHEET: case FLAC_METADATA_TYPE_VORBIS_COMMENT: buffer = av_mallocz(metadata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!buffer) { @@ -96,6 +98,31 @@ static int flac_read_header(AVFormatContext *s, if (si.samples > 0) st->duration = si.samples; } + } else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) { + uint8_t isrc[13]; + uint64_t start; + const uint8_t *offset; + int i, j, chapters, track, ti; + if (metadata_size < 431) + return AVERROR_INVALIDDATA; + offset = buffer + 395; + chapters = bytestream_get_byte(&offset) - 1; + if (chapters <= 0) + return AVERROR_INVALIDDATA; + for (i = 0; i < chapters; i++) { + if (offset + 36 - buffer > metadata_size) + return AVERROR_INVALIDDATA; + start = bytestream_get_be64(&offset); + track = bytestream_get_byte(&offset); + bytestream_get_buffer(&offset, isrc, 12); + isrc[12] = 0; + offset += 14; + ti = bytestream_get_byte(&offset); + if (ti <= 0) return AVERROR_INVALIDDATA; + for (j = 0; j < ti; j++) + offset += 12; + avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc); + } } else { /* STREAMINFO must be the first block */ if (!found_streaminfo) { From 65c1011404dc936ca93175d6c8bd439c657c66e4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 9 Dec 2011 00:45:27 +0000 Subject: [PATCH 09/21] cljr: remove unused code Signed-off-by: Diego Biurrun --- libavcodec/cljr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index 65b7433498..a5ee73864c 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -29,7 +29,6 @@ #include "put_bits.h" typedef struct CLJRContext { - AVCodecContext *avctx; AVFrame picture; } CLJRContext; @@ -38,7 +37,6 @@ static av_cold int common_init(AVCodecContext *avctx) CLJRContext * const a = avctx->priv_data; avctx->coded_frame = &a->picture; - a->avctx = avctx; return 0; } From 7d18d17abd9dadca1d717a7ace76bd611b7a289c Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 8 Dec 2011 23:42:02 +0000 Subject: [PATCH 10/21] Add CLJR encoding and decoding regression tests Signed-off-by: Diego Biurrun --- tests/codec-regression.sh | 5 +++++ tests/ref/vsynth1/cljr | 4 ++++ tests/ref/vsynth2/cljr | 4 ++++ 3 files changed, 13 insertions(+) create mode 100644 tests/ref/vsynth1/cljr create mode 100644 tests/ref/vsynth2/cljr diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index 0e6151b449..57e5f07f05 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -19,6 +19,11 @@ if [ -n "$do_aref" ]; then do_avconv $pcm_ref -b 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav fi +if [ -n "$do_cljr" ] ; then +do_video_encoding cljr.avi "-an -vcodec cljr" +do_video_decoding +fi + if [ -n "$do_mpeg" ] ; then # mpeg1 do_video_encoding mpeg1.mpg "-qscale 10 -f mpeg1video" diff --git a/tests/ref/vsynth1/cljr b/tests/ref/vsynth1/cljr new file mode 100644 index 0000000000..9865726ccc --- /dev/null +++ b/tests/ref/vsynth1/cljr @@ -0,0 +1,4 @@ +d149cadc43100d8e98ff04e57fdaa31f *./tests/data/vsynth1/cljr.avi + 5075660 ./tests/data/vsynth1/cljr.avi +4debaab994c2c7273bebaa0c5733017b *./tests/data/cljr.vsynth1.out.yuv +stddev: 30.75 PSNR: 18.37 MAXDIFF: 225 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/cljr b/tests/ref/vsynth2/cljr new file mode 100644 index 0000000000..6f8670ca71 --- /dev/null +++ b/tests/ref/vsynth2/cljr @@ -0,0 +1,4 @@ +86250984790dd745a932f36cf229cef7 *./tests/data/vsynth2/cljr.avi + 5075660 ./tests/data/vsynth2/cljr.avi +3a70ba2a535ef9c7fc6478b27a2cb58a *./tests/data/cljr.vsynth2.out.yuv +stddev: 10.48 PSNR: 27.72 MAXDIFF: 64 bytes: 7603200/ 7603200 From 8bd1f1a4c8e591e92e7f4933a89fe5de72e5563f Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Sun, 11 Dec 2011 01:10:57 +0530 Subject: [PATCH 11/21] ttadec: check channel count as read from extradata. fixes floating-point exception due to channels being set to 0. fixes Bug 128. Signed-off-by: Justin Ruggles --- libavcodec/tta.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 6b76f527c4..c8d58fd9ec 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -221,6 +221,11 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) s->data_length = get_bits_long(&s->gb, 32); skip_bits(&s->gb, 32); // CRC32 of header + if (s->channels == 0) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid number of channels\n"); + return AVERROR_INVALIDDATA; + } + switch(s->bps) { case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; From b262a05904bdb31862f0b2fc3c9e4aeee32d301c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 20:06:49 +0100 Subject: [PATCH 12/21] lavf doxy: add metadata docs to the main lavf group --- libavformat/avformat.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 5e00da12b2..16dc4e833a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -86,6 +86,7 @@ struct AVFormatContext; /** * @defgroup metadata_api Public Metadata API * @{ + * @ingroup libavf * The metadata API allows libavformat to export metadata tags to a client * application using a sequence of key/value pairs. Like all strings in Libav, * metadata must be stored as UTF-8 encoded Unicode. Note that metadata From e4f4a1f93e4573ac5e1ece6f667c807444a9a42c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 20:09:04 +0100 Subject: [PATCH 13/21] lavf doxy: rename lavf I/O group to lavf_io. --- libavformat/avformat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 16dc4e833a..2298d718c7 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -33,7 +33,7 @@ * @{ * @} * - * @defgroup lavf_proto I/O Read/Write + * @defgroup lavf_io I/O Read/Write * @{ * @} * From fb42db7c39f075baf59e53168a11a9feb2222761 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 20:11:28 +0100 Subject: [PATCH 14/21] lavf doxy: add avio groups into the lavf_io group. --- libavformat/avio.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/avio.h b/libavformat/avio.h index d7977022bf..98880bae38 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -211,6 +211,7 @@ extern URLInterruptCB *url_interrupt_cb; * @defgroup old_url_funcs Old url_* functions * The following functions are deprecated. Use the buffered API based on #AVIOContext instead. * @{ + * @ingroup lavf_io */ attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up, const char *url, int flags); @@ -270,6 +271,7 @@ attribute_deprecated AVIOContext *av_alloc_put_byte( * @defgroup old_avio_funcs Old put_/get_*() functions * The following functions are deprecated. Use the "avio_"-prefixed functions instead. * @{ + * @ingroup lavf_io */ attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size); attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size); @@ -307,6 +309,7 @@ attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_in * @defgroup old_url_f_funcs Old url_f* functions * The following functions are deprecated, use the "avio_"-prefixed functions instead. * @{ + * @ingroup lavf_io */ attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags); attribute_deprecated int url_fclose(AVIOContext *s); From eca06cbed9160a16f5e6c58302f1b9e2ff116283 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 20:16:57 +0100 Subject: [PATCH 15/21] lavf doxy: add installed headers to groups. --- libavformat/avformat.h | 6 ++++++ libavformat/avio.h | 1 + libavformat/version.h | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2298d718c7..525f8ff3b5 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -21,6 +21,12 @@ #ifndef AVFORMAT_AVFORMAT_H #define AVFORMAT_AVFORMAT_H +/** + * @file + * @ingroup libavf + * Main libavformat public API header + */ + /** * @defgroup libavf I/O and Muxing/Demuxing Library * @{ diff --git a/libavformat/avio.h b/libavformat/avio.h index 98880bae38..dec2a5effe 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -22,6 +22,7 @@ /** * @file + * @ingroup lavf_io * Buffered I/O operations */ diff --git a/libavformat/version.h b/libavformat/version.h index ba1254f63b..7ba411c494 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -21,6 +21,12 @@ #ifndef AVFORMAT_VERSION_H #define AVFORMAT_VERSION_H +/** + * @file + * @ingroup libavf + * Libavformat version macros + */ + #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 53 From 28b4c06b9dde290ac5a5743edd0eb8f7b4296d1a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 20:39:39 +0100 Subject: [PATCH 16/21] lavf doxy: expand/reword metadata API doxy. --- libavformat/avformat.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 525f8ff3b5..a0d8740566 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -94,9 +94,15 @@ struct AVFormatContext; * @{ * @ingroup libavf * The metadata API allows libavformat to export metadata tags to a client - * application using a sequence of key/value pairs. Like all strings in Libav, - * metadata must be stored as UTF-8 encoded Unicode. Note that metadata + * application when demuxing. Conversely it allows a client application to + * set metadata when muxing. + * + * Metadata is exported or set as pairs of key/value strings in the 'metadata' + * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs + * using the @ref lavu_dict "AVDictionary" API. Like all strings in Libav, + * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata * exported by demuxers isn't checked to be valid UTF-8 in most cases. + * * Important concepts to keep in mind: * - Keys are unique; there can never be 2 tags with the same key. This is * also meant semantically, i.e., a demuxer should not knowingly produce From 370f27dee34e9d26c2da1749d2ad31e690cdd61a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 21:04:30 +0100 Subject: [PATCH 17/21] lavf doxy: add demuxing stuff to lavf_decoding group --- libavformat/avformat.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index a0d8740566..aeea779e9b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -382,6 +382,10 @@ typedef struct AVOutputFormat { struct AVOutputFormat *next; } AVOutputFormat; +/** + * @addtogroup lavf_decoding + * @{ + */ typedef struct AVInputFormat { /** * A comma separated list of short names for the format. New names @@ -503,6 +507,9 @@ typedef struct AVInputFormat { /* private fields */ struct AVInputFormat *next; } AVInputFormat; +/** + * @} + */ enum AVStreamParseType { AVSTREAM_PARSE_NONE, @@ -1228,7 +1235,17 @@ enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int */ unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id); -/* media file input */ +/** + * Allocate an AVFormatContext. + * avformat_free_context() can be used to free the context and everything + * allocated by the framework within it. + */ +AVFormatContext *avformat_alloc_context(void); + +/** + * @addtogroup lavf_decoding + * @{ + */ /** * Find AVInputFormat based on the short name of the input format. @@ -1326,13 +1343,6 @@ attribute_deprecated int av_open_input_file(AVFormatContext **ic_ptr, const char */ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); -/** - * Allocate an AVFormatContext. - * avformat_free_context() can be used to free the context and everything - * allocated by the framework within it. - */ -AVFormatContext *avformat_alloc_context(void); - #if FF_API_FORMAT_PARAMETERS /** * Read packets of a media file to get stream information. This @@ -1512,6 +1522,9 @@ void av_close_input_stream(AVFormatContext *s); * @param s media file handle */ void av_close_input_file(AVFormatContext *s); +/** + * @} + */ /** * Free an AVFormatContext and all its streams. From 489a7b07e9c4df1bea04a4d428a9c5a44c07f883 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 21:04:30 +0100 Subject: [PATCH 18/21] lavf doxy: add muxing stuff to lavf_encoding group --- libavformat/avformat.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index aeea779e9b..ab1cd3fcf1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -323,6 +323,10 @@ typedef struct AVFormatParameters { #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ +/** + * @addtogroup lavf_encoding + * @{ + */ typedef struct AVOutputFormat { const char *name; /** @@ -381,6 +385,9 @@ typedef struct AVOutputFormat { /* private fields */ struct AVOutputFormat *next; } AVOutputFormat; +/** + * @} + */ /** * @addtogroup lavf_decoding @@ -1616,9 +1623,6 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); #endif -/** - * media file output - */ #if FF_API_FORMAT_PARAMETERS /** * @deprecated pass the options to avformat_write_header directly. @@ -1651,7 +1655,10 @@ void av_url_split(char *proto, int proto_size, int *port_ptr, char *path, int path_size, const char *url); - +/** + * @addtogroup lavf_encoding + * @{ + */ /** * Allocate the stream private data and write the stream header to * an output media file. @@ -1743,6 +1750,9 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, * @return 0 if OK, AVERROR_xxx on error */ int av_write_trailer(AVFormatContext *s); +/** + * @} + */ #if FF_API_DUMP_FORMAT attribute_deprecated void dump_format(AVFormatContext *ic, From e745d7525a21731a871318daff972608c1aeceec Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 12:40:05 +0100 Subject: [PATCH 19/21] rawdec: don't set codec timebase. It's not supposed to be set outside of lavc. Set r_frame_rate and avg_frame_rate instead. --- libavformat/rawdec.c | 2 +- tests/ref/fate/h264-lossless | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 81dd8b49e5..589cdd5db9 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -159,7 +159,7 @@ int ff_raw_video_read_header(AVFormatContext *s, goto fail; } - st->codec->time_base = (AVRational){framerate.den, framerate.num}; + st->r_frame_rate = st->avg_frame_rate = framerate; avpriv_set_pts_info(st, 64, 1, 1200000); fail: diff --git a/tests/ref/fate/h264-lossless b/tests/ref/fate/h264-lossless index c6659ca830..30a70b5118 100644 --- a/tests/ref/fate/h264-lossless +++ b/tests/ref/fate/h264-lossless @@ -1,10 +1,10 @@ 0, 0, 460800, 0x7731dd2f -0, 1500, 460800, 0x944b8c64 -0, 3000, 460800, 0xbe833041 -0, 4500, 460800, 0xbe95d96a -0, 6000, 460800, 0xfe7ea5e6 -0, 7500, 460800, 0x381743c7 -0, 9000, 460800, 0x63fcc2e9 -0, 10500, 460800, 0x79574960 -0, 12000, 460800, 0xdab9e18a -0, 13500, 460800, 0xd88e8fe8 +0, 3600, 460800, 0x944b8c64 +0, 7200, 460800, 0xbe833041 +0, 10800, 460800, 0xbe95d96a +0, 14400, 460800, 0xfe7ea5e6 +0, 18000, 460800, 0x381743c7 +0, 21600, 460800, 0x63fcc2e9 +0, 25200, 460800, 0x79574960 +0, 28800, 460800, 0xdab9e18a +0, 32400, 460800, 0xd88e8fe8 From 5bf663802233933aef81d220d7486b9c5be6ef3a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 17:33:52 +0100 Subject: [PATCH 20/21] avconv: drop code for special handling of avserver streams. It's broken and doesn't work anyway. This patch means that avconv will ignore encoding options from the ffm file and will instead use whatever is provided on the commandline as for normal output. --- avconv.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/avconv.c b/avconv.c index 3b1500b01d..0bc5aa0c3b 100644 --- a/avconv.c +++ b/avconv.c @@ -3518,40 +3518,6 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) return 0; } -static int read_avserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename) -{ - int i, err; - AVFormatContext *ic = avformat_alloc_context(); - - ic->interrupt_callback = int_cb; - err = avformat_open_input(&ic, filename, NULL, NULL); - if (err < 0) - return err; - /* copy stream format */ - for(i=0;inb_streams;i++) { - AVStream *st; - OutputStream *ost; - AVCodec *codec; - - codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); - ost = new_output_stream(o, s, codec->type); - st = ost->st; - - // FIXME: a more elegant solution is needed - memcpy(st, ic->streams[i], sizeof(AVStream)); - st->info = NULL; - avcodec_copy_context(st->codec, ic->streams[i]->codec); - - if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy) - choose_sample_fmt(st, codec); - else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy) - choose_pixel_fmt(st, codec); - } - - av_close_input_file(ic); - return 0; -} - static void opt_output_file(void *optctx, const char *filename) { OptionsContext *o = optctx; @@ -3589,16 +3555,7 @@ static void opt_output_file(void *optctx, const char *filename) oc->interrupt_callback = int_cb; av_strlcpy(oc->filename, filename, sizeof(oc->filename)); - if (!strcmp(file_oformat->name, "ffm") && - av_strstart(filename, "http:", NULL)) { - /* special case for files sent to avserver: we get the stream - parameters from avserver */ - int err = read_avserver_streams(o, oc, filename); - if (err < 0) { - print_error(filename, err); - exit_program(1); - } - } else if (!o->nb_stream_maps) { + if (!o->nb_stream_maps) { /* pick the "best" stream of each type */ #define NEW_STREAM(type, index)\ if (index >= 0) {\ From 2e87b4c51152e0241cae7f655d53920029a0e632 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 10 Dec 2011 18:30:03 +0100 Subject: [PATCH 21/21] Warn about avserver being broken. Also remove mentions of it from other avtools' manuals. --- doc/avconv.texi | 4 ++-- doc/avplay.texi | 2 +- doc/avprobe.texi | 2 +- doc/avserver.texi | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/avconv.texi b/doc/avconv.texi index 68266a9ce4..9946aaa61c 100644 --- a/doc/avconv.texi +++ b/doc/avconv.texi @@ -256,7 +256,7 @@ Set the number of video frames to record. This is an alias for @code{-frames:v}. @item -r[:@var{stream_specifier}] @var{fps} (@emph{input/output,per-stream}) Set frame rate (Hz value, fraction or abbreviation), (default = 25). @item -s[:@var{stream_specifier}] @var{size} (@emph{input/output,per-stream}) -Set frame size. The format is @samp{wxh} (avserver default = 160x128, avconv default = same as source). +Set frame size. The format is @samp{wxh} (default - same as source). The following abbreviations are recognized: @table @samp @item sqcif @@ -1025,7 +1025,7 @@ the input file in reverse order. @settitle avconv video converter @c man begin SEEALSO -avplay(1), avprobe(1), avserver(1) and the Libav HTML documentation +avplay(1), avprobe(1) and the Libav HTML documentation @c man end @c man begin AUTHORS diff --git a/doc/avplay.texi b/doc/avplay.texi index 502580fb31..8fc33081de 100644 --- a/doc/avplay.texi +++ b/doc/avplay.texi @@ -172,7 +172,7 @@ Seek to percentage in file corresponding to fraction of width. @settitle AVplay media player @c man begin SEEALSO -avconv(1), avprobe(1), avserver(1) and the Libav HTML documentation +avconv(1), avprobe(1) and the Libav HTML documentation @c man end @c man begin AUTHORS diff --git a/doc/avprobe.texi b/doc/avprobe.texi index 8955e1fdfa..6b2c800bf1 100644 --- a/doc/avprobe.texi +++ b/doc/avprobe.texi @@ -122,7 +122,7 @@ with name "STREAM". @settitle avprobe media prober @c man begin SEEALSO -avconv(1), avplay(1), avserver(1) and the Libav HTML documentation +avconv(1), avplay(1) and the Libav HTML documentation @c man end @c man begin AUTHORS diff --git a/doc/avserver.texi b/doc/avserver.texi index 9838028210..351ee0da19 100644 --- a/doc/avserver.texi +++ b/doc/avserver.texi @@ -22,6 +22,10 @@ avserver [options] @chapter Description @c man begin DESCRIPTION +WARNING: avserver is unmaintained, largely broken and in need of a +complete rewrite. It probably won't work for you. Use at your own +risk. + avserver is a streaming server for both audio and video. It supports several live feeds, streaming from files and time shifting on live feeds (you can seek to positions in the past on each live feed, provided you