From cbfa93aca33dda399dd946f1bc4e3097c124fa5d Mon Sep 17 00:00:00 2001 From: Compn Date: Sat, 9 Apr 2011 13:49:56 +0200 Subject: [PATCH 01/19] fix typo Signed-off-by: Luca Barbato --- doc/git-howto.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/git-howto.txt b/doc/git-howto.txt index 3ac21c87d9..ba377c99e0 100644 --- a/doc/git-howto.txt +++ b/doc/git-howto.txt @@ -120,7 +120,7 @@ I. BASICS: For cosmetics-only commits you should get (almost) empty output from - git diff -wb + git diff -w -b Also check the output of From 47dec30edb8565b7e0e8716dc6d0dc36d5b7bc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Tue, 5 Apr 2011 00:29:01 +0200 Subject: [PATCH 02/19] oggdec: fix demuxing chained audio streams Chained ogg served by icecast and mpd should demux properly now. Fixes issue2337 Signed-off-by: Luca Barbato --- libavformat/oggdec.c | 16 ++++++++++++++++ libavformat/oggdec.h | 1 + 2 files changed, 17 insertions(+) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index cd866d4108..5cf4faa686 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -164,6 +164,7 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial) os->bufsize = DECODER_BUFFER_SIZE; os->buf = av_malloc(os->bufsize); os->header = -1; + os->page_begin = 1; st = av_new_stream (s, idx); if (!st) @@ -241,12 +242,27 @@ ogg_read_page (AVFormatContext * s, int *str) idx = ogg_find_stream (ogg, serial); if (idx < 0){ + for (i = 0; i < ogg->nstreams; i++) { + if (!ogg->streams[i].page_begin) { + int n; + + for (n = 0; n < ogg->nstreams; n++) { + av_free(ogg->streams[n].buf); + av_free(ogg->streams[n].private); + } + ogg->curidx = -1; + ogg->nstreams = 0; + break; + } + } idx = ogg_new_stream (s, serial); if (idx < 0) return -1; } os = ogg->streams + idx; + if (!(flags & OGG_FLAG_BOS)) + os->page_begin = 0; os->page_pos = avio_tell(bc) - 27; if(os->psize > 0) diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index 7d66cd5638..785cd812f9 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -75,6 +75,7 @@ struct ogg_stream { int incomplete; ///< whether we're expecting a continuation in the next page int page_end; ///< current packet is the last one completed in the page int keyframe_seek; + int page_begin; ///< set to 1 if the stream only received a begin-of-stream packet, otherwise 0 void *private; }; From 73389754c911bc3171019f0bb98b7aeeb0ef32e6 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sat, 9 Apr 2011 13:49:45 +0200 Subject: [PATCH 03/19] pixfmt: add PIX_FMT_BGR48LE and PIX_FMT_BGR48BE PIX_FMT_BGR48LE is used by PhantomCINE demuxer. Signed-off-by: Luca Barbato --- doc/APIchanges | 3 +++ libavutil/avutil.h | 2 +- libavutil/pixdesc.c | 23 +++++++++++++++++++++++ libavutil/pixfmt.h | 3 +++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7d12737472..d65b2ddeea 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,9 @@ libavutil: 2009-03-08 API changes, most recent first: +2011-04-10 - lavu 50.40.0 - pixfmt.h + Add PIX_FMT_BGR48LE and PIX_FMT_BGR48BE pixel formats + 2011-04-08 - lavf 52.106.0 - avformat.h Minor avformat.h cleanup: a9bf9d8 deprecate av_guess_image2_codec diff --git a/libavutil/avutil.h b/libavutil/avutil.h index d69e989457..929c5ddcdc 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 50 -#define LIBAVUTIL_VERSION_MINOR 39 +#define LIBAVUTIL_VERSION_MINOR 40 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 55d2debadb..16a26da3da 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -630,6 +630,29 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { {0,1,1,0,3}, /* B */ }, }, + [PIX_FMT_BGR48BE] = { + .name = "bgr48be", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + {0,5,1,0,15}, /* B */ + {0,5,3,0,15}, /* G */ + {0,5,5,0,15}, /* R */ + }, + .flags = PIX_FMT_BE, + }, + [PIX_FMT_BGR48LE] = { + .name = "bgr48le", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + {0,5,1,0,15}, /* B */ + {0,5,3,0,15}, /* G */ + {0,5,5,0,15}, /* R */ + }, + }, [PIX_FMT_BGR565BE] = { .name = "bgr565be", .nb_components= 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 9877724eb6..dcdf4af4fb 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -133,6 +133,8 @@ enum PixelFormat { PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha + PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -152,6 +154,7 @@ enum PixelFormat { #define PIX_FMT_RGB565 PIX_FMT_NE(RGB565BE, RGB565LE) #define PIX_FMT_RGB555 PIX_FMT_NE(RGB555BE, RGB555LE) #define PIX_FMT_RGB444 PIX_FMT_NE(RGB444BE, RGB444LE) +#define PIX_FMT_BGR48 PIX_FMT_NE(BGR48BE, BGR48LE) #define PIX_FMT_BGR565 PIX_FMT_NE(BGR565BE, BGR565LE) #define PIX_FMT_BGR555 PIX_FMT_NE(BGR555BE, BGR555LE) #define PIX_FMT_BGR444 PIX_FMT_NE(BGR444BE, BGR444LE) From 3028b6ede624410d40ab7c77a67b62fc6ad3a8f0 Mon Sep 17 00:00:00 2001 From: Brad Date: Sat, 2 Apr 2011 17:16:59 -0400 Subject: [PATCH 04/19] os: fix OpenBSD/PowerPC compilation When attempting to re-enable the AltiVec support it was noticed that we need to undefine _POSIX_C_SOURCE to appease the headers for ff_get_cpu_flags_ppc() to be able to compile. Signed-off-by: Luca Barbato --- libavutil/ppc/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c index 85c1f2ca11..6b122ed8c4 100644 --- a/libavutil/ppc/cpu.c +++ b/libavutil/ppc/cpu.c @@ -20,6 +20,7 @@ #undef _POSIX_C_SOURCE #include #elif defined(__OpenBSD__) +#undef _POSIX_C_SOURCE #include #include #include From 6084ee5dc50aff488b611ad19ae1a6e72aa7ca39 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 08:30:15 +0200 Subject: [PATCH 05/19] avio: update file header. --- libavformat/avio.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 7bb8d175d0..6dfed4a35d 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -22,10 +22,7 @@ /** * @file - * unbuffered I/O operations - * - * @warning This file has to be considered an internal but installed - * header, so it should not be directly included in your projects. + * Buffered I/O operations */ #include From fafa7290f1bf7f91cc5afe6c5cc65808bacb5c42 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 08:44:14 +0200 Subject: [PATCH 06/19] avio: cosmetics, move AVIOContext to start of the file. --- libavformat/avio.h | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 6dfed4a35d..5a354b2381 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -32,6 +32,45 @@ #include "libavformat/version.h" + +#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ + +/** + * Bytestream IO Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVIOContext) must not be used outside libav*. + */ +typedef struct { + unsigned char *buffer; + int buffer_size; + unsigned char *buf_ptr, *buf_end; + void *opaque; + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); + int64_t (*seek)(void *opaque, int64_t offset, int whence); + int64_t pos; /**< position in the file of the current buffer */ + int must_flush; /**< true if the next seek should flush */ + int eof_reached; /**< true if eof reached */ + int write_flag; /**< true if open for writing */ +#if FF_API_OLD_AVIO + attribute_deprecated int is_streamed; +#endif + int max_packet_size; + unsigned long checksum; + unsigned char *checksum_ptr; + unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); + int error; ///< contains the error code or 0 if no error happened + int (*read_pause)(void *opaque, int pause); + int64_t (*read_seek)(void *opaque, int stream_index, + int64_t timestamp, int flags); + /** + * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. + */ + int seekable; +} AVIOContext; + /* unbuffered I/O */ #if FF_API_OLD_AVIO @@ -197,48 +236,10 @@ attribute_deprecated int av_register_protocol(URLProtocol *protocol); attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size); #endif -#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ - /** * @} */ -/** - * Bytestream IO Context. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * sizeof(AVIOContext) must not be used outside libav*. - */ -typedef struct { - unsigned char *buffer; - int buffer_size; - unsigned char *buf_ptr, *buf_end; - void *opaque; - int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); - int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); - int64_t (*seek)(void *opaque, int64_t offset, int whence); - int64_t pos; /**< position in the file of the current buffer */ - int must_flush; /**< true if the next seek should flush */ - int eof_reached; /**< true if eof reached */ - int write_flag; /**< true if open for writing */ -#if FF_API_OLD_AVIO - attribute_deprecated int is_streamed; -#endif - int max_packet_size; - unsigned long checksum; - unsigned char *checksum_ptr; - unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); - int error; ///< contains the error code or 0 if no error happened - int (*read_pause)(void *opaque, int pause); - int64_t (*read_seek)(void *opaque, int stream_index, - int64_t timestamp, int flags); - /** - * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. - */ - int seekable; -} AVIOContext; - #if FF_API_OLD_AVIO typedef attribute_deprecated AVIOContext ByteIOContext; From 37744e328257f7974e77574d746b338be2e3bab8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 08:52:35 +0200 Subject: [PATCH 07/19] avio: cosmetics, merge all the FF_API_OLD_AVIO blocks. --- libavformat/avio.h | 196 +++++++++++++++++++-------------------------- 1 file changed, 84 insertions(+), 112 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 5a354b2381..73b023c8a1 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -95,12 +95,38 @@ typedef struct URLContext { int is_connected; } URLContext; +#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ + +/** + * @deprecated This struct is to be made private. Use the higher-level + * AVIOContext-based API instead. + */ +typedef struct URLProtocol { + const char *name; + int (*url_open)(URLContext *h, const char *url, int flags); + int (*url_read)(URLContext *h, unsigned char *buf, int size); + int (*url_write)(URLContext *h, const unsigned char *buf, int size); + int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); + int (*url_close)(URLContext *h); + struct URLProtocol *next; + int (*url_read_pause)(URLContext *h, int pause); + int64_t (*url_read_seek)(URLContext *h, int stream_index, + int64_t timestamp, int flags); + int (*url_get_file_handle)(URLContext *h); + int priv_data_size; + const AVClass *priv_data_class; + int flags; +} URLProtocol; + typedef struct URLPollEntry { URLContext *handle; int events; int revents; } URLPollEntry; +/* not implemented */ +attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); + /** * @defgroup open_modes URL open modes * The flags argument to url_open and cosins must be one of the following @@ -129,6 +155,7 @@ typedef struct URLPollEntry { #define URL_FLAG_NONBLOCK 4 typedef int URLInterruptCB(void); +extern URLInterruptCB *url_interrupt_cb; /** * @defgroup old_url_funcs Old url_* functions @@ -153,94 +180,23 @@ attribute_deprecated int av_url_read_pause(URLContext *h, int pause); attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index, int64_t timestamp, int flags); attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void)); -#endif - -/** - * Return a non-zero value if the resource indicated by url - * exists, 0 otherwise. - */ -int url_exist(const char *url); - -/** - * The callback is called in blocking functions to test regulary if - * asynchronous interruption is needed. AVERROR_EXIT is returned - * in this case by the interrupted function. 'NULL' means no interrupt - * callback is given. - */ -void avio_set_interrupt_cb(int (*interrupt_cb)(void)); - -#if FF_API_OLD_AVIO -/* not implemented */ -attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); - - -#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ - -/** - * @deprecated This struct is to be made private. Use the higher-level - * AVIOContext-based API instead. - */ -typedef struct URLProtocol { - const char *name; - int (*url_open)(URLContext *h, const char *url, int flags); - int (*url_read)(URLContext *h, unsigned char *buf, int size); - int (*url_write)(URLContext *h, const unsigned char *buf, int size); - int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); - int (*url_close)(URLContext *h); - struct URLProtocol *next; - int (*url_read_pause)(URLContext *h, int pause); - int64_t (*url_read_seek)(URLContext *h, int stream_index, - int64_t timestamp, int flags); - int (*url_get_file_handle)(URLContext *h); - int priv_data_size; - const AVClass *priv_data_class; - int flags; -} URLProtocol; -#endif - -#if FF_API_REGISTER_PROTOCOL -extern URLProtocol *first_protocol; -#endif - -#if FF_API_OLD_AVIO -extern URLInterruptCB *url_interrupt_cb; -#endif - -#if FF_API_OLD_AVIO /** * If protocol is NULL, returns the first registered protocol, * if protocol is non-NULL, returns the next registered protocol after protocol, * or NULL if protocol is the last one. */ attribute_deprecated URLProtocol *av_protocol_next(URLProtocol *p); -#endif - -#if FF_API_REGISTER_PROTOCOL -/** - * @deprecated Use av_register_protocol() instead. - */ -attribute_deprecated int register_protocol(URLProtocol *protocol); - -/** - * @deprecated Use av_register_protocol2() instead. - */ -attribute_deprecated int av_register_protocol(URLProtocol *protocol); -#endif - -#if FF_API_OLD_AVIO /** * Register the URLProtocol protocol. * * @param size the size of the URLProtocol struct referenced */ attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size); -#endif - /** * @} */ -#if FF_API_OLD_AVIO + typedef attribute_deprecated AVIOContext ByteIOContext; attribute_deprecated int init_put_byte(AVIOContext *s, @@ -338,6 +294,62 @@ attribute_deprecated void init_checksum(AVIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum); attribute_deprecated unsigned long get_checksum(AVIOContext *s); +attribute_deprecated void put_strz(AVIOContext *s, const char *buf); +/** @note unlike fgets, the EOL character is not returned and a whole + line is parsed. return NULL if first char read was EOF */ +attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size); +/** + * @deprecated use avio_get_str instead + */ +attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen); +/** + * @deprecated Use AVIOContext.seekable field directly. + */ +attribute_deprecated static inline int url_is_streamed(AVIOContext *s) +{ + return !s->seekable; +} +attribute_deprecated URLContext *url_fileno(AVIOContext *s); + +/** + * @deprecated use AVIOContext.max_packet_size directly. + */ +attribute_deprecated int url_fget_max_packet_size(AVIOContext *s); + +attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags); + +/** return the written or read size */ +attribute_deprecated int url_close_buf(AVIOContext *s); +#endif // FF_API_OLD_AVIO + +/** + * Return a non-zero value if the resource indicated by url + * exists, 0 otherwise. + */ +int url_exist(const char *url); + +/** + * The callback is called in blocking functions to test regulary if + * asynchronous interruption is needed. AVERROR_EXIT is returned + * in this case by the interrupted function. 'NULL' means no interrupt + * callback is given. + */ +void avio_set_interrupt_cb(int (*interrupt_cb)(void)); + +#if FF_API_REGISTER_PROTOCOL +extern URLProtocol *first_protocol; +#endif + +#if FF_API_REGISTER_PROTOCOL +/** + * @deprecated Use av_register_protocol() instead. + */ +attribute_deprecated int register_protocol(URLProtocol *protocol); + +/** + * @deprecated Use av_register_protocol2() instead. + */ +attribute_deprecated int av_register_protocol(URLProtocol *protocol); #endif /** @@ -376,10 +388,6 @@ void avio_wb24(AVIOContext *s, unsigned int val); void avio_wl16(AVIOContext *s, unsigned int val); void avio_wb16(AVIOContext *s, unsigned int val); -#if FF_API_OLD_AVIO -attribute_deprecated void put_strz(AVIOContext *s, const char *buf); -#endif - /** * Write a NULL-terminated string. * @return number of bytes written. @@ -444,12 +452,6 @@ int avio_printf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ int avio_printf(AVIOContext *s, const char *fmt, ...); #endif -#if FF_API_OLD_AVIO -/** @note unlike fgets, the EOL character is not returned and a whole - line is parsed. return NULL if first char read was EOF */ -attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size); -#endif - void avio_flush(AVIOContext *s); @@ -490,27 +492,11 @@ int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen); int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); -#if FF_API_OLD_AVIO -/** - * @deprecated use avio_get_str instead - */ -attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen); -#endif unsigned int avio_rb16(AVIOContext *s); unsigned int avio_rb24(AVIOContext *s); unsigned int avio_rb32(AVIOContext *s); uint64_t avio_rb64(AVIOContext *s); -#if FF_API_OLD_AVIO -/** - * @deprecated Use AVIOContext.seekable field directly. - */ -attribute_deprecated static inline int url_is_streamed(AVIOContext *s) -{ - return !s->seekable; -} -#endif - #if FF_API_URL_RESETBUF /** Reset the buffer for reading or writing. * @note Will drop any data currently in the buffer without transmitting it. @@ -563,20 +549,6 @@ int avio_open(AVIOContext **s, const char *url, int flags); int avio_close(AVIOContext *s); -#if FF_API_OLD_AVIO -attribute_deprecated URLContext *url_fileno(AVIOContext *s); - -/** - * @deprecated use AVIOContext.max_packet_size directly. - */ -attribute_deprecated int url_fget_max_packet_size(AVIOContext *s); - -attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags); - -/** return the written or read size */ -attribute_deprecated int url_close_buf(AVIOContext *s); -#endif - /** * Open a write only memory stream. * From 72d4405b66be0ec22ba01cc360a7e826ab910efd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 08:55:53 +0200 Subject: [PATCH 08/19] avio: cosmetics, group the reading functions. --- libavformat/avio.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 73b023c8a1..b30866c4ee 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -461,13 +461,25 @@ void avio_flush(AVIOContext *s); */ int avio_read(AVIOContext *s, unsigned char *buf, int size); -/** @note return 0 if EOF, so you cannot use it if EOF handling is - necessary */ +/** + * @defgroup avio_read Functions for reading from AVIOContext. + * @{ + * + * @note return 0 if EOF, so you cannot use it if EOF handling is + * necessary + */ int avio_r8 (AVIOContext *s); unsigned int avio_rl16(AVIOContext *s); unsigned int avio_rl24(AVIOContext *s); unsigned int avio_rl32(AVIOContext *s); uint64_t avio_rl64(AVIOContext *s); +unsigned int avio_rb16(AVIOContext *s); +unsigned int avio_rb24(AVIOContext *s); +unsigned int avio_rb32(AVIOContext *s); +uint64_t avio_rb64(AVIOContext *s); +/** + * @} + */ /** * Read a string from pb into buf. The reading will terminate when either @@ -492,10 +504,6 @@ int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen); int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); -unsigned int avio_rb16(AVIOContext *s); -unsigned int avio_rb24(AVIOContext *s); -unsigned int avio_rb32(AVIOContext *s); -uint64_t avio_rb64(AVIOContext *s); #if FF_API_URL_RESETBUF /** Reset the buffer for reading or writing. From 893816ba1e7c8d89ee405e55bae8251366ff3df9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 12:21:36 +0200 Subject: [PATCH 09/19] avio: cosmetics, vertically align comments. --- libavformat/avio.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index b30866c4ee..ca5dc2d1ee 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -50,10 +50,10 @@ typedef struct { int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); int64_t (*seek)(void *opaque, int64_t offset, int whence); - int64_t pos; /**< position in the file of the current buffer */ - int must_flush; /**< true if the next seek should flush */ - int eof_reached; /**< true if eof reached */ - int write_flag; /**< true if open for writing */ + int64_t pos; /**< position in the file of the current buffer */ + int must_flush; /**< true if the next seek should flush */ + int eof_reached; /**< true if eof reached */ + int write_flag; /**< true if open for writing */ #if FF_API_OLD_AVIO attribute_deprecated int is_streamed; #endif @@ -61,7 +61,7 @@ typedef struct { unsigned long checksum; unsigned char *checksum_ptr; unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); - int error; ///< contains the error code or 0 if no error happened + int error; /**< contains the error code or 0 if no error happened */ int (*read_pause)(void *opaque, int pause); int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags); From e782a0c6da0daa7b65e0355e50e68b13441b5faa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 12:43:51 +0200 Subject: [PATCH 10/19] avio: document avio_close(). --- libavformat/avio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/avio.h b/libavformat/avio.h index ca5dc2d1ee..134df12057 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -555,6 +555,12 @@ int url_resetbuf(AVIOContext *s, int flags); */ int avio_open(AVIOContext **s, const char *url, int flags); +/** + * Close the resource accessed by the AVIOContext s and free it. + * This function can only be used if s was opened by avio_open(). + * + * @return 0 on success, an AVERROR < 0 on error. + */ int avio_close(AVIOContext *s); /** From c1a9012d62b76106d02f080adec28e13b039a53d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 9 Apr 2011 12:20:04 +0200 Subject: [PATCH 11/19] avio: document some members of AVIOContext. --- libavformat/avio.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 134df12057..95cad17787 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -43,10 +43,15 @@ * sizeof(AVIOContext) must not be used outside libav*. */ typedef struct { - unsigned char *buffer; - int buffer_size; - unsigned char *buf_ptr, *buf_end; - void *opaque; + unsigned char *buffer; /**< Start of the buffer. */ + int buffer_size; /**< Maximum buffer size */ + unsigned char *buf_ptr; /**< Current position in the buffer */ + unsigned char *buf_end; /**< End of the data, may be less than + buffer+buffer_size if the read function returned + less data than requested, e.g. for streams where + no more data has been received yet. */ + void *opaque; /**< A private pointer, passed to the read/write/seek/... + functions. */ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); int64_t (*seek)(void *opaque, int64_t offset, int whence); From 2fd8756b9f5f5e809bec8f2635216f236106dff4 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 13:49:48 +0200 Subject: [PATCH 12/19] documentation: add setdar and setsar description to filters.texi Signed-off-by: Anton Khirnov --- doc/filters.texi | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 872afc6ca1..00a954ca84 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -789,6 +789,36 @@ ratio of the input image. The default value of @var{width} and @var{height} is 0. +@anchor{setdar} +@section setdar + +Set the Display Aspect Ratio for the filter output video. + +This is done by changing the specified Sample (aka Pixel) Aspect +Ratio, according to the following equation: +@math{DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR} + +Keep in mind that this filter does not modify the pixel dimensions of +the video frame. Also the display aspect ratio set by this filter may +be changed by later filters in the filterchain, e.g. in case of +scaling or if another "setdar" or a "setsar" filter is applied. + +The filter accepts a parameter string which represents the wanted +display aspect ratio. +The parameter can be a floating point number string, or an expression +of the form @var{num}:@var{den}, where @var{num} and @var{den} are the +numerator and denominator of the aspect ratio. +If the parameter is not specified, it is assumed the value "0:1". + +For example to change the display aspect ratio to 16:9, specify: +@example +setdar=16:9 +# the above is equivalent to +setdar=1.77777 +@end example + +See also the "setsar" filter documentation (@pxref{setsar}). + @section setpts Change the PTS (presentation timestamp) of the input video frames. @@ -849,6 +879,32 @@ setpts=N/(25*TB) setpts='1/(25*TB) * (N + 0.05 * sin(N*2*PI/25))' @end example +@anchor{setsar} +@section setsar + +Set the Sample (aka Pixel) Aspect Ratio for the filter output video. + +Note that as a consequence of the application of this filter, the +output display aspect ratio will change according to the following +equation: +@math{DAR = HORIZONTAL_RESOLUTION / VERTICAL_RESOLUTION * SAR} + +Keep in mind that the sample aspect ratio set by this filter may be +changed by later filters in the filterchain, e.g. if another "setsar" +or a "setdar" filter is applied. + +The filter accepts a parameter string which represents the wanted +sample aspect ratio. +The parameter can be a floating point number string, or an expression +of the form @var{num}:@var{den}, where @var{num} and @var{den} are the +numerator and denominator of the aspect ratio. +If the parameter is not specified, it is assumed the value "0:1". + +For example to change the sample aspect ratio to 10:11, specify: +@example +setsar=10:11 +@end example + @section settb Set the timebase to use for the output frames timestamps. From 5ae4251c3b603cc7f44dd0e0839c5b6f6bbac61e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 13:49:54 +0200 Subject: [PATCH 13/19] eval: add support for trunc, ceil, and floor functions Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- doc/eval.texi | 12 ++++++++++++ libavutil/avutil.h | 2 +- libavutil/eval.c | 21 +++++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/doc/eval.texi b/doc/eval.texi index a989a373a6..d8c693f304 100644 --- a/doc/eval.texi +++ b/doc/eval.texi @@ -60,6 +60,18 @@ The function returns the loaded value. Evaluate expression @var{expr} while the expression @var{cond} is non-zero, and returns the value of the last @var{expr} evaluation, or NAN if @var{cond} was always false. + +@item ceil(expr) +Round the value of expression @var{expr} upwards to the nearest +integer. For example, "ceil(1.5)" is "2.0". + +@item floor(expr) +Round the value of expression @var{expr} downwards to the nearest +integer. For example, "floor(-1.5)" is "-2.0". + +@item trunc(expr) +Round the value of expression @var{expr} towards zero to the nearest +integer. For example, "trunc(-1.5)" is "-1.0". @end table Note that: diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 929c5ddcdc..4c86be1b86 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -41,7 +41,7 @@ #define LIBAVUTIL_VERSION_MAJOR 50 #define LIBAVUTIL_VERSION_MINOR 40 -#define LIBAVUTIL_VERSION_MICRO 0 +#define LIBAVUTIL_VERSION_MICRO 1 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/libavutil/eval.c b/libavutil/eval.c index 8994393cdb..7488a310a7 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -121,7 +121,7 @@ struct AVExpr { e_squish, e_gauss, e_ld, e_isnan, e_mod, e_max, e_min, e_eq, e_gt, e_gte, e_pow, e_mul, e_div, e_add, - e_last, e_st, e_while, + e_last, e_st, e_while, e_floor, e_ceil, e_trunc, } type; double value; // is sign in other types union { @@ -145,6 +145,9 @@ static double eval_expr(Parser *p, AVExpr *e) case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); } case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)]; case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0])); + case e_floor: return e->value * floor(eval_expr(p, e->param[0])); + case e_ceil : return e->value * ceil (eval_expr(p, e->param[0])); + case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); case e_while: { double d = NAN; while (eval_expr(p, e->param[0])) @@ -276,6 +279,9 @@ static int parse_primary(AVExpr **e, Parser *p) else if (strmatch(next, "isnan" )) d->type = e_isnan; else if (strmatch(next, "st" )) d->type = e_st; else if (strmatch(next, "while" )) d->type = e_while; + else if (strmatch(next, "floor" )) d->type = e_floor; + else if (strmatch(next, "ceil" )) d->type = e_ceil; + else if (strmatch(next, "trunc" )) d->type = e_trunc; else { for (i=0; p->func1_names && p->func1_names[i]; i++) { if (strmatch(next, p->func1_names[i])) { @@ -439,7 +445,11 @@ static int verify_expr(AVExpr *e) case e_squish: case e_ld: case e_gauss: - case e_isnan: return verify_expr(e->param[0]); + case e_isnan: + case e_floor: + case e_ceil: + case e_trunc: + return verify_expr(e->param[0]); default: return verify_expr(e->param[0]) && verify_expr(e->param[1]); } } @@ -611,6 +621,13 @@ int main(void) "st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))", "isnan(1)", "isnan(NAN)", + "floor(NAN)", + "floor(123.123)", + "floor(-123.123)", + "trunc(123.123)", + "trunc(-123.123)", + "ceil(123.123)", + "ceil(-123.123)", NULL }; From 3eccfaa01291ca90e7dcb934bb06d048fcba1f43 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 13:49:57 +0200 Subject: [PATCH 14/19] gradfun: add notice from the MPlayer manual Add notice telling that the filter is designed for playback only. Signed-off-by: Anton Khirnov --- doc/filters.texi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 00a954ca84..c2e5aed84c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -471,6 +471,10 @@ regions by truncation to 8bit colordepth. Interpolate the gradients that should go where the bands are, and dither them. +This filter is designed for playback only. Do not use it prior to +lossy compression, because compression tends to lose the dither and +bring back the bands. + The filter takes two optional parameters, separated by ':': @var{strength}:@var{radius} From aeefbf61c0dbed2977c919ea0ef22f2536ee1e48 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 13:50:01 +0200 Subject: [PATCH 15/19] pad: fix example explanation "row" and "column" term positions in the explanation were inverted. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- doc/filters.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index c2e5aed84c..1a26f10c59 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -752,7 +752,7 @@ For example: @example # Add paddings with color "violet" to the input video. Output video # size is 640x480, the top-left corner of the input video is placed at -# row 0, column 40. +# column 0, row 40. pad=640:480:0:40:violet @end example From f8de11cf7dbfefec535c3114a5fced3609d01343 Mon Sep 17 00:00:00 2001 From: Lou Logan Date: Sat, 9 Apr 2011 13:50:05 +0200 Subject: [PATCH 16/19] Redefine sameq I think the documentation of sameq is causing confusion and misuse of this option. Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- doc/ffmpeg.texi | 2 +- ffmpeg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 21c6f2cadf..38da9186e6 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -272,7 +272,7 @@ Set video buffer verifier buffer size (in bits). Force video codec to @var{codec}. Use the @code{copy} special value to tell that the raw codec data must be copied as is. @item -sameq -Use same video quality as source (implies VBR). +Use same quantizer as source (implies VBR). @item -pass @var{n} Select the pass number (1 or 2). It is used to do two-pass diff --git a/ffmpeg.c b/ffmpeg.c index 841c79895e..80d2cca2b7 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4208,7 +4208,7 @@ static const OptionDef options[] = { { "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" }, { "me_threshold", HAS_ARG | OPT_FUNC2 | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold", "threshold" }, { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality}, - "use same video quality as source (implies VBR)" }, + "use same quantizer as source (implies VBR)" }, { "pass", HAS_ARG | OPT_VIDEO, {(void*)&opt_pass}, "select the pass number (1 or 2)", "n" }, { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" }, { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace}, From 70ff55733d41303f55bee80041095bd10b87363a Mon Sep 17 00:00:00 2001 From: Lou Logan Date: Sat, 9 Apr 2011 13:50:07 +0200 Subject: [PATCH 17/19] Replace outdated info on the FAQ FAQ could use some work. This updates a few little details. Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- doc/faq.texi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/faq.texi b/doc/faq.texi index 27b26b6c3a..3daf44fe7a 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -87,7 +87,7 @@ The following list of video codecs should work on most Windows systems: .asf only @item mpeg4 Only if you have some MPEG-4 codec like ffdshow or Xvid installed. -@item mpeg1 +@item mpeg1video .mpg only @end table Note, ASF files often have .wmv or .wma extensions in Windows. It should also @@ -99,9 +99,9 @@ The following list of audio codecs should work on most Windows systems: @table @option @item adpcm_ima_wav @item adpcm_ms -@item pcm +@item pcm_s16le always -@item mp3 +@item libmp3lame If some MP3 codec like LAME is installed. @end table @@ -226,7 +226,7 @@ mv4, title @item non-working stuff B-frames @item example command line -ffmpeg -i input -acodec libfaac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +mv4 -trellis 2 -aic 2 -cmp 2 -subcmp 2 -s 320x180 -metadata title=X output.mp4 +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? @@ -239,7 +239,7 @@ mv4, title @item non-working stuff B-frames @item example command line -ffmpeg -i input -acodec libfaac -ab 128kb -vcodec mpeg4 -b 1200kb -ar 24000 -mbd 2 -flags +mv4 -trellis 2 -aic 2 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -metadata title=X -f psp output.mp4 +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 @@ -247,11 +247,11 @@ title, loop filter @item non-working stuff for H.264 CAVLC @item example command line -ffmpeg -i input -acodec libfaac -ab 128kb -vcodec libx264 -b 1200kb -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 +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 128kb -ac 2 -ar 48000 -vcodec libx264 -level 21 -b 640kb -coder 1 -f psp -flags +loop -trellis 2 -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -g 250 -s 480x272 output.mp4 +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? From 768c5251141be705d64a480b641c6b17d32a4e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Delm=C3=A1s?= Date: Fri, 8 Apr 2011 20:00:48 +0200 Subject: [PATCH 18/19] Parse sprite data for WMVP and WVP2, and decode sprites for the latter Signed-off-by: Anton Khirnov --- libavcodec/vc1.c | 3 - libavcodec/vc1.h | 6 ++ libavcodec/vc1dec.c | 127 ++++++++++++++++++++++++++++++++++++++++++- libavcodec/version.h | 2 +- libavformat/riff.c | 1 + 5 files changed, 132 insertions(+), 7 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 77e71db778..b058a38c40 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -605,9 +605,6 @@ int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant, status; - if(v->res_sprite) { - skip_bits(gb, 2); //not yet deciphered - } if(v->finterpflag) v->interpfrm = get_bits1(gb); skip_bits(gb, 2); //framecnt unused v->rangeredfrm = 0; diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 00dcfbf1d2..d0c0cccfb0 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -306,6 +306,12 @@ typedef struct VC1Context{ uint8_t range_mapuv; //@} + /** Frame decoding info for sprite modes */ + //@{ + int new_sprite; + int two_sprites; + //@} + int p_frame_skipped; int bi_type; int x8_type; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index cde284dac2..8200cde0ff 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3097,6 +3097,116 @@ static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end) } } +static inline float get_float_val(GetBitContext* gb) +{ + return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14); +} + +static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, float c[7]) +{ + c[1] = c[3] = 0.0f; + + switch (get_bits(gb, 2)) { + case 0: + c[0] = 1.0f; + c[2] = get_float_val(gb); + c[4] = 1.0f; + break; + case 1: + c[0] = c[4] = get_float_val(gb); + c[2] = get_float_val(gb); + break; + case 2: + c[0] = get_float_val(gb); + c[2] = get_float_val(gb); + c[4] = get_float_val(gb); + break; + case 3: + av_log_ask_for_sample(v->s.avctx, NULL); + c[0] = get_float_val(gb); + c[1] = get_float_val(gb); + c[2] = get_float_val(gb); + c[3] = get_float_val(gb); + c[4] = get_float_val(gb); + break; + } + c[5] = get_float_val(gb); + if (get_bits1(gb)) + c[6] = get_float_val(gb); + else + c[6] = 1.0f; +} + +static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb) +{ + int effect_type, effect_flag, effect_pcount1, effect_pcount2, i; + float effect_params1[14], effect_params2[10]; + + float coefs[2][7]; + vc1_sprite_parse_transform(v, gb, coefs[0]); + av_log(v->s.avctx, AV_LOG_DEBUG, "S1:"); + for (i = 0; i < 7; i++) + av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[0][i]); + av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); + + if (v->two_sprites) { + vc1_sprite_parse_transform(v, gb, coefs[1]); + av_log(v->s.avctx, AV_LOG_DEBUG, "S2:"); + for (i = 0; i < 7; i++) + av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[1][i]); + av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); + } + skip_bits(gb, 2); + if (effect_type = get_bits_long(gb, 30)){ + switch (effect_pcount1 = get_bits(gb, 4)) { + case 2: + effect_params1[0] = get_float_val(gb); + effect_params1[1] = get_float_val(gb); + break; + case 7: + vc1_sprite_parse_transform(v, gb, effect_params1); + break; + case 14: + vc1_sprite_parse_transform(v, gb, effect_params1); + vc1_sprite_parse_transform(v, gb, &effect_params1[7]); + break; + default: + av_log_ask_for_sample(v->s.avctx, NULL); + return; + } + if (effect_type != 13 || effect_params1[0] != coefs[0][6]) { + // effect 13 is simple alpha blending and matches the opacity above + av_log(v->s.avctx, AV_LOG_DEBUG, "Effect: %d; params: ", effect_type); + for (i = 0; i < effect_pcount1; i++) + av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params1[i]); + av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); + } + + effect_pcount2 = get_bits(gb, 16); + if (effect_pcount2 > 10) { + av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n"); + return; + } else if (effect_pcount2) { + i = 0; + av_log(v->s.avctx, AV_LOG_DEBUG, "Effect params 2: "); + while (i < effect_pcount2){ + effect_params2[i] = get_float_val(gb); + av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params2[i]); + i++; + } + av_log(v->s.avctx, AV_LOG_DEBUG, "\n"); + } + } + if (effect_flag = get_bits1(gb)) + av_log(v->s.avctx, AV_LOG_DEBUG, "Effect flag set\n"); + + if (get_bits_count(gb) >= gb->size_in_bits + + (v->s.avctx->codec_id == CODEC_ID_WMV3 ? 64 : 0)) + av_log(v->s.avctx, AV_LOG_ERROR, "Buffer overrun\n"); + if (get_bits_count(gb) < gb->size_in_bits - 8) + av_log(v->s.avctx, AV_LOG_WARNING, "Buffer not fully read\n"); +} + /** Initialize a VC1/WMV3 decoder * @todo TODO: Handle VC-1 IDUs (Transport level?) * @todo TODO: Decypher remaining bits in extra_data @@ -3160,7 +3270,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) { av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); } - } else { // VC1/WVC1 + } else { // VC1/WVC1/WVP2 const uint8_t *start = avctx->extradata; uint8_t *end = avctx->extradata + avctx->extradata_size; const uint8_t *next; @@ -3204,6 +3314,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n"); return -1; } + v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2')); } avctx->profile = v->profile; if (v->profile == PROFILE_ADVANCED) @@ -3359,6 +3470,14 @@ static int vc1_decode_frame(AVCodecContext *avctx, init_get_bits(&s->gb, buf2, buf_size2*8); } else init_get_bits(&s->gb, buf, buf_size*8); + + if (v->res_sprite) { + v->new_sprite = !get_bits1(&s->gb); + v->two_sprites = get_bits1(&s->gb); + if (!v->new_sprite) + goto end; + } + // do parse frame header if(v->profile < PROFILE_ADVANCED) { if(vc1_parse_frame_header(v, &s->gb) == -1) { @@ -3370,8 +3489,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, } } - if(v->res_sprite && (s->pict_type!=FF_I_TYPE)){ - goto err; + if (v->res_sprite && s->pict_type!=FF_I_TYPE) { + av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n"); } // for skipping the frame @@ -3455,6 +3574,8 @@ assert(s->current_picture.pict_type == s->pict_type); } end: + if (v->res_sprite) + vc1_parse_sprites(v, &s->gb); av_free(buf2); for (i = 0; i < n_slices; i++) av_free(slices[i].buf); diff --git a/libavcodec/version.h b/libavcodec/version.h index b60e264d7f..e40d4e5531 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -22,7 +22,7 @@ #define LIBAVCODEC_VERSION_MAJOR 52 #define LIBAVCODEC_VERSION_MINOR 117 -#define LIBAVCODEC_VERSION_MICRO 0 +#define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/riff.c b/libavformat/riff.c index f490b47eb4..792c206678 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -232,6 +232,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', 'P') }, { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') }, { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') }, + { CODEC_ID_VC1, MKTAG('W', 'V', 'P', '2') }, { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') }, { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') }, { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') }, From d1c5fdf8920b75f3b824368b8336f18c74b68803 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 10 Apr 2011 08:14:26 +0200 Subject: [PATCH 19/19] avio: add more documentation for AVIOContext. --- libavformat/avio.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavformat/avio.h b/libavformat/avio.h index 95cad17787..7e7e429117 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -41,6 +41,11 @@ * Removal, reordering and changes to existing fields require a major * version bump. * sizeof(AVIOContext) must not be used outside libav*. + * + * @note None of the function pointers in AVIOContext should be called + * directly, they should only be set by the client application + * when implementing custom I/O. Normally these are set to the + * function pointers specified in avio_alloc_context() */ typedef struct { unsigned char *buffer; /**< Start of the buffer. */ @@ -67,7 +72,15 @@ typedef struct { unsigned char *checksum_ptr; unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); int error; /**< contains the error code or 0 if no error happened */ + /** + * Pause or resume playback for network streaming protocols - e.g. MMS. + */ int (*read_pause)(void *opaque, int pause); + /** + * Seek to a given timestamp in stream with the specified stream_index. + * Needed for some network streaming protocols which don't support seeking + * to byte position. + */ int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags); /**