From b5fc571e4f730579f328ae9cf77435cb7fddc53d Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 11 Jan 2012 14:03:57 -0800 Subject: [PATCH 01/21] latmdec: Check AudioSpecificConfig length before decoding extradata. This is different than a normal get_bits() over read because decode_audio_specific_config() creates its own GetBitContext. Fixes Bug 170. --- libavcodec/aacdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index b2fc740d4d..ca1a876436 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2363,6 +2363,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, "config not byte aligned.\n", 1); return AVERROR_INVALIDDATA; } + if (asclen <= 0) + return AVERROR_INVALIDDATA; bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac, gb->buffer + (config_start_bit / 8), asclen, sync_extension); From f7f3563214a4deb4bf664057a4cce0c4bf0bdb02 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 11 Jan 2012 19:19:00 +0000 Subject: [PATCH 02/21] rgb2rgb: rgb12tobgr12() Signed-off-by: Ronald S. Bultje --- libswscale/rgb2rgb.c | 13 +++++++++++++ libswscale/rgb2rgb.h | 1 + libswscale/swscale_unscaled.c | 1 + 3 files changed, 15 insertions(+) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 0f07e57683..9fbb6cfd60 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -282,6 +282,19 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size) } } +void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size) +{ + uint16_t *d = (uint16_t*)dst; + uint16_t *s = (uint16_t*)src; + int i; + int num_pixels = src_size >> 1; + + for (i = 0; i < num_pixels; i++) { + unsigned rgb = s[i]; + d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF; + } +} + void bgr8torgb8(const uint8_t *src, uint8_t *dst, int src_size) { int i; diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h index 833a984cec..bfb85d722f 100644 --- a/libswscale/rgb2rgb.h +++ b/libswscale/rgb2rgb.h @@ -62,6 +62,7 @@ void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size); void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size); void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size); void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size); +void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size); void bgr8torgb8(const uint8_t *src, uint8_t *dst, int src_size); void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size); diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 57695483ea..a1b7199a23 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -400,6 +400,7 @@ static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) || (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) { switch (srcId | (dstId << 16)) { + case 0x000C000C: conv = rgb12tobgr12; break; case 0x000F000F: conv = rgb15tobgr15; break; case 0x000F0010: conv = rgb16tobgr15; break; case 0x000F0018: conv = rgb24tobgr15; break; From 43fe6a29050fc34848731aa220292587f7ace5bd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 30 Dec 2011 20:56:06 +0100 Subject: [PATCH 03/21] vsrc_buffer: release the buffer on uninit. --- libavfilter/vsrc_buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c index 178b3e68bb..e5b96a60cf 100644 --- a/libavfilter/vsrc_buffer.c +++ b/libavfilter/vsrc_buffer.c @@ -114,6 +114,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) return 0; } +static av_cold void uninit(AVFilterContext *ctx) +{ + BufferSourceContext *s = ctx->priv; + if (s->buf) + avfilter_unref_buffer(s->buf); + s->buf = NULL; +} + static int query_formats(AVFilterContext *ctx) { BufferSourceContext *c = ctx->priv; @@ -167,6 +175,7 @@ AVFilter avfilter_vsrc_buffer = { .query_formats = query_formats, .init = init, + .uninit = uninit, .inputs = (AVFilterPad[]) {{ .name = NULL }}, .outputs = (AVFilterPad[]) {{ .name = "default", From 3167dc9515810bbdd86d99d773bcf84657d2e72a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 31 Dec 2011 16:20:10 +0100 Subject: [PATCH 04/21] lavfi: move version macros to a new installed header version.h --- doc/APIchanges | 3 +++ libavfilter/Makefile | 2 +- libavfilter/avfilter.h | 14 ++------------ libavfilter/version.h | 43 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 libavfilter/version.h diff --git a/doc/APIchanges b/doc/APIchanges index e94c656e9e..751566afe2 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2012-01-xx - xxxxxxx - lavfi 2.15.0 + Add a new installed header -- libavfilter/version.h -- with version macros. + 2011-01-03 - b73ec05 - lavu 51.21.0 Add av_popcount64 diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 78c4692614..09865c148d 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -3,7 +3,7 @@ FFLIBS = avutil FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec FFLIBS-$(CONFIG_SCALE_FILTER) += swscale -HEADERS = avfilter.h avfiltergraph.h buffersrc.h vsrc_buffer.h +HEADERS = avfilter.h avfiltergraph.h buffersrc.h version.h vsrc_buffer.h OBJS = allfilters.o \ avfilter.o \ diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index cffcfcadc2..068c50bb48 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -29,20 +29,10 @@ #include "libavutil/rational.h" #include "libavcodec/avcodec.h" -#define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 14 -#define LIBAVFILTER_VERSION_MICRO 0 - -#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ - LIBAVFILTER_VERSION_MINOR, \ - LIBAVFILTER_VERSION_MICRO) -#define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \ - LIBAVFILTER_VERSION_MINOR, \ - LIBAVFILTER_VERSION_MICRO) -#define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT - #include +#include "libavfilter/version.h" + /** * Return the LIBAVFILTER_VERSION_INT constant. */ diff --git a/libavfilter/version.h b/libavfilter/version.h new file mode 100644 index 0000000000..09d6700d12 --- /dev/null +++ b/libavfilter/version.h @@ -0,0 +1,43 @@ +/* + * Version macros. + * + * 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 + */ + +#ifndef AVFILTER_VERSION_H +#define AVFILTER_VERSION_H + +/** + * @file + * Libavfilter version macros + */ + +#include "libavutil/avutil.h" + +#define LIBAVFILTER_VERSION_MAJOR 2 +#define LIBAVFILTER_VERSION_MINOR 15 +#define LIBAVFILTER_VERSION_MICRO 0 + +#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ + LIBAVFILTER_VERSION_MINOR, \ + LIBAVFILTER_VERSION_MICRO) +#define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \ + LIBAVFILTER_VERSION_MINOR, \ + LIBAVFILTER_VERSION_MICRO) +#define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT + +#endif // AVFILTER_VERSION_H From b2ce3b998b90c9ec8dcefe4b2c45fcf5b2f0a903 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 31 Dec 2011 17:15:50 +0100 Subject: [PATCH 05/21] avconv: use AVFrame.width/height/format instead of corresponding AVCodecContext fields --- avconv.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/avconv.c b/avconv.c index c96cc73280..817c0cf928 100644 --- a/avconv.c +++ b/avconv.c @@ -1262,19 +1262,18 @@ static void do_video_resample(OutputStream *ost, AVFrame **out_picture) { int resample_changed = 0; - AVCodecContext *dec = ist->st->codec; *out_picture = in_picture; - resample_changed = ost->resample_width != dec->width || - ost->resample_height != dec->height || - ost->resample_pix_fmt != dec->pix_fmt; + resample_changed = ost->resample_width != in_picture->width || + ost->resample_height != in_picture->height || + ost->resample_pix_fmt != in_picture->format; if (resample_changed) { av_log(NULL, AV_LOG_INFO, "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", ist->file_index, ist->st->index, ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt), - dec->width , dec->height , av_get_pix_fmt_name(dec->pix_fmt)); + in_picture->width, in_picture->height, av_get_pix_fmt_name(in_picture->format)); if (!ost->video_resample) ost->video_resample = 1; } @@ -1301,9 +1300,9 @@ static void do_video_resample(OutputStream *ost, 0, ost->resample_height, (*out_picture)->data, (*out_picture)->linesize); } if (resample_changed) { - ost->resample_width = dec->width; - ost->resample_height = dec->height; - ost->resample_pix_fmt = dec->pix_fmt; + ost->resample_width = in_picture->width; + ost->resample_height = in_picture->height; + ost->resample_pix_fmt = in_picture->format; } } #endif From 3faa303a47e0c3b59a53988e0f76018930c6cb1a Mon Sep 17 00:00:00 2001 From: Christophe GISQUET Date: Sun, 1 Jan 2012 18:33:22 +0100 Subject: [PATCH 06/21] rv34: DC-only inverse transform When decoding coefficients, detect whether the block is DC-only, and take advantage of this knowledge to perform DC-only inverse transform. This is achieved by: - first, changing the 108x4 element modulo_three_table into a 108 element table (kind of base4), and accessing each value using mask and shifts. - then, checking low bits for 0 (as they represent the presence of higher frequency coefficients) Also provide x86 SIMD code for the DC-only inverse transform. Signed-off-by: Kostya Shishkov --- libavcodec/rv34.c | 95 +++++++++++++++++++++-------------- libavcodec/rv34data.h | 44 ++++++---------- libavcodec/rv34dsp.c | 24 +++++++++ libavcodec/rv34dsp.h | 2 + libavcodec/x86/Makefile | 6 ++- libavcodec/x86/rv34dsp.asm | 55 ++++++++++++++++++++ libavcodec/x86/rv34dsp_init.c | 40 +++++++++++++++ 7 files changed, 200 insertions(+), 66 deletions(-) create mode 100644 libavcodec/x86/rv34dsp.asm create mode 100644 libavcodec/x86/rv34dsp_init.c diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index ec826fd074..6cfefa0e1b 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -204,7 +204,7 @@ static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table) } for(i = 0; i < 4; i++){ - t = modulo_three_table[code][i]; + t = (modulo_three_table[code] >> (6 - 2*i)) & 3; if(t == 1) cbp |= cbp_masks[get_bits1(gb)] << i; if(t == 2) @@ -238,41 +238,42 @@ static inline void decode_coeff(DCTELEM *dst, int coef, int esc, GetBitContext * */ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q) { - int coeffs[4]; + int flags = modulo_three_table[code]; - coeffs[0] = modulo_three_table[code][0]; - coeffs[1] = modulo_three_table[code][1]; - coeffs[2] = modulo_three_table[code][2]; - coeffs[3] = modulo_three_table[code][3]; - decode_coeff(dst , coeffs[0], 3, gb, vlc, q); + decode_coeff( dst+0, (flags >> 6) , 3, gb, vlc, q); if(is_block2){ - decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q); - decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q); + decode_coeff(dst+8, (flags >> 4) & 3, 2, gb, vlc, q); + decode_coeff(dst+1, (flags >> 2) & 3, 2, gb, vlc, q); }else{ - decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q); - decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q); + decode_coeff(dst+1, (flags >> 4) & 3, 2, gb, vlc, q); + decode_coeff(dst+8, (flags >> 2) & 3, 2, gb, vlc, q); } - decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q); + decode_coeff( dst+9, (flags >> 0) & 3, 2, gb, vlc, q); +} + +/** + * Decode a single coefficient. + */ +static inline void decode_subblock1(DCTELEM *dst, int code, GetBitContext *gb, VLC *vlc, int q) +{ + int coeff = modulo_three_table[code] >> 6; + decode_coeff(dst, coeff, 3, gb, vlc, q); } static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q_dc, int q_ac1, int q_ac2) { - int coeffs[4]; + int flags = modulo_three_table[code]; - coeffs[0] = modulo_three_table[code][0]; - coeffs[1] = modulo_three_table[code][1]; - coeffs[2] = modulo_three_table[code][2]; - coeffs[3] = modulo_three_table[code][3]; - decode_coeff(dst , coeffs[0], 3, gb, vlc, q_dc); + decode_coeff( dst+0, (flags >> 6) , 3, gb, vlc, q_dc); if(is_block2){ - decode_coeff(dst+8, coeffs[1], 2, gb, vlc, q_ac1); - decode_coeff(dst+1, coeffs[2], 2, gb, vlc, q_ac1); + decode_coeff(dst+8, (flags >> 4) & 3, 2, gb, vlc, q_ac1); + decode_coeff(dst+1, (flags >> 2) & 3, 2, gb, vlc, q_ac1); }else{ - decode_coeff(dst+1, coeffs[1], 2, gb, vlc, q_ac1); - decode_coeff(dst+8, coeffs[2], 2, gb, vlc, q_ac1); + decode_coeff(dst+1, (flags >> 4) & 3, 2, gb, vlc, q_ac1); + decode_coeff(dst+8, (flags >> 2) & 3, 2, gb, vlc, q_ac1); } - decode_coeff(dst+9, coeffs[3], 2, gb, vlc, q_ac2); + decode_coeff( dst+9, (flags >> 0) & 3, 2, gb, vlc, q_ac2); } /** @@ -286,16 +287,24 @@ static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, * o--o */ -static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2) +static inline int rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2) { - int code, pattern; + int code, pattern, has_ac = 1; code = get_vlc2(gb, rvlc->first_pattern[fc].table, 9, 2); pattern = code & 0x7; code >>= 3; - decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2); + + if (modulo_three_table[code] & 0x3F) { + decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2); + } else { + decode_subblock1(dst, code, gb, &rvlc->coefficient, q_dc); + if (!pattern) + return 0; + has_ac = 0; + } if(pattern & 4){ code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2); @@ -309,7 +318,7 @@ static inline void rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *r code = get_vlc2(gb, rvlc->third_pattern[sc].table, 9, 2); decode_subblock(dst + 8*2+2, code, 0, gb, &rvlc->coefficient, q_ac2); } - + return has_ac || pattern; } /** @@ -1118,7 +1127,7 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) MpegEncContext *s = &r->s; GetBitContext *gb = &s->gb; int cbp, cbp2; - int q_dc, q_ac; + int q_dc, q_ac, has_ac; int i, blknum, blkoff; LOCAL_ALIGNED_16(DCTELEM, block16, [64]); int luma_dc_quant; @@ -1157,33 +1166,45 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types) if(r->is16){ q_dc = rv34_qscale_tab[luma_dc_quant]; q_ac = rv34_qscale_tab[s->qscale]; - memset(block16, 0, 64 * sizeof(*block16)); - rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac); - r->rdsp.rv34_inv_transform_tab[1](block16); + s->dsp.clear_block(block16); + if (rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac)) + r->rdsp.rv34_inv_transform_tab[1](block16); + else + r->rdsp.rv34_inv_transform_dc_tab[1](block16); } q_ac = rv34_qscale_tab[s->qscale]; for(i = 0; i < 16; i++, cbp >>= 1){ + DCTELEM *ptr; if(!r->is16 && !(cbp & 1)) continue; blknum = ((i & 2) >> 1) + ((i & 8) >> 2); blkoff = ((i & 1) << 2) + ((i & 4) << 3); + ptr = s->block[blknum] + blkoff; if(cbp & 1) - rv34_decode_block(s->block[blknum] + blkoff, gb, - r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac); + has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac); + else + has_ac = 0; if(r->is16) //FIXME: optimize - s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)]; - r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff); + ptr[0] = block16[(i & 3) | ((i & 0xC) << 1)]; + if(has_ac) + r->rdsp.rv34_inv_transform_tab[0](ptr); + else + r->rdsp.rv34_inv_transform_dc_tab[0](ptr); } if(r->block_type == RV34_MB_P_MIX16x16) r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]]; q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]; for(; i < 24; i++, cbp >>= 1){ + DCTELEM *ptr; if(!(cbp & 1)) continue; blknum = ((i & 4) >> 2) + 4; blkoff = ((i & 1) << 2) + ((i & 2) << 4); - rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac); - r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff); + ptr = s->block[blknum] + blkoff; + if (rv34_decode_block(ptr, gb, r->cur_vlcs, r->chroma_vlc, 1, q_dc, q_ac, q_ac)) + r->rdsp.rv34_inv_transform_tab[0](ptr); + else + r->rdsp.rv34_inv_transform_dc_tab[0](ptr); } if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])) rv34_output_macroblock(r, intra_types, cbp2, r->is16); diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h index fa41a882a6..41c5b20ad7 100644 --- a/libavcodec/rv34data.h +++ b/libavcodec/rv34data.h @@ -50,34 +50,22 @@ static const uint8_t rv34_cbp_code[16] = { * A lot of four-tuples in RV40 are represented as c0*27+c1*9+c2*3+c3. * This table allows conversion from a value back to a vector. */ -static const uint8_t modulo_three_table[108][4] = { - { 0, 0, 0, 0 }, { 0, 0, 0, 1 }, { 0, 0, 0, 2 }, { 0, 0, 1, 0 }, - { 0, 0, 1, 1 }, { 0, 0, 1, 2 }, { 0, 0, 2, 0 }, { 0, 0, 2, 1 }, - { 0, 0, 2, 2 }, { 0, 1, 0, 0 }, { 0, 1, 0, 1 }, { 0, 1, 0, 2 }, - { 0, 1, 1, 0 }, { 0, 1, 1, 1 }, { 0, 1, 1, 2 }, { 0, 1, 2, 0 }, - { 0, 1, 2, 1 }, { 0, 1, 2, 2 }, { 0, 2, 0, 0 }, { 0, 2, 0, 1 }, - { 0, 2, 0, 2 }, { 0, 2, 1, 0 }, { 0, 2, 1, 1 }, { 0, 2, 1, 2 }, - { 0, 2, 2, 0 }, { 0, 2, 2, 1 }, { 0, 2, 2, 2 }, { 1, 0, 0, 0 }, - { 1, 0, 0, 1 }, { 1, 0, 0, 2 }, { 1, 0, 1, 0 }, { 1, 0, 1, 1 }, - { 1, 0, 1, 2 }, { 1, 0, 2, 0 }, { 1, 0, 2, 1 }, { 1, 0, 2, 2 }, - { 1, 1, 0, 0 }, { 1, 1, 0, 1 }, { 1, 1, 0, 2 }, { 1, 1, 1, 0 }, - { 1, 1, 1, 1 }, { 1, 1, 1, 2 }, { 1, 1, 2, 0 }, { 1, 1, 2, 1 }, - { 1, 1, 2, 2 }, { 1, 2, 0, 0 }, { 1, 2, 0, 1 }, { 1, 2, 0, 2 }, - { 1, 2, 1, 0 }, { 1, 2, 1, 1 }, { 1, 2, 1, 2 }, { 1, 2, 2, 0 }, - { 1, 2, 2, 1 }, { 1, 2, 2, 2 }, { 2, 0, 0, 0 }, { 2, 0, 0, 1 }, - { 2, 0, 0, 2 }, { 2, 0, 1, 0 }, { 2, 0, 1, 1 }, { 2, 0, 1, 2 }, - { 2, 0, 2, 0 }, { 2, 0, 2, 1 }, { 2, 0, 2, 2 }, { 2, 1, 0, 0 }, - { 2, 1, 0, 1 }, { 2, 1, 0, 2 }, { 2, 1, 1, 0 }, { 2, 1, 1, 1 }, - { 2, 1, 1, 2 }, { 2, 1, 2, 0 }, { 2, 1, 2, 1 }, { 2, 1, 2, 2 }, - { 2, 2, 0, 0 }, { 2, 2, 0, 1 }, { 2, 2, 0, 2 }, { 2, 2, 1, 0 }, - { 2, 2, 1, 1 }, { 2, 2, 1, 2 }, { 2, 2, 2, 0 }, { 2, 2, 2, 1 }, - { 2, 2, 2, 2 }, { 3, 0, 0, 0 }, { 3, 0, 0, 1 }, { 3, 0, 0, 2 }, - { 3, 0, 1, 0 }, { 3, 0, 1, 1 }, { 3, 0, 1, 2 }, { 3, 0, 2, 0 }, - { 3, 0, 2, 1 }, { 3, 0, 2, 2 }, { 3, 1, 0, 0 }, { 3, 1, 0, 1 }, - { 3, 1, 0, 2 }, { 3, 1, 1, 0 }, { 3, 1, 1, 1 }, { 3, 1, 1, 2 }, - { 3, 1, 2, 0 }, { 3, 1, 2, 1 }, { 3, 1, 2, 2 }, { 3, 2, 0, 0 }, - { 3, 2, 0, 1 }, { 3, 2, 0, 2 }, { 3, 2, 1, 0 }, { 3, 2, 1, 1 }, - { 3, 2, 1, 2 }, { 3, 2, 2, 0 }, { 3, 2, 2, 1 }, { 3, 2, 2, 2 }, +static const uint8_t modulo_three_table[108] = { + 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x08, 0x09, 0x0A, + 0x10, 0x11, 0x12, 0x14, 0x15, 0x16, 0x18, 0x19, 0x1A, + 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A, + + 0x40, 0x41, 0x42, 0x44, 0x45, 0x46, 0x48, 0x49, 0x4A, + 0x50, 0x51, 0x52, 0x54, 0x55, 0x56, 0x58, 0x59, 0x5A, + 0x60, 0x61, 0x62, 0x64, 0x65, 0x66, 0x68, 0x69, 0x6A, + + 0x80, 0x81, 0x82, 0x84, 0x85, 0x86, 0x88, 0x89, 0x8A, + 0x90, 0x91, 0x92, 0x94, 0x95, 0x96, 0x98, 0x99, 0x9A, + 0xA0, 0xA1, 0xA2, 0xA4, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA, + + 0xC0, 0xC1, 0xC2, 0xC4, 0xC5, 0xC6, 0xC8, 0xC9, 0xCA, + 0xD0, 0xD1, 0xD2, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, + 0xE0, 0xE1, 0xE2, 0xE4, 0xE5, 0xE6, 0xE8, 0xE9, 0xEA, }; /** diff --git a/libavcodec/rv34dsp.c b/libavcodec/rv34dsp.c index 1f4cea8544..1767be4173 100644 --- a/libavcodec/rv34dsp.c +++ b/libavcodec/rv34dsp.c @@ -97,13 +97,37 @@ static void rv34_inv_transform_noround_c(DCTELEM *block){ } } +static void rv34_inv_transform_dc_c(DCTELEM *block) +{ + DCTELEM dc = (13 * 13 * block[0] + 0x200) >> 10; + int i, j; + + for (i = 0; i < 4; i++, block += 8) + for (j = 0; j < 4; j++) + block[j] = dc; +} + +static void rv34_inv_transform_dc_noround_c(DCTELEM *block) +{ + DCTELEM dc = (13 * 13 * 3 * block[0]) >> 11; + int i, j; + + for (i = 0; i < 4; i++, block += 8) + for (j = 0; j < 4; j++) + block[j] = dc; +} + /** @} */ // transform av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) { c->rv34_inv_transform_tab[0] = rv34_inv_transform_c; c->rv34_inv_transform_tab[1] = rv34_inv_transform_noround_c; + c->rv34_inv_transform_dc_tab[0] = rv34_inv_transform_dc_c; + c->rv34_inv_transform_dc_tab[1] = rv34_inv_transform_dc_noround_c; if (HAVE_NEON) ff_rv34dsp_init_neon(c, dsp); + if (HAVE_MMX) + ff_rv34dsp_init_x86(c, dsp); } diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h index f2bc20e911..6f53a09928 100644 --- a/libavcodec/rv34dsp.h +++ b/libavcodec/rv34dsp.h @@ -56,6 +56,7 @@ typedef struct RV34DSPContext { h264_chroma_mc_func avg_chroma_pixels_tab[3]; rv40_weight_func rv40_weight_pixels_tab[2]; rv34_inv_transform_func rv34_inv_transform_tab[2]; + void (*rv34_inv_transform_dc_tab[2])(DCTELEM *block); rv40_weak_loop_filter_func rv40_weak_loop_filter[2]; rv40_strong_loop_filter_func rv40_strong_loop_filter[2]; rv40_loop_filter_strength_func rv40_loop_filter_strength[2]; @@ -66,6 +67,7 @@ void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp); void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp); void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext *dsp); +void ff_rv34dsp_init_x86(RV34DSPContext *c, DSPContext *dsp); void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp); void ff_rv40dsp_init_neon(RV34DSPContext *c, DSPContext *dsp); diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 2abe4fbe72..1e88e4a847 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -24,7 +24,11 @@ YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o \ x86/h264_intrapred_10bit.o MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o -MMX-OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp.o \ +MMX-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o +YASM-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp.o +MMX-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp_init.o \ + x86/rv40dsp.o +YASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp.o YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_yasm.o diff --git a/libavcodec/x86/rv34dsp.asm b/libavcodec/x86/rv34dsp.asm new file mode 100644 index 0000000000..58f1af0495 --- /dev/null +++ b/libavcodec/x86/rv34dsp.asm @@ -0,0 +1,55 @@ +;****************************************************************************** +;* MMX/SSE2-optimized functions for the RV30 and RV40 decoders +;* Copyright (C) 2012 Christophe Gisquet +;* +;* 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 "x86inc.asm" +%include "x86util.asm" + +SECTION .text + +%macro IDCT_DC_NOROUND 1 + imul %1, 13*13*3 + sar %1, 11 +%endmacro + +%macro IDCT_DC_ROUND 1 + imul %1, 13*13 + add %1, 0x200 + sar %1, 10 +%endmacro + +%macro rv34_idct_dequant4x4_dc 1 +cglobal rv34_idct_dequant4x4_%1_mmx2, 1, 2, 0 + movsx r1, word [r0] + IDCT_DC r1 + movd mm0, r1 + pshufw mm0, mm0, 0 + movq [r0+ 0], mm0 + movq [r0+16], mm0 + movq [r0+32], mm0 + movq [r0+48], mm0 + REP_RET +%endmacro + +INIT_MMX +%define IDCT_DC IDCT_DC_ROUND +rv34_idct_dequant4x4_dc dc +%define IDCT_DC IDCT_DC_NOROUND +rv34_idct_dequant4x4_dc dc_noround diff --git a/libavcodec/x86/rv34dsp_init.c b/libavcodec/x86/rv34dsp_init.c new file mode 100644 index 0000000000..4317e9b23b --- /dev/null +++ b/libavcodec/x86/rv34dsp_init.c @@ -0,0 +1,40 @@ +/* + * RV30/40 MMX/SSE2 optimizations + * Copyright (C) 2012 Christophe Gisquet + * + * 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 "libavutil/cpu.h" +#include "libavutil/x86_cpu.h" +#include "libavcodec/dsputil.h" +#include "libavcodec/rv34dsp.h" + +void ff_rv34_idct_dequant4x4_dc_mmx2(DCTELEM *block); +void ff_rv34_idct_dequant4x4_dc_noround_mmx2(DCTELEM *block); + +av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c, DSPContext *dsp) +{ +#if HAVE_YASM + int mm_flags = av_get_cpu_flags(); + + if (mm_flags & AV_CPU_FLAG_MMX2) { + c->rv34_inv_transform_dc_tab[0] = ff_rv34_idct_dequant4x4_dc_mmx2; + c->rv34_inv_transform_dc_tab[1] = ff_rv34_idct_dequant4x4_dc_noround_mmx2; + } +#endif +} From 08bab32cf1dff7dc25dab4f010c42c13ba9627c7 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 12 Jan 2012 10:01:33 +0100 Subject: [PATCH 07/21] indeo4: add some missing static and const qualifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the patch by Reimar Döffinger. --- libavcodec/indeo4.c | 2 +- libavcodec/indeo4data.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c index dd8e5b1830..573718e374 100644 --- a/libavcodec/indeo4.c +++ b/libavcodec/indeo4.c @@ -94,7 +94,7 @@ typedef struct { } IVI4DecContext; -struct { +static const struct { InvTransformPtr *inv_trans; DCTransformPtr *dc_trans; int is_2d_trans; diff --git a/libavcodec/indeo4data.h b/libavcodec/indeo4data.h index affd9c6203..9b8945a2ba 100644 --- a/libavcodec/indeo4data.h +++ b/libavcodec/indeo4data.h @@ -86,7 +86,7 @@ static const uint8_t *scan_index_to_tab[15] = { /** * Indeo 4 dequant tables */ -static uint16_t ivi4_quant_8x8_intra[9][64] = { +static const uint16_t ivi4_quant_8x8_intra[9][64] = { { 43, 342, 385, 470, 555, 555, 598, 726, 342, 342, 470, 513, 555, 598, 726, 769, @@ -179,7 +179,7 @@ static uint16_t ivi4_quant_8x8_intra[9][64] = { } }; -static uint16_t ivi4_quant_8x8_inter[9][64] = { +static const uint16_t ivi4_quant_8x8_inter[9][64] = { { 427, 427, 470, 427, 427, 427, 470, 470, 427, 427, 470, 427, 427, 427, 470, 470, @@ -272,7 +272,7 @@ static uint16_t ivi4_quant_8x8_inter[9][64] = { } }; -static uint16_t ivi4_quant_4x4_intra[5][16] = { +static const uint16_t ivi4_quant_4x4_intra[5][16] = { { 22, 214, 257, 299, 214, 257, 299, 342, @@ -305,7 +305,7 @@ static uint16_t ivi4_quant_4x4_intra[5][16] = { } }; -static uint16_t ivi4_quant_4x4_inter[5][16] = { +static const uint16_t ivi4_quant_4x4_inter[5][16] = { { 107, 214, 257, 299, 214, 257, 299, 299, @@ -342,7 +342,7 @@ static uint16_t ivi4_quant_4x4_inter[5][16] = { * Table for mapping quant matrix index from the bitstream * into internal quant table number. */ -static uint8_t quant_index_to_tab[22] = { +static const uint8_t quant_index_to_tab[22] = { 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes }; From 0fd88d398896353074fee153259dbf3530ca423f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:12:59 +0100 Subject: [PATCH 08/21] riff: remove references to sonic codec ids They are deprecated and will be purged on next major bump. --- libavformat/riff.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavformat/riff.c b/libavformat/riff.c index 8489bc7ae6..4caac80643 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -327,8 +327,6 @@ const AVCodecTag ff_codec_wav_tags[] = { { CODEC_ID_AAC_LATM, 0x1602 }, { CODEC_ID_AC3, 0x2000 }, { CODEC_ID_DTS, 0x2001 }, - { CODEC_ID_SONIC, 0x2048 }, - { CODEC_ID_SONIC_LS, 0x2048 }, { CODEC_ID_PCM_MULAW, 0x6c75 }, { CODEC_ID_AAC, 0x706d }, { CODEC_ID_AAC, 0x4143 }, From 0c71cc65266469253d531e8101a211ce8f26387c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:25:05 +0100 Subject: [PATCH 09/21] mpegvideo_enc: ifdef out/replace references to deprecated codec flags. --- libavcodec/mpegvideo_enc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 84a5cdaac8..08484a7a9c 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -498,8 +498,11 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) return -1; } - if ((s->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME | - CODEC_FLAG_ALT_SCAN)) && + if ((s->flags & (CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME +#if FF_API_MPEGVIDEO_GLOBAL_OPTS + | CODEC_FLAG_ALT_SCAN +#endif + )) && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n"); return -1; @@ -531,12 +534,14 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) return -1; } +#if FF_API_MPEGVIDEO_GLOBAL_OPTS if ((s->flags2 & CODEC_FLAG2_INTRA_VLC) && s->codec_id != CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "intra vlc table not supported by codec\n"); return -1; } +#endif if (s->flags & CODEC_FLAG_LOW_DELAY) { if (s->codec_id != CODEC_ID_MPEG2VIDEO) { @@ -570,8 +575,11 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO && - (s->codec_id != CODEC_ID_H263P || - !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))) { + (s->codec_id != CODEC_ID_H263P +#if FF_API_MPEGVIDEO_GLOBAL_OPTS + || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) +#endif + )) { av_log(avctx, AV_LOG_ERROR, "multi threaded encoding not supported by codec\n"); return -1; @@ -810,8 +818,8 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->progressive_frame = s->progressive_sequence = !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT | - CODEC_FLAG_INTERLACED_ME | - CODEC_FLAG_ALT_SCAN)); + CODEC_FLAG_INTERLACED_ME) || + s->alternate_scan); /* init */ if (MPV_common_init(s) < 0) From d54f1e640790b9690cdb4f543f374016615ec000 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:26:11 +0100 Subject: [PATCH 10/21] nellymoserdec: SAMPLE_FMT -> AV_SAMPLE_FMT --- libavcodec/nellymoserdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 7f585e4128..69c1b86f5e 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -187,7 +187,7 @@ static int decode_tag(AVCodecContext *avctx, void *data, samples_flt = (float *)s->frame.data[0]; for (i=0 ; isample_fmt == SAMPLE_FMT_FLT) { + if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { nelly_decode_block(s, buf, samples_flt); samples_flt += NELLY_SAMPLES; } else { From a29c25a9b27456367c7550364d5ba5d7e3798323 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:28:15 +0100 Subject: [PATCH 11/21] lavc: ifdef out parse_only AVOption --- libavcodec/options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/options.c b/libavcodec/options.c index a99aed7ad1..00d80e07c3 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -215,7 +215,9 @@ static const AVOption options[]={ {"explode", "abort decoding on minor error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, V|D, "err_filter"}, {"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +#if FF_API_PARSE_FRAME {"parse_only", NULL, OFFSET(parse_only), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +#endif {"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"stats_out", NULL, OFFSET(stats_out), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX}, {"stats_in", NULL, OFFSET(stats_in), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX}, From f3d02a8b280e189bb59db0f194d224bffd4db573 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:29:43 +0100 Subject: [PATCH 12/21] lavc: replace some remaining FF_I_TYPE with AV_PICTURE_TYPE_I --- libavcodec/v410dec.c | 2 +- libavcodec/v410enc.c | 2 +- libavcodec/vble.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/v410dec.c b/libavcodec/v410dec.c index 54c9595826..a6f236bd6d 100644 --- a/libavcodec/v410dec.c +++ b/libavcodec/v410dec.c @@ -68,7 +68,7 @@ static int v410_decode_frame(AVCodecContext *avctx, void *data, } pic->key_frame = 1; - pic->pict_type = FF_I_TYPE; + pic->pict_type = AV_PICTURE_TYPE_I; y = (uint16_t *)pic->data[0]; u = (uint16_t *)pic->data[1]; diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index 11c6abc88e..a6b3ddbf30 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -57,7 +57,7 @@ static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf, avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = FF_I_TYPE; + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; y = (uint16_t *)pic->data[0]; u = (uint16_t *)pic->data[1]; diff --git a/libavcodec/vble.c b/libavcodec/vble.c index fa205f5982..574582af7b 100644 --- a/libavcodec/vble.c +++ b/libavcodec/vble.c @@ -135,7 +135,7 @@ static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size, /* Set flags */ pic->key_frame = 1; - pic->pict_type = FF_I_TYPE; + pic->pict_type = AV_PICTURE_TYPE_I; /* Version should always be 1 */ version = AV_RL32(src); From e01a29a461ec15aad745fa89e510a92918d872aa Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:33:16 +0100 Subject: [PATCH 13/21] avserver: remove code using deprecated CODEC_CAP_PARSE_ONLY. --- avserver.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/avserver.c b/avserver.c index 9016d1f9df..15fa64c144 100644 --- a/avserver.c +++ b/avserver.c @@ -2112,22 +2112,6 @@ static void compute_status(HTTPContext *c) c->buffer_end = c->pb_buffer + len; } -/* check if the parser needs to be opened for stream i */ -static void open_parser(AVFormatContext *s, int i) -{ - AVStream *st = s->streams[i]; - AVCodec *codec; - - if (!st->codec->codec) { - codec = avcodec_find_decoder(st->codec->codec_id); - if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) { - st->codec->parse_only = 1; - if (avcodec_open2(st->codec, codec, NULL) < 0) - st->codec->parse_only = 0; - } - } -} - static int open_input_stream(HTTPContext *c, const char *info) { char buf[128]; @@ -2173,10 +2157,6 @@ static int open_input_stream(HTTPContext *c, const char *info) return -1; } - /* open each parser */ - for(i=0;inb_streams;i++) - open_parser(s, i); - /* choose stream as clock source (we favorize video stream if present) for packet sending */ c->pts_stream_index = 0; From e5c708151e3dbf09c9564051c432b1b83a1674d0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:36:11 +0100 Subject: [PATCH 14/21] lavf: undeprecate read_seek(). The "new seeking API" was never finished and nobody is working on it. --- libavformat/avformat.h | 7 +++---- libavformat/version.h | 3 --- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 89b9eda4a4..fff911a483 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -503,7 +503,6 @@ typedef struct AVInputFormat { */ int (*read_close)(struct AVFormatContext *); -#if FF_API_READ_SEEK /** * Seek to a given timestamp relative to the frames in * stream component stream_index. @@ -512,9 +511,9 @@ typedef struct AVInputFormat { * match is available. * @return >= 0 on success (but not necessarily the new offset) */ - attribute_deprecated int (*read_seek)(struct AVFormatContext *, - int stream_index, int64_t timestamp, int flags); -#endif + int (*read_seek)(struct AVFormatContext *, + int stream_index, int64_t timestamp, int flags); + /** * Get the next timestamp in stream[stream_index].time_base units. * @return the timestamp or AV_NOPTS_VALUE if an error occurred diff --git a/libavformat/version.h b/libavformat/version.h index e113a24482..fb5a1eb9db 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -50,9 +50,6 @@ #ifndef FF_API_OLD_METADATA2 #define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_READ_SEEK -#define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) -#endif #ifndef FF_API_OLD_AVIO #define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 54) #endif From 44bcab5883fcfdc9e9b1cc5315e994fd33391deb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:38:13 +0100 Subject: [PATCH 15/21] ffmenc: remove references to deprecated AVFormatContext.timestamp. --- libavformat/ffmenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c index d304f57ac4..b8d3d315bd 100644 --- a/libavformat/ffmenc.c +++ b/libavformat/ffmenc.c @@ -205,7 +205,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt) uint8_t header[FRAME_HEADER_SIZE+4]; int header_size = FRAME_HEADER_SIZE; - dts = s->timestamp + pkt->dts; + dts = pkt->dts; /* packet size & key_frame */ header[0] = pkt->stream_index; header[1] = 0; @@ -213,7 +213,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt) header[1] |= FLAG_KEY_FRAME; AV_WB24(header+2, pkt->size); AV_WB24(header+5, pkt->duration); - AV_WB64(header+8, s->timestamp + pkt->pts); + AV_WB64(header+8, pkt->pts); if (pkt->pts != pkt->dts) { header[1] |= FLAG_DTS; AV_WB32(header+16, pkt->pts - pkt->dts); From 136ee32da3c728fb4e3490393efb947cc7c4e898 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Jan 2012 09:45:13 +0100 Subject: [PATCH 16/21] avprobe: use avio_size() instead of deprecated AVFormatContext.file_size. --- avprobe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/avprobe.c b/avprobe.c index de9657b7e3..4d2ed67606 100644 --- a/avprobe.c +++ b/avprobe.c @@ -243,6 +243,7 @@ static void show_format(AVFormatContext *fmt_ctx) { AVDictionaryEntry *tag = NULL; char val_str[128]; + int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1; printf("[FORMAT]\n"); @@ -254,8 +255,9 @@ static void show_format(AVFormatContext *fmt_ctx) &AV_TIME_BASE_Q)); printf("duration=%s\n", time_value_string(val_str, sizeof(val_str), fmt_ctx->duration, &AV_TIME_BASE_Q)); - printf("size=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->file_size, - unit_byte_str)); + printf("size=%s\n", size >= 0 ? value_string(val_str, sizeof(val_str), + size, unit_byte_str) + : "unknown"); printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str)); From e1e369049e3d2f88eed6ed38eb3dd704681c7f1a Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Thu, 12 Jan 2012 17:21:48 +0100 Subject: [PATCH 17/21] rv34: NEON optimised dc only inverse transform 30-50% faster than the C implementation, 0.5% overall speedup on bourne.rmvb. --- libavcodec/arm/rv34dsp_init_neon.c | 9 +++++++-- libavcodec/arm/rv34dsp_neon.S | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/libavcodec/arm/rv34dsp_init_neon.c b/libavcodec/arm/rv34dsp_init_neon.c index 9a09fde7a9..16bda46658 100644 --- a/libavcodec/arm/rv34dsp_init_neon.c +++ b/libavcodec/arm/rv34dsp_init_neon.c @@ -26,8 +26,13 @@ void ff_rv34_inv_transform_neon(DCTELEM *block); void ff_rv34_inv_transform_noround_neon(DCTELEM *block); +void ff_rv34_inv_transform_dc_neon(DCTELEM *block); +void ff_rv34_inv_transform_noround_dc_neon(DCTELEM *block); + void ff_rv34dsp_init_neon(RV34DSPContext *c, DSPContext* dsp) { - c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon; - c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon; + c->rv34_inv_transform_tab[0] = ff_rv34_inv_transform_neon; + c->rv34_inv_transform_tab[1] = ff_rv34_inv_transform_noround_neon; + c->rv34_inv_transform_dc_tab[0] = ff_rv34_inv_transform_dc_neon; + c->rv34_inv_transform_dc_tab[1] = ff_rv34_inv_transform_noround_dc_neon; } diff --git a/libavcodec/arm/rv34dsp_neon.S b/libavcodec/arm/rv34dsp_neon.S index f700f5c321..e776af0330 100644 --- a/libavcodec/arm/rv34dsp_neon.S +++ b/libavcodec/arm/rv34dsp_neon.S @@ -107,3 +107,32 @@ function ff_rv34_inv_transform_noround_neon, export=1 vst4.16 {d0[3], d1[3], d2[3], d3[3]}, [r2,:64], r1 bx lr endfunc + +/* void rv34_inv_transform_dc_c(DCTELEM *block) */ +function ff_rv34_inv_transform_dc_neon, export=1 + vld1.16 d28[], [r0:16] @ block[0] + vmov.i16 d4, #169 + mov r1, #16 + vmull.s16 q3, d28, d4 + vrshrn.s32 d0, q3, #10 + vst1.16 {d0}, [r0:64], r1 + vst1.16 {d0}, [r0:64], r1 + vst1.16 {d0}, [r0:64], r1 + vst1.16 {d0}, [r0:64], r1 + bx lr +endfunc + +/* void rv34_inv_transform_dc_noround_c(DCTELEM *block) */ +function ff_rv34_inv_transform_noround_dc_neon, export=1 + vld1.16 d28[], [r0:16] @ block[0] + vmov.i16 d4, #251 + vorr.s16 d4, #256 @ 13^2 * 3 + mov r1, #16 + vmull.s16 q3, d28, d4 + vshrn.s32 d0, q3, #11 + vst1.64 {d0}, [r0:64], r1 + vst1.64 {d0}, [r0:64], r1 + vst1.64 {d0}, [r0:64], r1 + vst1.64 {d0}, [r0:64], r1 + bx lr +endfunc From 3547f8e8f8418af0c578eba0de62ecba08e460c2 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 11 Jan 2012 20:10:23 +0100 Subject: [PATCH 18/21] rv34: fix and optimise frame dependency checking The sporadic threading errors during fate-rv30 were caused by calling ff_thread_await_progress with mb row -1 as argument. That returns immediately since progress is initialized to -1. Not yet computed motion vectors from the reference could be used for the first macroblocks. --- libavcodec/rv34.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 6cfefa0e1b..48b5193f38 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -685,7 +685,8 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { /* wait for the referenced mb row to be finished */ - int mb_row = FFMIN(s->mb_height - 1, s->mb_y + ((yoff + my + 21) >> 4)); + int mb_row = FFMIN(s->mb_height - 1, + s->mb_y + ((yoff + my + 5 + 8 * height) >> 4)); AVFrame *f = dir ? &s->next_picture_ptr->f : &s->last_picture_ptr->f; ff_thread_await_progress(f, mb_row, 0); } @@ -847,7 +848,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) //surprisingly, it uses motion scheme from next reference frame /* wait for the current mb row to be finished */ if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) - ff_thread_await_progress(&s->next_picture_ptr->f, s->mb_y - 1, 0); + ff_thread_await_progress(&s->next_picture_ptr->f, FFMAX(0, s->mb_y-1), 0); next_bt = s->next_picture_ptr->f.mb_type[s->mb_x + s->mb_y * s->mb_stride]; if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ From 6b9e4eea839b9f75dc4cad628c923d5c70d704d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 12 Jan 2012 17:06:04 +0200 Subject: [PATCH 19/21] avio: Fix the value of the deprecated URL_FLAG_NONBLOCK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn't used in practice anywhere within libav at the moment, but change it for consistency until it is removed. URL_RDONLY/WRONLY were fixed in commit 5b81e295931 (after the values that actually were used were changed at the major bump, in commit cbea3ac8), but this flag was unintentionally left unfixed. Signed-off-by: Martin Storsjö --- libavformat/avio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index e73264f4aa..78935d9416 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -204,7 +204,7 @@ attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); * Warning: non-blocking protocols is work-in-progress; this flag may be * silently ignored. */ -#define URL_FLAG_NONBLOCK 4 +#define URL_FLAG_NONBLOCK 8 typedef int URLInterruptCB(void); extern URLInterruptCB *url_interrupt_cb; From 81dc6a2a3cefc1f1bbbc249052b3374e524d1ea0 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 12 Jan 2012 19:37:31 +0000 Subject: [PATCH 20/21] ARM: rv34: fix asm syntax in dc transform functions Signed-off-by: Mans Rullgard Signed-off-by: Janne Grunau --- libavcodec/arm/rv34dsp_neon.S | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavcodec/arm/rv34dsp_neon.S b/libavcodec/arm/rv34dsp_neon.S index e776af0330..1e8d4b49a1 100644 --- a/libavcodec/arm/rv34dsp_neon.S +++ b/libavcodec/arm/rv34dsp_neon.S @@ -110,29 +110,29 @@ endfunc /* void rv34_inv_transform_dc_c(DCTELEM *block) */ function ff_rv34_inv_transform_dc_neon, export=1 - vld1.16 d28[], [r0:16] @ block[0] + vld1.16 {d28[]}, [r0,:16] @ block[0] vmov.i16 d4, #169 mov r1, #16 vmull.s16 q3, d28, d4 vrshrn.s32 d0, q3, #10 - vst1.16 {d0}, [r0:64], r1 - vst1.16 {d0}, [r0:64], r1 - vst1.16 {d0}, [r0:64], r1 - vst1.16 {d0}, [r0:64], r1 + vst1.16 {d0}, [r0,:64], r1 + vst1.16 {d0}, [r0,:64], r1 + vst1.16 {d0}, [r0,:64], r1 + vst1.16 {d0}, [r0,:64], r1 bx lr endfunc /* void rv34_inv_transform_dc_noround_c(DCTELEM *block) */ function ff_rv34_inv_transform_noround_dc_neon, export=1 - vld1.16 d28[], [r0:16] @ block[0] + vld1.16 {d28[]}, [r0,:16] @ block[0] vmov.i16 d4, #251 - vorr.s16 d4, #256 @ 13^2 * 3 + vorr.s16 d4, #256 @ 13^2 * 3 mov r1, #16 vmull.s16 q3, d28, d4 vshrn.s32 d0, q3, #11 - vst1.64 {d0}, [r0:64], r1 - vst1.64 {d0}, [r0:64], r1 - vst1.64 {d0}, [r0:64], r1 - vst1.64 {d0}, [r0:64], r1 + vst1.64 {d0}, [r0,:64], r1 + vst1.64 {d0}, [r0,:64], r1 + vst1.64 {d0}, [r0,:64], r1 + vst1.64 {d0}, [r0,:64], r1 bx lr endfunc From 4df30f71147b7bedd4457bcfa0e4efe01085af9f Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 12 Jan 2012 11:12:24 -0800 Subject: [PATCH 21/21] utils: Check for extradata size overflows. --- libavcodec/internal.h | 7 +++++++ libavcodec/utils.c | 3 +++ libavformat/utils.c | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index b5a04546f3..1c2d0daaef 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -94,4 +94,11 @@ unsigned int avpriv_toupper4(unsigned int x); int avpriv_lock_avformat(void); int avpriv_unlock_avformat(void); +/** + * Maximum size in bytes of extradata. + * This value was chosen such that every bit of the buffer is + * addressable by a 32-bit signed integer as used by get_bits. + */ +#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE) + #endif /* AVCODEC_INTERNAL_H */ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 2bc1dcf5da..6f4d7e68da 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -610,6 +610,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD int ret = 0; AVDictionary *tmp = NULL; + if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) + return AVERROR(EINVAL); + if (options) av_dict_copy(&tmp, *options, 0); diff --git a/libavformat/utils.c b/libavformat/utils.c index a79665801f..373f06831d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2442,9 +2442,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) } if(st->parser && st->parser->parser->split && !st->codec->extradata){ int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); - if(i){ + if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) { st->codec->extradata_size= i; st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size); memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE); }