diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-07-09 02:06:40 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-07-09 02:06:40 +0200 |
commit | 58257ea29e0716a50dc742959de876606ed22416 (patch) | |
tree | a4949244816d4eb7a4231b1798b54bea4a79d4e5 /libavformat | |
parent | 971c04066c601bdd38ed5e8eb585d2f5ba211fe2 (diff) | |
parent | bda168d2b0210dda84f1a9d32c8aa4653d1674d5 (diff) | |
download | ffmpeg-streaming-58257ea29e0716a50dc742959de876606ed22416.zip ffmpeg-streaming-58257ea29e0716a50dc742959de876606ed22416.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (28 commits)
mp3enc: write a xing frame containing number of frames in the file
lavf: update AVStream.nb_frames when muxing.
ffmpeg: remove unused variables from InputStream.
doc: update ffmpeg -ar and -ac documentation to reflect reality.
ffmpeg: remove pointless if (nb_input_files)
ffmpeg: merge input_files_ts_offset into input_files.
ffmpeg: merge input_codecs into input_streams.
ffmpeg: drop AV prefixes from struct names.
ffmpeg: deprecate loop_input and loop_output options
gif: add loop private option.
img2: add loop private option.
AVOptions: in av_opt_find() don't return named constants unless unit is specified.
x11grab: replace undocumented nomouse hackery with a private option.
dict: extend documentation.
lls: whitespace cosmetics
docs: Use proper markup for a literal command line option
docs: Remove a remark that isn't relevant any longer
docs: Explain how to regenerate import libraries with MSVC tools
docs: Mention that libraries for MSVC can be built with a cross compiler
docs: Remove old docs that mention setting up a build environment with lib.exe
...
Conflicts:
doc/ffmpeg.texi
doc/general.texi
ffmpeg.c
libavcodec/Makefile
libavcodec/dnxhddata.c
libavformat/mp3enc.c
libavformat/utils.c
libavutil/Makefile
tests/copycooker.sh
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avformat.h | 13 | ||||
-rw-r--r-- | libavformat/gif.c | 29 | ||||
-rw-r--r-- | libavformat/img2.c | 9 | ||||
-rw-r--r-- | libavformat/matroskaenc.c | 2 | ||||
-rw-r--r-- | libavformat/mp3enc.c | 43 | ||||
-rw-r--r-- | libavformat/utils.c | 9 | ||||
-rw-r--r-- | libavformat/version.h | 6 |
7 files changed, 88 insertions, 23 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f8eb7f7..3d57fa9 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -747,12 +747,16 @@ typedef struct AVFormatContext { int preload; int max_delay; +#if FF_API_LOOP_OUTPUT #define AVFMT_NOOUTPUTLOOP -1 #define AVFMT_INFINITEOUTPUTLOOP 0 /** * number of times to loop output in formats that support it + * + * @deprecated use the 'loop' private option in the gif muxer. */ - int loop_output; + attribute_deprecated int loop_output; +#endif int flags; #define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. @@ -770,7 +774,12 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Dont merge side data but keep it seperate. - int loop_input; +#if FF_API_LOOP_INPUT + /** + * @deprecated, use the 'loop' img2 demuxer private option. + */ + attribute_deprecated int loop_input; +#endif /** * decoding: size of data to probe; encoding: unused. diff --git a/libavformat/gif.c b/libavformat/gif.c index 0960705..81a1b6f 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -40,6 +40,8 @@ */ #include "avformat.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" /* The GIF format uses reversed order for bitstreams... */ /* at least they don't use PDP_ENDIAN :) */ @@ -245,8 +247,10 @@ static int gif_image_write_image(AVIOContext *pb, } typedef struct { + AVClass *class; /** Class for private options. */ int64_t time, file_time; uint8_t buffer[100]; /* data chunks */ + int loop; } GIFContext; static int gif_write_header(AVFormatContext *s) @@ -254,7 +258,7 @@ static int gif_write_header(AVFormatContext *s) GIFContext *gif = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *enc, *video_enc; - int i, width, height, loop_count /*, rate*/; + int i, width, height /*, rate*/; /* XXX: do we reject audio streams or just ignore them ? if(s->nb_streams > 1) @@ -276,7 +280,6 @@ static int gif_write_header(AVFormatContext *s) } else { width = video_enc->width; height = video_enc->height; - loop_count = s->loop_output; // rate = video_enc->time_base.den; } @@ -285,7 +288,12 @@ static int gif_write_header(AVFormatContext *s) return AVERROR(EIO); } - gif_image_write_header(pb, width, height, loop_count, NULL); +#if FF_API_LOOP_OUTPUT + if (s->loop_output) + gif->loop = s->loop_output; +#endif + + gif_image_write_header(pb, width, height, gif->loop, NULL); avio_flush(s->pb); return 0; @@ -340,6 +348,20 @@ static int gif_write_trailer(AVFormatContext *s) return 0; } +#define OFFSET(x) offsetof(GIFContext, x) +#define ENC AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "loop", "Number of times to loop the output.", OFFSET(loop), FF_OPT_TYPE_INT, {0}, 0, 65535, ENC }, + { NULL }, +}; + +static const AVClass gif_muxer_class = { + .class_name = "GIF muxer", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, + .option = options, +}; + AVOutputFormat ff_gif_muxer = { "gif", NULL_IF_CONFIG_SMALL("GIF Animation"), @@ -351,4 +373,5 @@ AVOutputFormat ff_gif_muxer = { gif_write_header, gif_write_packet, gif_write_trailer, + .priv_class = &gif_muxer_class, }; diff --git a/libavformat/img2.c b/libavformat/img2.c index ca391aa..0531a1a 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -43,6 +43,7 @@ typedef struct { char *pixel_format; /**< Set by a private option. */ char *video_size; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ + int loop; } VideoData; typedef struct { @@ -247,6 +248,11 @@ static int read_header(AVFormatContext *s1, AVFormatParameters *ap) framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif +#if FF_API_LOOP_INPUT + if (s1->loop_input) + s->loop = s1->loop_input; +#endif + av_strlcpy(s->path, s1->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; @@ -306,7 +312,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) if (!s->is_pipe) { /* loop over input */ - if (s1->loop_input && s->img_number > s->img_last) { + if (s->loop && s->img_number > s->img_last) { s->img_number = s->img_first; } if (s->img_number > s->img_last) @@ -467,6 +473,7 @@ static const AVOption options[] = { { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "video_size", "", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "loop", "", OFFSET(loop), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, { NULL }, }; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 68a05c3..4bfd197 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -939,7 +939,7 @@ static int mkv_write_ass_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p size -= start - data; sscanf(data, "Dialogue: %d,", &layer); i = snprintf(buffer, sizeof(buffer), "%"PRId64",%d,", - s->streams[pkt->stream_index]->nb_frames++, layer); + s->streams[pkt->stream_index]->nb_frames, layer); size = FFMIN(i+size, sizeof(buffer)); memcpy(buffer+i, start, size-i); diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index 50342bb..46b65a5 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -21,10 +21,14 @@ #include <strings.h> #include "avformat.h" +#include "avio_internal.h" #include "id3v1.h" #include "id3v2.h" #include "rawenc.h" #include "libavutil/avstring.h" +#include "libavcodec/mpegaudio.h" +#include "libavcodec/mpegaudiodata.h" +#include "libavcodec/mpegaudiodecheader.h" #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavcodec/mpegaudio.h" @@ -132,15 +136,39 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2 return len + ID3v2_HEADER_SIZE; } +#define VBR_NUM_BAGS 400 +#define VBR_TOC_SIZE 100 +typedef struct MP3Context { + const AVClass *class; + int id3v2_version; + int64_t frames_offset; + int32_t frames; + int32_t size; + uint32_t want; + uint32_t seen; + uint32_t pos; + uint64_t bag[VBR_NUM_BAGS]; +} MP3Context; + static int mp2_write_trailer(struct AVFormatContext *s) { uint8_t buf[ID3v1_TAG_SIZE]; + MP3Context *mp3 = s->priv_data; /* write the id3v1 tag */ if (id3v1_create_tag(s, buf) > 0) { avio_write(s->pb, buf, ID3v1_TAG_SIZE); - avio_flush(s->pb); } + + /* write number of frames */ + if (mp3 && mp3->frames_offset) { + avio_seek(s->pb, mp3->frames_offset, SEEK_SET); + avio_wb32(s->pb, s->streams[0]->nb_frames); + avio_seek(s->pb, 0, SEEK_END); + } + + avio_flush(s->pb); + return 0; } @@ -160,19 +188,6 @@ AVOutputFormat ff_mp2_muxer = { #endif #if CONFIG_MP3_MUXER -#define VBR_NUM_BAGS 400 -#define VBR_TOC_SIZE 100 -typedef struct MP3Context { - const AVClass *class; - int id3v2_version; - int64_t frames_offset; - int32_t frames; - int32_t size; - uint32_t want; - uint32_t seen; - uint32_t pos; - uint64_t bag[VBR_NUM_BAGS]; -} MP3Context; static const AVOption options[] = { { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.", diff --git a/libavformat/utils.c b/libavformat/utils.c index 9a7d6b7..58b1f56 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3122,8 +3122,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt) return ret; ret= s->oformat->write_packet(s, pkt); - if(!ret) - ret= url_ferror(s->pb); + + if (ret >= 0) + s->streams[pkt->stream_index]->nb_frames++; return ret; } @@ -3244,6 +3245,8 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ return ret; ret= s->oformat->write_packet(s, &opkt); + if (ret >= 0) + s->streams[opkt.stream_index]->nb_frames++; av_free_packet(&opkt); pkt= NULL; @@ -3268,6 +3271,8 @@ int av_write_trailer(AVFormatContext *s) break; ret= s->oformat->write_packet(s, &pkt); + if (ret >= 0) + s->streams[pkt.stream_index]->nb_frames++; av_free_packet(&pkt); diff --git a/libavformat/version.h b/libavformat/version.h index 9aaf395..96cc6d4 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -80,5 +80,11 @@ #ifndef FF_API_AVSTREAM_QUALITY #define FF_API_AVSTREAM_QUALITY (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_LOOP_INPUT +#define FF_API_LOOP_INPUT (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_LOOP_OUTPUT +#define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ |